/* Shared design system for the portfolio site.
   Per-case `<style>` blocks override accent tokens and add unique components. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── TOKENS ─────────────────────────────────────────────── */
:root {
  --font-sans: 'Inter', -apple-system, system-ui, sans-serif;

  /* neutrals */
  --c-bg: #050505;
  --c-surface: rgba(255,255,255,0.02);
  --c-border: #1a1a1a;
  --c-fade: #7a7a7a;
  --c-muted: #9a9a9a;
  --c-body: #b5b5b5;
  --c-strong: #e8e8e8;
  --c-text: var(--c-strong);

  /* accents — per-case override these */
  --c-accent: #6366f1;
  --c-accent-soft: rgba(99,102,241,0.10);
  --c-accent-mid:  rgba(99,102,241,0.20);
  --c-warn: #f59e0b;
  --c-hover: #c7d2fe;

  /* cover glow — per-case may override */
  --cover-glow-color-1: rgba(255,255,255,0.07);
  --cover-glow-color-2: rgba(255,255,255,0.04);

  /* showcase background — per-case override */
  --showcase-gradient: radial-gradient(ellipse at 10% 10%, #1a1a2e 0%, transparent 60%),
                       radial-gradient(ellipse at 90% 90%, #15151f 0%, transparent 60%),
                       #0a0a0a;

  /* spacing */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --s-9: 96px; --s-10: 120px;

  --focus: var(--c-accent);
}

/* ─── RESETS ─────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--c-bg);
  color: var(--c-strong);
  font-family: var(--font-sans);
  overflow-x: hidden;
}

/* ─── CURSOR GLOW (shared across pages) ──────────────────── */
.glow {
  position: fixed;
  top: 0; left: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99,102,241,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 5;
  border-radius: 50%;
  transition: transform 0.15s ease-out;
  will-change: transform;
}

/* ─── CUSTOM CURSOR (fine pointer devices only) ──────────── */
@media (hover: hover) and (pointer: fine) {
  html.has-custom-cursor,
  html.has-custom-cursor body,
  html.has-custom-cursor * {
    cursor: none !important;
  }
  .cursor-dot,
  .cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10000;
    will-change: transform;
    transform: translate3d(-100px, -100px, 0);
  }
  .cursor-dot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: #c7d2fe;
    transition: opacity 0.2s ease, background 0.2s ease;
  }
  .cursor-ring {
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 1px solid rgba(165, 180, 252, 0.55);
    border-radius: 50%;
    transition:
      width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
      height 0.22s cubic-bezier(0.16, 1, 0.3, 1),
      margin 0.22s cubic-bezier(0.16, 1, 0.3, 1),
      border-color 0.2s ease,
      background 0.2s ease,
      opacity 0.2s ease;
  }
  .cursor-ring.is-hovering {
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border-color: rgba(129, 140, 248, 0.9);
    background: rgba(99, 102, 241, 0.08);
  }
  .cursor-ring.is-pressing {
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border-color: rgba(199, 210, 254, 0.95);
  }
  .cursor-dot.is-hidden,
  .cursor-ring.is-hidden {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* ─── ACCESSIBILITY ──────────────────────────────────────── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── NAV ────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 24px 8vw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}
.nav a {
  font-size: 13px;
  color: var(--c-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav a:hover { color: var(--c-hover); }
.nav-name {
  font-weight: 600;
  color: var(--c-strong) !important;
  letter-spacing: -0.5px;
}

/* ─── CASE HERO ──────────────────────────────────────────── */
.case-hero {
  padding: 160px 8vw 80px;
  max-width: 1280px;
  margin: 0 auto;
}
.case-hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 80px;
  margin-top: 56px;
  align-items: start;
}
@media (max-width: 900px) {
  .case-hero-grid { grid-template-columns: 1fr; gap: 40px; }
}
.case-hero-meta {
  display: flex;
  flex-direction: column;
}
.meta-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--c-border);
  align-items: baseline;
}
.meta-row:last-child { border-bottom: 1px solid var(--c-border); }
.meta-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--c-fade);
}
.meta-value {
  font-size: 15px;
  color: var(--c-strong);
  line-height: 1.5;
}
.meta-scope {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
}

.case-hero-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.panel-block h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-strong);
  margin-bottom: 8px;
  letter-spacing: -0.1px;
}
.panel-block p {
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--c-muted);
}
.panel-block.outcome p { color: var(--c-body); }
.panel-block.outcome strong {
  color: var(--c-accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.case-hero .case-back {
  font-size: 12px;
  color: var(--c-fade);
  text-decoration: none;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 48px;
  padding: 6px 0;
  transition: color 0.2s;
}
.case-hero .case-back:hover { color: var(--c-hover); }

.case-meta-top {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: 20px;
}
.case-hero h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 1.05;
  margin-bottom: 20px;
}
@media (max-width: 720px) {
  .case-hero {
    padding: 120px 6vw 48px;
  }
  .case-hero h1 {
    font-size: clamp(32px, 9vw, 44px);
    letter-spacing: -1.5px;
  }
  .case-hero .case-subtitle { font-size: 17px; }
  .case-hero .case-back { margin-bottom: 32px; }
  .case-hero-grid { gap: 32px; margin-top: 40px; }
  .meta-row { grid-template-columns: 92px 1fr; gap: 12px; }
  .meta-value { font-size: 14px; }
  .panel-block p { font-size: 15px; }
  .case-cover { max-width: 94vw; margin-bottom: 48px; }
  .metrics-bar { gap: 24px 32px; padding: 28px 6vw; }
  .m-value { font-size: 26px; }
  .case-section h2,
  .case-section.tension h2,
  .case-section.decision h2 {
    font-size: 24px;
  }
  .case-section p,
  .case-section.tension p,
  .case-section.decision p {
    font-size: 17px;
    line-height: 1.6;
    margin-bottom: 20px;
  }
  .case-section { margin-bottom: 48px; }
  .case-content { padding: 0 6vw; }
  .next-project { flex-direction: column; align-items: flex-start; gap: 12px; padding: 48px 6vw; }
  .next-project a { font-size: 18px; }
  .footer { flex-direction: column; gap: 16px; text-align: center; padding: 40px 6vw; }
}
.case-hero .case-subtitle {
  font-size: 20px;
  color: var(--c-muted);
  font-weight: 400;
  line-height: 1.6;
  max-width: 640px;
}

/* ─── COVER IMAGE ────────────────────────────────────────── */
.case-cover {
  max-width: 80vw;
  margin: 0 auto 80px;
}
.case-cover img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 80px var(--cover-glow-color-1))
          drop-shadow(0 0 30px var(--cover-glow-color-2));
}

/* ─── METRICS BAR ────────────────────────────────────────── */
.metrics-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 48px;
  padding: 40px 8vw;
  border-top: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 16px;
}
.m-item { text-align: center; }
.m-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
}
.m-label {
  font-size: 10px;
  color: var(--c-fade);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 4px;
}
.metrics-footnote {
  max-width: 720px;
  margin: 0 auto 80px;
  padding: 16px 8vw 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--c-fade);
  font-style: italic;
}

/* ─── CONTENT COLUMN + SECTIONS ──────────────────────────── */
.case-content {
  max-width: min(900px, 100%);
  width: clamp(320px, 92vw, 900px);
  margin: 0 auto;
  padding: 0 8vw;
}
.case-section { margin-bottom: 64px; }
.case-section h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--c-strong);
  margin-bottom: 24px;
  line-height: 1.2;
}
.case-section p {
  font-size: 19px;
  line-height: 1.7;
  color: var(--c-body);
  margin-bottom: 28px;
}
.case-section p strong {
  color: var(--c-strong);
  font-weight: 500;
}

/* ─── TENSION ────────────────────────────────────────────── */
.case-section.tension h2 {
  color: var(--c-strong);
  letter-spacing: 0;
  text-transform: none;
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 24px;
}
.case-section.tension p {
  color: var(--c-body);
  font-size: 19px;
  line-height: 1.7;
}

/* ─── DECISION SECTIONS ──────────────────────────────────── */
.case-section .eyebrow,
.case-section.decision .eyebrow {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: 10px;
}
.case-section.decision h2 {
  color: var(--c-strong);
  letter-spacing: -0.5px;
  text-transform: none;
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 24px;
}
.case-section.decision p {
  color: var(--c-body);
  font-size: 19px;
  line-height: 1.7;
}

/* ─── IMAGE GRID ─────────────────────────────────────────── */
.case-images {
  margin: 64px 0;
  padding: 0 8vw;
}
.img-grid {
  display: grid;
  gap: 12px;
}
.img-grid.two   { grid-template-columns: 1fr 1fr; }
.img-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.img-grid.full  { grid-template-columns: 1fr; }
.img-grid img {
  width: 100%;
  height: auto;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.img-grid.two,
.img-grid.three { align-items: center; }

.img-caption {
  font-size: 12px;
  color: var(--c-fade);
  margin-top: 12px;
  letter-spacing: 0.3px;
  text-align: center;
}

/* ─── OUTCOME BLOCKS ─────────────────────────────────────── */
.outcome-block {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  align-items: start;
  padding: 48px 0;
  border-top: 1px solid var(--c-border);
}
.outcome-block:last-of-type {
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 24px;
}
.outcome-metric {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--c-accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.outcome-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: 12px;
}
.outcome-body p {
  font-size: 18px;
  line-height: 1.7;
  color: var(--c-body);
  margin: 0;
}
.outcome-footnote {
  font-size: 12px !important;
  color: var(--c-fade) !important;
  font-style: italic;
  line-height: 1.6 !important;
  margin-top: 24px !important;
}
@media (max-width: 720px) {
  .outcome-block { grid-template-columns: 1fr; gap: 12px; }
  .outcome-metric { font-size: 44px; }
}

/* ─── TAGS ───────────────────────────────────────────────── */
.case-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.case-tag {
  font-size: 11px;
  padding: 5px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--c-border);
  border-radius: 100px;
  color: var(--c-fade);
}

/* ─── NEXT PROJECT ───────────────────────────────────────── */
.next-project {
  margin-top: 120px;
  padding: 64px 8vw;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.next-project-text {
  font-size: 12px;
  color: var(--c-fade);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.next-project a {
  font-size: 20px;
  font-weight: 600;
  color: var(--c-strong);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: color 0.2s, gap 0.2s;
}
.next-project a:hover {
  color: var(--c-hover);
  gap: 18px;
}

/* ─── SHOWCASE SCROLL ────────────────────────────────────── */
.showcase-scroll {
  overflow-x: hidden;
  overflow-y: visible;
  margin: 80px 0;
  padding: 64px 0;
  background: var(--showcase-gradient);
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  -webkit-mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,0.4) 8%, #000 22%, #000 78%, rgba(0,0,0,0.4) 92%, transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,0.4) 8%, #000 22%, #000 78%, rgba(0,0,0,0.4) 92%, transparent 100%);
}
.showcase-track {
  display: flex;
  align-items: flex-start;
  gap: 0;
  width: max-content;
  animation: scroll-left 40s linear infinite;
  /* Force GPU compositor layer so long tracks with many large images
     don't fight the main thread. */
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}
.showcase-track img + img { margin-left: -2vw; }
.showcase-track img {
  max-height: 98vh;
  width: auto;
  flex-shrink: 0;
  display: block;
}
@keyframes scroll-left {
  0%   { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}
@media (max-width: 720px) {
  .showcase-scroll { padding: 40px 0; margin: 48px 0; }
  .showcase-track img + img { margin-left: 12px; }
  .showcase-track img { max-height: 60vh; }
  .showcase-track { animation-duration: 60s; }
}
@media (prefers-reduced-motion: reduce) {
  .showcase-track { animation: none; overflow-x: auto; }
}

/* ─── FOOTER ─────────────────────────────────────────────── */
.footer {
  padding: 40px 8vw;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer-left { font-size: 14px; color: var(--c-fade); }
.footer-links { display: flex; gap: 24px; }
.footer-links a {
  font-size: 13px;
  color: var(--c-fade);
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--c-hover); }

/* ─── SIGN-OFF ──────────────────────────────────────────── */
/* Signature sits at the end of the Reflection body, left-aligned
   within the reading column — like the closing of a letter. */
.signoff {
  margin-top: 28px;
}
.signoff img {
  display: inline-block;
  width: 135px;
  height: 60px;
  max-width: 100%;
  opacity: 0.55;
  transition: opacity 0.4s ease;
}
.signoff:hover img { opacity: 0.85; }
@media (max-width: 720px) {
  .signoff { margin-top: 20px; }
  .signoff img { width: 108px; height: 48px; }
}

/* ─── READING PROGRESS ──────────────────────────────────── */
/* Thin accent line below the nav, filled by JS as you scroll.
   Keeps the chrome-less feel but gives a small reading cue. */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--c-accent);
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.3s;
  opacity: 0.9;
  mix-blend-mode: screen;
}

/* ─── SHARED: DIAGRAM FRAME ─────────────────────────────── */
/* Container for inline-SVG diagrams. Per-case overrides extend. */
.diagram-frame {
  max-width: 1040px;
  margin: 48px auto;
  padding: 40px 32px 32px;
  background: var(--c-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  overflow-x: auto;
}
.diagram-frame svg {
  width: 100%;
  height: auto;
  display: block;
}
.diagram-title {
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--c-fade);
  margin-bottom: 24px;
  text-align: center;
}
@media (max-width: 720px) {
  .diagram-frame {
    padding: 28px 20px 22px;
    margin: 32px auto;
    border-radius: 10px;
  }
  .diagram-frame svg { min-width: 680px; }
  .diagram-frame::after {
    content: 'swipe →';
    position: sticky;
    right: 12px;
    bottom: 4px;
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-top: -16px;
    padding: 4px 10px;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--c-fade);
    background: rgba(255,255,255,0.08);
    border-radius: 100px;
    pointer-events: none;
  }
  .diagram-title { font-size: 10px; margin-bottom: 16px; }
}

/* ─── SHARED: STAT CARDS ───────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0 32px;
}
.stat-card {
  padding: 24px 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
}
.stat-value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: var(--c-accent);
  line-height: 1;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}
.stat-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-muted);
}
@media (max-width: 720px) {
  .stat-cards { grid-template-columns: 1fr; }
}

/* ─── SHARED: BRIEF REFRAME ─────────────────────────────── */
.brief-reframe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 24px 0;
}
.brief-card {
  padding: 24px 22px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.brief-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.brief-card p {
  font-size: 17px !important;
  line-height: 1.5 !important;
  font-style: italic;
  margin: 0 !important;
}
.brief-old { background: rgba(255,255,255,0.03); }
.brief-old .brief-label { color: var(--c-fade); }
.brief-old p { color: var(--c-muted) !important; }
.brief-new {
  background: var(--c-accent-soft);
  border-color: var(--c-accent-mid);
}
.brief-new .brief-label { color: var(--c-accent); }
.brief-new p { color: var(--c-strong) !important; }
@media (max-width: 720px) {
  .brief-reframe { grid-template-columns: 1fr; }
}

/* ─── SHARED: BEFORE / AFTER TABLE ──────────────────────── */
.before-after {
  margin: 24px 0;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  overflow: hidden;
}
.ba-header,
.ba-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.ba-row { border-bottom: 1px solid rgba(255,255,255,0.04); }
.ba-row:last-child { border-bottom: none; }
.ba-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 14px 20px;
}
.ba-label-old {
  color: var(--c-fade);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ba-label-new {
  color: var(--c-accent);
  background: var(--c-accent-soft);
  border-bottom: 1px solid var(--c-accent-mid);
  border-left: 1px solid rgba(255,255,255,0.06);
}
.ba-old {
  padding: 14px 20px;
  font-size: 14px;
  color: var(--c-fade);
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.15);
}
.ba-new {
  padding: 14px 20px;
  font-size: 14px;
  color: var(--c-strong);
  border-left: 1px solid rgba(255,255,255,0.06);
  background: var(--c-accent-soft);
}
@media (max-width: 720px) {
  .ba-header, .ba-row { grid-template-columns: 1fr; }
  .ba-new { border-left: none; border-top: 1px solid rgba(255,255,255,0.04); }
  .ba-label-new { border-left: none; }
}

/* ─── READING PROGRESS SCRIPT HOOK ──────────────────────── */
/* Add <div class="reading-progress"></div> after <nav> and include the
   tiny inline script:
   <script>
     (function(){
       const bar = document.querySelector('.reading-progress');
       if (!bar) return;
       function tick(){
         const h = document.documentElement;
         const max = h.scrollHeight - h.clientHeight;
         const pct = max > 0 ? (h.scrollTop / max) * 100 : 0;
         bar.style.width = pct + '%';
       }
       tick();
       addEventListener('scroll', tick, { passive: true });
       addEventListener('resize', tick);
     })();
   </script>
*/
