/* ============================================================
   case.css: the case study page layer.

   Loaded after main.css and fx.css, only on /work/<slug>/ pages.
   Implements the block components specified in
   Blueprints/CASE-STUDY-FORMAT.md section 6, in the same language
   as the rest of the site: hairline borders, no radius, Oswald
   display, mono labels at 0.06em, Manrope prose.
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   PAGE SHELL
   ════════════════════════════════════════════════════════════ */

/* No hero to reveal from, so the header is on from the first paint.
   Done in CSS as well as JS: waiting for main.js would let the header
   slide in a beat after the page renders. */
body.page-case .site-header {
  transform: none;
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* The same paper grain the landing page sections carry, so a case study
   sits in the same air rather than reading as a flat document. */
body.page-case:not(.no-distress) main {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='d'><feTurbulence type='fractalNoise' baseFrequency='0.012' numOctaves='5'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.015 0'/></filter><rect width='100%' height='100%' filter='url(%23d)'/></svg>");
}

/* ════════════════════════════════════════════════════════════
   PROJECT HEADER
   ════════════════════════════════════════════════════════════ */
.case-hero {
  padding: 132px var(--gutter) 0;
  position: relative;
}
.case-hero__kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-2);
  margin-bottom: 22px;
}
.case-hero__kicker .sep {
  width: 28px;
  height: 1px;
  background: var(--line);
}
.case-hero__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(44px, 6vw, 88px);
  line-height: 0.92;
  letter-spacing: 0.005em;
  text-transform: uppercase;
  color: var(--fg-0);
}
.case-hero__title .sub {
  display: block;
  font-weight: 400;
  font-size: 0.42em;
  color: var(--fg-2);
  margin-top: 0.24em;
  letter-spacing: 0.02em;
}
.case-hero__summary {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  max-width: 720px;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--fg-1);
  text-wrap: pretty;
}

/* Front-matter meta strip. Same treatment as the work preview on
   the landing page, widened to carry more fields. */
.case-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 26px 32px;
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid var(--line-soft);
}
.case-meta dt {
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 8px;
}
.case-meta dd {
  font-family: var(--body);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--fg-0);
}

/* Solid call to action. The only filled element on the site, which is why
   it is reserved for one thing: going to the real, live product. Inverts
   to an outline on hover so it stays in the site's hairline language. */
.case-cta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
  padding: 15px 24px;
  font-family: var(--label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--fg-0);
  color: var(--bg-0);
  border: 1px solid var(--fg-0);
  transition: background 220ms ease, color 220ms ease;
}
.case-cta:hover,
.case-cta:focus-visible {
  background: transparent;
  color: var(--fg-0);
}
.case-cta .arrow {
  font-size: 14px;
  line-height: 1;
  transition: transform 240ms cubic-bezier(.2,.7,.2,1);
}
.case-cta:hover .arrow { transform: translate(3px, -3px); }

/* ════════════════════════════════════════════════════════════
   SECTIONS
   ════════════════════════════════════════════════════════════ */
.case-section { padding: 96px var(--gutter) 0; }
.case-section:last-of-type { padding-bottom: 40px; }

/* A rule above the title as well as below it, so each section reads as a
   bounded block instead of a run of headings. Deliberately fainter than
   the bottom rule: the one below closes the header and carries the
   distressed accent mark, this one only separates. */
.case-section .section-head {
  border-top: 1px solid var(--line-faint);
  padding-top: 30px;
  padding-bottom: 34px;
  margin-bottom: 40px;
}
.case-section .section-head__title {
  font-size: clamp(26px, 3vw, 40px);
  display: flex;
  align-items: baseline;
  gap: 18px;
}
.case-section__num {
  font-family: var(--label);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  font-weight: 400;
}

/* The lede is the framing voice, the body is the detail. Set apart with
   the site's left-rule motif (as on the Why row and the callouts), a
   decorative quote mark, italics, and a step down in tone.

   --fg-2 is as dark as this can safely go: roughly 5.3:1 on --bg-1, which
   still clears WCAG AA for body text. --fg-3 would fall to about 2.6:1
   and fail, not a trade worth making on a portfolio that lists
   accessibility as a skill. (There is no --fg-5; the ladder ends at 4.) */
.case-section .section-head__lede {
  position: relative;
  padding: 44px 0 0 26px;
  font-size: 1.1875rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--fg-2);
  max-width: 700px;
}
/* Structural rule */
.case-section .section-head__lede::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 0.28em;
  width: 2px;
  background: var(--accent-dim);
}
/* Decorative opening quote, set above the text rather than behind it so
   nothing is ever printed over a letter. Purely ornamental, so it is
   hidden from screen readers by being a pseudo-element with no role. */
.case-section .section-head__lede::after {
  content: "\201C";
  position: absolute;
  left: 20px;
  top: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.6em;
  line-height: 0.84;
  color: var(--fg-3);
  pointer-events: none;
}

/* Prose */
.case-body { max-width: 720px; }
.case-body p {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--fg-1);
  margin-bottom: 1.3em;
  text-wrap: pretty;
}
.case-body p:last-child { margin-bottom: 0; }
.case-body strong { color: var(--fg-0); font-weight: 600; }
.case-body em { font-style: italic; color: var(--fg-0); }

/* ════════════════════════════════════════════════════════════
   FIGURES
   ════════════════════════════════════════════════════════════ */
.figure { margin: 44px 0; }
.figure--inset { max-width: 900px; margin-left: auto; margin-right: auto; }
.figure--full,
.figure--wide { max-width: 100%; }

.figure__frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--bg-2);
}
.figure__frame img { width: 100%; height: auto; display: block; }

/* Grain over every image, so screenshots sit in the same air as
   the rest of the page instead of floating on top of it. */
.figure__frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.figure__caption {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
}

/* Placeholder for src: TODO, and the fallback when a file 404s.
   A labelled empty frame is more useful than a broken image icon:
   it shows the page is finished and the asset is not. */
.figure__placeholder {
  aspect-ratio: 16 / 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,0.015) 0px,
    rgba(255,255,255,0.015) 14px,
    transparent 14px,
    transparent 28px
  );
}
.figure__placeholder .tag {
  font-family: var(--label);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--hazard);
}
.figure__placeholder .what {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--fg-3);
  max-width: 46ch;
}
.figure--hero .figure__placeholder { aspect-ratio: 16 / 9; }

/* The hero is the one image that gets more width than the section figures,
   which is what makes it read as the hero. Edge to edge was too much of a
   good thing though: a 16:9 image across the full gutter is taller than the
   viewport on a laptop, so the project header becomes a whole screen of
   picture before a word of the case study. Three quarters, centered, keeps
   the hierarchy and gives the page back its first screen.

   Declared after .figure--full so it wins on source order for an element
   carrying both classes. */
.figure--hero {
  max-width: 75%;
  margin-left: auto;
  margin-right: auto;
}
/* Swapped in by initFigures when an image fails to load */
.figure.is-missing .figure__frame img { display: none; }
.figure:not(.is-missing) .figure__frame .figure__placeholder--fallback { display: none; }

/* Figure pair */
.figurepair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 44px 0;
}

/* Gallery */
.gallery { margin: 44px 0; }
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.gallery__caption {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
}

/* ════════════════════════════════════════════════════════════
   DECISION

   The centrepiece component. Structured so the reasoning is
   impossible to skip: the alternative that was rejected sits
   directly above the choice, and WHY gets the accent rule.
   ════════════════════════════════════════════════════════════ */
.decision {
  margin: 44px 0;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.decision__head {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.decision__label {
  display: block;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-2);
  margin-bottom: 10px;
}
.decision__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(20px, 2.2vw, 27px);
  line-height: 1.15;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--fg-0);
}
.decision__rows { padding: 6px 28px 24px; }
.decision__row {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-faint);
}
.decision__row:last-child { border-bottom: 0; }
.decision__row dt {
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding-top: 3px;
}
.decision__row dd {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--fg-1);
  text-wrap: pretty;
}
/* The reasoning is the part worth reading twice */
.decision__row--why {
  background: rgba(255,255,255,0.014);
  margin: 0 -28px;
  padding: 16px 28px;
  border-left: 2px solid var(--accent-dim);
}
.decision__row--why dt { color: var(--fg-1); }
.decision__row--why dd { color: var(--fg-0); }

/* ════════════════════════════════════════════════════════════
   CALLOUT
   ════════════════════════════════════════════════════════════ */
.callout {
  margin: 40px 0;
  padding: 24px 26px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--fg-3);
  max-width: 760px;
}
.callout__label {
  display: block;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 10px;
}
.callout__body {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--fg-1);
  text-wrap: pretty;
}
/* A named limitation is a credibility signal, so it gets the accent */
.callout--limitation { border-left-color: var(--hazard); }

/* ════════════════════════════════════════════════════════════
   PULL QUOTE
   ════════════════════════════════════════════════════════════ */
.quote {
  margin: 56px 0;
  padding: 36px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.quote__text {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(24px, 3.4vw, 42px);
  line-height: 1.12;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--fg-0);
  max-width: 20ch;
}
.quote__source {
  display: block;
  margin-top: 18px;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-2);
}

/* ════════════════════════════════════════════════════════════
   TECHNICAL SPEC
   ════════════════════════════════════════════════════════════ */
.spec {
  margin: 40px 0;
  border: 1px solid var(--line-soft);
  background: var(--bg-2);
  max-width: 620px;
}
.spec__row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line-faint);
  font-family: var(--mono);
  font-size: 12px;
}
.spec__row:last-child { border-bottom: 0; }
.spec__row dt { color: var(--fg-3); }
.spec__row dd { color: var(--fg-0); text-align: right; }

/* ════════════════════════════════════════════════════════════
   DATA TABLE
   ════════════════════════════════════════════════════════════ */
.case-table-wrap {
  margin: 40px 0;
  overflow-x: auto;               /* the page must never scroll sideways */
  border: 1px solid var(--line-soft);
}
.case-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}
.case-table th {
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  text-align: left;
  padding: 14px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.case-table td {
  padding: 14px 18px;
  font-size: 0.9375rem;
  color: var(--fg-1);
  border-bottom: 1px solid var(--line-faint);
}
.case-table tr:last-child td { border-bottom: 0; }

/* ════════════════════════════════════════════════════════════
   MARGINAL NOTE
   ════════════════════════════════════════════════════════════ */
.case-margin {
  font-family: var(--hand);
  font-size: 21px;
  line-height: 1.3;
  color: var(--fg-3);
  margin: 34px 0 0;
  transform: rotate(-0.6deg);
}

/* ════════════════════════════════════════════════════════════
   NEXT / PREV NAVIGATION
   ════════════════════════════════════════════════════════════ */
.case-nav {
  margin-top: 110px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.case-nav__link {
  padding: 40px var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 240ms ease, padding 240ms ease;
}
.case-nav__link + .case-nav__link {
  border-left: 1px solid var(--line-soft);
  text-align: right;
  align-items: flex-end;
}
.case-nav__link:hover { background: rgba(255,255,255,0.02); }
.case-nav__dir {
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-3);
}
.case-nav__name {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(18px, 2.2vw, 26px);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--fg-2);
  transition: color 240ms ease;
}
.case-nav__link:hover .case-nav__name { color: var(--fg-0); }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .gallery__grid { grid-template-columns: repeat(2, 1fr); }
  .case-hero { padding-top: 108px; }
}

@media (max-width: 768px) {
  .case-hero { padding-top: 92px; }
  .case-hero__summary { margin-top: 24px; padding-top: 20px; font-size: 1rem; }
  .case-meta { gap: 20px 24px; margin-top: 28px; padding-top: 22px; }

  .case-section { padding-top: 60px; }
  .case-section .section-head { padding-bottom: 24px; margin-bottom: 28px; }
  .case-section .section-head__title { gap: 12px; }
  .case-section .section-head__lede {
    padding: 34px 0 0 18px;
    font-size: 1.0625rem;
  }
  .case-section .section-head__lede::after { left: 14px; font-size: 3.1em; }

  .case-body p { font-size: 1rem; }

  /* Full width again down here. The gutter is already doing the containing,
     and 75% of a phone screen is not a hero, it is a thumbnail. */
  .figure--hero { max-width: 100%; }

  .figure, .figurepair, .gallery, .decision { margin: 32px 0; }
  .figurepair { grid-template-columns: 1fr; gap: 18px; }
  .gallery__grid { grid-template-columns: 1fr; }

  /* Stacked labels: a 108px label column leaves nothing for the text */
  .decision__head { padding: 20px 20px 16px; }
  .decision__rows { padding: 4px 20px 20px; }
  .decision__row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 0;
  }
  .decision__row--why {
    margin: 0 -20px;
    padding: 14px 20px;
  }

  .callout { padding: 20px; }
  .quote { margin: 40px 0; padding: 28px 0; }
  .quote__text { max-width: none; }

  .case-nav { grid-template-columns: 1fr; }
  .case-nav__link { padding: 28px var(--gutter); }
  .case-nav__link + .case-nav__link {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    text-align: left;
    align-items: flex-start;
  }
}

/* Narrow phone, the third rung of the BLUEPRINT §10 ladder.

   .spec gets its first real use on the engine page. Down here the label and
   the right-aligned value stop fitting on one line, and a wrapped value column
   ragged against its label reads as broken rather than tabular. Stack them,
   the same fix .decision__row takes one tier up. */
@media (max-width: 600px) {
  .spec__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  .spec__row dd { text-align: left; }
}
