/*
 * Counterweight case study. Built to sit beside the case studies in the
 * design portfolio: the same white ground, hairlines, square corners, Inter
 * and JetBrains Mono, one magenta accent for links, lowercase copy and an
 * italic light title. Tokens and type roles are copied from
 * design-portfolio/src/app/globals.css and components/case/case-shell.css.
 * The product's own look only appears inside framed captures.
 */
:root {
  --bg: #ffffff;
  --fg: #111111;
  --line: #dedede;
  --dim: #8a8a8a;
  --accent: #d400a0;
  --sunk: #f6f6f6;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0b0b0b; --fg: #ffffff; --line: #262626; --dim: #7a7a7a; --accent: #fc0fc0; --sunk: #141414; }
}
:root[data-theme="dark"] { --bg: #0b0b0b; --fg: #ffffff; --line: #262626; --dim: #7a7a7a; --accent: #fc0fc0; --sunk: #141414; }

* { box-sizing: border-box; border-radius: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, video, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
sup { font-size: .7em; line-height: 0; }
sup a { color: inherit; opacity: .62; }

/* type roles: 12 / 14 / 17 / 20 / 36 at 1440 */
.t-lead { font-size: clamp(1.5rem, 2.6vw, 2.25rem); line-height: 1.22; letter-spacing: -.02em; font-weight: 500; }
.t-head { font-size: clamp(1.125rem, 1.4vw, 1.25rem); line-height: 1.35; letter-spacing: -.011em; font-weight: 500; }
.t-body { font-size: 1.0625rem; line-height: 1.62; letter-spacing: -.003em; }
.t-note { font-size: .875rem; line-height: 1.6; letter-spacing: -.002em; }
.label { font-size: .75rem; line-height: 1.5; letter-spacing: .02em; font-weight: 400; }
.mono { font-family: var(--mono); }
.t-dim { opacity: .62; }
.measure { max-width: 46rem; }
.measure-narrow { max-width: 34rem; }
.t-body + .t-body { margin-top: 1em; }

/* frame */
.conf { position: sticky; top: 0; z-index: 20; padding: 7px 16px; text-align: center; font: 11px var(--mono); background: var(--bg); border-bottom: 1px solid var(--line); }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
@media (min-width: 768px) { .wrap { padding: 0 40px; } }
.band { padding: 64px 0; }
@media (min-width: 768px) { .band { padding: 112px 0; } }
.band + .band { border-top: 1px solid var(--line); }
h2.label { margin-bottom: 40px; }
.g12 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 40px; }
.g12 > *, .dec > *, .alts > *, .cells > * { min-width: 0; }
@media (min-width: 768px) {
  .g12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; } .c12 { grid-column: span 12; }
}

/* header */
.case-head { max-width: 760px; margin: 0 auto; padding: 96px 32px 0; text-align: left; }
.c-ctx { display: inline-block; font-size: 11px; line-height: 1.4; padding: 5px 8px; border: 1px solid var(--line); margin-bottom: 20px; }
.c-title { font-style: italic; font-weight: 300; font-size: clamp(32px, 4vw, 56px); line-height: 1.05; letter-spacing: -.01em; margin-bottom: 12px; }
.c-tags { font-size: 13px; line-height: 1.5; color: var(--dim); }
.c-kw { margin-top: 10px; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }

/* media */
.frame { border: 1px solid var(--line); overflow: hidden; background: var(--sunk); position: relative; }
figcaption.label { margin-top: 16px; max-width: 46rem; }
.hero { padding: 48px 0 0; }
@media (min-width: 768px) { .hero { padding: 80px 0 0; } }
.player { position: relative; aspect-ratio: 16 / 10; }
.player video { width: 100%; height: 100%; object-fit: cover; }
.play { position: absolute; inset: 0; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; }
.play span { display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; background: var(--fg); color: var(--bg); font: 13px var(--sans); }
.play svg { width: 14px; height: 14px; }
/* a capture of the prototype at 1440 × 900, shown whole or cropped to one region */
.shot, .crop { position: relative; overflow: hidden; background: var(--sunk); }
.shot img, .crop img { position: absolute; left: 0; top: 0; width: 1440px; max-width: none; height: 900px; transform-origin: 0 0; }

/* meta */
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); margin-top: 48px; }
@media (min-width: 1024px) { .meta { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.meta div { border-bottom: 1px solid var(--line); padding: 20px 24px 20px 0; }
.meta dt { margin-bottom: 4px; }
.meta dd { font-size: .875rem; line-height: 1.6; font-weight: 500; }

/* rows with a label rail */
.rows { border-top: 1px solid var(--line); }
.rows > div { border-bottom: 1px solid var(--line); padding: 28px 0; }

/* hairline grid of short items */
.cells { display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--line); }
@media (min-width: 640px) { .cells { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .cells.three { grid-template-columns: repeat(3, 1fr); } .cells.four { grid-template-columns: repeat(4, 1fr); } }
.cells > div { border-bottom: 1px solid var(--line); padding: 28px 32px 28px 0; }
@media (min-width: 640px) { .cells > div { padding-left: 32px; border-left: 1px solid var(--line); margin-left: -1px; } }
.cells .t-note + .t-note { margin-top: 8px; }
.cells b { display: block; font-weight: 500; margin-bottom: 8px; }
.cells .big { display: block; font-size: clamp(1.5rem, 2.6vw, 2.25rem); line-height: 1.1; letter-spacing: -.02em; font-weight: 500; margin-bottom: 12px; }

/* mono metric lists and tables */
.metrics { border-top: 1px solid var(--line); font: 12px/1.6 var(--mono); }
.metrics li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.metrics li > span:last-child { text-align: right; opacity: .62; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; line-height: 1.55; }
th { text-align: left; font-weight: 400; font-size: .75rem; letter-spacing: .02em; color: var(--dim); padding: 0 24px 12px 0; border-bottom: 1px solid var(--line); vertical-align: bottom; }
td { padding: 16px 24px 16px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td.mono { font-size: 12px; white-space: nowrap; }
td:first-child { font-weight: 500; }
.scroll-x { overflow-x: auto; }
.scroll-x table { min-width: 820px; }

/* step diagrams */
.diagram { border: 1px solid var(--line); padding: 32px 24px; overflow-x: auto; }
.diagram svg { min-width: 960px; width: 100%; height: auto; }
.diagram text { font-family: var(--sans); fill: var(--fg); font-size: 12px; }
.diagram .m { font-family: var(--mono); font-size: 10.5px; }
.diagram .dim { opacity: .62; }
.diagram .bx { fill: var(--bg); stroke: var(--line); }
.diagram .bx.k { stroke: var(--fg); }
.diagram .ln { stroke: var(--fg); fill: none; stroke-width: 1; }
.diagram .ln.d { stroke-dasharray: 3 4; opacity: .5; }
.diagram .ah { fill: var(--fg); }

/* chart alternatives */
.alts { display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--line); }
@media (min-width: 640px) { .alts { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .alts { grid-template-columns: repeat(5, 1fr); } }
.alts > div { border-bottom: 1px solid var(--line); padding: 28px 24px 28px 0; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 640px) { .alts > div { padding-left: 24px; border-left: 1px solid var(--line); margin-left: -1px; } }
.alts svg { width: 100%; height: auto; }
.alts .s { stroke: var(--fg); fill: none; stroke-width: 1; }
.alts .h { stroke: var(--line); fill: none; stroke-width: 1; }
.alts .f { fill: var(--fg); }
.alts .ff { fill: var(--fg); opacity: .12; }
.alts text { font-family: var(--mono); font-size: 8px; fill: var(--fg); }
.alts .ours { background: var(--sunk); }
.alts .verdict { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

/* anatomy */
.anat svg { width: 100%; height: auto; }
.anat .s { stroke: var(--fg); fill: none; stroke-width: 1; }
.anat .h { stroke: var(--line); fill: none; stroke-width: 1; }
.anat .f { fill: var(--fg); }
.anat .fog { fill: var(--fg); opacity: .07; }
.anat text { font-family: var(--sans); font-size: 11px; fill: var(--fg); }
.anat .m { font-family: var(--mono); font-size: 9.5px; opacity: .62; }
.anat .nb { fill: var(--accent); }
.anat .num { font-family: var(--mono); font-size: 9px; fill: #fff; }
.keyed li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.keyed li:first-child { border-top: 1px solid var(--line); }
.keyed .n { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font: 9px/18px var(--mono); text-align: center; margin-top: 2px; }
.keyed b { font-weight: 500; display: block; }

/* decisions */
.dec { display: flex; flex-direction: column; gap: 80px; }
@media (min-width: 768px) { .dec { gap: 120px; } }
.dec .frame { margin-bottom: 32px; }
.micro { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 640px) { .micro { grid-template-columns: repeat(3, 1fr); } }
.micro .label { margin-bottom: 8px; }

/* edge cases */
.edges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 24px; }
@media (min-width: 900px) { .edges { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.edges .wide { grid-column: 1 / -1; }
@media (min-width: 900px) { .edges .wide { grid-column: span 2; } }
.edges figcaption { margin-top: 12px; }
.edges figcaption b { display: block; font-weight: 500; margin-bottom: 2px; }

/* language */
.pairs > div { display: grid; grid-template-columns: 1fr; gap: 8px 40px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.pairs > div:first-child { border-top: 1px solid var(--line); }
@media (min-width: 768px) { .pairs > div { grid-template-columns: 1fr 1fr; } }
.pairs s { text-decoration-color: currentColor; opacity: .62; }

/* try it */
.live { position: relative; width: 100%; aspect-ratio: 16 / 10; }
.live iframe { position: absolute; left: 0; top: 0; width: 1440px; height: 900px; border: 0; transform-origin: 0 0; }
.cover { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.cover span { padding: 12px 18px; background: var(--fg); color: var(--bg); font: 13px var(--sans); }
.steps { counter-reset: s; display: grid; gap: 8px; margin-top: 20px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; }
.steps li::before { content: "0" counter(s); font: 12px/1.6 var(--mono); opacity: .62; }

/* sources */
.refs { font-size: .8125rem; line-height: 1.6; counter-reset: r; }
.refs li { counter-increment: r; display: grid; grid-template-columns: 32px 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); }
.refs li::before { content: counter(r); font: 12px/1.6 var(--mono); opacity: .62; }
.refs li:first-child { border-top: 1px solid var(--line); }

/* end bar */
.case-end { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.case-end a, .case-end span { padding: 20px; text-align: center; font-size: 13px; font-style: italic; font-weight: 300; color: var(--fg); }
.case-end > * + * { border-left: 1px solid var(--line); }

/* reveal, once, as the portfolio does */
.rv { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.rv.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .rv { opacity: 1; transform: none; transition: none; } }

/* Needs: what architects need, and what the tool does about it. */
.needs .t-head { margin-bottom: 4px; }
.needs .so { margin-top: 12px; }
.needs .so .label { margin-right: 8px; }

/* Appendix: reference material, folded away. */
.appendix details { border-top: 1px solid var(--line); }
.appendix details:last-child { border-bottom: 1px solid var(--line); }
.appendix summary { cursor: pointer; list-style: none; padding: 20px 0; display: flex; justify-content: space-between; gap: 24px; }
.appendix summary::-webkit-details-marker { display: none; }
.appendix summary::after { content: "+"; color: var(--dim); font-weight: 400; }
.appendix details[open] summary::after { content: "−"; }
.appendix details > :last-child { margin-bottom: 40px; }

/* Small diagrams beside each claim. */
.mini { display: block; width: 100%; max-width: 240px; height: auto; margin: 16px 0 20px; overflow: visible; }
.does .mini { margin-top: 0; }
.mini .k { stroke: var(--fg); fill: none; stroke-width: 1; }
.mini .h { stroke: var(--line); fill: none; stroke-width: 1; }
.mini .d { stroke: var(--dim); fill: none; stroke-width: 1; stroke-dasharray: 3 3; }
.mini .s { fill: var(--sunk); stroke: var(--fg); stroke-width: 1; }
.mini .f { fill: var(--fg); }
.mini .fog { fill: var(--sunk); stroke: var(--line); stroke-dasharray: 2 3; }
.mini .a { stroke: var(--accent); fill: none; stroke-width: 1.5; }
.mini .af { fill: var(--accent); }
.mini text { font: 10px var(--mono); fill: var(--fg); }
.mini .t { fill: var(--dim); }

/* The film's play button. */
.play { flex-direction: column; gap: 14px; background: rgba(0, 0, 0, .06); transition: background .3s var(--ease); }
.play[hidden] { display: none; }
.play:hover { background: rgba(0, 0, 0, .12); }
.play { display: flex; align-items: center; justify-content: center; }
.play .disc { display: grid; place-items: center; width: 88px; height: 88px; padding: 0; border-radius: 50%; background: var(--fg); color: var(--bg); transition: transform .3s var(--ease); }
.play:hover .disc { transform: scale(1.06); }
.play .disc svg { width: 30px; height: 30px; margin-left: 4px; }
.play .cap { padding: 6px 10px; background: var(--bg); color: var(--fg); font: 12px var(--mono); }

/* Try it: tasks that drive the prototype. */
.tasks { display: grid; grid-template-columns: 1fr; margin: 40px 0 24px; border-bottom: 1px solid var(--line); }
@media (min-width: 900px) { .tasks { grid-template-columns: repeat(5, 1fr); gap: 0 24px; } }
.tasks button { display: grid; gap: 6px; padding: 16px 0; text-align: left; background: none; border: 0; border-top: 2px solid var(--line); color: var(--dim); font: 500 14px/1.4 var(--sans); cursor: pointer; transition: color .2s, border-color .2s; }
.tasks button .n { font: 11px var(--mono); }
.tasks button:hover { color: var(--fg); }
.tasks button[aria-selected="true"] { color: var(--fg); border-top-color: var(--accent); }
.hint { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; margin-top: 20px; }
.hint a { white-space: nowrap; }
