/* =====================================================================
   waranyah · case-study pages
   Structure follows a long-form case layout: hero media, title, role,
   impact, numbers, then the story in a narrow reading column with
   media breaking out to wide and full widths.
   Needs site.css first (tokens + primitives).
   ===================================================================== */

/* White page; figures, tables and note cards use the soft grey surface */
body.case-page { --page: var(--ref-white); --card: var(--surface); background: var(--page); }
body.case-page .pill.light { background: var(--ref-white); }

/* ---------- Sticky case bar ---------- */
.cs-bar { position: sticky; top: 0; z-index: 10; padding: 12px 0; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cs-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cs-bar .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cs-bar .crumb { font-size: 14px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; background: var(--card-soft); padding: 4px; border-radius: 999px; gap: 2px; }
.seg button { border: 0; background: transparent; font: 500 14px var(--font); color: var(--text-soft); padding: 8px 16px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ref-white); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Widths ---------- */
.cs-col { max-width: 700px; margin: 0 auto; padding: 0 24px; }
.cs-wide { max-width: 1000px; margin: 0 auto; padding: 0 24px; }
.cs-full { max-width: 1360px; margin: 0 auto; padding: 0 24px; }

/* ---------- Hero ---------- */
.cs-hero { max-width: 1000px; margin: 8px auto 0; padding: 0 24px; }
.cs-hero .stage { border-radius: var(--r-card); padding: clamp(24px, 5vw, 56px); display: grid; place-items: center; min-height: 380px; overflow: hidden; position: relative; }
.stage.lime { background: var(--card-accent); }
.stage.sage { background: var(--card-sage); }
.stage.dark { background: var(--card-dark); }
.stage.soft { background: var(--card-soft); }
.stage .browser, .stage .laptop { width: min(760px, 100%); }
.stage .phone { width: 230px; }

/* ---------- Title block ---------- */
.cs-head { padding-top: 56px; }
.cs-head .chips { margin-bottom: 18px; }
.cs-title { font-weight: 400; font-size: clamp(34px, 4.2vw, 50px); line-height: 1.05; letter-spacing: -.03em; }
.cs-sub { font-size: 20px; line-height: 1.5; color: var(--text-soft); margin-top: 18px; }
.cs-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 36px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cs-meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.cs-meta dd { font-size: 15px; line-height: 1.4; margin-top: 4px; }

/* ---------- Impact + stats ---------- */
.cs-h { font-weight: 500; font-size: clamp(24px, 2.4vw, 30px); letter-spacing: -.02em; line-height: 1.15; margin: 64px 0 16px; }
.cs-h3 { font-weight: 500; font-size: 19px; letter-spacing: -.01em; margin: 32px 0 8px; }
.cs-impact { list-style: none; display: grid; gap: 22px; }
.cs-impact li { display: grid; grid-template-columns: 44px 1fr; gap: 16px; }
.cs-impact .ic { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.cs-impact .ic svg { width: 20px; height: 20px; }
.cs-impact b { display: block; font-weight: 500; font-size: 18px; margin-bottom: 4px; }
.cs-impact p { color: var(--text-soft); }
.cs-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 48px; }
.cs-stats > div { padding: 0 20px; border-left: 1px solid var(--ref-mist-300); }
.cs-stats > div:first-child { padding-left: 0; border-left: 0; }
.cs-stats b { display: block; font-weight: 300; font-size: clamp(40px, 4.4vw, 56px); line-height: 1; letter-spacing: -.03em; }
.cs-stats span { display: block; margin-top: 10px; font-size: 14px; color: var(--text-soft); line-height: 1.4; }

/* ---------- Story text ---------- */
.cs-body p, .cs-body li { font-size: 17px; line-height: 1.7; }
.cs-body p + p { margin-top: 16px; }
.cs-body ul, .cs-body ol { padding-left: 1.2em; margin-top: 12px; }
.cs-body li + li { margin-top: 6px; }
.cs-body strong { font-weight: 600; }
.cs-quote { margin: 40px 0; padding-left: 22px; border-left: 3px solid var(--accent); font-size: 24px; line-height: 1.3; letter-spacing: -.015em; }
.cs-quote cite { display: block; font-style: normal; font-size: 14px; color: var(--text-muted); margin-top: 10px; letter-spacing: 0; }

/* ---------- Figures ---------- */
.cs-fig { margin: 40px auto; }
.cs-fig > .frame { background: var(--card); border-radius: 24px; padding: 18px; overflow: hidden; }
.cs-fig > .frame.dark { background: var(--card-dark); color: var(--text-on-dark); }
.cs-fig > .frame.lime { background: var(--card-accent); }
.cs-fig > .frame.soft { background: var(--card-soft); }
.cs-fig figcaption { text-align: center; font-size: 14px; color: var(--text-muted); margin-top: 12px; display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.tag-i { background: var(--ref-ink-900); color: var(--accent); font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; }

/* Placeholder for a screen, board or photo the owner still has to add */
.ph-media {
  position: relative; border-radius: 14px; overflow: hidden; display: grid; place-items: center; text-align: center;
  background: repeating-linear-gradient(135deg, var(--card-soft) 0 14px, var(--card) 14px 28px);
  color: var(--text-muted); font-size: 13px; padding: 20px; aspect-ratio: var(--ar, 16 / 9);
}
.ph-media b { display: block; font-weight: 500; font-size: 15px; color: var(--text-soft); margin-bottom: 4px; }
.frame.dark .ph-media { background: repeating-linear-gradient(135deg, var(--ref-ink-800) 0 14px, #262b25 14px 28px); color: var(--text-on-dark-soft); }
.frame.dark .ph-media b { color: var(--text-on-dark); }

/* Zoomable board viewer (Miro boards, journeys, blueprints) */
.zoom { position: relative; }
.zoom-view { height: min(520px, 70vh); overflow: auto; border-radius: 14px; background: repeating-linear-gradient(0deg, transparent 0 23px, #e3e6df 23px 24px), repeating-linear-gradient(90deg, transparent 0 23px, #e3e6df 23px 24px), #f3f4f0; }
.zoom-canvas { width: calc(100% * var(--z, 1)); min-height: calc(100% * var(--z, 1)); padding: 24px; transition: width .2s ease; }
.zoom-canvas .ph-media { --ar: 16 / 10; }
.zoom-ctrl { position: absolute; right: 14px; bottom: 14px; display: grid; gap: 8px; }
.zoom-ctrl button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font: 500 18px var(--font); cursor: pointer; }

/* Before / after iterations */
.iters { display: grid; gap: 16px; }
.iter { background: var(--card); border-radius: 24px; padding: 22px; }
.iter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.iter-head b { font-weight: 500; font-size: 18px; }
.iter-head .chip { background: var(--accent); color: var(--text); }
.iter > p { color: var(--text-soft); font-size: 15px; margin-bottom: 14px; }
.ba { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; }
.ba > div { border-radius: 16px; padding: 14px 16px; font-size: 15px; line-height: 1.5; }
.ba .b { border: 1.5px dashed var(--ref-ink-400); }
.ba .a { background: var(--accent-soft); }
.ba small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 4px; }
.ba .arr { display: grid; place-items: center; color: var(--text-muted); }

/* Flow chips: A → B → C */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flow span { background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 14px; }
.flow span.k { background: var(--ref-ink-900); color: #fff; }
.flow i { font-style: normal; color: var(--text-muted); }

/* Small card grids */
.cs-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 20px; }
.cs-cards.three { grid-template-columns: repeat(3, 1fr); }
.cs-cards.four { grid-template-columns: repeat(4, 1fr); }
.cs-cards > div { background: var(--card); border-radius: 20px; padding: 18px; }
.cs-cards > div.dark { background: var(--card-dark); color: var(--text-on-dark); }
.cs-cards > div.lime { background: var(--card-accent); }
.cs-cards small { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px; }
.cs-cards > div.dark small { color: var(--accent); }
.cs-cards b { display: block; font-weight: 500; font-size: 17px; line-height: 1.3; margin-bottom: 6px; }
.cs-cards p { font-size: 15px !important; line-height: 1.55 !important; color: var(--text-soft); }
.cs-cards > div.dark p { color: var(--text-on-dark-soft); }

/* Tables (tokens, test setup) */
.cs-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: 18px; overflow: hidden; font-size: 14px; }
.cs-table th, .cs-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cs-table th { font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--card-soft); }
.cs-table tr:last-child td { border-bottom: 0; }
.cs-table code, .cs-body code { font: 13px ui-monospace, Menlo, monospace; background: var(--card-soft); padding: 2px 6px; border-radius: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; border: 1px solid rgba(0,0,0,.08); }
.table-scroll { overflow-x: auto; border-radius: 18px; }

/* Reframe (assumption -> reality) */
.flip { display: grid; gap: 10px; }
.flip > div { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; }
.flip .as, .flip .re { border-radius: 16px; padding: 14px 16px; font-size: 15px; }
.flip .as { border: 1.5px dashed var(--ref-ink-400); color: var(--text-soft); }
.flip .re { background: var(--accent); }
.flip small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 4px; }
.flip .arr { display: grid; place-items: center; color: var(--text-muted); }

/* Callout */
.cs-note { display: flex; gap: 14px; align-items: flex-start; background: var(--card-dark); color: var(--text-on-dark); border-radius: 22px; padding: 20px; margin: 40px 0; }
.cs-note .circle { width: 40px; height: 40px; }
.cs-note p { font-size: 16px !important; color: var(--text-on-dark-soft); }
.cs-note b { color: var(--text-on-dark); }

/* Annotated screen: notes around a centred device */
.annot { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center; }
.annot .notes { display: grid; gap: 14px; }
.annot .note { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.annot .note b { display: block; font-weight: 500; font-size: 15px; margin-bottom: 2px; }
.annot .note p { font-size: 13px !important; line-height: 1.45 !important; color: var(--text-soft); }

/* Options side by side */
.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.options figure { margin: 0; text-align: center; }
.options figcaption { margin-top: 10px; font-size: 14px; color: var(--text-muted); }

/* Next case */
.cs-next { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; text-decoration: none; background: var(--card-dark); color: var(--text-on-dark); border-radius: var(--r-card); padding: 28px 30px; margin: 80px 0 24px; }
.cs-next small { display: block; color: var(--text-on-dark-soft); font-size: 13px; margin-bottom: 6px; }
.cs-next b { font-weight: 400; font-size: clamp(22px, 2.6vw, 32px); letter-spacing: -.02em; line-height: 1.15; }

/* TL;DR mode */
.tldr-more { display: none; text-align: center; margin: 48px 0 0; }
body.tldr .detail { display: none; }
body.tldr .tldr-more { display: block; }

@media (max-width: 760px) {
  .cs-meta { grid-template-columns: 1fr 1fr; }
  .cs-stats { grid-template-columns: 1fr; gap: 22px; }
  .cs-stats > div { padding: 0 0 0 16px; border-left: 2px solid var(--accent); }
  .cs-stats > div:first-child { padding-left: 16px; border-left: 2px solid var(--accent); }
  .cs-cards, .cs-cards.three { grid-template-columns: 1fr; }
  .cs-cards.four { grid-template-columns: 1fr 1fr; }
  .ba, .flip > div { grid-template-columns: 1fr; }
  .ba .arr, .flip .arr { transform: rotate(90deg); }
  .annot { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; max-width: 260px; margin: 0 auto; }
  .cs-bar .crumb { display: none; }
  .cs-hero .stage { min-height: 260px; }
  .cs-next { grid-template-columns: 1fr; }
}

/* Before / after image pair */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.pair figure { margin: 0; }
.pair img { width: 100%; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
.pair .lbl { display: inline-block; font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; background: var(--card-soft); color: var(--text-soft); }
.pair .lbl.after { background: var(--accent); color: var(--text); }
.pair figcaption { font-size: 13px; color: var(--text-muted); margin-top: 8px; text-align: left; }

/* Status chips (prototype language) */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--card); white-space: nowrap; }
.st i { width: 8px; height: 8px; border-radius: 50%; }
.st.need i { background: #e0a100; } .st.wait i { background: #2f6fde; } .st.done i { background: #1f8a4c; } .st.none i { background: #9aa09a; }
.status-grid { display: grid; grid-template-columns: 1fr auto 1.4fr; gap: 14px; align-items: center; }
.status-grid .old { display: flex; flex-wrap: wrap; gap: 6px; }
.status-grid .old span { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: #fde4e4; color: #a33; }
.status-grid .old span.g { background: #e3f4e8; color: #1f6b3a; } .status-grid .old span.x { background: #ececec; color: #666; } .status-grid .old span.b { background: #e4ecfb; color: #2f55a8; }
.status-grid .new { display: grid; gap: 8px; }
.status-grid .new div { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.embed-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 30px 0; }

@media (max-width: 760px) {
  .pair, .status-grid { grid-template-columns: 1fr; }
  .status-grid .arr { transform: rotate(90deg); justify-self: center; }
}

/* Expand / full view for screens, images and live embeds */
.xp-wrap { position: relative; display: block; }
.xp-btn {
  position: absolute; top: 10px; right: 10px; z-index: 4;
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: zoom-in;
  display: grid; place-items: center; color: #fff;
  background: rgba(15, 16, 14, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: .85; transition: opacity .2s, transform .2s;
}
.xp-btn:hover, .xp-btn:focus-visible { opacity: 1; transform: scale(1.06); }
.xp-btn svg { width: 18px; height: 18px; }
.zoom > .xp-btn { top: 14px; right: 14px; }
dialog.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(15, 16, 14, .94); color: #fff; }
dialog.lightbox::backdrop { background: transparent; }
.lb-scroll { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; padding: 56px 24px 64px; }
.lb-scroll img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; border-radius: 10px; background: #fff; cursor: zoom-in; }
.lb-scroll.actual { place-items: start center; }
.lb-scroll.actual img { max-width: none; max-height: none; cursor: zoom-out; }
.lb-close { position: fixed; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: #111; font: 500 22px var(--font); cursor: pointer; z-index: 2; }
.lb-cap { position: fixed; left: 0; right: 0; bottom: 16px; text-align: center; font-size: 14px; color: #c9cec6; padding: 0 70px; }

/* multi-device: one screen on TV + two tablet orientations */
.md-devices { display: grid; grid-template-columns: 1194fr 834fr; gap: 18px; align-items: start; }
.md-devices .md-tv { grid-column: 1 / -1; }
.md-devices img { border-radius: 12px; outline: 1px solid #2e2e2e; }
.md-devices p { margin: 10px 0 0; font-size: 14px; color: var(--text-on-dark-soft); }
@media (max-width: 600px) { .md-devices { grid-template-columns: 1fr; } }
/* expand button sits bottom-right on device mockups so it doesn't cover the app's close button */
.md-devices .xp-wrap .xp-btn { top: auto; bottom: -46px; right: 0; }
.md-devices p { min-height: 38px; padding-right: 48px; display: flex; align-items: center; }
/* live TV demo: same move, so the full-screen button stays off the demo's close button */
.md-embed .xp-wrap { margin-bottom: 46px; }
.md-embed .xp-wrap .xp-btn { top: auto; bottom: -46px; right: 0; }
/* multi-device v2 screens: two-up grids and tablet landscape + portrait at equal height */
.md-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.md-grid.tab { grid-template-columns: 1431fr 698fr; align-items: end; }
.md-grid.one { grid-template-columns: 1fr; }
.md-grid img { display: block; width: 100%; height: auto; border-radius: 12px; outline: 1px solid #2e2e2e; }
.md-grid p { margin: 10px 0 0; font-size: 14px; color: var(--text-on-dark-soft); min-height: 38px; padding-right: 48px; display: flex; align-items: center; }
.md-grid .xp-wrap .xp-btn { top: auto; bottom: -46px; right: 0; }
@media (max-width: 600px) { .md-grid, .md-grid.tab { grid-template-columns: 1fr; } }
