/* ==========================================================================
   WORK PAGE
   A member of the case study family: it loads tokens.css, base.css and
   case-study.css, so the nav, hero, eyebrows, facts and "Up next" match.
   What's its own: a numbered index of projects, a split header for each
   project, and a sideways reel of bare screens (no device frames) sitting
   in a well tinted with that project's colour.

   Each project sets --study on its <section>, like a case study's <body>.
   ========================================================================== */
.work-page {
  --reel-h: clamp(380px, 40vw, 580px);   /* how tall the screens are */
  --reel-pad: clamp(20px, 3.5vw, 56px);  /* space inside the tinted well */
}
.work > section { min-height: 0; padding-bottom: 0; }
.work > * { max-width: var(--wide); margin-inline: auto; }

/* ---------- Hero ---------- */
.work-hero > .eyebrow { color: var(--color-text); opacity: 0.55; }

/* The projects on this page: a compact grid of jump links, each with a small thumbnail.
   Deliberately unnumbered, so it reads as a collection, not a timeline. */
.work-index {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
  margin-top: clamp(40px, 5vw, 72px) !important;
  padding: 0;
  list-style: none;
}
/* Each entry is an outlined card, so it reads as something to click before you hover */
.work-index a {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 0 14px;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 18px -10px rgba(0, 0, 0, 0.18);
  color: inherit;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, translate 0.2s;
}
.work-index a:hover {
  text-decoration: none;
  translate: 0 -2px;
  border-color: color-mix(in srgb, var(--study) 45%, transparent);
  background: color-mix(in srgb, var(--study) 6%, #fff);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 24px -12px rgba(0, 0, 0, 0.22);
}
.work-index a:focus-visible { outline: 2px solid var(--study); outline-offset: 3px; }
.work-thumb {
  grid-row: span 2;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  object-position: top;
  background: color-mix(in srgb, var(--study) 12%, #f3f3f5);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: scale 0.2s;
}
.work-name { align-self: end; font-family: var(--font-display); font-size: var(--text-sm); line-height: 1.1; transition: color 0.2s; }
.work-meta { align-self: start; margin-top: 2px; font-size: 14px; line-height: 1.35; opacity: 0.6; }
.work-index a:hover .work-name { color: var(--study); }
.work-index a:hover .work-thumb { scale: 1.05; }

/* ---------- One project ---------- */
.work-project { padding-top: var(--gap-section) !important; scroll-margin-top: var(--nav-height); }

/* Title on the left, the why and the facts on the right */
.work-head {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: var(--space-2xl) clamp(32px, 6vw, 96px);
  align-items: start;
}
.work-title h2 { margin-top: var(--space-md); font-size: var(--text-xxl); line-height: 1; text-wrap: balance; }
.work-sub { margin-top: var(--space-sm); font-family: var(--font-display); font-size: var(--text-lg); line-height: var(--leading-snug); color: var(--study); }
.work-about .prose > p:first-child { font-size: var(--text-md); line-height: 1.4; }
.work-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-2xl);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--line);
}
.work-facts dt { font-size: var(--text-fine); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.55; }
.work-facts dd { margin: 4px 0 0; font-size: 16px; line-height: 1.4; }

/* ---------- The reel of screens ---------- */
.reel { margin-top: var(--gap-block); }
.reel-track {
  display: flex;
  gap: clamp(16px, 2vw, 28px);
  align-items: center;
  padding: var(--reel-pad);
  border-radius: clamp(16px, 2vw, 28px);
  background: color-mix(in srgb, var(--study) 9%, #f6f6f8);
  margin: 0;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--reel-pad);
  scrollbar-width: none;
}
.reel-track::-webkit-scrollbar { display: none; }
.reel-track:focus-visible { outline: 2px solid var(--study); outline-offset: 4px; }
.reel-item { flex: none; scroll-snap-align: start; }

/* Bare screens: rounded corners and a soft shadow instead of a phone */
.screen {
  display: block;
  padding: 0;
  border: 0;
  border-radius: clamp(14px, 1.6vw, 24px);
  background: #fff;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 32px -8px rgba(0, 0, 0, 0.18);
  transition: translate 0.25s, box-shadow 0.25s;
}
.reel-item--desk .screen { border-radius: clamp(8px, 0.9vw, 14px); }
.screen img { display: block; width: auto; height: var(--reel-h); }
.screen:hover { translate: 0 -4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 20px 40px -10px rgba(0, 0, 0, 0.24); }
.screen:focus-visible { outline: 2px solid var(--study); outline-offset: 4px; }

/* Under the reel: where you are, and arrows to step through */
.reel-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.reel-count { font-size: var(--text-caption); font-weight: 600; opacity: 0.6; font-variant-numeric: tabular-nums; }
.reel-buttons { display: flex; gap: var(--space-xs); }
.reel-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}
.reel-btn img { width: 16px; height: auto; }
.reel-btn[data-dir="1"] img { transform: scaleX(-1); }
.reel-btn:hover:not(:disabled) { border-color: var(--study); background: color-mix(in srgb, var(--study) 10%, #fff); }
.reel-btn:disabled { opacity: 0.3; cursor: default; }
.reel-btn:focus-visible { outline: 2px solid var(--study); outline-offset: 2px; }

/* ---------- Screen viewer ----------
   Matches the archive's image viewer (archive/assets/archive.css, "lightbox"):
   a blurred backdrop, dark glass buttons on the edges, a counter top left.
   It shows the whole screen (the reel shows a crop of tall ones); long screens
   scroll. One difference: phone screens stay phone-sized instead of growing. */
.lightbox { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: #fff; overflow: hidden; }
.lightbox::backdrop { background: rgba(8, 8, 10, 0.62); backdrop-filter: blur(18px) saturate(0.9); -webkit-backdrop-filter: blur(18px) saturate(0.9); }
.lb-scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; place-items: center; padding: 72px clamp(16px, 7vw, 96px) 56px; }
.lb-fig { margin: 0; max-width: min(1400px, 100%); }
.lb-fig img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100dvh - 128px); border-radius: 12px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55); background: #111; }
/* The frame takes the screen's display width, so the screen sits centred (not at the frame's left) */
.lb-fig.is-tall { width: min(100%, 900px); }
.lb-fig.is-phone { width: min(100%, 420px); }
.lb-fig.is-tall img, .lb-fig.is-phone img { max-height: none; width: 100%; }
.lb-fig.is-phone img { border-radius: 20px; }
.lb-btn { position: fixed; z-index: 2; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(20, 20, 22, 0.6); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background 0.15s ease, transform 0.15s ease; }
.lb-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.lb-close { top: 16px; right: 16px; font-size: 26px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: fixed; top: 28px; left: 20px; z-index: 2; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.75); }
@media (max-width: 720px) {
  .lb-scroll { padding: 72px 12px 88px; }
  .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; }
  .lb-prev { left: calc(50% - 56px); }
  .lb-next { right: calc(50% - 56px); }
}
@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] .lb-fig { animation: lb-in 0.22s ease-out; }
  @keyframes lb-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
}

/* ---------- Smaller screens ---------- */
@media (max-width: 1040px) {
  .work-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .work-page { --reel-h: 400px; }
  .work-head { grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); }
  .work-index { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
  .work-index a { grid-template-columns: 44px 1fr; gap: 0 10px; padding: 8px; border-radius: 14px; }
  .work-thumb { width: 44px; height: 44px; border-radius: 10px; }
  .work-name { align-self: center; font-size: 17px; }
  .work-thumb { grid-row: auto; }
  .work-meta { display: none; }

  /* Wide desktop screens fit the phone's width instead of the reel's height */
  .reel-item--desk .screen img { width: calc(100vw - 2 * var(--space-page) - 2 * var(--reel-pad) - 24px); height: auto; }
}
@media (max-width: 480px) {
  .work-page { --reel-h: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen, .reel-btn, .work-index a { transition: none; }
  .work-index a:hover { translate: none; }
  .screen:hover { translate: none; }
}
