:root {
  --canvas: #f2f2ef;
  --ink: #1a1a18;
  --ink-2: #4a4a46;
  --muted: #8c8c86;
  --faint: #b9b9b3;
  --line: #dcdcd7;
  --select: #0d99ff;
  --serif: "Timeless Serif", Georgia, "Times New Roman", serif;
  --sans: "Timeless Sans", "Helvetica Neue", sans-serif;
  --mono: var(--sans);
  --ease: cubic-bezier(.22, .8, .24, 1);
}

@font-face {
  font-family: "Timeless Sans";
  src: url("assets/fonts/TimelessSansVF.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Timeless Serif";
  src: url("assets/fonts/TimelessSerifVF.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Timeless Serif";
  src: url("assets/fonts/TimelessSerifItalicVF.woff2") format("woff2");
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
.ruler:focus-visible {
  outline: 1.5px solid var(--select);
  outline-offset: 3px;
  border-radius: 4px;
}

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

/* ── Canvas: the Figma-style dot grid that pans and zooms with the work ── */

.canvas {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  transform-origin: 50% 46%;
  transition: transform 1.1s var(--ease);
  -webkit-mask-image: radial-gradient(120% 95% at 50% 46%, #000 30%, transparent 82%);
  mask-image: radial-gradient(120% 95% at 50% 46%, #000 30%, transparent 82%);
}

.canvas.is-zoomed { transform: scale(1.14); }

.canvas-dots {
  position: absolute;
  inset: -24px;
  background-image: radial-gradient(circle, rgba(26, 26, 24, .13) 1px, transparent 1.3px);
  background-size: 24px 24px;
  will-change: transform;
}

/* ── Layout ── */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100svh;
}

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 22px 28px;
  font: 11px/1 var(--mono);
  letter-spacing: .01em;
  color: var(--muted);
}

.mark {
  justify-self: start;
  color: var(--ink);
  font: 400 19px/1 var(--serif);
  letter-spacing: -.01em;
  text-decoration: none;
}

.meta { margin: 0; }
.meta span { color: var(--ink-2); }

.top-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}

.count { font-variant-numeric: tabular-nums; }

.play {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .2s ease;
}

.play:hover { background: #fff; }
.play .icon { width: 10px; height: 10px; fill: var(--ink-2); }
.play .icon-pause,
.play[aria-pressed="true"] .icon-play { display: none; }
.play[aria-pressed="true"] .icon-pause { display: block; }

.play .ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  opacity: 0;
  transition: opacity .3s ease;
}

.play .ring circle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-dasharray: 87.97;
  stroke-dashoffset: 87.97;
}

.play[aria-pressed="true"] .ring { opacity: 1; }

/* ── Stage + frames ── */

.stage {
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.stage.is-dragging,
.stage.is-dragging * { cursor: grabbing !important; }

.track { position: absolute; inset: 0; }

.frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--fw, 560px);
  height: var(--fh, 350px);
  margin: calc(var(--fh, 350px) / -2) 0 0 calc(var(--fw, 560px) / -2);
  transform-origin: 50% 50%;
  will-change: transform, opacity, filter;
}

.frame-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  font: 11px/1 var(--mono);
  color: var(--muted);
  white-space: nowrap;
  transition: color .25s ease, opacity .35s ease;
}

.frame.is-center .frame-name { color: var(--ink); }

.frame-box {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  border-radius: 2px;
  background: var(--fill);
  cursor: pointer;
}

.frame.is-center .frame-box { cursor: zoom-in; }

.frame-box img,
.detail-media-inner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
}

.frame-preview {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  pointer-events: none;
}

.product-preview {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  border: 0;
  background: #101114;
}

.frame-box .product-preview { transform-origin: top left; }

/* Figma-style selection on hover */
.sel {
  position: absolute;
  inset: -1px;
  border: 1px solid var(--select);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.sel i {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fff;
  border: 1px solid var(--select);
}

.sel i:nth-child(1) { left: -4px; top: -4px; }
.sel i:nth-child(2) { right: -4px; top: -4px; }
.sel i:nth-child(3) { left: -4px; bottom: -4px; }
.sel i:nth-child(4) { right: -4px; bottom: -4px; }

.frame.is-center .frame-box:hover .sel,
.frame.is-center .frame-box:focus-visible .sel { opacity: 1; }
.frame.is-center:has(.frame-box:hover) .frame-name,
.frame.is-center:has(.frame-box:focus-visible) .frame-name { color: var(--select); }
.frame-box:focus-visible { outline: none; }
.stage.is-dragging .sel { opacity: 0 !important; }

.frame.is-lifted .frame-box { opacity: 0; }
.frame.is-lifted .frame-label { opacity: 0; transition: none; }

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  margin: 0;
  text-align: center;
  font: 10.5px/1 var(--mono);
  letter-spacing: .03em;
  color: var(--faint);
  transition: opacity .6s ease;
}

.hint.is-gone { opacity: 0; }

/* ── Timeline ruler ── */

.timeline {
  width: min(460px, calc(100vw - 40px));
  margin: 0 auto;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  transition: opacity .45s ease, transform .6s var(--ease);
}

.ruler {
  position: relative;
  height: 88px;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.ruler.is-dragging { cursor: grabbing; }
.ruler:focus { outline: none; }

.pill {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  margin-left: -24px;
  height: 22px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 500 10px/22px var(--mono);
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 32px;
  bottom: 14px;
  pointer-events: none;
}

.tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 100%;
  margin-left: -.5px;
  border-radius: 1px;
  background: #a6a6a0;
  transform-origin: 50% 100%;
}

.tick.major { width: 1.5px; margin-left: -.75px; background: #8a8a84; }

.playhead {
  position: absolute;
  left: 0;
  top: 27px;
  bottom: 14px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink);
  pointer-events: none;
}

.keys {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  height: 3px;
  pointer-events: none;
}

.key {
  position: absolute;
  top: 0;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: var(--faint);
  transition: background .2s ease, transform .2s ease;
}

.key.is-on { background: var(--ink); transform: scale(1.35); }

.years { display: flex; margin-top: 4px; }

.year {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border-radius: 5px;
  font: 10.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: color .2s ease, background-color .2s ease;
}

.year:hover { color: var(--ink); background: rgba(26, 26, 24, .04); }
.year[aria-pressed="true"] { color: var(--ink); }
.year:disabled { color: var(--faint); cursor: default; background: none; }

/* ── Away state while a case study is open ── */

.top,
.hint { transition: opacity .45s ease; }

.app.is-away .top,
.app.is-away .hint { opacity: 0; }

.app.is-away .timeline { opacity: 0; transform: translateY(10px); }

/* ── Case study ── */

.detail {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.detail[hidden] { display: none; }

.detail-bar,
.detail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  font: 11px/1 var(--mono);
  color: var(--muted);
  opacity: 0;
  transition: opacity .25s ease;
}

.detail.is-open .detail-bar,
.detail.is-open .detail-foot { opacity: 1; transition: opacity .5s ease .4s; }

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: -7px -9px;
  padding: 7px 9px;
  border-radius: 6px;
  font: 11px/1 var(--mono);
  color: var(--muted);
  transition: color .2s ease, background-color .2s ease;
}

.ctl:hover { color: var(--ink); background: rgba(26, 26, 24, .045); }
.ctl:disabled { opacity: .35; cursor: default; background: none; color: var(--muted); }

.ctl kbd {
  padding: 2px 5px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--line);
  font: 9.5px/1 var(--mono);
  color: var(--faint);
}

.ctl-count { font-variant-numeric: tabular-nums; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, .8fr) minmax(0, 1.9fr);
  align-items: center;
  gap: clamp(28px, 4.5vw, 80px);
  min-height: 0;
  padding: 0 clamp(24px, 4.5vw, 80px);
}

.detail-copy {
  align-self: stretch;
  justify-self: end;
  width: 100%;
  max-width: 360px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
  padding: clamp(28px, 6vh, 64px) 10px clamp(28px, 6vh, 64px) 0;
}

.eyebrow {
  display: flex;
  gap: 14px;
  margin: 0 0 20px;
  font: 11px/1 var(--mono);
  color: var(--muted);
}

.eyebrow span + span::before { content: "—"; margin-right: 14px; color: var(--faint); }

.detail-title {
  margin: 0;
  font: 400 clamp(36px, 4.3vw, 62px)/.98 var(--serif);
  letter-spacing: -.025em;
}

.detail-lede {
  margin: 22px 0 0;
  font-size: clamp(17px, 1.3vw, 20px);
  line-height: 1.5;
  color: var(--ink-2);
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 24px;
  margin: 30px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font: 11px/1.2 var(--mono);
}

.facts[hidden] { display: none; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink-2); }

.detail-media-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
}

.detail-media {
  position: relative;
  display: block;
  width: min(100%, calc((100svh - 160px) * 1.6));
  aspect-ratio: 16 / 10;
  border-radius: 2px;
  overflow: hidden;
  transform-origin: 0 0;
  cursor: zoom-in;
}

.detail-media:focus-visible { outline-offset: 4px; }

.detail-media-inner {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  background: var(--fill);
  pointer-events: none;
}

.detail-media-inner .product-preview {
  pointer-events: none;
}

.media-action {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 2px;
  background: rgba(20, 20, 20, .72);
  color: #fff;
  font: 10px/1 var(--mono);
  letter-spacing: .02em;
  opacity: .8;
  transition: opacity .2s ease, background .2s ease;
}

.detail-media:hover .media-action,
.detail-media:focus-visible .media-action {
  opacity: 1;
  background: rgba(20, 20, 20, .9);
}

.case-content {
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-2);
}

.case-content[hidden] { display: none; }
.case-content.is-loading { color: var(--muted); font-style: italic; }
.case-content.case-error { color: #8b5148; font-size: 12px; font-family: var(--mono); line-height: 1.6; }

.case-content h2,
.case-content h3,
.case-content h4 {
  margin: 32px 0 12px;
  color: var(--ink);
  font: 700 25px/1.1 var(--serif);
  letter-spacing: -.015em;
}

.case-content h3 { font-size: 21px; }
.case-content h4 { font-size: 18px; }
.case-content p { margin: 0 0 16px; }
.case-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 22px 0;
  border-radius: 2px;
}
.case-content ul,
.case-content ol { margin: 0 0 18px; padding-left: 20px; }
.case-content li { margin: 0 0 6px; padding-left: 3px; }
.case-content strong { color: var(--ink); font-weight: 600; }
.case-content a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.case-content code {
  padding: 2px 4px;
  border-radius: 2px;
  background: rgba(26, 26, 24, .055);
  font: .85em var(--mono);
}
.case-content pre { overflow-x: auto; padding: 14px; background: rgba(26, 26, 24, .055); }
.case-content pre code { padding: 0; background: none; }
.case-content blockquote {
  margin: 20px 0;
  padding-left: 14px;
  border-left: 1px solid var(--faint);
  color: var(--muted);
}
.case-content hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.case-table-wrap {
  max-width: 100%;
  margin: 18px 0 24px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}

.case-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.5;
}

.case-content th,
.case-content td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.case-content th { color: var(--ink); font-weight: 600; }
.case-content td:first-child { color: var(--ink); }

.experience-modal {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #101114;
  color: #fff;
}

.experience-modal[hidden] { display: none; }

.experience-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  font: 11px/1 var(--mono);
}

.experience-note {
  margin-left: 12px;
  color: rgba(255, 255, 255, .48);
}

.experience-modal .ctl { color: rgba(255, 255, 255, .68); }
.experience-modal .ctl:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.experience-frame {
  position: absolute;
  top: calc(54px + (100% - 54px) / 2);
  left: 50%;
  display: block;
  width: 1280px;
  height: 800px;
  transform: translate(-50%, -50%) scale(var(--experience-scale, 1));
  transform-origin: center;
  border: 0;
  background: #101114;
}

/* ── Small screens ── */

@media (max-width: 760px) {
  .top { grid-template-columns: 1fr auto; padding: 18px 20px; }
  .meta { display: none; }
  .year { font-size: 9.5px; }

  .detail-bar,
  .detail-foot { padding: 18px 20px; }

  .detail-grid {
    grid-template-columns: 1fr;
    align-content: start;
    align-items: start;
    gap: 28px;
    padding: 8px 20px 24px;
    overflow-y: auto;
  }

  .detail-media-wrap { order: -1; }
  .detail-media { width: 100%; }
  .detail-copy {
    align-self: auto;
    justify-self: start;
    max-width: none;
    max-height: none;
    overflow: visible;
    padding: 0 0 20px;
  }
}

@media (max-height: 620px) and (min-width: 761px) {
  .top { padding-block: 14px; }
  .ruler { height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .canvas,
  .timeline,
  .hint,
  .top { transition: none; }
}
