/* =========================================================================
   Sriram P R — UX portfolio
   1. Design tokens   2. Themes   3. Base & typography   4. Layout
   5. Components      6. Sections 7. Responsive        8. States & a11y
   ========================================================================= */

/* 1. DESIGN TOKENS ------------------------------------------------------- */
:root {
  /* AIIS spacing scale */
  --s-2: 2px; --s-4: 4px; --s-8: 8px; --s-12: 12px; --s-16: 16px; --s-20: 20px;
  --s-24: 24px; --s-32: 32px; --s-40: 40px; --s-44: 44px; --s-48: 48px;
  --s-56: 56px; --s-64: 64px; --s-72: 72px; --s-80: 80px;

  /* Typography */
  --font: Graphik, Inter, "Segoe UI", Arial, sans-serif;
  --fs-hero: clamp(2.125rem, 1.2rem + 3.6vw, 3.5rem);   /* 34 → 56 */
  --fs-h2: clamp(1.6875rem, 1.3rem + 1.4vw, 2.25rem);    /* 27 → 36 */
  --fs-h3: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);       /* 20 → 24 */
  --fs-case: clamp(1.5rem, 1.25rem + 0.9vw, 1.875rem);   /* 24 → 30 */
  --fs-card: clamp(1.0625rem, 1rem + 0.25vw, 1.25rem);   /* 17 → 20 */
  --fs-body: clamp(1rem, 0.97rem + 0.12vw, 1.0625rem);   /* 16 → 17 */
  --fs-small: 0.9375rem;                                  /* 15 */
  --fs-label: 0.8125rem;                                  /* 13 */
  --lh-tight: 1.15; --lh-head: 1.25; --lh-body: 1.6;

  /* Layout */
  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 68ch;
  --header-h: 64px;

  /* Shape & elevation: three radii, two shadows */
  --r-sm: 4px; --r-md: 8px; --r-lg: 12px;
  --dur: 160ms;
}

/* 2. THEMES -------------------------------------------------------------- */
/* Light (default) = official AIIS Design System v2.1 values (CLAUDE.md §5).
   "official" = v2.1 library value; "derived" = project value, contrast-tested,
   used only where v2.1 has no suitable token. See docs/design-theme-extension.md. */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #FDFFFF;                 /* official primary surface */
  --bg-tint: #F7F7F8;            /* derived neutral subtle surface */
  --surface: #FFFFFF;
  --surface-2: #F7F7F8;          /* derived */
  --surface-sunk: #EBEBEB;       /* official grey 100 */
  --text: #333333;               /* official primary text */
  --text-strong: #333333;        /* official primary text (headings rely on weight, not a new hue) */
  --text-muted: #5C5C5C;         /* official grey 700 */
  --border: #D6D6D6;             /* official grey 200 */
  --border-strong: #858585;      /* official grey 500; control boundaries ≥3:1 */
  --accent: #631BDB;             /* official brand primary */
  --accent-hover: #451399;       /* official hover */
  --accent-pressed: #280B58;     /* official selected/pressed */
  --accent-ink: #FFFFFF;
  --accent-soft: #F0E8FC;        /* official purple 50 */
  --accent-2: #451399;           /* official secondary */
  --focus: #9460EB;              /* official purple 400 */
  --status-success: #148030;     --status-success-soft: #E7F7EA;  /* official */
  --status-success-fill: #2DBA52;
  --status-warning: #8A5800;     --status-warning-soft: #FFF6E5;  /* text derived: official #E19000 is 2.6:1 on white */
  --status-warning-fill: #E19000;
  --status-anomaly: #D80005;     --status-anomaly-soft: #FDE7E8;  /* official danger */
  --status-anomaly-fill: #F0464A;
  --status-high: #B33F00;        --status-high-soft: #FDEEE4;     /* derived: v2.1 has no "high" level */
  --status-high-fill: #F2711C;   /* derived fill for charts/dots; text uses --status-high */
  --status-simulation: #3C5F96;  --status-simulation-soft: #E9EFF8; /* derived; mapping still to confirm */
  --status-info: #5E20C6;        --status-info-soft: #F0E9FB;     /* official info */
  --shadow-1: 0 1px 2px rgba(51, 51, 51, .06), 0 1px 1px rgba(51, 51, 51, .04);
  --shadow-2: 0 8px 24px rgba(31, 8, 68, .08);
  --overlay: rgba(10, 3, 23, .85);
  --dot: rgba(99, 27, 219, .14);
  --contact-bg: #1F0844;         /* official purple 900 */
  --contact-fg: #FFFFFF;
  --contact-line: rgba(255, 255, 255, .32);
}

/* Dark = project-level extension derived from the v2.1 purple and grey scales.
   NOT part of the official single-mode v2.1 library. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121118;
  --bg-tint: #17151E;
  --surface: #1C1A23;
  --surface-2: #24212D;
  --surface-sunk: #0E0D13;
  --text: #D8D1E3;
  --text-strong: #F7F4FC;
  --text-muted: #B8AEC8;
  --border: #37313F;
  --border-strong: #7D7189;      /* ≥3:1 control boundary on all dark surfaces */
  --hmi-frame: #51475C;
  --accent: #B38DF1;             /* official purple 300 */
  --accent-hover: #D1BBF7;       /* official purple 200 */
  --accent-pressed: #9460EB;     /* official purple 400 */
  --accent-ink: #121118;
  --accent-soft: rgba(179, 141, 241, .14);
  --accent-2: #D1BBF7;
  --focus: #D1BBF7;
  --status-success: #5DD47D;     --status-success-soft: rgba(45, 186, 82, .16);
  --status-success-fill: #2DBA52;
  --status-warning: #FFC04D;     --status-warning-soft: rgba(255, 167, 9, .14);
  --status-warning-fill: #FFA709;
  --status-anomaly: #FF8A8C;     --status-anomaly-soft: rgba(240, 70, 74, .18);
  --status-anomaly-fill: #F0464A;
  --status-high: #FF9A5C;        --status-high-soft: rgba(255, 154, 92, .14);
  --status-high-fill: #FF9A5C;
  --status-simulation: #A3BFE6;  --status-simulation-soft: rgba(108, 146, 197, .18);
  --status-info: #C3A3F5;        --status-info-soft: rgba(130, 73, 226, .2);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 10px 28px rgba(0, 0, 0, .4);
  --overlay: rgba(6, 5, 10, .9);
  --dot: rgba(179, 141, 241, .12);
  --contact-bg: #24212D;
  --contact-fg: #F7F4FC;
  --contact-line: #7D7189;
}

/* 3. BASE & TYPOGRAPHY --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + var(--s-16)); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh-body);
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, h5 { color: var(--text-strong); line-height: var(--lh-head); margin: 0; font-weight: 650; text-wrap: balance; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-h2); letter-spacing: -0.02em; }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-card); }
h5 { font-size: var(--fs-small); font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }
code, pre { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.875em; }
code { background: var(--surface-sunk); padding: 0.1em 0.35em; border-radius: var(--r-sm); color: var(--text-strong); }
ul, ol { margin: 0; padding: 0; }
table { border-collapse: collapse; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-small); }
.lead { font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem); line-height: 1.55; color: var(--text-strong); }
.measure { max-width: var(--measure); }
.h-small { font-size: var(--fs-body); font-weight: 600; margin-bottom: var(--s-12); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prose > * + * { margin-top: var(--s-16); }
.prose { max-width: var(--measure); }

/* 4. LAYOUT -------------------------------------------------------------- */
.wrap { max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(var(--s-56), 8vw, var(--s-80)); }
.section--tint { background: var(--bg-tint); }
.section__head { margin-bottom: var(--s-40); max-width: 760px; }
.section__intro { margin-top: var(--s-16); color: var(--text-muted); font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem); max-width: var(--measure); }
.sub-h { font-size: var(--fs-h3); margin: var(--s-56) 0 var(--s-24); }
.sub-h:first-child { margin-top: 0; }

/* 5. COMPONENTS ---------------------------------------------------------- */
/* Skip link */
.skip { position: absolute; left: var(--s-16); top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--s-12) var(--s-16); border-radius: var(--r-md); font-weight: 600; }
.skip:focus { top: var(--s-12); color: var(--accent-ink); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-8);
  min-height: 44px; padding: var(--s-8) var(--s-20); border-radius: var(--r-md);
  font: inherit; font-weight: 600; font-size: var(--fs-small); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color var(--dur), border-color var(--dur), color var(--dur);
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn--secondary { background: transparent; color: var(--text-strong); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn--ghost { background: transparent; color: var(--accent); border-color: var(--border); padding-inline: var(--s-16); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-hover); }
.btn--sm { min-height: 36px; padding: var(--s-4) var(--s-12); font-size: var(--fs-label); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md);
  background: transparent; border: 1px solid var(--border); color: var(--text-strong); cursor: pointer; padding: 0;
  transition: border-color var(--dur), color var(--dur), background-color var(--dur);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Chips & tags */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-8); min-height: 40px; padding: var(--s-4) var(--s-16);
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-strong);
  font: inherit; font-size: var(--fs-small); cursor: pointer; transition: background-color var(--dur), border-color var(--dur), color var(--dur);
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip__n { font-size: var(--fs-label); opacity: 0.85; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s-8); }
.tag { display: inline-block; font-size: var(--fs-label); line-height: 1.4; padding: var(--s-2) var(--s-8); border-radius: var(--r-sm); background: var(--surface-sunk); color: var(--text-muted); }
.tag--info { background: var(--accent-soft); color: var(--text-strong); }
.pill-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-8); margin-bottom: var(--s-32); }
.pill-list li { padding: var(--s-4) var(--s-12); border-radius: var(--r-md); background: var(--accent-soft); color: var(--text-strong); font-size: var(--fs-small); }

/* Severity & state chips: colour + icon + text, never colour alone */
.sev, .state { display: inline-flex; align-items: center; gap: var(--s-4); font-size: var(--fs-label); font-weight: 600; line-height: 1.3; padding: var(--s-4) var(--s-8); border-radius: var(--r-sm); white-space: nowrap; }
.sev .icon, .state .icon { width: 16px; height: 16px; }
.sev--critical, .state--alarm { color: var(--status-anomaly); background: var(--status-anomaly-soft); }
.sev--high { color: var(--status-high); background: var(--status-high-soft); }
.sev--medium, .state--warn { color: var(--status-warning); background: var(--status-warning-soft); }
.sev--low { color: var(--status-info); background: var(--status-info-soft); }
.state--run { color: var(--status-success); background: var(--status-success-soft); }
.state--reco { color: var(--status-simulation); background: var(--status-simulation-soft); }
.sev-legend { list-style: none; display: grid; gap: var(--s-12); margin-top: var(--s-16); }
.sev-legend li { display: grid; grid-template-columns: 7.5rem 1fr; gap: var(--s-12); align-items: start; font-size: var(--fs-small); color: var(--text-muted); }
.sev-legend .sev { justify-self: start; }

/* Lists */
.list { padding-left: 1.15em; display: grid; gap: var(--s-8); }
.list li::marker { color: var(--accent); }
.list--two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); column-gap: var(--s-32); margin-top: var(--s-24); }
.checklist { list-style: none; display: grid; gap: var(--s-12); }
.checklist li { display: grid; grid-template-columns: 20px 1fr; gap: var(--s-12); font-size: var(--fs-small); }
.icon--check { color: var(--status-success); margin-top: 2px; }

/* Tables (intentionally horizontally scrollable on narrow screens) */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; min-width: 620px; font-size: var(--fs-small); }
.table th, .table td { text-align: left; vertical-align: top; padding: var(--s-12) var(--s-16); border-bottom: 1px solid var(--border); }
.table thead th { font-size: var(--fs-label); font-weight: 600; color: var(--text-muted); background: var(--surface-2); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody th { font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.table--transfer tbody th { white-space: normal; min-width: 11rem; }

/* Code block */
.code { margin: var(--s-16) 0 0; padding: var(--s-16); background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--r-md); overflow-x: auto; color: var(--text-strong); }
.code code { background: none; padding: 0; }

/* Figures & zoom */
.figure { margin: 0; min-width: 0; }
.figure figcaption { margin-top: var(--s-8); font-size: var(--fs-label); line-height: 1.45; color: var(--text-muted); }
.zoom {
  position: relative; display: block; width: 100%; padding: var(--s-8); border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface-2); cursor: zoom-in; color: inherit;
  transition: border-color var(--dur);
}
.zoom:hover { border-color: var(--accent); }
.zoom img { width: 100%; height: auto; border-radius: var(--r-sm); background: #fff; }
.zoom__hint {
  position: absolute; right: var(--s-16); bottom: var(--s-16); display: inline-flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-8); border-radius: var(--r-sm); background: var(--surface); color: var(--text-strong);
  border: 1px solid var(--border); font-size: var(--fs-label); font-weight: 600; box-shadow: var(--shadow-1);
}
.zoom__hint .icon { width: 14px; height: 14px; }
.fig-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--s-24); }

/* Explanatory diagrams */
.figure--diagram .diagram { border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface); padding: var(--s-24); }
.flow { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-8); margin-top: var(--s-16); counter-reset: none; }
.flow li { display: inline-flex; align-items: center; gap: var(--s-8); padding: var(--s-8) var(--s-12); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-small); color: var(--text-strong); position: relative; }
.flow li + li::before { content: ""; position: absolute; left: calc(-1 * var(--s-8)); top: 50%; width: var(--s-8); height: 1px; background: var(--border-strong); }
.flow__n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; flex: none; }
.flow--stack { flex-direction: column; flex-wrap: nowrap; margin-top: 0; gap: var(--s-12); }
.flow--stack li + li::before { left: 22px; top: calc(-1 * var(--s-12)); width: 1px; height: var(--s-12); }
.tiers { list-style: none; display: grid; gap: var(--s-8); }
.tier { display: grid; gap: var(--s-2); padding: var(--s-12) var(--s-16); border-radius: var(--r-md); border-left: 4px solid; background: var(--surface-2); font-size: var(--fs-small); }
.tier strong { color: var(--text-strong); }
.tier span { color: var(--text-muted); }
.tier--now { border-color: var(--status-anomaly-fill); }
.tier--ctx { border-color: var(--accent); }
.tier--act { border-color: var(--accent-2); }
.dg { width: 100%; height: auto; max-height: 240px; }
.dg text { font: 600 12px var(--font); fill: var(--text-strong); text-anchor: middle; }
.dg .dg-note { fill: var(--text-muted); font-weight: 400; }
.dg-layer path { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1; }
.dg-layer--2 path { fill: var(--accent-soft); stroke: var(--accent); }
.dg-layer--3 path { fill: var(--surface-sunk); stroke: var(--accent-2); stroke-dasharray: 4 3; }
.dg-nodes circle { fill: var(--accent); }
.dg-nodes path { fill: none; stroke: var(--accent); stroke-width: 1.5; }

/* Status dot */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot--run { background: var(--status-success); box-shadow: 0 0 0 3px var(--status-success-soft); }
.dot--brand { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 6. SECTIONS ------------------------------------------------------------ */
/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--bg); border-bottom: 1px solid var(--border); }
.site-header__inner { display: flex; align-items: center; gap: var(--s-24); height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: var(--s-12); text-decoration: none; color: var(--text-strong); font-weight: 650; margin-right: auto; min-height: 44px; }
.brand:hover { color: var(--text-strong); }
.brand__mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--text-strong); color: var(--bg); font-size: 11px; letter-spacing: 0.06em; font-weight: 700; }
.nav__list { list-style: none; display: flex; gap: var(--s-4); }
.nav a { display: block; padding: var(--s-8) var(--s-12); border-radius: var(--r-md); color: var(--text-muted); text-decoration: none; font-size: var(--fs-small); font-weight: 500; position: relative; white-space: nowrap; }
.nav a:hover { color: var(--text-strong); background: var(--surface-2); }
.nav a[aria-current="true"] { color: var(--text-strong); }
.nav a[aria-current="true"]::after { content: ""; position: absolute; left: var(--s-12); right: var(--s-12); bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); }
.header-actions { display: flex; gap: var(--s-8); }
.menu-toggle { display: none; }
.theme-toggle .icon--moon, [data-theme="dark"] .theme-toggle .icon--sun { display: none; }
[data-theme="dark"] .theme-toggle .icon--moon { display: block; }
.menu-toggle .icon--close, .menu-toggle[aria-expanded="true"] .icon--menu { display: none; }
.menu-toggle[aria-expanded="true"] .icon--close { display: block; }

/* Hero */
.hero { position: relative; padding-block: clamp(var(--s-48), 7vw, var(--s-80)); overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0 0 0 auto; width: 55%;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(to left, #000 30%, transparent); mask-image: linear-gradient(to left, #000 30%, transparent);
  pointer-events: none;
}
.hero__grid { position: relative; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: clamp(var(--s-32), 5vw, var(--s-72)); align-items: center; }
.hero__role { margin-top: var(--s-16); font-size: clamp(1rem, 0.95rem + 0.35vw, 1.1875rem); font-weight: 600; color: var(--accent); line-height: 1.45; max-width: 36em; }
.hero__role .nw { white-space: nowrap; }
.hero__role .sep { color: var(--text-muted); padding-inline: 0.15em; font-weight: 400; }
@media (max-width: 359px) { .hero__role .nw { white-space: normal; } }
.hero__title { font-size: var(--fs-hero); line-height: var(--lh-tight); letter-spacing: -0.035em; font-weight: 700; }
.hero__lede { margin-top: var(--s-20); font-size: clamp(1.0625rem, 1rem + 0.45vw, 1.3125rem); line-height: 1.5; color: var(--text); max-width: 34em; }
.hero__ctas { display: flex; flex-wrap: wrap; gap: var(--s-12); margin-top: var(--s-32); }
.hero__signals { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-8) var(--s-20); margin-top: var(--s-40); padding-top: var(--s-24); border-top: 1px solid var(--border); font-size: var(--fs-small); color: var(--text-strong); }
.hero__signals li { display: inline-flex; align-items: center; gap: var(--s-8); }
.hero__figure { position: relative; max-width: 420px; justify-self: end; width: 100%; }
.hero__portrait { width: 100%; aspect-ratio: 418 / 402; object-fit: cover; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-2); }
.hero__badge { position: absolute; left: calc(-1 * var(--s-24)); bottom: var(--s-24); max-width: 15rem; padding: var(--s-12) var(--s-16); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: var(--fs-label); line-height: 1.4; color: var(--text-muted); }
.hero__badge strong { display: block; font-size: var(--fs-card); color: var(--text-strong); }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-56); }
.about__aside { padding: var(--s-24); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); align-self: start; }

/* Work overview */
.overview { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-16); }
.overview li { padding: var(--s-24); background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--r-md); display: flex; flex-direction: column; gap: var(--s-12); }
.overview li p { font-size: var(--fs-small); color: var(--text-muted); }
.overview .overview__refs { margin-top: auto; color: var(--text); }

/* Featured cards */
.cards { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-24); }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; transition: border-color var(--dur), box-shadow var(--dur); }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.card:focus-within { border-color: var(--accent); }
.card__shot { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: var(--s-12); display: grid; place-items: center; }
.card__shot img { width: 100%; height: 100%; object-fit: contain; }
.card__shot--diagram { place-items: stretch; align-content: center; }
.card__shot--diagram .figure--diagram .diagram { border: 0; padding: var(--s-8); background: transparent; }
.card__shot--diagram .flow li, .card__shot--diagram .tier { padding-block: var(--s-4); font-size: var(--fs-label); }
.card__shot--diagram .flow--stack { gap: var(--s-8); }
.card__shot--diagram .tier span { display: none; }
.card__shot--diagram .tiers { gap: var(--s-12); }
.card__shot--diagram .flow--stack li + li::before { top: calc(-1 * var(--s-8)); height: var(--s-8); }
.card__body { padding: var(--s-24); display: flex; flex-direction: column; gap: var(--s-12); flex: 1; }
.card__cat { font-size: var(--fs-label); color: var(--text-muted); }
.card__title { font-size: var(--fs-card); }
.card__link { color: var(--text-strong); text-decoration: none; }
.card__link::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
@supports selector(:has(*)) {
  .card__link:focus-visible { outline: none; }
  .card:has(.card__link:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
}
.card__facts { display: grid; gap: var(--s-8); font-size: var(--fs-small); margin: 0; }
.card__facts dt { font-size: var(--fs-label); color: var(--text-muted); }
.card__facts dd { margin: 0; }
.card__cta { margin-top: auto; padding-top: var(--s-8); display: inline-flex; align-items: center; gap: var(--s-8); color: var(--accent); font-weight: 600; font-size: var(--fs-small); }

/* Library */
.library { margin-top: var(--s-72); }
.library__head { position: relative; padding-bottom: var(--s-24); border-bottom: 1px solid var(--border); margin-bottom: var(--s-48); }
.library__head > p { max-width: var(--measure); }
.filters { display: flex; flex-wrap: wrap; gap: var(--s-8); margin-top: var(--s-24); }
.filters__status { margin-top: var(--s-12); font-size: var(--fs-label); color: var(--text-muted); min-height: 1.4em; }
.group + .group { margin-top: var(--s-80); }
.group__head { display: grid; grid-template-columns: auto 1fr; gap: var(--s-20); align-items: start; max-width: 820px; }
.group__head p { margin-top: var(--s-8); color: var(--text-muted); }
.group__letter { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-md); background: var(--text-strong); color: var(--bg); font-weight: 700; font-size: 1.25rem; }
.group__index { margin: var(--s-24) 0 var(--s-40) 68px; }
.group__index ul { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-8); }
.group__index a { display: inline-flex; gap: var(--s-8); align-items: baseline; padding: var(--s-8) var(--s-12); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: var(--text-strong); font-size: var(--fs-small); min-height: 40px; }
.group__index a:hover { border-color: var(--accent); }

/* Case study: sequence line down the left, like an event timeline */
.case { position: relative; margin-left: 23px; padding: 0 0 var(--s-56) 45px; border-left: 2px solid var(--border); }
.case:last-child { padding-bottom: 0; border-left-color: transparent; }
.case:last-child::after { content: ""; position: absolute; left: -2px; top: 0; height: 24px; border-left: 2px solid var(--border); }
.case::before { content: ""; position: absolute; left: -9px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-tint); border: 2px solid var(--accent); z-index: 1; }
.case__head { max-width: 860px; display: grid; gap: var(--s-12); }
.case__meta { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-16); font-size: var(--fs-label); color: var(--text-muted); }
.case__code { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.case__title { font-size: var(--fs-case); letter-spacing: -0.02em; }
.case__summary { font-size: clamp(1rem, 0.97rem + 0.2vw, 1.125rem); max-width: var(--measure); }
.case__lead { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--s-32); margin-top: var(--s-24); align-items: start; }
.facts { margin: 0; display: grid; gap: var(--s-16); padding: var(--s-20); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.facts dt { font-size: var(--fs-label); color: var(--text-muted); margin-bottom: var(--s-2); }
.facts dd { margin: 0; font-size: var(--fs-small); color: var(--text-strong); }
.case__toggle { margin-top: var(--s-24); }
.case__toggle .icon { transition: transform var(--dur); }
.case__toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.case__body { margin-top: var(--s-32); display: grid; gap: var(--s-24); max-width: 1000px; }
.case__body[hidden] { display: none; }
.case__sec { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: var(--s-24); padding-top: var(--s-24); border-top: 1px solid var(--border); }
.case__sec > h5 { color: var(--text-strong); }
.case__sec > :not(h5) { grid-column: 2; max-width: var(--measure); }
.case__sec > .fig-grid { max-width: none; }
.case__sec .flow { margin-top: var(--s-16); }
.case__related, .case__back { font-size: var(--fs-small); }
.case__back { padding-top: var(--s-8); }
.case[hidden], .group[hidden] { display: none; }

/* Review mode (?review) */
.review-banner { position: relative; z-index: 60; background: #FFF2DF; color: #3D2600; border-bottom: 2px solid #9A5200; padding: var(--s-12) var(--gutter); font-size: var(--fs-small); }
.review-banner ol { margin: var(--s-8) 0 0 1.2em; max-height: 30vh; overflow: auto; }
.review-banner code { background: rgba(0,0,0,.06); color: inherit; }
.review-note { display: none; }
.is-review .review-note { display: flex; gap: var(--s-8); align-items: flex-start; margin-top: var(--s-16); padding: var(--s-12) var(--s-16); border-radius: var(--r-md); background: #FFF2DF; color: #3D2600; border-left: 4px solid #9A5200; font-size: var(--fs-small); max-width: 860px; }
.is-review [data-verify], .is-review [data-review] { outline: 2px dashed #9A5200; outline-offset: 3px; }

/* Design systems */
.ds { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-24); }
.ds__block, .ds__cols > *, .case, .case__body, .case__sec > * { min-width: 0; }
.ds__block { padding: clamp(var(--s-24), 3vw, var(--s-40)); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.ds__block > h3 { margin-bottom: var(--s-8); }
.ds__lede { color: var(--text-muted); max-width: var(--measure); margin-bottom: var(--s-24); }
.ds__block > .table-wrap { margin-top: var(--s-16); }
.ds__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-40); margin-top: var(--s-16); }
.ds__cols--type { margin-top: var(--s-40); }
.palettes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-16); }
.palette, .compare__pane { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-24); }
.palette h4 { margin-bottom: var(--s-16); }
.palette--wide { grid-column: 1 / -1; }
.swatches { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-12); }
.swatches li { display: grid; grid-template-columns: 32px 1fr; grid-template-rows: auto auto; column-gap: var(--s-8); font-size: var(--fs-label); align-items: center; }
.swatches .sw { grid-row: span 2; width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--c); border: 1px solid var(--border-strong); }
.swatches code { background: none; padding: 0; color: var(--text-strong); font-size: var(--fs-label); }
.swatches span:last-child { color: var(--text-muted); }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-16); }
.compare__label { font-size: var(--fs-label); color: var(--text-muted); margin-bottom: var(--s-12); }
.equip { background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 4px solid var(--status-warning); border-radius: var(--r-md); padding: var(--s-16); }
.equip__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-12); flex-wrap: wrap; margin-bottom: var(--s-16); }
.equip__name { font-size: var(--fs-body); }
.equip__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-12); margin: 0; }
.equip__grid div { padding: var(--s-8) var(--s-12); background: var(--surface); border-radius: var(--r-sm); border: 1px solid var(--border); }
.equip__grid dt { font-size: var(--fs-label); color: var(--text-muted); }
.equip__grid dd { margin: 0; font-size: 1.125rem; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.equip__grid dd span { font-size: var(--fs-label); font-weight: 400; color: var(--text-muted); }
.equip__grid em { display: block; font-style: normal; font-size: var(--fs-label); font-weight: 600; color: var(--status-warning); }
.equip__grid .is-out { border-color: var(--status-warning); }
.equip__foot { margin-top: var(--s-12); font-size: var(--fs-label); color: var(--text-muted); }
.type-scale { list-style: none; display: grid; gap: var(--s-12); }
.type-scale li { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-8) var(--s-16); padding-bottom: var(--s-12); border-bottom: 1px solid var(--border); }
.ts { color: var(--text-strong); font-weight: 650; line-height: 1.1; }
.ts--h1 { font-size: 3.5rem; letter-spacing: -0.035em; }
.ts--h2 { font-size: 2.25rem; letter-spacing: -0.02em; }
.ts--h4 { font-size: 1.25rem; }
.ts--body { font-size: 1.0625rem; font-weight: 400; }
.ts--label { font-size: 0.8125rem; font-weight: 600; }
.l10n { display: grid; gap: var(--s-12); margin-top: var(--s-16); padding: var(--s-16); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.l10n__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-12); }
.l10n__lang { width: 2rem; font-size: var(--fs-label); font-weight: 700; color: var(--text-muted); }
.l10n .btn { pointer-events: none; }

/* Capabilities */
.pillars { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-16); }
.pillars li { padding: var(--s-24); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.pillars h3 { font-size: var(--fs-card); margin-bottom: var(--s-8); }
.pillars p { font-size: var(--fs-small); color: var(--text-muted); }
#capabilities .measure { margin-bottom: var(--s-24); margin-top: calc(-1 * var(--s-8)); }

/* Approach: a true sequence, so numbered */
.approach { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-16); }
.approach li { counter-increment: step; padding: var(--s-24); border-top: 2px solid var(--accent); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.approach li::before { content: counter(step); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: var(--fs-label); margin-bottom: var(--s-12); }
.approach h3 { font-size: var(--fs-card); margin-bottom: var(--s-8); }
.approach p { font-size: var(--fs-small); color: var(--text-muted); }
.impact { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--s-40); margin-top: var(--s-64); padding-top: var(--s-48); border-top: 1px solid var(--border); }
.impact__main > p { margin-top: var(--s-16); max-width: var(--measure); }
.impact__note { padding: var(--s-24); background: var(--surface-2); border-radius: var(--r-lg); border: 1px solid var(--border); align-self: start; font-size: var(--fs-small); color: var(--text-muted); }

/* Contact */
.section--contact { --c-bg: var(--contact-bg); --c-fg: var(--contact-fg); --c-line: var(--contact-line); background: var(--c-bg); color: var(--c-fg); }
[data-theme="dark"] .section--contact { border-top: 1px solid var(--border); }
.section--contact h2 { color: var(--c-fg); }
.section--contact .lead { color: var(--c-fg); opacity: 0.9; margin-top: var(--s-16); max-width: 40ch; }
.contact { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s-40); align-items: center; }
.contact__links { list-style: none; display: grid; gap: var(--s-12); }
.contact__link { display: flex; align-items: center; gap: var(--s-16); padding: var(--s-16) var(--s-20); border-radius: var(--r-md); border: 1px solid var(--c-line); color: var(--c-fg); text-decoration: none; min-height: 56px; overflow-wrap: anywhere; }
.contact__link:hover { color: var(--c-fg); border-color: var(--c-fg); background: rgba(255,255,255,.06); }
.contact__link > span { display: grid; }
.contact__k { font-size: var(--fs-label); opacity: 0.8; }
.section--contact :focus-visible { outline-color: var(--c-fg); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding-block: var(--s-48); background: var(--bg); }
.footer { display: grid; grid-template-columns: 1.3fr 2fr 1fr auto; gap: var(--s-32); align-items: start; }
.footer__name { font-weight: 650; color: var(--text-strong); margin-bottom: var(--s-4); }
.footer__nav, .footer__contact { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-16); font-size: var(--fs-small); }
.footer__nav a, .footer__contact a { display: inline-block; padding-block: var(--s-8); color: var(--text); text-decoration: none; }
.footer__nav a:hover, .footer__contact a:hover { color: var(--accent); text-decoration: underline; }
.footer__contact { flex-direction: column; gap: 0; }
.footer__legal { grid-column: 1 / -1; padding-top: var(--s-24); border-top: 1px solid var(--border); }
.to-top { text-decoration: none; }
.to-top .icon { width: 20px; height: 20px; }

/* Lightbox */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--overlay); color: #fff; }
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: transparent; }
.lightbox__bar { display: flex; align-items: center; gap: var(--s-16); padding: var(--s-12) var(--gutter); }
.lightbox__cap { flex: 1; font-size: var(--fs-small); color: #EBEBEB; }
.lightbox__close { color: #fff; border-color: rgba(255,255,255,.4); background: rgba(0,0,0,.25); }
.lightbox__close:hover { color: #fff; border-color: #fff; }
.lightbox__stage { flex: 1; overflow: auto; display: grid; place-items: center; padding: 0 var(--gutter) var(--gutter); overscroll-behavior: contain; }
.lightbox__img { max-width: 100%; max-height: calc(100dvh - 96px); width: auto; height: auto; border-radius: var(--r-sm); background: #fff; cursor: zoom-in; }
.lightbox__img.is-actual { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox__stage:has(.is-actual) { place-items: start; }

/* 7. RESPONSIVE ---------------------------------------------------------- */
/* Navigation collapses before it would crowd (content-driven breakpoint) */
@media (max-width: 1099px) {
  .menu-toggle { display: inline-grid; }
  .nav { position: fixed; inset: var(--header-h) 0 auto 0; background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-2); padding: var(--s-8) var(--gutter) var(--s-24); max-height: calc(100dvh - var(--header-h)); overflow-y: auto; display: none; }
  .nav.is-open { display: block; }
  .nav__list { flex-direction: column; gap: 0; }
  .nav a { padding: var(--s-12) var(--s-8); font-size: var(--fs-body); min-height: 48px; display: flex; align-items: center; border-bottom: 1px solid var(--border); border-radius: 0; }
  .nav li:last-child a { border-bottom: 0; }
  .nav a[aria-current="true"]::after { left: 0; right: auto; top: 12px; bottom: 12px; width: 3px; height: auto; }
  .nav a[aria-current="true"] { padding-left: var(--s-16); }
}
/* Tablet */
@media (max-width: 1023px) {
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about { grid-template-columns: 1fr; gap: var(--s-32); }
  .case__lead { grid-template-columns: 1fr; }
  .case__sec { grid-template-columns: 1fr; gap: var(--s-8); }
  .case__sec > :not(h5) { grid-column: 1; }
  .approach { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .impact, .contact { grid-template-columns: 1fr; }
  .footer { grid-template-columns: 1fr 1fr; }
  .to-top { justify-self: end; grid-row: 1; grid-column: 2; }
  .ds__cols { grid-template-columns: 1fr; gap: var(--s-32); }
}
/* Mobile */
@media (max-width: 767px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__figure { justify-self: start; max-width: 340px; order: -1; }
  .hero__badge { left: auto; right: calc(-1 * var(--s-12)); bottom: var(--s-16); }
  .hero::before { width: 100%; }
  .hero__ctas .btn { flex: 1 1 100%; }
  .overview, .cards, .pillars, .approach, .palettes, .compare { grid-template-columns: 1fr; }
  .case { margin-left: 7px; padding-left: 25px; }
  .group__letter { width: 40px; height: 40px; font-size: 1.0625rem; }
  .group__index { margin-left: 0; }
  .sev-legend li { grid-template-columns: 1fr; gap: var(--s-4); }
  .footer { grid-template-columns: 1fr; }
  .to-top { grid-row: auto; grid-column: auto; justify-self: start; }
  .ts--h1 { font-size: 2.375rem; }
  .ts--h2 { font-size: 1.75rem; }
  .brand__name { font-size: var(--fs-small); }
  .zoom__hint span { display: none; }
}
@media (max-width: 359px) {
  .hero__badge { position: static; margin-top: var(--s-12); max-width: none; box-shadow: none; }
  .swatches { grid-template-columns: 1fr; }
}

/* 8. STATES & ACCESSIBILITY --------------------------------------------- */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.zoom:focus-visible { outline-offset: 3px; }
.table-wrap:focus-visible, .code:focus-visible { outline-offset: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .chip[aria-pressed="true"] { outline: 2px solid CanvasText; }
  .nav a[aria-current="true"]::after { background: CanvasText; }
}
@media print {
  .site-header, .menu-toggle, .theme-toggle, .case__toggle, .filters, .to-top, .zoom__hint, .lightbox { display: none !important; }
  .case__body[hidden] { display: grid !important; }
  .section--contact { background: none; color: #000; }
}

/* Recruiter-remediation additions: theme-specific reconstructed previews, flagship tag, screen link */
[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }
.tag--flag { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.figure__screen { display: inline-block; margin-left: var(--s-4); font-weight: 600; }
.flagship-note { margin-top: var(--s-8); }
/* Typographic profile (portrait not approved for public use) and withheld-screen placeholder */
.hero__profile { width: 100%; aspect-ratio: 418 / 402; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--contact-bg); color: var(--contact-fg);
  display: grid; place-content: center; justify-items: center; gap: var(--s-16); text-align: center;
  background-image: radial-gradient(var(--contact-line) 1.2px, transparent 1.2px); background-size: 18px 18px; }
.hero__mono { font-size: clamp(4rem, 3rem + 4vw, 6.5rem); font-weight: 700; letter-spacing: .02em; line-height: 1; }
.hero__profile-k { font-size: var(--fs-small); font-weight: 600; opacity: .9; }
.figure--withheld .withheld { display: flex; align-items: center; justify-content: center; gap: var(--s-8); min-height: 220px; padding: var(--s-24);
  border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-sunk); color: var(--text-muted); font-size: var(--fs-small); text-align: center; }
.card__shot .withheld { display: flex; align-items: center; justify-content: center; gap: var(--s-8); height: 100%; color: var(--text-muted); font-size: var(--fs-label); }
