/* ===================================
   FONTS (Sorani)
   =================================== */
@font-face {
  font-family: "UniSIRWAN SST";
  src: url("assets/UniSIRWAN SST Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "UniSIRWAN SST";
  src: url("assets/UniSIRWAN SST Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "UniSIRWAN SST";
  src: url("assets/UniSIRWAN SST Bold.ttf") format("truetype");
  font-weight: 600 700;
  font-display: swap;
}

/* ===================================
   TOKENS
   =================================== */
:root {
  --ink: #16171a;
  --text: #45474d; /* body copy, ~9:1 on paper */
  --muted: #696b72; /* meta and labels, ~5:1 on paper */
  --line: #e6e6e3;
  --paper: #fcfcfb;
  --fog: #f3f3f1;
  --surface: rgba(252, 252, 251, 0.97);

  --font-display: "Lora", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --container: 1080px;
  --gutter: clamp(20px, 5vw, 48px);
  --label-col: 180px;
  --section-pad: clamp(72px, 10vw, 128px);
  --header-h: 88px;
  --radius: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html[lang="ckb"] {
  --font-display: "Lateef", "UniSIRWAN SST", serif;
  --font-body: "UniSIRWAN SST", Tahoma, sans-serif;
}

/* ===================================
   BASE
   =================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Set early in <head> when a saved language isn't English; cleared once applied */
html.i18n-pending body {
  visibility: hidden;
}

/* Arabic script: no tracking, slightly taller lines */
html[lang="ckb"] * {
  letter-spacing: normal !important;
}

html[lang="ckb"] body {
  line-height: 1.85;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

ul,
ol {
  list-style: none;
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-weight: 500;
  text-wrap: balance;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

section {
  padding-block: var(--section-pad);
  border-top: 1px solid var(--line);
}

.hero {
  border-top: none;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 4.5vw, 3.25rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin-block-end: clamp(40px, 6vw, 72px);
}

html[lang="ckb"] .section-title {
  font-size: clamp(2.75rem, 5.5vw, 4rem);
}

/* Label column + content column, shared by every section so edges line up */
.split {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.split + .split {
  margin-block-start: clamp(48px, 7vw, 88px);
}

.split-label {
  position: sticky;
  top: var(--header-h);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-block-start: 4px;
}

/* Monospace and uppercase don't suit Arabic script */
html[lang="ckb"] .hero-label,
html[lang="ckb"] .site-footer p {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  text-transform: none;
}

html[lang="ckb"] .split-label {
  font-family: var(--font-body);
  font-size: 0.95rem;
  text-transform: none;
}

/* ===================================
   HEADER - one floating pill
   =================================== */
.site-header {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  padding: 16px var(--gutter);
  pointer-events: none;
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid rgba(22, 23, 26, 0.07);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(22, 23, 26, 0.04), 0 8px 24px rgba(22, 23, 26, 0.06);
  pointer-events: auto;
  max-width: 100%;
  transition: box-shadow 0.4s var(--ease), background-color 0.4s var(--ease);
}

.site-header.scrolled .nav-pill {
  box-shadow: 0 1px 2px rgba(22, 23, 26, 0.05), 0 12px 32px rgba(22, 23, 26, 0.1);
}

.nav-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-menu li {
  position: relative;
  z-index: 1;
}

/* Pill that slides to the active link (positioned by script.js) */
.nav-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--fog);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), width 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s var(--ease);
  pointer-events: none;
}

.nav-link {
  display: block;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.nav-link:hover {
  color: var(--ink);
}

.nav-link.active {
  color: var(--ink);
}

/* Language switcher sits inside the pill, after a hairline divider */
.lang-switcher {
  position: relative;
  padding-inline-start: 4px;
  margin-inline-start: 2px;
  border-inline-start: 1px solid var(--line);
}

.lang-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 37px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 999px;
  font: 500 0.8125rem/1 var(--font-body);
  letter-spacing: 0.04em;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.lang-button:hover,
.lang-switcher.open .lang-button {
  background: var(--fog);
}

.lang-icon {
  transition: transform 0.2s var(--ease);
}

.lang-switcher.open .lang-icon {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 12px);
  inset-inline-end: -5px;
  min-width: 148px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--paper);
  border: 1px solid rgba(22, 23, 26, 0.08);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(22, 23, 26, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
}

.lang-switcher.open .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.lang-option {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font: 500 0.875rem/1.2 var(--font-body);
  text-align: start;
  color: var(--muted);
  cursor: pointer;
}

.lang-option[data-lang="ckb"] {
  font-family: "UniSIRWAN SST", Tahoma, sans-serif;
}

.lang-option:hover {
  color: var(--ink);
  background: var(--fog);
}

.lang-option[aria-selected="true"] {
  color: var(--ink);
  background: var(--fog);
}

/* ===================================
   HERO
   =================================== */
.hero {
  padding-block: calc(var(--header-h) + clamp(64px, 12vw, 160px)) clamp(72px, 10vw, 128px);
}

.hero-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-block-end: 28px;
}

.hero-name {
  font-family: var(--font-display);
  font-size: clamp(3.25rem, 9vw, 6.5rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin-block-end: 28px;
}

html[lang="ckb"] .hero-name {
  font-size: clamp(4rem, 11vw, 8rem);
  line-height: 1.1;
}

.hero-lede {
  max-width: 34ch;
  font-size: clamp(1.125rem, 2.2vw, 1.375rem);
  line-height: 1.5;
  color: var(--text);
  margin-block-end: 40px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}

/* ===================================
   BUTTONS
   =================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 999px;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.btn-primary {
  padding: 13px 24px;
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover {
  background: #33353b;
}

.btn-quiet {
  padding: 13px 4px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.btn-quiet:hover {
  text-decoration-color: var(--ink);
}

.btn-outline {
  padding: 11px 20px;
  border: 1px solid var(--ink);
  color: var(--ink);
}

.btn-outline:hover {
  background: var(--ink);
  color: var(--paper);
}

/* ===================================
   CARDS
   =================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 56px 32px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-media {
  position: relative;
  aspect-ratio: 5 / 3;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--fog);
  box-shadow: 0 0 0 1px rgba(22, 23, 26, 0.08);
  transition: box-shadow 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
  .card:hover .card-media {
    transform: translateY(-4px);
    box-shadow: 0 0 0 1px rgba(22, 23, 26, 0.12), 0 18px 40px -12px rgba(22, 23, 26, 0.18);
  }

  .card:hover .card-img {
    transform: scale(1.03);
  }
}

/* Touch feedback instead of hover on phones */
.card:active .card-media {
  transform: scale(0.99);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-tags {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

html[lang="ckb"] .card-tags {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  text-transform: none;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
}

.card-text {
  font-size: 0.9375rem;
  line-height: 1.65;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

/* The whole card is the link's hit area */
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.card-link .arrow {
  transition: transform 0.2s var(--ease);
}

.card:hover .card-link .arrow {
  transform: translateX(3px);
}

[dir="rtl"] .card-link .arrow {
  transform: scaleX(-1);
}

[dir="rtl"] .card:hover .card-link .arrow {
  transform: scaleX(-1) translateX(3px);
}

.card:has(.card-link:focus-visible) .card-media {
  box-shadow: 0 0 0 2px var(--ink);
}

.card-link:focus-visible {
  outline: none;
}

/* ===================================
   PUBLICATIONS
   =================================== */
.pub-list {
  display: flex;
  flex-direction: column;
}

.pub {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 24px;
  padding-block: 32px;
  border-top: 1px solid var(--line);
}

.pub:first-child {
  padding-block-start: 0;
  border-top: none;
}

.pub-year {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  padding-block-start: 5px;
}

.pub-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
}

.pub-title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  font-weight: 400;
  line-height: 1.3;
}

.pub-title a {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.35s var(--ease);
}

.pub-title a:hover {
  background-size: 100% 1px;
}

[dir="rtl"] .pub-title a {
  background-position: 100% 100%;
}

html[lang="ckb"] .pub-title {
  font-family: "Lora", Georgia, serif;
}

.pub-venue {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
}

html[lang="ckb"] .pub-venue {
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.pub-text {
  font-size: 0.9375rem;
  line-height: 1.65;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 22px;
  margin-block: -6px -10px;
}

.pub-links a {
  padding-block: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
  transition: text-decoration-color 0.2s var(--ease);
}

.pub-links a:hover {
  text-decoration-color: var(--ink);
}

/* ===================================
   ABOUT
   =================================== */
.prose {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lead {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.8vw, 1.875rem);
  font-style: italic;
  line-height: 1.35;
  color: var(--ink);
  text-wrap: balance;
}

html[lang="ckb"] .lead {
  font-style: normal;
  font-size: clamp(1.875rem, 3.4vw, 2.375rem);
}

.entries {
  max-width: 640px;
  display: flex;
  flex-direction: column;
}

.entry {
  display: grid;
  gap: 4px;
  padding-block: 28px;
  border-top: 1px solid var(--line);
}

.entry:first-child {
  padding-block-start: 0;
  border-top: none;
}

.entry-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-block-end: 6px;
}

html[lang="ckb"] .entry-date {
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.entry-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
}

.entry-org {
  font-size: 0.9375rem;
  color: var(--muted);
}

.entry-text {
  margin-block-start: 8px;
  font-size: 0.9375rem;
}

.cv-button {
  margin-block-start: 16px;
}

/* ===================================
   SKILLS
   =================================== */
#skills .split + .split {
  margin-block-start: 0;
  padding-block-start: 28px;
  border-top: 1px solid var(--line);
}

#skills .split {
  padding-block-end: 28px;
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  max-width: 720px;
  font-size: 1rem;
  color: var(--ink);
}

/* ===================================
   CONTACT
   =================================== */
.contact {
  max-width: 640px;
}

.contact-lead {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.8vw, 1.875rem);
  font-style: italic;
  line-height: 1.35;
  color: var(--ink);
  text-wrap: balance;
  margin-block-end: 32px;
}

html[lang="ckb"] .contact-lead {
  font-style: normal;
  font-size: clamp(1.875rem, 3.4vw, 2.375rem);
}

.contact-email {
  display: inline-block;
  font-size: clamp(1.125rem, 2.6vw, 1.5rem);
  font-weight: 500;
  color: var(--ink);
  direction: ltr;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  transition: text-decoration-color 0.2s var(--ease);
  margin-block-end: 32px;
}

.contact-email:hover {
  text-decoration-color: var(--ink);
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 28px;
  margin-block: -10px;
}

.social-links a {
  padding-block: 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.social-links a:hover {
  color: var(--ink);
}

/* ===================================
   FOOTER
   =================================== */
.site-footer {
  padding-block: 32px;
  border-top: 1px solid var(--line);
}

.site-footer p {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 900px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .split-label {
    position: static;
  }

  .split-label:empty {
    display: none;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 16px;
  }

  :root {
    --header-h: 72px;
    --section-pad: 64px;
  }

  .site-header {
    padding: 12px 12px;
  }

  .nav-link {
    padding: 8px 11px;
    font-size: 0.8125rem;
  }

  .lang-button {
    padding: 8px 10px;
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 44px;
  }

  .entry {
    padding-block: 22px;
  }

  .hero-actions {
    gap: 8px 20px;
  }
}

@media (max-width: 380px) {
  .nav-link {
    padding: 8px 8px;
  }
}

/* ===================================
   MOTION
   =================================== */
/* Hero enters in a short stagger on load; ends fully visible even without JS */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero .container > * {
  animation: rise-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero .container > :nth-child(1) { animation-delay: 0.05s; }
.hero .container > :nth-child(2) { animation-delay: 0.15s; }
.hero .container > :nth-child(3) { animation-delay: 0.27s; }
.hero .container > :nth-child(4) { animation-delay: 0.39s; }

.site-header {
  animation: rise-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Scroll reveal: only armed once script.js adds .motion */
html.motion .reveal {
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
}

html.motion .reveal:not(.in) {
  opacity: 0;
  transform: translate3d(0, 16px, 0);
}

/* Language change crossfade */
main,
.site-footer {
  transition: opacity 0.22s var(--ease);
}

html.lang-switching main,
html.lang-switching .site-footer {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
