/* =========================================================
   CASE STUDY PAGES (gloss.html)
   Builds on the tokens and base styles in style.css (both themes). The
   screenshots are of a light-themed app, so they always sit in light "paper"
   frames — in the dark theme that reads as deliberate rather than as holes
   punched in the page.
========================================================= */
.cs {
  --paper: #f4f2ec;
  --paper-edge: #dcd8cc;
  --paper-text: #6b6555;
}

/* ---------- top bar ---------- */
.cs-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  /* full-bleed and opaque, with the content aligned to the 1080px column */
  padding: 14px max(24px, calc((100% - 1032px) / 2));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.cs-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  transition: color 0.2s ease;
}
.cs-back span { color: var(--text-muted); }
.cs-back i { transition: transform 0.2s cubic-bezier(.22, .61, .36, 1); }
.cs-back:hover, .cs-back:focus-visible { color: var(--accent); }
.cs-back:hover i { transform: translateX(-3px); }

.cs-top-links { display: flex; align-items: center; gap: 14px; font-size: 17px; color: var(--text-muted); }
.cs-top-links > a:not(.cs-btn):hover, .cs-top-links > a:not(.cs-btn):focus-visible { color: var(--accent); }
.cs-top .theme-toggle { width: 34px; height: 34px; font-size: 16px; }

.cs-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 13px;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.cs-btn:hover, .cs-btn:focus-visible { color: var(--accent); border-color: var(--accent); }
.cs-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.cs-btn-primary:hover, .cs-btn-primary:focus-visible { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }

/* ---------- layout ---------- */
.cs-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 88px;
}

/* ---------- hero ---------- */
.cs-hero { padding-top: 64px; }
.cs-kicker { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); }
.cs-title {
  font-size: clamp(44px, 8vw, 72px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 10px 0 18px;
}
.cs-lede {
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 34ch;
}

.cs-facts {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  gap: 12px 48px;
  margin: 32px 0 40px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cs-facts dt, .cs-stack dt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.cs-facts dd {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- screenshot frames ---------- */
.cs-shot { margin: 0; }
.cs-shot .cs-zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--paper);
  cursor: zoom-in;
  box-shadow: var(--shadow-lg);
  transition: transform 260ms cubic-bezier(.22, .61, .36, 1), box-shadow 260ms ease;
}
.cs-shot .cs-zoom:hover, .cs-shot .cs-zoom:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent-ring);
}
.cs-shot img { display: block; width: 100%; height: auto; }
.cs-shot figcaption {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 80ch;
}

/* the hero gets a browser chrome bar; the frame below it squares off its top */
.cs-chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: #e8e5dd;
  border: 1px solid var(--paper-edge);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.cs-chrome + .cs-zoom { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cs-chrome .dot { width: 10px; height: 10px; border-radius: 50%; }
.cs-chrome .dot-r { background: #e0675a; }
.cs-chrome .dot-y { background: #e3b341; }
.cs-chrome .dot-g { background: #5bb974; }
.cs-url {
  margin: 0 auto;
  padding: 3px 16px;
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--paper-text);
}
/* nothing should lift while the chrome bar stays put */
.cs-shot-hero .cs-zoom:hover, .cs-shot-hero .cs-zoom:focus-visible { transform: none; }

/* ---------- section labels ---------- */
.cs-section { scroll-margin-top: 80px; }
.cs-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: color-mix(in srgb, var(--text-primary) 75%, var(--text-secondary));
  margin: 0 0 28px;
}
.cs-label span { color: var(--accent); font-weight: 500; }
.cs-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------- 01 problem ---------- */
.cs-split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }
.cs-statement {
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.cs-prose { display: flex; flex-direction: column; gap: 14px; color: var(--text-secondary); font-size: 15px; line-height: 1.75; }

/* ---------- 02 flow ---------- */
.cs-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.cs-flow li {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 18px 18px 20px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.6;
}
/* arrow into the next step */
.cs-flow li:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -11px;
  top: 22px;
  z-index: 1;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-size: 11px;
}
.cs-flow-n { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.cs-flow-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- 03 features ---------- */
.cs-feature {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 48px;
  align-items: center;
}
.cs-feature + .cs-feature { margin-top: 72px; }
.cs-feature-flip { grid-template-columns: 1fr 1.35fr; }
.cs-feature-flip .cs-shot { order: 2; }
.cs-feature-kicker { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; }
.cs-feature-text h3 { font-size: 22px; line-height: 1.3; font-weight: 600; margin: 8px 0 12px; }
.cs-feature-text p:not(.cs-feature-kicker) { color: var(--text-secondary); font-size: 15px; line-height: 1.75; }
.cs-shot-soft .cs-zoom { background: #eeece6; }

/* ---------- 04 decisions ---------- */
.cs-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cs-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 20px 20px 22px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}
.cs-card:hover { border-color: var(--border-strong); }
.cs-card > i {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 17px;
}
.cs-card-title { font-weight: 600; font-size: 15.5px; color: var(--text-primary); margin: 12px 0 6px; }
.cs-card code { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); background: var(--bg-subtle); padding: 1px 5px; border-radius: 4px; }

/* ---------- 05 stack ---------- */
.cs-stack { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.cs-stack > div { display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: center; }
.cs-stack dd { margin: 0; }

/* ---------- end ---------- */
.cs-end {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.cs-end-links { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- lightbox ----------
   A plain dimmed backdrop: no backdrop-filter blur, which has to re-blur the
   animated page behind it every frame and is what made the old popup lag. */
.cs-lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 56px 24px 24px;
  border: 0;
  background: rgb(10 9 7 / 0.92);
  color: var(--text-primary);
  cursor: zoom-out;
}
.cs-lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.cs-lightbox::backdrop { background: transparent; }
.cs-lightbox img {
  max-width: min(1400px, 100%);
  max-height: calc(100vh - 140px);
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.7);
  cursor: default;
}
.cs-lightbox-cap { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); text-align: center; }
.cs-lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
}
.cs-lightbox-close:hover, .cs-lightbox-close:focus-visible { color: var(--accent); border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .cs-lightbox[open] { animation: cs-fade 180ms ease; }
}
@keyframes cs-fade { from { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .cs-main { gap: 64px; }
  .cs-facts { grid-template-columns: repeat(2, auto); gap: 14px 40px; }
  .cs-split, .cs-feature, .cs-feature-flip { grid-template-columns: 1fr; gap: 22px; }
  .cs-feature-flip .cs-shot { order: 0; }
  .cs-feature + .cs-feature { margin-top: 52px; }
  .cs-flow { grid-template-columns: 1fr 1fr; }
  .cs-flow li:nth-child(2)::after { display: none; }
  .cs-cards { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .cs-top { padding: 12px 16px; }
  .cs-back span { display: none; }
  .cs-main { padding: 0 16px 40px; }
  .cs-hero { padding-top: 40px; }
  .cs-chrome .cs-url { display: none; }
  .cs-flow { grid-template-columns: 1fr; }
  .cs-flow li:not(:last-child)::after { display: none; }
  .cs-stack > div { grid-template-columns: 1fr; gap: 6px; }
  .cs-lightbox { padding: 56px 12px 16px; }
}

/* ---------- motion ----------
   Same language as the home page: transform-only lifts, and accent rings that
   are pre-painted so only their opacity animates. */
.cs-flow li, .cs-card { transition: transform 260ms var(--ease), border-color 0.2s ease; }
.cs-flow li:hover, .cs-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.cs-card { position: relative; }
.cs-flow li::before, .cs-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--accent-ring), 0 14px 34px -18px var(--accent-ring);
  opacity: 0;
  transition: opacity 260ms ease;
}
.cs-flow li:hover::before, .cs-card:hover::before { opacity: 1; }
.cs-flow-title i, .cs-card > i { transition: transform 260ms var(--ease); }
.cs-flow li:hover .cs-flow-title i, .cs-card:hover > i { transform: translateY(-1px) scale(1.12); }
.cs-stack .tags li { transition: transform 220ms var(--ease), border-color 0.2s ease; }
.cs-stack > div:hover .tags li { transform: translateY(-2px); border-color: var(--border-strong); }
.cs-back:hover i { transform: translateX(-3px); }
