/* hendzel.is — case-study pages (/building/<project>)
   One template, shared by every case. Blocks, top to bottom:
   .case-hero · .case-facts · .case-kpis · .case-section (prose) · .case-compare (before/after slider)
   · .case-steps (horizontal milestones) · .case-chart · .case-phone · .case-flow · .case-fig · .case-next
   Images inside .case-fig / .case-compare open full size via js/case.js.
   Headings never end with a full stop.
*/

.case { padding-top: 96px; padding-bottom: 96px; }

/* --- Hero --- */
.case-hero h1 {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.case-hero .lede {
  margin-top: 24px;
  font-size: 22px;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
  max-width: 40em;
}

.case-tag { margin-left: 8px; padding: 4px 10px; line-height: 1; border: 1px solid var(--rule); border-radius: 99px; font-size: 11px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }

/* --- Facts strip --- */
.case-facts {
  margin: 48px 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.case-facts > div { padding: 16px 16px 16px 0; }
.case-facts > div + div { padding-left: 16px; border-left: 1px solid var(--rule); }
.case-facts dt { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.case-facts dd { margin: 4px 0 0; font-size: 16px; line-height: 1.45; }
.case-facts .live::before { content: "● "; color: var(--accent); font-size: 11px; vertical-align: 2px; }

/* --- KPI numbers: tiles with a soft light that follows the cursor (js/case.js sets --mx/--my) --- */
.case-kpis {
  margin-top: 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.case-kpis > div {
  --mx: 50%; --my: 50%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 20px 20px 24px;
  border-radius: 10px;
  background: #F1EFE8;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow .3s ease;
}
.case-kpis > div[hidden] { display: none; }
.case-kpis > div::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(180px circle at var(--mx) var(--my), rgba(255,255,255,.85), rgba(255,255,255,0) 70%);
  opacity: 0;
  transition: opacity .3s ease;
}
.case-kpis > div:hover { box-shadow: inset 0 0 0 1px #E2DED3; }
.case-kpis > div:hover::before { opacity: 1; }
.case-kpis .n {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums lining-nums;
}
.case-kpis .l { margin-top: 10px; font-size: 15px; line-height: 1.4; color: var(--muted); text-wrap: pretty; }
.case-kpis .is-accent .n { color: var(--accent); }
.case-source, .case-section .case-source { margin-top: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); line-height: 1.6; max-width: none; }

/* --- Prose sections --- */
.case-section { margin-top: 96px; }
.case-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.case-label b { font-weight: 400; color: var(--accent); }
.case-label::after { content: ""; flex: 1; border-top: 1px solid var(--rule); transform: translateY(-4px); }
.case-section h2 {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin-bottom: 24px;
}
.case-section p { font-size: 18px; line-height: 1.65; max-width: 44em; text-wrap: pretty; }
.case-section p + p { margin-top: 18px; }
.case-section .gap { margin-top: 56px; }
.case-section ul.plain { list-style: none; margin: 18px 0 0; padding: 0; max-width: 44em; }
.case-section ul.plain li { display: grid; grid-template-columns: 1.2em 1fr; font-size: 18px; line-height: 1.65; }
.case-section ul.plain li::before { content: "–"; color: var(--muted); }

/* --- Figures: always the full text width --- */
.case-fig { margin: 40px 0 0; }
.case-fig img, .case-fig video { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; background: #0E0E10; }
.case-fig figcaption, .case-compare + .cap { margin-top: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); line-height: 1.5; }
.case-fig img[data-zoom], .case-compare img { cursor: zoom-in; }
.case-fig img[data-zoom] { transition: transform .5s cubic-bezier(.2,.7,.2,1), box-shadow .5s ease; }
.case-fig img[data-zoom]:hover { transform: scale(1.012); box-shadow: 0 18px 48px rgba(14,14,14,.14); }

/* --- Screenshot pairs (desktop + phone) --- */
.case-shots { margin: 40px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.case-shots-device { grid-template-columns: 3fr 1fr; align-items: start; }
.case-shots figure { margin: 0; }
.case-shots img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; cursor: zoom-in; }
.case-shots figcaption { margin-top: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); line-height: 1.5; }

/* --- Before / after slider --- */
.case-compare {
  --pos: 50%;
  position: relative;
  margin-top: 40px;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: #0E0E10;
  user-select: none;
  touch-action: pan-y;
}
.case-compare > img, .case-compare > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.case-compare .before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); z-index: 1; }
.case-compare .handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos); z-index: 2; width: 0;
  border-left: 2px solid #fff; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.case-compare .handle::after {
  content: "‹ ›"; position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%; background: #fff; color: var(--ink);
  display: grid; place-items: center; font-family: var(--mono); font-size: 14px; letter-spacing: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.case-compare .tag {
  position: absolute; top: 14px; z-index: 3; pointer-events: none;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: #fff;
  background: rgba(14,14,16,.72); border: 1px solid rgba(255,255,255,.18); border-radius: 99px; padding: 6px 12px; line-height: 1;
}
.case-compare .tag.l { left: 14px; }
.case-compare .tag.r { right: 14px; }
.case-compare input[type="range"] {
  position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none;
}
.case-compare input[type="range"]:focus-visible ~ .handle::after { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Milestones, horizontal --- */
.case-steps {
  list-style: none; margin: 32px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0 20px;
  position: relative;
}
.case-steps::before { content: ""; position: absolute; left: 0; right: 0; top: 5px; border-top: 1px solid var(--rule); }
.case-steps li { position: relative; padding-top: 26px; }
.case-steps li::before {
  content: ""; position: absolute; top: 0; left: 0; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--ink);
}
.case-steps li.now::before { background: var(--accent); border-color: var(--accent); }
.case-steps .when { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.case-steps .what { display: block; margin-top: 4px; font-size: 18px; font-weight: 500; line-height: 1.3; }
.case-steps .why { display: block; margin-top: 6px; font-size: 15px; line-height: 1.45; color: var(--muted); }
.case-more { margin-top: 28px; }
.case-more summary {
  cursor: pointer; list-style: none; font-family: var(--mono); font-size: 13px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 4px; width: max-content;
}
.case-more summary::-webkit-details-marker { display: none; }
.case-more summary:hover { color: var(--ink); }
.case-more[open] summary { margin-bottom: 8px; }
.case-log { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.case-log li { display: grid; grid-template-columns: 112px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 16px; line-height: 1.5; }
.case-log .when { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 3px; }
.case-log b { font-weight: 500; }
.case-log span:last-child { color: var(--muted); }
.case-log b + span { display: block; }

/* --- Charts (drawn by js/case.js; table is the no-JS fallback) --- */
.case-chart { position: relative; margin: 32px 0 0; }
.case-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.case-chart .grid { stroke: var(--rule); stroke-width: 1; }
.case-chart .axis { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.case-chart .bar { fill: var(--ink); pointer-events: none; }
.case-chart .bar.is-hl { fill: var(--accent); }
.case-chart .col-hit { fill: transparent; }
.case-chart .col-hit:hover + .bar, .case-chart .col-hit:focus + .bar { fill: var(--accent); }
.case-chart .col-hit:focus { outline: none; }
.case-chart .mark { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.case-chart .mark-label { font-family: var(--mono); font-size: 11px; fill: var(--ink); }
.case-chart figcaption { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.case-chart.is-drawn .fallback { display: none; }
.case-chart .fallback { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
.case-chart .fallback td { padding: 4px 0; border-bottom: 1px solid var(--rule); }
.case-chart .fallback td + td { text-align: right; }
.case-tip { position: absolute; top: 0; pointer-events: none; background: var(--bg); border: 1px solid var(--rule); border-radius: 6px;
  padding: 8px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.6; min-width: 140px;
  box-shadow: 0 6px 24px rgba(14,14,14,.08); opacity: 0; transition: opacity .08s ease; z-index: 2; }
.case-tip.on { opacity: 1; }
.case-tip .d { color: var(--muted); }
.case-tip .r { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }

/* --- Phone with a screen recording --- */
.case-phone-row { margin-top: 56px; display: grid; grid-template-columns: 300px 1fr; gap: 56px; align-items: center; }
.case-phone {
  position: relative; margin: 0; width: 100%; aspect-ratio: 600 / 1304;
  border-radius: 46px; padding: 10px; background: #0E0E10;
  box-shadow: 0 0 0 1px #2A2A2E inset, 0 30px 60px rgba(14,14,14,.18), 0 8px 18px rgba(14,14,14,.10);
}
.case-phone video { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 36px; background: #0B0B0E; }
.case-feats { list-style: none; margin: 24px 0 0; padding: 0; counter-reset: s; border-top: 1px solid var(--rule); }
.case-feats li { counter-increment: s; border-bottom: 1px solid var(--rule); }
.case-feats button {
  position: relative; display: grid; grid-template-columns: 32px 1fr; width: 100%; padding: 13px 12px 13px 0;
  background: none; border: 0; text-align: left; cursor: pointer; color: var(--muted);
  font-family: var(--serif); font-size: 17px; line-height: 1.5; transition: color .15s ease;
}
.case-feats button::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: 12px; padding-top: 4px; color: var(--muted); }
.case-feats button::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
  background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left; opacity: 0;
}
.case-feats button:hover, .case-feats button:focus-visible, .case-feats button[aria-pressed="true"] { color: var(--ink); }
.case-feats button[aria-pressed="true"]::before { color: var(--accent); }
.case-feats button[aria-pressed="true"]::after { opacity: 1; }
.case-feats button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.case-phone video { transition: opacity .2s ease; }
.case-phone video.is-swapping { opacity: .2; }

/* --- Photos from users + press mention --- */
.case-photos { margin-top: 32px; display: grid; grid-template-columns: 1.33fr 0.75fr 1.33fr; gap: 12px; }
.case-photos img { display: block; width: 100%; height: 340px; object-fit: cover; border-radius: 8px; border: 1px solid var(--rule); cursor: zoom-in; transition: transform .5s cubic-bezier(.2,.7,.2,1), box-shadow .5s ease; }
.case-photos img:hover { transform: scale(1.015); box-shadow: 0 18px 48px rgba(14,14,14,.14); }
.case-press {
  margin-top: 32px; display: grid; grid-template-columns: 148px 1fr; gap: 24px; align-items: center;
  padding: 16px; border: 1px solid var(--rule); border-radius: 10px; text-decoration: none; color: inherit;
  transition: background .2s ease, border-color .2s ease;
}
.case-press:hover { background: #F1EFE8; border-color: #DCD8CC; }
.case-press img { width: 148px; height: 112px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--rule); }
.case-press .src { display: block; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--muted); }
.case-press q { display: block; margin-top: 6px; font-size: 21px; line-height: 1.35; font-weight: 500; quotes: "„" "”"; }
.case-press .en { display: block; margin-top: 4px; font-size: 15px; color: var(--muted); }
.case-press .go { display: block; margin-top: 10px; font-family: var(--mono); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }

/* --- Links --- */
.case-links { margin-top: 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.case-links h3 em { font-style: normal; text-transform: none; letter-spacing: 0; }
.case-links h3 { font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.case-links a {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule);
  text-decoration: none; font-size: 17px; transition: color .15s ease, padding .2s ease;
}
.case-links a span { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 4px; text-align: right; }
.case-links a::after { content: "↗"; font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 4px; }
.case-links a span { margin-left: auto; }
.case-links a:hover { color: var(--accent); padding-left: 4px; }

/* --- Two phones side by side (then / now) --- */
.case-phones { margin: 40px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); justify-content: center; gap: 24px 56px; }
.case-phones figure { margin: 0; }
.case-phones .case-phone { aspect-ratio: 540 / 960; }
.case-phones figcaption { margin-top: 14px; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--muted); line-height: 1.5; }
.case-phones figcaption b { display: block; font-weight: 400; color: var(--ink); }

/* --- Flow / pipeline (e.g. the social machine) --- */
.case-flow {
  list-style: none; margin: 40px 0 0; padding: 0; counter-reset: f;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 0 16px; position: relative;
}
.case-flow::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; border-top: 1px solid var(--rule); }
.case-flow li { counter-increment: f; position: relative; }
.case-flow li::before {
  content: counter(f); position: relative; display: grid; place-items: center;
  width: 27px; height: 27px; border-radius: 50%; background: var(--bg); border: 1px solid var(--ink);
  font-family: var(--mono); font-size: 12px;
}
.case-flow b { display: block; margin-top: 14px; font-weight: 500; font-size: 16px; line-height: 1.3; }
.case-flow span { display: block; margin-top: 6px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.case-flow .is-human::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.case-flow .is-human b { color: var(--accent); }

/* --- Zoom overlay (js/case.js) --- */
.case-zoom {
  position: fixed; inset: 0; z-index: 50; cursor: zoom-out;
  background: rgba(250,250,247,0); transition: background .35s ease;
}
.case-zoom.on { background: rgba(250,250,247,.94); }
.case-zoom img {
  position: fixed; margin: 0; border-radius: 8px; box-shadow: 0 30px 80px rgba(14,14,14,.25);
  transition: transform .45s cubic-bezier(.2,.7,.2,1);
  transform-origin: 0 0; will-change: transform;
}

/* --- Next / back --- */
.case-next { margin-top: 96px; padding-top: 24px; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 24px; font-family: var(--mono); font-size: 13px; }
.case-next a { color: var(--ink); text-underline-offset: 4px; }

@media (max-width: 860px) {
  .case-facts { grid-template-columns: 1fr 1fr; }
  .case-kpis { grid-template-columns: 1fr 1fr; }
  .case-facts > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .case-facts > div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .case-flow { grid-template-columns: repeat(3, 1fr); gap: 32px 16px; }
  .case-flow::before { display: none; }
}
@media (max-width: 720px) {
  .case { padding-top: 40px; padding-bottom: 48px; }
  .case-hero h1 { font-size: 36px; }
  .case-hero .lede { font-size: 19px; }
  .case-kpis .n { font-size: 30px; }
  .case-section { margin-top: 64px; }
  .case-section h2 { font-size: 24px; }
  .case-section p, .case-section ul.plain li { font-size: 17px; }
  .case-label { font-size: 13px; }
  .case-compare { aspect-ratio: 4 / 3; }
  .case-steps { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 20px; padding-bottom: 8px; margin-right: -20px; padding-right: 20px; }
  .case-steps::before { right: auto; width: calc(5 * 220px); }
  .case-steps li { flex: 0 0 200px; scroll-snap-align: start; }
  .case-log li { grid-template-columns: 1fr; gap: 2px; }
  .case-phone-row { display: flex; flex-direction: column; gap: 20px; }
  .case-phone-row > div { display: contents; }
  .case-phone-row > div > p { order: 1; }
  .case-phone { order: 2; max-width: 240px; margin: 0 auto; }
  .case-feats {
    order: 3; display: flex; gap: 8px; margin: 0 -20px; padding: 0 20px 4px; border: 0;
    width: calc(100% + 40px); max-width: calc(100vw); align-self: center; box-sizing: border-box;
    overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  }
  .case-feats::-webkit-scrollbar { display: none; }
  .case-feats li { border: 0; flex: 0 0 auto; scroll-snap-align: start; }
  .case-feats button {
    display: block; width: auto; max-width: 220px; padding: 8px 14px; border: 1px solid var(--rule); border-radius: 99px;
    font-size: 15px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .case-feats button::before { content: none; }
  .case-feats button::after { left: 14px; right: 14px; width: auto; bottom: 4px; height: 1.5px; }
  .case-feats button[aria-pressed="true"] { border-color: var(--ink); }
  .case-shots, .case-shots-device { grid-template-columns: 1fr; }
  .case-shots-device figure:last-child img { max-width: 240px; }
  .case-phones { grid-template-columns: 1fr 1fr; gap: 16px; }
  .case-phones .case-phone { border-radius: 28px; padding: 6px; }
  .case-phones .case-phone video { border-radius: 22px; }
  .case-photos { grid-template-columns: 1fr 1fr; }
  .case-photos img { height: 220px; }
  .case-photos img:first-child { grid-column: 1 / -1; }
  .case-press { grid-template-columns: 1fr; gap: 14px; }
  .case-press img { width: 100%; height: 140px; }
  .case-links { grid-template-columns: 1fr; gap: 24px; }
  .case-flow { grid-template-columns: 1fr; gap: 0; }
  .case-flow li { display: grid; grid-template-columns: 27px 1fr; column-gap: 16px; padding-bottom: 20px; }
  .case-flow li::before { grid-row: 1 / span 2; }
  .case-flow li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 27px; bottom: 0; border-left: 1px solid var(--rule); }
  .case-flow b { margin-top: 3px; }
  .case-next { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .case-fig img[data-zoom], .case-zoom, .case-zoom img, .case-kpis > div::before, .case-photos img { transition: none; }
  .case-fig img[data-zoom]:hover { transform: none; }
}
