/* Case-study pages (work/*.html).
   Page chrome follows the portfolio's tokens (dark by default, light via the toggle).
   Figures, scenes, films and infographics keep the fixed graphite palette they were drawn in. */

:root {
  --bg: #06070d;
  --bg-2: #0b0d17;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e7e9f3;
  --muted: #969ab5;
  --faint: #6a6f8c;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --glow: rgba(124, 92, 255, 0.35);
  --max: 1080px;
  --orb-opacity: 0.5;
  --grid-line: rgba(255,255,255,0.025);
  --nav-bg: rgba(6, 7, 13, 0.55);
  --nav-bg-scrolled: rgba(6, 7, 13, 0.8);

  /* fixed figure palette (matches the diagrams, scenes and films) */
  --void: #0a0b0e;
  --slab: #111318;
  --slab-2: #171a20;
  --line: rgba(233, 230, 223, 0.12);
  --line-strong: rgba(233, 230, 223, 0.28);
  --bone: #e9e6df;
  --ash: #8f949c;
  --ti: #b8c2cc;
  --ember: #d9742b;
  --ok: #6fbf95;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-2: #ffffff;
  --panel: rgba(10, 12, 30, 0.02);
  --panel-border: rgba(10, 12, 30, 0.1);
  --text: #14162b;
  --muted: #4c5170;
  --faint: #868bab;
  --accent: #6b46f0;
  --accent-2: #0891b2;
  --accent-3: #db2777;
  --glow: rgba(107, 70, 240, 0.25);
  --orb-opacity: 0.28;
  --grid-line: rgba(10,12,30,0.04);
  --nav-bg: rgba(244, 245, 251, 0.65);
  --nav-bg-scrolled: rgba(244, 245, 251, 0.85);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--body); background: var(--bg); color: var(--text); line-height: 1.65;
  overflow-x: hidden; -webkit-font-smoothing: antialiased; transition: background 0.4s, color 0.4s;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; }

/* background */
.bg-orbs { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--orb-opacity); animation: float 22s ease-in-out infinite; }
.orb.a { width: 520px; height: 520px; background: #4c2fd6; top: -160px; left: -120px; }
.orb.b { width: 460px; height: 460px; background: #0e7490; top: 40%; right: -140px; animation-delay: -7s; }
.orb.c { width: 380px; height: 380px; background: #9d174d; bottom: -120px; left: 30%; animation-delay: -14s; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(40px, -30px) scale(1.08); } 66% { transform: translate(-30px, 40px) scale(0.94); } }
.grid-overlay {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 54px 54px; mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}

/* nav */
nav#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(20px, 5vw, 60px); backdrop-filter: blur(12px); background: var(--nav-bg);
  border-bottom: 1px solid transparent; transition: border-color 0.3s, background 0.3s;
}
nav#nav.scrolled { border-bottom-color: var(--panel-border); background: var(--nav-bg-scrolled); }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; display: flex; align-items: center; gap: 9px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2); }
.nav-actions { display: flex; align-items: center; gap: 18px; }
.nav-links { display: flex; gap: 30px; }
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; transition: color 0.2s; position: relative; }
.nav-links a:hover { color: var(--text); }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; background: var(--panel); border: 1px solid var(--panel-border);
  color: var(--text); display: grid; place-items: center; font-size: 1.05rem; transition: border-color 0.2s, transform 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-2px); }
@media (max-width: 720px) { .nav-links { display: none; } }

/* buttons (same look as the home page); the résumé ones sit in the nav and the footer */
.btn {
  font-family: var(--display); font-weight: 600; font-size: 0.95rem; padding: 13px 26px; border-radius: 12px; cursor: pointer;
  text-decoration: none; border: 1px solid transparent; transition: transform 0.15s, box-shadow 0.25s, background 0.25s;
  display: inline-flex; align-items: center; gap: 9px;
}
.btn.primary { background: linear-gradient(115deg, var(--accent), #5b3fd6); color: #fff; box-shadow: 0 8px 30px var(--glow, rgba(124, 92, 255, 0.35)); }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px var(--glow, rgba(124, 92, 255, 0.35)); }
.btn.ghost { background: var(--panel); border-color: var(--panel-border); color: var(--text); }
.btn.ghost:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn.nav-resume { padding: 9px 16px; font-size: 0.85rem; border-radius: 10px; white-space: nowrap; }
.btn.footer-resume { padding: 10px 20px; font-size: 0.88rem; margin: 14px 0 6px; }

/* page */
main.case { max-width: var(--max); margin: 0 auto; padding: 108px clamp(20px, 5vw, 40px) 40px; }
.eyebrow { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-2); }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.6rem; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); padding-bottom: 1.6rem; }
.crumbs a:hover { color: var(--text); }

.case-hero { padding-block: 1rem clamp(2.5rem, 6vh, 4rem); border-bottom: 1px solid var(--panel-border); display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 2rem 3rem; align-items: end; }
.case-hero h1 { font-size: clamp(2.2rem, 5vw, 4.2rem); font-weight: 700; line-height: 1.02; letter-spacing: -0.04em; margin-block: 1rem 1.2rem; }
.case-hero h1 em { font-style: normal; color: transparent; background: linear-gradient(115deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-3) 100%); -webkit-background-clip: text; background-clip: text; }
.case-hero .lede { max-width: 38rem; font-size: 1.08rem; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.stat b { font-family: var(--display); font-weight: 700; font-size: clamp(1.5rem, 2.6vw, 2.1rem); letter-spacing: -0.03em; line-height: 1; color: var(--text); }
.stat b small { font-size: 0.55em; color: var(--accent-2); font-weight: 600; margin-left: 0.15rem; }
.stat span { font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--panel-border); }
.facts li { padding: 1.1rem 1.2rem 1.1rem 0; border-right: 1px solid var(--panel-border); }
.facts li + li { padding-left: 1.2rem; }
.facts li:last-child { border-right: 0; }
.facts span { display: block; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.3rem; }
.facts b { font-family: var(--display); font-weight: 600; font-size: 1.02rem; letter-spacing: -0.01em; color: var(--text); }

.block { padding-block: clamp(3rem, 7vh, 5rem); border-bottom: 1px solid var(--panel-border); }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: 2rem; }
.side { display: flex; flex-direction: column; gap: 0.6rem; }
.side-note { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); line-height: 1.7; max-width: 18rem; }
.block-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem 2rem; margin-bottom: 2.2rem; }
.block-head h2 { font-weight: 700; font-size: clamp(1.6rem, 3.2vw, 2.4rem); line-height: 1.08; letter-spacing: -0.03em; margin-top: 0.5rem; }
.block-head p { color: var(--muted); max-width: 30rem; }

.prose { max-width: 42rem; color: var(--muted); font-size: 1.02rem; display: grid; gap: 1rem; }
.prose strong { color: var(--text); font-weight: 600; }
.prose ul { display: grid; gap: 0.6rem; padding-left: 1.1rem; list-style: square; }
.prose li::marker { color: var(--accent-2); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
.two-col h3 { font-weight: 600; font-size: 1.12rem; letter-spacing: -0.015em; margin-bottom: 0.8rem; color: var(--text); }

.xref { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); border-bottom: 1px solid var(--panel-border); align-self: flex-start; padding-bottom: 2px; margin-top: 0.6rem; }
.xref:hover { border-color: var(--text); }
.stack { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.stack span { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--panel-border); border-radius: 7px; padding: 0.35rem 0.65rem; color: var(--muted); }

/* figures: fixed graphite palette */
.fig { display: grid; gap: 0.8rem; min-width: 0; margin-top: 3rem; }
.fig-title { display: flex; gap: 0.8rem; align-items: baseline; font-family: var(--display); font-weight: 600; font-size: 1rem; line-height: 1.3; color: var(--text); }
.fig-title .no { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; color: var(--accent-2); white-space: nowrap; font-weight: 400; }
figcaption { font-size: 0.86rem; line-height: 1.5; color: var(--faint); max-width: 64rem; }
figcaption b { font-weight: 500; color: var(--text); }
.diagram-host { border: 1px solid var(--line); background: var(--slab); padding: 1rem; overflow-x: auto; border-radius: 14px; }
.diagram-host svg.diagram { display: block; width: 100%; min-width: 640px; height: auto; }
.diagram .grp rect { fill: rgba(233, 230, 223, 0.025); stroke: var(--line-strong); stroke-dasharray: 4 4; }
.diagram .grp-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 1.4px; fill: var(--ash); }
.diagram .node rect { fill: var(--slab-2); stroke: var(--line-strong); stroke-width: 1; }
.diagram .node.model rect { stroke: var(--ti); }
.diagram .node.io rect { fill: var(--void); stroke-dasharray: 3 3; }
.diagram .node.human rect { fill: var(--void); stroke: var(--ember); }
.diagram .node.store rect { fill: var(--slab); }
.diagram .node .inner { fill: none; stroke: var(--line); stroke-width: 1; }
.diagram .node .title { font-family: var(--body); font-size: 12.5px; font-weight: 500; fill: var(--bone); }
.diagram .node .sub { font-family: var(--mono); font-size: 9.5px; fill: var(--ash); }
.diagram .badge-bg { fill: var(--void); stroke: var(--line-strong); }
.diagram .badge { font-family: var(--mono); font-size: 8.5px; fill: var(--ti); letter-spacing: 0.6px; }
.diagram .edge path { fill: none; stroke: rgba(233, 230, 223, 0.5); stroke-width: 1.1; }
.diagram .edge.dash path { stroke-dasharray: 4 3; }
.diagram .arrowhead { fill: rgba(233, 230, 223, 0.7); }
.diagram .lbl-bg { fill: var(--void); }
.diagram .lbl { font-family: var(--mono); font-size: 9px; fill: var(--ash); letter-spacing: 0.5px; }
.scene-wrap { border: 1px solid var(--line-strong); background: var(--void); aspect-ratio: 16 / 9; max-width: 100%; border-radius: 14px; overflow: hidden; }
.scene-wrap canvas { display: block; width: 100%; height: 100%; }
.film { display: grid; gap: 0.8rem; }
.film video { display: block; width: 100%; height: auto; background: var(--void); border: 1px solid var(--line-strong); aspect-ratio: 16 / 9; border-radius: 14px; }
.film-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.film-meta a { color: var(--text); border-bottom: 1px solid var(--panel-border); }
.ill-note { font-family: var(--mono); font-size: 0.7rem; line-height: 1.7; color: var(--faint); border-left: 2px solid var(--accent-3); padding-left: 0.9rem; max-width: 46rem; }
.infographic { margin: 0; }
.infographic img { display: block; width: 100%; max-width: 520px; height: auto; border: 1px solid var(--line-strong); border-radius: 14px; }

.case-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 3rem; }
.case-nav a { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 1.3rem 1.5rem; display: grid; gap: 0.3rem; transition: transform 0.25s, border-color 0.25s; }
.case-nav a:hover { transform: translateY(-3px); border-color: rgba(124,92,255,0.45); }
.case-nav a:last-child { text-align: right; }
.case-nav span { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.case-nav b { font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--text); }

footer { text-align: center; padding: 40px 20px; color: var(--faint); font-size: 0.85rem; border-top: 1px solid var(--panel-border); margin-top: 40px; }
footer .brand { justify-content: center; margin-bottom: 10px; font-size: 0.95rem; }
footer a:hover { color: var(--text); }

@media (max-width: 900px) {
  .case-hero { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts li:nth-child(2) { border-right: 0; }
  .facts li:nth-child(n + 3) { border-top: 1px solid var(--panel-border); }
  .facts li:nth-child(3) { padding-left: 0; }
  .split { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 2rem; }
  .case-nav { grid-template-columns: 1fr; }
  .case-nav a:last-child { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .orb { animation: none; } }
