/* ==========================================================================
   Portfolio — global styles
   Tokens first; every colour on the page comes from these, so the dark theme
   is one block of overrides. Section-specific rules live beside each section
   (sections/<name>/<name>.css).

   Palette — Nordic daylight / polar night:
     snow    #F2F4F1   page
     fjord   #15283A   ink, headings
     slate   #5B6B78   secondary text
     frost   #D5DCD9   lines
     spruce  #2E6B57   links, bars, focus
     berry   #E58A2E   cloudberry — the one warm thing: primary buttons
   ========================================================================== */

:root {
  --paper: #f2f4f1;
  --surface: #ffffff;
  --ink: #15283a;
  --muted: #5b6b78;
  --line: #d5dcd9;
  --spruce: #2e6b57;
  --spruce-soft: #dfeae5;
  --berry: #e58a2e;
  --berry-ink: #1d1206;
  --danger: #b3261e;
  --ok: #2e6b57;

  --font-display: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Readex Pro", system-ui, sans-serif;

  /* Type scale — a perfect fourth (1.333) from 17px. */
  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: 1.4rem;
  --step-2: 1.875rem;
  --step-3: clamp(2rem, 4.2vw, 2.6rem);
  --step-4: clamp(2.5rem, 6.4vw, 4.6rem);

  --gutter: clamp(16px, 4vw, 40px);
  --max: 1160px;
  --radius-s: 6px;
  --radius-m: 14px;
  --header-h: 64px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1b25;
    --surface: #152431;
    --ink: #e6ecea;
    --muted: #93a3ae;
    --line: #243443;
    --spruce: #74b9a0;
    --spruce-soft: #1b3330;
    --berry: #f0a24f;
    --danger: #ff8a80;
    --ok: #74b9a0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1b25;
  --surface: #152431;
  --ink: #e6ecea;
  --muted: #93a3ae;
  --line: #243443;
  --spruce: #74b9a0;
  --spruce-soft: #1b3330;
  --berry: #f0a24f;
  --danger: #ff8a80;
  --ok: #74b9a0;
  color-scheme: dark;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.7;
  overflow-x: hidden;
}
:lang(en) body, body:lang(en) { line-height: 1.6; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

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

.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }
.icon { width: 24px; height: 24px; flex: none; }
.icon-img { width: 28px; height: 28px; object-fit: contain; }
.icon-emoji { font-size: 26px; line-height: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--radius-s);
}
.skip:focus { top: 12px; }

/* ── Sections ──────────────────────────────────────────────────────────── */
.section { padding-block: clamp(64px, 10vw, 120px); }
.section + .section { border-top: 1px solid var(--line); }
.section-title {
  font-size: var(--step-3);
  margin-bottom: clamp(28px, 4vw, 48px);
  max-width: 22ch;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 1.5px solid var(--ink);
  background: transparent; color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .15s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--berry); border-color: var(--berry); color: var(--berry-ink); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-small { min-height: 38px; padding: 0 16px; font-size: var(--step--1); }
.btn[disabled] { opacity: .6; cursor: progress; }

.link {
  color: var(--spruce); font-weight: 600; text-decoration: underline;
  text-decoration-thickness: 1.5px; text-underline-offset: 4px;
}
.link:hover { color: var(--ink); }

.tag {
  display: inline-block; padding: 2px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: var(--step--1); color: var(--muted); white-space: nowrap;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }
.header-row { height: var(--header-h); display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.brand img { height: 34px; width: auto; }
.nav { margin-inline-start: auto; }
.nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: 8px 12px; border-radius: 999px;
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a:hover, .nav a[aria-current="true"] { color: var(--ink); background: var(--spruce-soft); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 42px; height: 42px; display: inline-grid; place-items: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--spruce-soft); }
.lang-switch { padding: 8px 12px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .95rem; }
.lang-switch:hover { background: var(--spruce-soft); }
.menu-btn { display: none; }
.theme-btn .icon-moon { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: block; }

@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0; margin: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 12px var(--gutter) 20px;
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity .18s, transform .18s, visibility .18s;
  }
  .nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav ul { flex-direction: column; }
  .nav a { padding: 12px; font-size: 1.1rem; }
  .header-actions { margin-inline-start: auto; }
}

/* ── About ─────────────────────────────────────────────────────────────── */
.about-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: clamp(32px, 6vw, 80px); align-items: start; }
.about-photo { border-radius: var(--radius-m); aspect-ratio: 4 / 5; object-fit: cover; width: 100%; background: var(--spruce-soft); }
.about-bio { font-size: 1.15rem; max-width: 60ch; white-space: pre-line; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 40px 0 0; padding: 0; }
.stat { border-top: 2px solid var(--ink); padding-top: 14px; }
.stat dt { color: var(--muted); font-size: var(--step--1); }
.stat dd { margin: 0; font-family: var(--font-display); font-size: var(--step-2); font-weight: 600; font-variant-numeric: tabular-nums; order: -1; }
.stat { display: flex; flex-direction: column; }
@media (max-width: 780px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-photo { max-width: 360px; }
}

/* ── Services ──────────────────────────────────────────────────────────── */
.services { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(32px, 6vw, 72px); list-style: none; margin: 0; padding: 0; }
.service { display: grid; grid-template-columns: 44px 1fr; gap: 6px 18px; padding: 26px 0; border-top: 1px solid var(--line); }
.service-icon { grid-row: span 2; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--spruce-soft); color: var(--spruce); }
.service h3 { font-size: var(--step-1); }
.service p { color: var(--muted); max-width: 52ch; }
@media (max-width: 720px) { .services { grid-template-columns: 1fr; } }

/* ── Skills ────────────────────────────────────────────────────────────── */
.skill-groups { display: grid; gap: 8px; }
.skill-group { display: grid; grid-template-columns: 200px 1fr; gap: 24px; padding: 24px 0; border-top: 1px solid var(--line); }
.skill-group h3 { font-size: var(--step-1); }
.skill-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 32px; }
.skill-head { display: flex; align-items: center; gap: 10px; }
.skill-head img { width: 20px; height: 20px; object-fit: contain; }
.skill-name { font-weight: 600; }
.skill-pct { margin-inline-start: auto; color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--spruce); border-radius: inherit; width: var(--w, 0%); }
@media (max-width: 720px) { .skill-group { grid-template-columns: 1fr; gap: 14px; } }

/* ── Testimonials ──────────────────────────────────────────────────────── */
.quotes-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: clamp(28px, 4vw, 48px); }
.quotes-head .section-title { margin: 0; }
.quotes-nav { display: flex; gap: 8px; }
.quotes-nav .icon-btn { border: 1.5px solid var(--line); }
[dir="rtl"] .quotes-nav .prev .icon { transform: none; }
[dir="ltr"] .quotes-nav .prev .icon { transform: scaleX(-1); }
[dir="rtl"] .quotes-nav .next .icon { transform: scaleX(-1); }
.quotes {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(560px, 86%);
  gap: 24px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 12px;
  list-style: none; margin: 0; padding-inline: 0; scrollbar-width: thin;
}
.quote { scroll-snap-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; display: flex; flex-direction: column; gap: 22px; }
.quote blockquote { margin: 0; font-size: 1.15rem; white-space: pre-line; }
.quote-stars { display: flex; gap: 2px; color: var(--berry); }
.quote-stars .icon { width: 16px; height: 16px; fill: currentColor; }
.quote figcaption { display: flex; align-items: center; gap: 12px; margin-top: auto; }
.quote-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--spruce-soft); display: grid; place-items: center; font-weight: 600; color: var(--spruce); flex: none; }
.quote-name { font-weight: 600; display: block; }
.quote-role { color: var(--muted); font-size: var(--step--1); }

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--line); padding-block: 40px; color: var(--muted); }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; }
.footer-row .brand { color: var(--ink); }
.socials { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; margin: 0; padding: 0; }
.socials a { text-decoration: none; font-weight: 500; }
.socials a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.to-top { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }

/* ── Skeletons (only when the page arrived without its content) ────────── */
.skeleton { position: relative; overflow: hidden; background: var(--line); border-radius: var(--radius-s); color: transparent !important; min-height: 1em; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-line { height: 14px; margin: 10px 0; }
.sk-title { height: 34px; width: 60%; }
.sk-block { height: 180px; border-radius: var(--radius-m); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; z-index: 200; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: min(92vw, 480px);
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(10, 20, 30, .25);
  animation: toast-in .2s ease-out;
}
.toast.is-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
