/* =============================================================================
   Mohamed Khaled Shoaib — portfolio
   Palette: "Ledger". Warm paper, deep ink, petrol teal, stamp gold — drawn from
   the world this work lives in: invoices, ledgers, tax-authority documents.
   ========================================================================== */

/* ---- tokens: complete light palette on bare :root ------------------------ */
:root {
  --paper:    #EEEFE9;
  --surface:  #F8F9F5;
  --sunk:     #E6E8DF;
  --ink:      #14181B;
  --ink-2:    #3A433F;
  --muted:    #6B746E;
  --line:     #D6D9CF;
  --line-soft:#E2E5DA;

  --teal:     #0B7A75;
  --teal-dim: #0B7A7526;
  --gold:     #A8761A;
  --rust:     #A8442A;

  --shadow:   0 1px 2px rgba(20,24,27,.04), 0 12px 32px -18px rgba(20,24,27,.30);
  --shadow-lg:0 2px 4px rgba(20,24,27,.05), 0 28px 60px -30px rgba(20,24,27,.40);

  --f-display: 'Familjen Grotesk', 'Segoe UI', system-ui, sans-serif;
  --f-body:    'Public Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-mono:    'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --rail: 76px;                 /* left rail width on desktop */
  --measure: 66ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:    #0C1211;
    --surface:  #121A18;
    --sunk:     #0F1716;
    --ink:      #E9EDE7;
    --ink-2:    #BDC6BF;
    --muted:    #869089;
    --line:     #202C29;
    --line-soft:#1A2422;

    --teal:     #4FC3B8;
    --teal-dim: #4FC3B821;
    --gold:     #DCA84E;
    --rust:     #E0745A;

    --shadow:   0 1px 2px rgba(0,0,0,.5), 0 12px 32px -18px rgba(0,0,0,.8);
    --shadow-lg:0 2px 4px rgba(0,0,0,.55), 0 28px 60px -30px rgba(0,0,0,.9);
  }
}

:root[data-theme="dark"] {
  --paper:    #0C1211;
  --surface:  #121A18;
  --sunk:     #0F1716;
  --ink:      #E9EDE7;
  --ink-2:    #BDC6BF;
  --muted:    #869089;
  --line:     #202C29;
  --line-soft:#1A2422;

  --teal:     #4FC3B8;
  --teal-dim: #4FC3B821;
  --gold:     #DCA84E;
  --rust:     #E0745A;

  --shadow:   0 1px 2px rgba(0,0,0,.5), 0 12px 32px -18px rgba(0,0,0,.8);
  --shadow-lg:0 2px 4px rgba(0,0,0,.55), 0 28px 60px -30px rgba(0,0,0,.9);
}

/* ---- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.022em;
  text-wrap: balance;
  margin: 0;
}

a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 3px; }

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

/* ---- scroll progress rail ------------------------------------------------ */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 90;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}
@supports (animation-timeline: scroll()) {
  .progress {
    transform: scaleX(0);
    animation: grow linear both;
    animation-timeline: scroll(root block);
  }
  @keyframes grow { to { transform: scaleX(1); } }
}

/* ---- shell --------------------------------------------------------------- */
.shell { max-width: 1120px; margin: 0 auto; padding: 0 26px; }

section { position: relative; }

.eyebrow {
  font-family: var(--f-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: .2em; text-transform: uppercase; color: var(--teal);
  display: flex; align-items: center; gap: 12px; margin: 0 0 18px;
}
.eyebrow::before {
  content: ""; width: 26px; height: 1.5px; background: var(--teal); flex: none;
}

.sec-head { margin-bottom: 44px; }
.sec-head h2 { font-size: clamp(30px, 4.4vw, 46px); margin-bottom: 14px; }
.sec-head p { color: var(--muted); max-width: var(--measure); margin: 0; font-size: 17.5px; }

/* =============================================================================
   HERO
   ========================================================================== */
/* sized to what it holds, not to the viewport — a tall screen should show the
   first section underneath, not a screenful of empty ground */
.hero {
  display: flex; align-items: center;
  padding: clamp(84px, 11vh, 132px) 0 clamp(60px, 8vh, 96px);
  border-bottom: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.hero-grid {
  position: absolute; inset: 0; z-index: 0; opacity: .5;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 85% 70% at 70% 30%, #000 25%, transparent 78%);
}
.hero .shell { position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(42px, 8.4vw, 92px);
  margin: 0 0 26px;
  max-width: 17ch;
}
.hero h1 .accent {
  color: var(--teal);
  position: relative; white-space: nowrap;
}
.hero-sub {
  font-size: clamp(17px, 2.1vw, 21px); color: var(--ink-2);
  max-width: 58ch; margin: 0 0 34px;
}
.hero-meta {
  display: flex; gap: 10px 26px; flex-wrap: wrap; align-items: center;
  font-family: var(--f-mono); font-size: 13px; color: var(--muted);
  padding-top: 22px; border-top: 1px solid var(--line);
}
.hero-meta .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); display: inline-block; margin-right: 8px; }

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 40px; }
.btn {
  font-family: var(--f-mono); font-size: 12.5px; font-weight: 500;
  letter-spacing: .07em; text-transform: uppercase;
  padding: 13px 22px; border-radius: 2px; border: 1.5px solid var(--ink);
  background: var(--ink); color: var(--paper); text-decoration: none;
  transition: background .18s, color .18s, border-color .18s;
  display: inline-block;
}
.btn:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* =============================================================================
   SCROLLYTELLING — the system builds itself as you scroll
   ========================================================================== */
.scrolly { padding: 104px 0 40px; }
.scrolly-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; }

.scrolly-stage {
  position: sticky; top: 12vh; height: 76vh;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface); box-shadow: var(--shadow);
  overflow: hidden;
}
.stage-svg { width: 100%; height: 100%; }

/* every node starts drawn but dim; the active step lifts it */
.node { opacity: .26; transition: opacity .55s ease; }
.node.lit { opacity: 1; }

/* diagram paint lives here, not in presentation attributes: var() is not
   reliably honoured inside SVG attributes, especially font-family */
.n-box  { fill: var(--sunk);    stroke: var(--line); stroke-width: 1; }
.n-core { fill: var(--surface); stroke: var(--teal); stroke-width: 2; }
.n-gate { fill: var(--surface); stroke: var(--gold); stroke-width: 2; }
.n-tax  { fill: var(--sunk);    stroke: var(--rust); stroke-width: 1.4; }

.stage-svg text { text-anchor: middle; }
.t-mono { font-family: var(--f-mono); font-size: 13px; fill: var(--ink-2); }
.t-disp { font-family: var(--f-display); font-size: 21px; font-weight: 700; fill: var(--ink); }
.t-disp.sm { font-size: 16px; }
.t-sub  { font-family: var(--f-mono); font-size: 11.5px; fill: var(--muted); }

.lock-disc    { fill: var(--gold); }
.lock-shackle { fill: none; stroke: var(--surface); stroke-width: 2; }
.lock-body    { fill: var(--surface); }

.stage-svg marker path { fill: var(--teal); }

.wire {
  fill: none; stroke: var(--teal); stroke-width: 1.8;
  stroke-dasharray: 5 8; opacity: .16; transition: opacity .55s ease;
}
.wire.lit { opacity: .95; animation: dash 2.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -26; } }
@media (prefers-reduced-motion: reduce) { .wire.lit { animation: none; } }

.badge-lock { opacity: 0; transition: opacity .5s ease .15s; }
.badge-lock.lit { opacity: 1; }

.scrolly-steps { display: flex; flex-direction: column; gap: 4vh; padding: 8vh 0 18vh; }
.step {
  min-height: 46vh; display: flex; flex-direction: column; justify-content: center;
  padding-left: 26px; border-left: 2px solid var(--line);
  transition: border-color .4s ease;
}
.step.active { border-left-color: var(--teal); }
.step-n {
  font-family: var(--f-mono); font-size: 12px; letter-spacing: .16em;
  color: var(--muted); margin-bottom: 12px; transition: color .4s;
}
.step.active .step-n { color: var(--teal); }
.step h3 { font-size: clamp(23px, 2.9vw, 31px); margin-bottom: 13px; }
.step p { color: var(--ink-2); margin: 0; max-width: 46ch; font-size: 16.5px; }
.step code {
  font-family: var(--f-mono); font-size: .86em; background: var(--sunk);
  padding: 2px 6px; border-radius: 2px; border: 1px solid var(--line-soft);
}

/* =============================================================================
   WORK
   ========================================================================== */
.work { padding: 104px 0; border-top: 1px solid var(--line); }
.work-list { display: flex; flex-direction: column; gap: 22px; }

.proj {
  display: grid; grid-template-columns: var(--rail) 1fr; gap: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 3px; overflow: hidden;
  transition: border-color .25s, box-shadow .25s, transform .25s;
}
.proj:hover { border-color: var(--teal); box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.proj-rail {
  background: var(--sunk); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 22px 0; gap: 10px;
}
.proj-num {
  font-family: var(--f-mono); font-size: 12px; color: var(--muted); letter-spacing: .08em;
}
.proj-commits {
  font-family: var(--f-mono); font-size: 10.5px; color: var(--teal);
  writing-mode: vertical-rl; letter-spacing: .14em; margin-top: 4px;
}

.proj-body { padding: 26px 30px 28px; min-width: 0; }
.proj-top { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.proj-body h3 { font-size: 24px; letter-spacing: -.015em; }
.proj-kind {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 2px; padding: 3px 8px;
}
.proj-kind.mine { color: var(--gold); border-color: var(--gold); }
.proj-lede { color: var(--ink-2); margin: 0 0 16px; max-width: var(--measure); }
.proj-note {
  border-left: 2px solid var(--gold); padding: 11px 0 11px 16px;
  margin: 0 0 16px; color: var(--ink-2); font-size: 15.5px;
  background: linear-gradient(90deg, var(--teal-dim), transparent 70%);
  max-width: var(--measure);
}
.proj-note b { color: var(--ink); font-weight: 600; }
.tags { display: flex; gap: 7px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.tags li {
  font-family: var(--f-mono); font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 2px; padding: 3px 9px;
  background: var(--paper);
}

/* =============================================================================
   PRINCIPLES
   ========================================================================== */
.principles { padding: 104px 0; border-top: 1px solid var(--line); background: var(--surface); }
.prin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.prin { background: var(--surface); padding: 32px 30px; }
.prin h3 { font-size: 19px; margin-bottom: 10px; }
.prin p { margin: 0; color: var(--muted); font-size: 16px; }
.prin .mark {
  font-family: var(--f-mono); font-size: 11px; color: var(--gold);
  letter-spacing: .16em; display: block; margin-bottom: 14px;
}

/* =============================================================================
   TIMELINE
   ========================================================================== */
.xp { padding: 104px 0; border-top: 1px solid var(--line); }
.xp-list { border-top: 1px solid var(--line); }
.xp-row {
  display: grid; grid-template-columns: 200px 1fr; gap: 28px;
  padding: 28px 0; border-bottom: 1px solid var(--line); align-items: start;
}
.xp-co { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.xp-role { font-family: var(--f-mono); font-size: 12px; color: var(--teal); margin-top: 5px; letter-spacing: .04em; }
.xp-body { color: var(--ink-2); max-width: var(--measure); }
.xp-body p { margin: 0; }

/* =============================================================================
   STACK
   ========================================================================== */
.stack { padding: 104px 0; border-top: 1px solid var(--line); background: var(--surface); }
.stack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.stack-col h3 {
  font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold); font-weight: 500; margin-bottom: 14px;
  padding-bottom: 9px; border-bottom: 1px solid var(--line);
}
.stack-col ul { list-style: none; margin: 0; padding: 0; columns: 1; }
.stack-col li { padding: 4px 0; color: var(--ink-2); font-size: 15.5px; }

/* =============================================================================
   CONTACT
   ========================================================================== */
.contact { padding: 112px 0 96px; border-top: 1px solid var(--line); }
.contact h2 { font-size: clamp(32px, 5.6vw, 60px); max-width: 16ch; margin-bottom: 22px; }
.contact p { color: var(--ink-2); max-width: 52ch; font-size: 18px; margin: 0 0 34px; }

footer {
  border-top: 1px solid var(--line); padding: 26px 0;
  font-family: var(--f-mono); font-size: 12px; color: var(--muted);
}
footer .shell { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* =============================================================================
   SCROLL-DRIVEN REVEALS  (progressive enhancement — content is visible by
   default; browsers that support view() timelines get the motion)
   ========================================================================== */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 8% cover 26%;
    }
    @keyframes rise {
      from { opacity: 0; transform: translateY(26px); }
      to   { opacity: 1; transform: none; }
    }
    .hero h1, .hero-sub { animation: fadeOut linear both; animation-timeline: view(); animation-range: exit 0% exit 90%; }
    @keyframes fadeOut { to { opacity: .12; transform: translateY(-26px); } }
  }
}

/* =============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  .scrolly-layout { grid-template-columns: 1fr; gap: 0; }
  .scrolly-stage { height: 44vh; top: 8vh; margin-bottom: 18px; }
  .scrolly-steps { padding: 4vh 0 10vh; gap: 2vh; }
  .step { min-height: 34vh; }
  .prin-grid, .stack-grid { grid-template-columns: 1fr; }
  .xp-row { grid-template-columns: 1fr; gap: 10px; }
  .proj { grid-template-columns: 46px 1fr; }
  .proj-commits { display: none; }
  .proj-body { padding: 20px 18px 22px; }
  body { font-size: 16px; }
}
@media (max-width: 560px) {
  .hero { min-height: auto; padding: 84px 0 56px; }
  .shell { padding: 0 18px; }
}
