/* ============================================================
   style.css — Mansoor Mamnoon — Route Table Portfolio
   Fonts: Fraunces (headings) · DM Sans (body) · JetBrains Mono (code/tables)
   Dark:  Charcoal Plum + Bone + Signal Orange
   Light: Bone Light + Clay Red + Eucalyptus
   ============================================================ */

@layer reset, tokens, base, layout, components, utilities;

@property --gradient-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 135deg;
}

/* ============================================================
   RESET
   ============================================================ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; tab-size: 4; }
  img, video, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; }
  p, h1, h2, h3, h4 { overflow-wrap: break-word; }
  button { cursor: pointer; background: none; border: none; }
  a { color: inherit; }
  ul, ol { list-style: none; }
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
@layer tokens {
  :root {
    /* ── Dark mode (default): Charcoal Plum + Bone + Signal Orange ── */
    --bg:           #15111c;
    --surface:      #211a2b;
    --surface-soft: #2a2135;
    --surface-muted:#191420;

    --text:         #f4efe7;
    --muted:        #a99bb5;
    --muted-dim:    #7f718b;

    --border:       #3a3047;
    --border-dim:   #2e2540;

    --accent:       #ff8a4c;   /* signal orange — primary CTAs, active nav, left-border highlights */
    --accent-2:     #c7f464;   /* acid pistachio — route paths, technical mono highlights */
    --metric:       #91e6b3;   /* soft mint — numeric metrics */
    --danger:       #ff6b6b;

    /* Derived semi-transparent tints */
    --accent-glow:  color-mix(in srgb, var(--accent)   12%, transparent);
    --accent-dim:   color-mix(in srgb, var(--accent-2)  7%, transparent);
    --accent-mid:   color-mix(in srgb, var(--accent-2) 14%, transparent);
    --metric-dim:   color-mix(in srgb, var(--metric)    8%, transparent);

    /* Typography */
    --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-sans:  'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono:  'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

    /* Spacing */
    --s1: 0.25rem;  --s2: 0.5rem;   --s3: 0.75rem;  --s4: 1rem;
    --s5: 1.25rem;  --s6: 1.5rem;   --s8: 2rem;     --s10: 2.5rem;
    --s12: 3rem;    --s16: 4rem;    --s20: 5rem;    --s24: 6rem;

    /* Layout */
    --nav-h: 56px;
    --max-w: 1080px;
    --content-px: clamp(1rem, 4vw, 2.5rem);
    --radius: 4px;

    /* Transitions */
    --t: 120ms ease;
    --t-slow: 280ms ease;
  }

  [data-theme="light"] {
    /* ── Light mode: Bone Light + Clay Red + Eucalyptus ── */
    --bg:           #f4eadc;
    --surface:      #fff8ec;
    --surface-soft: #eadcc8;
    --surface-muted:#efe2cf;

    --text:         #231916;
    --muted:        #74665d;
    --muted-dim:    #9a8b80;

    --border:       #dbcab8;
    --border-dim:   #e8d8c6;

    --accent:       #b7412e;   /* clay red — primary CTAs, active nav */
    --accent-2:     #315c54;   /* eucalyptus — route paths, technical highlights */
    --metric:       #26735d;   /* muted green — metrics */
    --danger:       #b7412e;

    /* Derived */
    --accent-glow:  color-mix(in srgb, var(--accent)   10%, transparent);
    --accent-dim:   color-mix(in srgb, var(--accent-2)  8%, transparent);
    --accent-mid:   color-mix(in srgb, var(--accent-2) 15%, transparent);
    --metric-dim:   color-mix(in srgb, var(--metric)    8%, transparent);
  }
}

/* ============================================================
   BASE
   ============================================================ */
@layer base {
  html { background: var(--bg); scroll-behavior: smooth; }

  body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background var(--t-slow), color var(--t-slow);
    position: relative;
  }

  /* Engineering-paper grid texture */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image:
      linear-gradient(color-mix(in srgb, var(--border) 18%, transparent) 1px, transparent 1px),
      linear-gradient(90deg, color-mix(in srgb, var(--border) 18%, transparent) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.18;
  }

  [data-theme="light"] body::before { opacity: 0.12; }

  /* Serif only for major display text */
  h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 400;
    line-height: 1.2;
    font-optical-sizing: auto;
  }

  h4, h5, h6 {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 400;
  }

  a { text-decoration: none; transition: color var(--t); }

  code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--metric);
    background: var(--metric-dim);
    padding: 0.1em 0.35em;
    border-radius: var(--radius);
  }

  /* Prose links (notes, about story) */
  .note-body a,
  .about-story a {
    color: var(--accent-2);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent-2) 40%, transparent);
  }

  ::selection { background: var(--accent); color: var(--bg); }

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

  ::-webkit-scrollbar { width: 5px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--muted-dim); }
}

/* ============================================================
   LAYOUT
   ============================================================ */
@layer layout {

  /* ── Scroll Progress (pure CSS scroll-driven) ──────────── */
  #scroll-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    transform-origin: left center;
    transform: scaleX(0);
    z-index: 2000;
  }

  @supports (animation-timeline: scroll()) {
    #scroll-progress {
      animation: grow-progress linear both;
      animation-timeline: scroll(root block);
    }
    @keyframes grow-progress { to { transform: scaleX(1); } }
  }

  /* ── Nav ─────────────────────────────────────────────────── */
  .nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--nav-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border-dim);
    display: flex;
    align-items: center;
    padding: 0 var(--content-px);
    transition: background var(--t-slow), border-color var(--t-slow);
  }

  .nav-inner {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--s5);
  }

  .nav-logo {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    color: var(--text);
    font-weight: 400;
    flex-shrink: 0;
    text-decoration: none;
    transition: color var(--t);
    font-optical-sizing: auto;
  }
  .nav-logo:hover { color: var(--accent); }

  .nav-links {
    display: flex;
    align-items: center;
    gap: var(--s5);
    margin-left: auto;
  }

  .nav-link {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
    transition: color var(--t);
  }

  .nav-link:hover { color: var(--text); }
  .nav-link.active { color: var(--accent); }

  .nav-resume {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.28rem 0.65rem;
    border-radius: 3px;
    transition: border-color var(--t), color var(--t);
    text-decoration: none;
    white-space: nowrap;
  }

  .nav-resume:hover, .nav-resume.active { border-color: var(--accent); color: var(--accent); }

  .nav-actions {
    display: flex;
    align-items: center;
    gap: var(--s2);
    margin-left: var(--s3);
  }

  .nav-icon-btn {
    color: var(--muted);
    padding: var(--s1);
    transition: color var(--t);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 0.9rem;
  }

  .nav-icon-btn:hover { color: var(--text); }

  .nav-cmd-subtle {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--muted-dim);
    border: 1px solid var(--border-dim);
    padding: 0.18rem 0.45rem;
    border-radius: 3px;
    letter-spacing: 0.04em;
    opacity: 0.45;
    transition: color var(--t), border-color var(--t), opacity var(--t);
  }
  .nav-cmd-subtle:hover { color: var(--muted); border-color: var(--border); opacity: 1; }

  @media (max-width: 760px) {
    .nav-cmd-subtle { display: none; }
  }

  .nav-hamburger {
    display: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    margin-left: auto;
    transition: color var(--t);
  }
  .nav-hamburger:hover { color: var(--text); }

  .nav-drawer {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--s6) var(--content-px);
    z-index: 999;
    flex-direction: column;
    gap: var(--s4);
  }

  .nav-drawer.open { display: flex; }

  .nav-drawer .nav-link {
    font-size: 0.95rem;
    color: var(--text);
    padding: var(--s2) 0;
    border-bottom: 1px solid var(--border-dim);
  }

  .nav-drawer .nav-resume { display: inline-block; margin-top: var(--s2); }

  @media (max-width: 700px) {
    .nav-links, .nav-actions { display: none; }
    .nav-hamburger { display: block; }
  }

  /* ── Page Wrapper ─────────────────────────────────────────── */
  .page {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--s12) var(--content-px) var(--s24);
  }

  /* ── Section Label ────────────────────────────────────────── */
  .section-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted-dim);
    padding-bottom: var(--s3);
    border-bottom: 1px solid var(--border);
  }

  .section-kicker {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted-dim);
    margin: var(--s3) 0 var(--s5);
    line-height: 1.5;
    max-width: 560px;
  }

  /* ── Footer ───────────────────────────────────────────────── */
  .footer {
    border-top: 1px solid var(--border-dim);
    padding: var(--s8) var(--content-px);
    margin-top: var(--s24);
  }

  .footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    flex-wrap: wrap;
  }

  .footer-copy {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted-dim);
  }

  .footer-links { display: flex; gap: var(--s5); flex-wrap: wrap; }

  .footer-link {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted);
    transition: color var(--t);
  }

  .footer-link:hover { color: var(--accent); }
}

/* ============================================================
   COMPONENTS
   ============================================================ */
@layer components {

  /* ── Buttons ──────────────────────────────────────────────── */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--t), color var(--t), background var(--t), transform var(--t);
    white-space: nowrap;
  }

  .btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
  }

  .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
  }

  [data-theme="light"] .btn-primary { color: #fff8ec; }

  .btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
    color: var(--bg);
  }

  [data-theme="light"] .btn-primary:hover { color: #fff8ec; }

  .btn-group { display: flex; flex-wrap: wrap; gap: var(--s3); }

  /* ── Badges ───────────────────────────────────────────────── */
  .badge {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.05em;
    padding: 0.18rem 0.5rem;
    border-radius: 2px;
    white-space: nowrap;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
  }

  .badge-hot, .badge-intern, .badge-incoming, .badge-security, .badge-perf, .badge-metric {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  }

  .badge-tools, .badge-ml {
    color: var(--accent-2);
    border-color: color-mix(in srgb, var(--accent-2) 35%, transparent);
  }

  .badge-neutral {
    color: var(--muted-dim);
    border-color: var(--border);
  }

  /* ── Identity (Hero) ──────────────────────────────────────── */
  .identity {
    padding: var(--s12) 0 var(--s10);
    border-bottom: 1px solid var(--border);
  }

  .identity-meta {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.04em;
    margin-bottom: var(--s4);
    display: flex;
    align-items: center;
    gap: var(--s3);
    flex-wrap: wrap;
  }

  /* Blinking block cursor */
  .identity-meta::before {
    content: '▋';
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent);
    animation: cursor-blink 1.2s step-end infinite;
    flex-shrink: 0;
    line-height: 1;
  }

  @keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
  }

  .identity-name {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400;
    margin-bottom: var(--s3);
    letter-spacing: -0.01em;
    font-optical-sizing: auto;
  }

  .identity-role {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: var(--s6);
    letter-spacing: 0.02em;
  }

  .identity-proof {
    display: flex;
    flex-direction: column;
    gap: var(--s3);
    max-width: 660px;
    margin-bottom: var(--s8);
  }

  .identity-proof p {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.65;
    padding-left: var(--s4);
    border-left: 2px solid var(--border);
    transition: border-color var(--t);
  }

  .identity-proof p:hover { border-left-color: var(--accent); }

  .identity-proof strong {
    color: var(--text);
    font-weight: 500;
  }

  .identity-photo {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-bottom: var(--s5);
    display: block;
  }

  /* ── 5-Second Scan Block ─────────────────────────────────── */
  .scan-card {
    padding: var(--s6) 0;
    border-bottom: 1px solid var(--border);
  }

  .scan-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2) var(--s5);
    margin-top: var(--s4);
  }

  .scan-grid span {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--muted);
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border-dim);
    border-radius: 2px;
    transition: border-color var(--t), color var(--t);
  }

  .scan-grid span:hover { border-color: var(--border); color: var(--text); }

  /* ── Routes / Signal Table ──────────────────────────────── */
  .routes {
    padding: var(--s10) 0;
    border-bottom: 1px solid var(--border);
  }

  .routes-outer {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: var(--s8);
    align-items: start;
  }

  @media (max-width: 860px) {
    .routes-outer { grid-template-columns: 1fr; }
    .route-preview { display: none !important; }
  }

  .routes-head {
    display: grid;
    grid-template-columns: 2fr 100px 1.6fr 1.2fr 1.5rem;
    gap: var(--s4);
    padding: var(--s3) 0;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-dim);
    border-bottom: 1px solid var(--border-dim);
  }

  .route-row {
    display: grid;
    grid-template-columns: 2fr 100px 1.6fr 1.2fr 1.5rem;
    gap: var(--s4);
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-dim);
    text-decoration: none;
    color: inherit;
    align-items: center;
    border-left: 2px solid transparent;
    padding-left: 0;
    transition: border-color var(--t), background var(--t), padding var(--t);
  }

  .route-row:hover,
  .route-row:focus-visible {
    border-left-color: var(--accent);
    background: var(--surface-soft);
    padding-left: var(--s3);
  }

  .route-row:hover .route-path { color: var(--accent-2); }
  .route-row:hover .route-arrow { color: var(--accent); opacity: 1; }

  .route-path {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-2);
    transition: color var(--t);
  }

  .route-signal {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
  }

  .route-tech {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted-dim);
  }

  .route-arrow {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity var(--t), color var(--t);
    text-align: right;
  }

  /* Route Preview Panel */
  .route-preview {
    position: sticky;
    top: calc(var(--nav-h) + var(--s6));
    padding: var(--s5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    min-height: 140px;
  }

  .route-preview.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .preview-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: var(--s3);
  }

  .preview-name {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--text);
    margin-bottom: var(--s2);
    font-optical-sizing: auto;
  }

  .preview-desc {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: var(--s3);
  }

  .preview-tech {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--accent-2);
  }

  @media (max-width: 700px) {
    .routes-head { display: none; }
    .route-row {
      grid-template-columns: 1fr auto;
      grid-template-rows: auto auto;
      gap: var(--s1) var(--s3);
    }
    .route-path   { grid-column: 1; grid-row: 1; }
    .route-signal { grid-column: 1; grid-row: 2; font-size: 0.7rem; }
    .route-tech   { display: none; }
    .route-arrow  { grid-column: 2; grid-row: 1; opacity: 1; }
  }

  /* ── Experience Bullets ─────────────────────────────────── */
  .exp-bullets {
    margin-top: var(--s2);
    display: flex;
    flex-direction: column;
    gap: var(--s2);
  }

  .exp-bullets li {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.6;
    padding-left: var(--s4);
    position: relative;
  }

  .exp-bullets li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: var(--muted-dim);
    font-family: var(--font-mono);
  }

  /* ── Project Logos ───────────────────────────────────────── */
  .system-logo {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-dim);
  }

  .proj-logo {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-dim);
  }

  /* ── Profile Strip (experience page header) ─────────────── */
  .profile-strip {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2) var(--s5);
    padding: var(--s6) 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
    margin-bottom: var(--s8);
  }

  .profile-strip span {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
    position: relative;
  }

  .profile-strip span:first-child { color: var(--text); font-weight: 500; }

  .profile-strip span:not(:first-child)::before {
    content: '·';
    margin-right: var(--s5);
    color: var(--border);
  }

  /* ── System Records ──────────────────────────────────────── */
  .systems {
    padding: var(--s10) 0;
    border-bottom: 1px solid var(--border);
  }

  .system-record {
    padding: var(--s6) 0;
    border-bottom: 1px solid var(--border-dim);
  }

  .system-record:first-of-type { padding-top: var(--s5); }
  .system-record:last-of-type { border-bottom: none; }

  .system-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s4);
    margin-bottom: var(--s2);
  }

  .system-name {
    font-family: var(--font-serif);
    font-size: 1.12rem;
    font-weight: 400;
    font-optical-sizing: auto;
  }

  .system-link {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted-dim);
    flex-shrink: 0;
    transition: color var(--t);
  }
  .system-link:hover { color: var(--accent); }

  .system-desc {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.65;
    max-width: 680px;
    margin-bottom: var(--s3);
  }

  .system-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s3);
    align-items: center;
  }

  .system-metric {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--metric);
  }

  .system-metric::before { content: '· '; color: var(--muted-dim); }
  .system-metric:first-child::before { content: ''; }

  .system-stack {
    font-family: var(--font-mono);
    font-size: 0.67rem;
    color: var(--muted-dim);
    margin-left: auto;
  }

  /* ── Experience Ledger ──────────────────────────────────── */
  .exp-ledger { padding: var(--s10) 0; }

  .exp-year {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-top: var(--s8);
    margin-bottom: var(--s4);
  }

  .exp-entry {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: var(--s4) var(--s8);
    padding: var(--s4) 0;
    border-top: 1px solid var(--border-dim);
    align-items: start;
  }

  .exp-org {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: var(--s1);
  }

  .exp-org-meta {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted-dim);
  }

  .exp-role {
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: var(--s2);
  }

  .exp-desc {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.65;
  }

  .exp-tech {
    margin-top: var(--s2);
    font-family: var(--font-mono);
    font-size: 0.67rem;
    color: var(--muted-dim);
  }

  @media (max-width: 600px) {
    .exp-entry { grid-template-columns: 1fr; gap: var(--s2); }
  }

  /* ── Projects Page: Two-Column ──────────────────────────── */
  .work-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    min-height: calc(100vh - var(--nav-h));
    border-top: 1px solid var(--border-dim);
  }

  .work-sidebar {
    border-right: 1px solid var(--border-dim);
    padding: var(--s8) var(--s5);
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
  }

  .work-sidebar .section-label { margin-bottom: var(--s4); }

  .proj-nav-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--s3) var(--s4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--t), border-color var(--t);
    margin-bottom: var(--s1);
  }

  .proj-nav-item:hover { background: var(--surface); border-color: var(--border); }

  .proj-nav-item.active {
    background: var(--accent-glow);
    border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  }

  .proj-nav-item.active .proj-nav-name { color: var(--accent); }

  .proj-nav-name {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: var(--s1);
    transition: color var(--t);
  }

  .proj-nav-type {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--muted-dim);
    letter-spacing: 0.04em;
  }

  .proj-nav-metric {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--metric);
    margin-top: var(--s1);
    letter-spacing: 0.02em;
  }

  .work-detail {
    padding: var(--s10) var(--s12);
    max-width: 720px;
  }

  .proj-panel { display: none; }
  .proj-panel.active { display: block; }

  .proj-panel-title {
    font-size: 1.55rem;
    font-weight: 400;
    margin-bottom: var(--s2);
    font-optical-sizing: auto;
  }

  .proj-panel-summary {
    font-size: 0.98rem;
    color: var(--muted);
    margin-bottom: var(--s6);
    line-height: 1.6;
  }

  /* Project Brief (Problem / System / Proof grid) */
  .project-brief {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s3);
    margin-bottom: var(--s8);
    padding-bottom: var(--s8);
    border-bottom: 1px solid var(--border-dim);
  }

  @media (max-width: 680px) {
    .project-brief { grid-template-columns: 1fr; }
  }

  .project-brief > div {
    padding: var(--s4);
    background: var(--surface);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
  }

  [data-theme="light"] .project-brief > div {
    box-shadow: 0 2px 8px rgba(35, 25, 22, 0.05);
  }

  .brief-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    display: block;
    margin-bottom: var(--s2);
  }

  .project-brief p {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.6;
  }

  .proj-section { margin-bottom: var(--s8); }
  .proj-section h4 { margin-bottom: var(--s3); }

  .proj-section p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: var(--s3);
  }

  .proj-section ul {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
  }

  .proj-section li {
    font-size: 0.86rem;
    color: var(--muted);
    display: flex;
    gap: var(--s3);
    line-height: 1.55;
  }

  .proj-section li::before {
    content: '→';
    color: var(--accent);
    flex-shrink: 0;
    font-family: var(--font-mono);
  }

  .proj-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s3);
    margin-top: var(--s3);
  }

  .proj-metric {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--metric);
    background: var(--metric-dim);
    padding: 0.28rem 0.7rem;
    border: 1px solid color-mix(in srgb, var(--metric) 20%, transparent);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }

  .metric-note {
    font-size: 0.6rem;
    color: var(--muted-dim);
    font-family: var(--font-mono);
  }

  .proj-stack-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
    margin-top: var(--s3);
  }

  .proj-stack-chip {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.18rem 0.55rem;
    border-radius: 2px;
  }

  .proj-links {
    display: flex;
    gap: var(--s3);
    flex-wrap: wrap;
    margin-top: var(--s5);
    padding-top: var(--s5);
    border-top: 1px solid var(--border-dim);
  }

  @media (max-width: 700px) {
    .work-layout { grid-template-columns: 1fr; }
    .work-sidebar {
      position: relative; height: auto;
      border-right: none; border-bottom: 1px solid var(--border-dim);
      padding: var(--s4) var(--content-px) var(--s3);
    }
    .work-sidebar .section-label { margin-bottom: var(--s3); }
    .work-sidebar nav {
      display: flex;
      flex-direction: row;
      gap: var(--s2);
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      padding-bottom: var(--s1);
    }
    .work-sidebar nav::-webkit-scrollbar { display: none; }
    .proj-nav-item {
      flex-shrink: 0;
      padding: var(--s2) var(--s3);
      margin-bottom: 0;
    }
    .proj-nav-type, .proj-nav-metric { display: none; }
    .proj-nav-name { margin-bottom: 0; font-size: 0.8rem; }
    .work-detail { padding: var(--s6) var(--content-px); }
  }

  /* ── Notes Page ─────────────────────────────────────────── */
  .notes-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
    margin: var(--s5) 0;
  }

  .filter-btn {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.28rem 0.7rem;
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    background: transparent;
    transition: all var(--t);
    border-radius: 2px;
  }

  .filter-btn:hover, .filter-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
  }

  .note-item { border-top: 1px solid var(--border-dim); }
  .note-item details { padding: var(--s4) 0; }

  .note-item summary {
    display: grid;
    grid-template-columns: 56px 1fr auto auto;
    gap: var(--s4);
    align-items: center;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  .note-item summary::-webkit-details-marker { display: none; }
  .note-item summary::marker { display: none; }

  .note-date {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted-dim);
    white-space: nowrap;
  }

  .note-title {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text);
    transition: color var(--t);
  }

  .note-tag {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--muted-dim);
    white-space: nowrap;
  }

  .note-item summary:hover .note-title { color: var(--accent); }

  .note-toggle {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted-dim);
    transition: transform var(--t), color var(--t);
    display: inline-block;
  }

  details[open] .note-toggle { transform: rotate(90deg); color: var(--accent); }

  .note-body {
    padding: var(--s4) 0 var(--s2) calc(56px + var(--s4));
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.75;
  }

  .note-body p { margin-bottom: var(--s4); }
  .note-body p:last-child { margin-bottom: 0; }

  @media (max-width: 600px) {
    .note-item summary { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
    .note-date   { grid-column: 1; grid-row: 1; }
    .note-tag    { grid-column: 2; grid-row: 1; }
    .note-title  { grid-column: 1 / -1; grid-row: 2; }
    .note-toggle { grid-column: 2; grid-row: 2; }
    .note-body   { padding-left: 0; }
  }

  /* ── About / Profile page ───────────────────────────────── */
  .about-lead {
    font-size: 1rem;
    color: var(--text);
    max-width: 680px;
    line-height: 1.8;
    padding: var(--s10) 0;
    border-bottom: 1px solid var(--border);
  }

  .about-lead p + p { margin-top: var(--s5); }

  .about-header {
    display: flex;
    align-items: center;
    gap: var(--s6);
    padding: var(--s10) 0 var(--s8);
    border-bottom: 1px solid var(--border);
  }

  .about-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
  }

  .about-name {
    font-family: var(--font-serif);
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 400;
    color: var(--text);
    margin-bottom: var(--s2);
    font-optical-sizing: auto;
  }

  .about-sub {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.03em;
  }

  .about-story {
    max-width: 680px;
    padding: var(--s10) 0;
    border-bottom: 1px solid var(--border);
  }

  .about-story p {
    font-size: 1rem;
    line-height: 1.85;
    color: var(--text);
  }

  .about-story p + p { margin-top: var(--s6); }

  .about-story strong { color: var(--text); font-weight: 500; }

  .about-facts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--s4);
    padding: var(--s8) 0;
    border-bottom: 1px solid var(--border);
  }

  .about-fact {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    padding: var(--s4);
    background: var(--surface);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
  }

  [data-theme="light"] .about-fact {
    box-shadow: 0 2px 8px rgba(35, 25, 22, 0.04);
  }

  .about-fact-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
  }

  .about-fact-value {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.5;
  }

  .about-contact {
    padding: var(--s8) 0;
  }

  .about-contact-note {
    font-size: 0.92rem;
    color: var(--muted);
    line-height: 1.65;
    max-width: 520px;
    margin-bottom: var(--s6);
  }

  @media (max-width: 480px) {
    .about-header { flex-direction: column; align-items: flex-start; gap: var(--s4); }
    .about-photo { width: 64px; height: 64px; }
    .about-facts-grid { grid-template-columns: 1fr; }
  }

  /* ── Resume Page ────────────────────────────────────────── */
  .resume-page {
    max-width: 740px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s8);
    margin-top: var(--s6);
  }

  [data-theme="light"] .resume-page {
    background: #fff8ec;
    box-shadow: 0 8px 32px rgba(35, 25, 22, 0.07);
  }

  [data-theme="dark"] .resume-page {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  }

  .resume-section {
    padding: var(--s8) 0;
    border-bottom: 1px solid var(--border-dim);
  }

  .resume-section:last-of-type { border-bottom: none; }

  .resume-section .section-label { margin-bottom: var(--s5); }

  .resume-row {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    padding: var(--s5) 0;
    border-top: 1px solid var(--border-dim);
  }

  .resume-row:first-of-type { border-top: none; }

  .resume-org {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
  }

  .resume-title {
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: var(--s1);
  }

  .resume-detail {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.6;
  }

  @media (max-width: 600px) {
    .resume-row { gap: var(--s1); }
    .resume-row-head { flex-wrap: wrap; }
    .resume-page { padding: var(--s5); }
  }

  .resume-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--s6);
    padding-bottom: var(--s6);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--s6);
    flex-wrap: wrap;
  }

  .resume-name {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    font-optical-sizing: auto;
    margin-bottom: var(--s2);
  }

  .resume-tagline {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.04em;
  }

  .resume-actions { display: flex; gap: var(--s3); align-items: center; }

  .resume-contact {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2) var(--s5);
    margin-bottom: var(--s8);
  }

  .resume-contact-link {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    text-decoration: none;
    transition: color var(--t);
  }

  .resume-contact-link:hover { color: var(--accent); }

  .resume-section-title {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: var(--s4);
  }

  .resume-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s4);
    margin-bottom: var(--s1);
  }

  .resume-date {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted-dim);
    white-space: nowrap;
  }

  .resume-role {
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: var(--s2);
  }

  .resume-desc {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: var(--s2);
  }

  .resume-bullets {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--s2);
    display: flex;
    flex-direction: column;
    gap: var(--s2);
  }

  .resume-bullets li {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.65;
    padding-left: var(--s5);
    position: relative;
  }

  .resume-bullets li::before {
    content: "–";
    position: absolute;
    left: 0;
    color: var(--muted-dim);
    font-family: var(--font-mono);
  }

  .resume-tech {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted-dim);
    margin-top: var(--s2);
  }

  .resume-skills-grid {
    display: flex;
    flex-direction: column;
    gap: var(--s3);
  }

  .resume-skills-grid > div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: var(--s4);
    align-items: baseline;
  }

  .resume-skills-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .resume-skills-value {
    font-size: 0.84rem;
    color: var(--muted);
  }

  @media (max-width: 600px) {
    .resume-skills-grid > div { grid-template-columns: 1fr; gap: var(--s1); }
    .resume-row-head { flex-direction: column; gap: var(--s1); }
  }

  @media print {
    .nav, .footer, #scroll-progress, #cmd-overlay, #toast { display: none !important; }
    body { background: #fff; color: #111; font-size: 0.85rem; }
    body::before { display: none; }
    .resume-page { max-width: 100%; box-shadow: none; border: none; padding: 0; }
    .resume-header { padding-top: 0; }
    .btn { display: none; }
    a[href]::after { content: ' (' attr(href) ')'; font-size: 0.7rem; color: #666; }
  }

  /* ── Command Palette ──────────────────────────────────────── */
  .cmd-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(4px);
    z-index: 1500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 18vh;
  }

  .cmd-overlay[hidden] { display: none; }

  .cmd-box {
    width: 100%;
    max-width: 500px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  }

  .cmd-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--border-dim);
  }

  .cmd-prompt { font-family: var(--font-mono); font-size: 0.9rem; color: var(--accent); flex-shrink: 0; }

  .cmd-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text);
    caret-color: var(--accent);
  }

  .cmd-list { max-height: 300px; overflow-y: auto; padding: var(--s2) 0; }

  .cmd-item {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3) var(--s5);
    cursor: pointer;
    transition: background var(--t);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
  }

  .cmd-item:hover, .cmd-item.selected { background: var(--accent-glow); color: var(--accent); }

  .cmd-item-icon { color: var(--accent); font-size: 0.85rem; width: 1rem; text-align: center; flex-shrink: 0; }

  .cmd-footer {
    border-top: 1px solid var(--border-dim);
    padding: var(--s2) var(--s5);
    display: flex;
    gap: var(--s4);
  }

  .cmd-hint {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--muted-dim);
    display: flex;
    align-items: center;
    gap: var(--s1);
  }

  .cmd-hint kbd {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 0.08rem 0.3rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--muted);
  }

  /* ── Toast ────────────────────────────────────────────────── */
  .toast {
    position: fixed;
    bottom: var(--s8);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: var(--s2) var(--s5);
    border-radius: 2px;
    opacity: 0;
    transition: opacity var(--t-slow), transform var(--t-slow);
    pointer-events: none;
    z-index: 2000;
    white-space: nowrap;
  }

  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ── Reveal Animation ─────────────────────────────────────── */
  .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.45s ease, transform 0.45s ease;
  }

  .reveal.revealed {
    opacity: 1;
    transform: translateY(0);
  }

  /* ── Experience Page ─────────────────────────────────────── */
  .exp-section {
    padding: var(--s8) 0;
    border-bottom: 1px solid var(--border-dim);
  }

  .exp-section:last-of-type { border-bottom: none; }

}

/* ============================================================
   UTILITIES
   ============================================================ */
@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}
