/* ==========================================================================
   Case study — Instrument
   --------------------------------------------------------------------------
   Self-contained on purpose. These pages live in /public and are copied to the
   build root verbatim, so they cannot reach /src. Previously they linked
   ../src/styles/globals.css, which does not exist in the built output — every
   case study shipped unstyled. The tokens below mirror src/styles/globals.css;
   keep the two in step.

   Each page sets its channel on <body>, e.g. style="--cs-ch: var(--ch-vision)".
   ========================================================================== */

/* Self-hosted fonts — the same files and faces as src/styles/globals.css */
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-weight: 100 800;
  font-stretch: 75% 112%;
  font-display: swap;
  src: url("../fonts/martian-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("../fonts/instrument-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: italic;
  font-weight: 400 700;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("../fonts/instrument-sans-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg:        #e9eef4;
  --bg-raised: #f2f5f9;
  --bg-sunk:   #dee5ee;

  --ink:       #0b111a;
  --ink-soft:  #3d4c5f;
  --ink-mute:  #5c6d82;

  --rule:      #0b111a;
  --rule-soft: rgba(11, 17, 26, 0.14);
  --rule-hair: rgba(11, 17, 26, 0.08);
  --grid:      rgba(11, 17, 26, 0.05);

  --sig-0: #2e3163;
  --sig-1: #7a2c63;
  --sig-2: #c42e63;
  --sig-3: #b34410;
  --sig-4: #8a6208;

  --accent:     var(--sig-2);
  --accent-ink: #ffffff;

  --ch-vision:  #1f6f78;
  --ch-ml:      #7a2c63;
  --ch-data:    #8a6208;
  --ch-llm:     #c42e63;
  --ch-app:     #2e3163;
  --ch-systems: #b34410;

  --display: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans:    "Instrument Sans", ui-sans-serif, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono:    "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Type floor, mirrored from src/styles/globals.css */
  --t-label: 11px;
  --t-micro: 11px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --cs-ch: var(--accent);
}

html[data-theme="dark"] {
  --bg:        #0a0f16;
  --bg-raised: #111925;
  --bg-sunk:   #060a0f;

  --ink:       #e4ecf6;
  --ink-soft:  #97a9c0;
  --ink-mute:  #70839b;

  --rule:      #e4ecf6;
  --rule-soft: rgba(228, 236, 246, 0.16);
  --rule-hair: rgba(228, 236, 246, 0.08);
  --grid:      rgba(126, 168, 222, 0.07);

  --sig-0: #7b82dd;
  --sig-1: #d264a8;
  --sig-2: #ff5c8a;
  --sig-3: #ff8a4c;
  --sig-4: #ffc15e;

  --accent:     var(--sig-2);
  --accent-ink: #0a0f16;

  --ch-vision:  #3fb6c2;
  --ch-ml:      #c874d6;
  --ch-data:    #ffc15e;
  --ch-llm:     #ff5c8a;
  --ch-app:     #7b82dd;
  --ch-systems: #ff8a4c;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a { color: inherit; }

/* Keeps a lone word off the last line of a paragraph */
p { text-wrap: pretty; }

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

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

/* Graph-paper ground, same as the portfolio */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right,  var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 25%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 25%, transparent 78%);
}

.cs-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 32px);
  position: relative;
  z-index: 1;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */

.cs-topbar {
  position: sticky; top: 0; z-index: 50;
  padding: 14px 0;
  background: color-mix(in oklab, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  border-bottom: 1px solid var(--rule-hair);
}

.cs-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 32px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.cs-back,
.cs-meta {
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 500;
  font-size: var(--t-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.cs-back {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none;
  transition: color 200ms ease;
}

.cs-back:hover { color: var(--accent); }
.cs-back .arr { display: inline-block; transition: transform 200ms var(--ease); }
.cs-back:hover .arr { transform: translateX(-3px); }

/* ── Hero ───────────────────────────────────────────────────────────────── */

.cs-hero {
  padding: 88px 0 48px;
  border-bottom: 1px solid var(--rule);
}

.cs-eyebrow {
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 500;
  font-size: var(--t-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 22px;
  display: flex; align-items: center; gap: 11px;
}

/* Square, not round — nothing on this page is a pill */
.cs-eyebrow .dot {
  width: 7px; height: 7px;
  background: var(--cs-ch);
  flex: none;
}

h1.cs-title {
  font-family: var(--display);
  font-variation-settings: "wdth" 84, "wght" 700;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin: 0 0 24px;
}

.cs-deck {
  font-size: clamp(16.5px, 1.6vw, 20px);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 58ch;
  margin: 0 0 34px;
}

.cs-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule-hair);
}

.cs-meta-grid > div {
  padding: 14px 16px 14px 0;
  border-right: 1px solid var(--rule-hair);
}

.cs-meta-grid > div:last-child { border-right: 0; }

.cs-meta-grid dt,
.cs-meta-grid .k {
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 500;
  font-size: var(--t-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}

.cs-meta-grid dd,
.cs-meta-grid .v {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
}

/* ── Cover plate ────────────────────────────────────────────────────────── */

/* Tag and number are one meta line, not two stacked ones */
.cs-cover {
  margin: 44px 0;
  padding: 34px;
  background: var(--cs-ch);
  /* Ink on a signal colour: white in light, the ground in dark (the dark
     channel colours are too bright to carry white text). */
  color: var(--accent-ink);
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 18px;
  align-items: baseline;
}

.cs-cover-num,
.cs-cover-tag {
  font-family: var(--mono);
  font-variation-settings: "wdth" 85, "wght" 500;
  font-size: var(--t-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.cs-cover-tag { grid-column: 1; grid-row: 1; }
.cs-cover-num { grid-column: 2; grid-row: 1; text-align: right; }

.cs-cover-quote {
  grid-column: 1 / -1;
  grid-row: 2;
  font-family: var(--display);
  font-variation-settings: "wdth" 84, "wght" 600;
  font-size: clamp(19px, 2.4vw, 30px);
  line-height: 1.24;
  letter-spacing: -0.025em;
  margin: 0;
  max-width: 30ch;
}

/* ── Stats ──────────────────────────────────────────────────────────────── */

.cs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule-soft);
  margin: 44px 0;
}

.cs-stat {
  padding: 20px 18px 18px 0;
  border-right: 1px solid var(--rule-hair);
}

.cs-stat:last-child { border-right: 0; }

.cs-stat-n {
  font-family: var(--mono);
  font-variation-settings: "wdth" 82, "wght" 700;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--cs-ch);
  display: block;
}

.cs-stat-label {
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 500;
  font-size: var(--t-micro);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 9px;
  display: block;
}

/* ── Sections ───────────────────────────────────────────────────────────── */

.cs-section { padding: 44px 0; }

.cs-section-num {
  font-family: var(--mono);
  font-variation-settings: "wdth" 82, "wght" 700;
  font-size: var(--t-label);
  letter-spacing: 0.1em;
  color: var(--cs-ch);
  display: block;
  margin-bottom: 10px;
}

h2.cs-h,
.cs-h {
  font-family: var(--display);
  font-variation-settings: "wdth" 84, "wght" 600;
  font-size: clamp(22px, 2.6vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-soft);
}

/* Measured in em, not ch: a ch is the wide "0", so 66ch ran ~95 characters */
.cs-prose p {
  font-size: 16px;
  line-height: 1.72;
  color: var(--ink-soft);
  max-width: 34em;
  margin: 0 0 18px;
}

.cs-prose strong { color: var(--ink); font-weight: 600; }

.cs-prose ul, .cs-prose ol {
  max-width: 34em;
  padding-left: 0;
  list-style: none;
  margin: 0 0 18px;
  display: grid;
  gap: 9px;
}

.cs-prose li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.cs-prose li::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--cs-ch);
  flex: none;
  transform: translateY(-1px);
}

.cs-prose code {
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 400;
  font-size: 0.86em;
  padding: 2px 5px;
  background: var(--bg-sunk);
  border: 1px solid var(--rule-hair);
}

.cs-prose a { color: var(--cs-ch); text-underline-offset: 3px; }

.cs-pullquote {
  font-family: var(--display);
  font-variation-settings: "wdth" 84, "wght" 500;
  font-size: clamp(18px, 2.1vw, 25px);
  line-height: 1.34;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 34px 0;
  padding: 22px 0 22px 24px;
  border-left: 2px solid var(--cs-ch);
  max-width: 40ch;
}

/* ── Architecture blocks ────────────────────────────────────────────────── */

.cs-arch {
  display: grid;
  gap: 0;
  margin: 26px 0;
  border-top: 1px solid var(--rule);
}

.cs-arch-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule-hair);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 18px;
  align-items: baseline;
}

.cs-arch-block-name {
  font-family: var(--mono);
  font-variation-settings: "wdth" 85, "wght" 600;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cs-arch-block-tag {
  font-family: var(--mono);
  font-variation-settings: "wdth" 85, "wght" 400;
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 4px 7px;
  border: 1px solid var(--rule-hair);
  background: var(--bg-raised);
  white-space: nowrap;
}

.cs-arch-block-detail {
  grid-column: 1 / -1;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ── Lessons ────────────────────────────────────────────────────────────── */

.cs-lessons {
  list-style: none;
  margin: 24px 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--rule);
  counter-reset: lesson;
}

.cs-lessons li {
  counter-increment: lesson;
  padding: 16px 0 16px 44px;
  border-bottom: 1px solid var(--rule-hair);
  position: relative;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.cs-lessons li::before {
  content: counter(lesson, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 18px;
  font-family: var(--mono);
  font-variation-settings: "wdth" 82, "wght" 700;
  font-size: var(--t-label);
  letter-spacing: 0.1em;
  color: var(--cs-ch);
}

/* ── CTA ────────────────────────────────────────────────────────────────── */

.cs-cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 40px 0;
}

.cs-cta {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 15px 20px;
  border: 1px solid var(--rule-soft);
  text-decoration: none;
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 500;
  font-size: var(--t-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  transition: color 220ms var(--ease), border-color 220ms var(--ease), background 220ms var(--ease);
}

.cs-cta:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.cs-cta--solid {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.cs-cta--solid:hover {
  background: var(--cs-ch);
  border-color: var(--cs-ch);
  color: #fff;
}

.cs-cta--ghost { background: transparent; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.cs-footer {
  margin-top: 56px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-variation-settings: "wdth" 88, "wght" 500;
  font-size: var(--t-micro);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

/* ── Responsive + motion ────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .cs-hero { padding: 60px 0 36px; }
  .cs-cover { padding: 28px 22px; margin: 32px 0; }
  .cs-section { padding: 32px 0; }
  .cs-meta-grid > div,
  .cs-stat { border-right: 0; border-bottom: 1px solid var(--rule-hair); }
}

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

@media print {
  body::before { display: none; }
  .cs-topbar { display: none; }
  .cs-cover { background: none; color: var(--ink); border: 1px solid var(--ink); }
}
