/* /work and /work/{slug}: type filter, TL;DR, comparison bars, flow chain,
   phone-width image frame. Reuses tokens from styles.css
   (--ink, --navy, --line, --line-soft, --paper-2, --font-sans, --font-mono,
   --ease-out). Logical properties throughout for RTL. */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── /work type filter ── */
.work-filter { padding: 4px 0 28px; }
.wf-group { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; }
.wf-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; background: var(--white);
  transition: background 200ms var(--ease-out), border-color 200ms var(--ease-out), color 200ms var(--ease-out);
}
.wf-btn input {
  position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
}
.wf-btn:hover { border-color: var(--navy); }
.wf-btn:has(input:checked) { background: var(--navy); border-color: var(--navy); color: var(--white); }
.wf-btn:has(input:focus-visible) { outline: 2px solid var(--navy); outline-offset: 2px; }
.wf-count { font-family: var(--font-mono); font-size: 11px; opacity: .65; direction: ltr; }
.wf-btn:has(input:checked) .wf-count { opacity: 1; }

/* Filtering: pure CSS, works with no JS. .case-wrap generates no box of its
   own so the grid layout is identical to a bare .case-card list. */
.case-wrap { display: contents; }
.work-page:has(#wf-ai-agents:checked)  .case-wrap:not([data-type~="ai-agents"])  { display: none; }
.work-page:has(#wf-automation:checked) .case-wrap:not([data-type~="automation"]) { display: none; }
.work-page:has(#wf-web:checked)        .case-wrap:not([data-type~="web"])        { display: none; }
.work-page:has(#wf-operations:checked) .case-wrap:not([data-type~="operations"]) { display: none; }

/* ── TL;DR ── */
.case-tldr {
  font-size: 17px; line-height: 1.6; font-weight: 500; color: var(--ink);
  max-width: 68ch; margin: 18px 0 0; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2);
}

/* ── Comparison bars (accessible table; the bars ARE the table) ── */
.case-compare { padding: var(--space-head) 0 8px; }
.compare-table { width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink); margin-top: 8px; }
.compare-table thead th {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gray-600); text-align: start; padding: 10px 12px; font-weight: 500;
}
.cmp-row th[scope="row"] {
  text-align: start; font-size: 14px; font-weight: 500; color: var(--ink);
  padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.cmp-cell { border-bottom: 1px solid var(--line); padding: 12px; vertical-align: middle; }
.cmp-cell-flex { display: flex; align-items: center; gap: 10px; }
.cmp-track { position: relative; flex: none; width: 120px; max-width: 30vw; height: 8px; }
.cmp-bar { position: absolute; inset-inline-start: 0; top: 0; height: 100%; border-radius: 2px; }
.cmp-bar--before { background: var(--line); }
.cmp-bar--after { background: var(--navy); }
.cmp-val { font-family: var(--font-mono); font-size: 13px; color: var(--ink); direction: ltr; text-align: start; white-space: nowrap; }
@media (max-width: 560px) {
  .compare-table thead { display: none; }
  .compare-table, .compare-table tbody, .cmp-row, .cmp-row th, .cmp-row td { display: block; width: auto; }
  .cmp-row { border-bottom: 1px solid var(--line); padding: 10px 0; }
  .cmp-row th[scope="row"] { border-bottom: 0; padding: 0 0 6px; }
  .cmp-cell { border-bottom: 0; padding: 4px 0; }
  .cmp-track { max-width: 55vw; }
}

/* ── Flow chain ── */
.case-flow { padding: var(--space-head) 0 8px; }
.flow-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.flow-step {
  min-height: 44px; display: inline-flex; align-items: center; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--ink); background: var(--white);
}
.flow-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; flex: none; color: var(--navy); font-family: var(--font-mono); font-size: 16px;
}
[dir="rtl"] .flow-arrow { transform: scaleX(-1); }
@media (max-width: 640px) {
  .flow-chain { flex-direction: column; align-items: stretch; }
  .flow-step { width: 100%; }
  .flow-arrow { align-self: center; transform: rotate(90deg); }
  [dir="rtl"] .flow-arrow { transform: rotate(90deg); }
}

/* ── Phone-width chat crop: capped and centered, never stretched ── */
.work-shot--phone { max-width: 320px; margin-inline: auto; }

/* ── Case images: max 3, fixed 3-column grid, no orphan row ── */
.case-img-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-block); }
.case-img-grid .work-shot--phone { grid-column: auto; }
@media (max-width: 760px) {
  .case-img-grid { grid-template-columns: 1fr; }
}
.case-more-link { margin-top: 20px; font-size: 14px; }
.case-more-link a { color: var(--navy); font-weight: 500; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.case-more-link a:hover, .case-more-link a:focus-visible { text-decoration-color: var(--navy); }
.case-more-link a:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .wf-btn { transition: none; }
}
/* Same frame for every non-phone case image, whatever its shape */
.case-img-grid .work-shot:not(.work-shot--phone) img { aspect-ratio: 4 / 3; object-fit: contain; }

/* ── Case header: verdict on the left, proof on the right ── */
.back-link { margin-bottom: 20px; }
.case-hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.case-hero-grid.no-shot { grid-template-columns: minmax(0, 1fr); }
.case-hero-grid .page-lede { font-size: 18px; color: var(--ink); max-width: 52ch; }
.case-hero-shot { margin: 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-soft); background: var(--paper-2); }
.case-hero-shot img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.page-hero .case-meta { margin-top: 32px; }
@media (max-width: 860px) {
  .case-hero-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
.page-hero + .work-filter { padding: 24px 0; }
