/* The gallery only: the poster grid, the filters and the theatre. Colours, fonts, header and footer come from site/shared. */
:root { --gap: 28px; --ease: cubic-bezier(0.215, 0.61, 0.355, 1); --cols: 3; }   /* power3.out */
@media (max-width: 1099px) { :root { --cols: 2; } }
@media (max-width: 639px)  { :root { --cols: 1; --gap: 32px; } }

html.theatre-open { overflow: hidden; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr; gap: 28px 56px; align-items: end;
  padding-top: 56px; padding-bottom: 48px; background-image: linear-gradient(var(--line), var(--line)); background-repeat: no-repeat; background-size: calc(100% - 2 * var(--gutter)) 1px; background-position: center bottom;
}
.hero .eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.hero h1 { font-size: clamp(56px, 14.5vw, 128px); letter-spacing: -0.045em; line-height: 0.95; }
.hero .intro { max-width: 46ch; }
.hero .intro p { margin: 0 0 14px; font-size: clamp(16px, 1.35vw, 19px); line-height: 1.45; color: var(--ink); }
.hero .intro p.sub { color: var(--ink-2); font-size: 15px; }
.hero pre {
  margin: 22px 0 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--code-bg);
  font: 11.5px/1.55 var(--mono); color: var(--code-com); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
}
.hero pre b { font-weight: 400; color: var(--code-key); }
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); padding-top: 80px; padding-bottom: 64px; }
}

/* one orchestrated entrance: the headline lands like a layer keyframe; the grid follows */
@media (prefers-reduced-motion: no-preference) {
  .hero h1 { opacity: 0; transform: translateY(24px); animation: land .9s var(--ease) .05s forwards; }
  .hero .intro { opacity: 0; animation: fade .7s ease .45s forwards; }
  .piece { opacity: 0; animation: fade .6s ease calc(.55s + var(--i, 0) * 28ms) forwards; }
  @keyframes land { to { opacity: 1; transform: none; } }
  @keyframes fade { to { opacity: 1; } }
}

/* ---------- filters ---------- */
.filters {
  position: sticky; top: 56px; z-index: 5; background-color: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background-image: linear-gradient(var(--line), var(--line)); background-repeat: no-repeat; background-size: calc(100% - 2 * var(--gutter)) 1px; background-position: center bottom;
  padding-top: 14px; padding-bottom: 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; border-radius: 999px; padding: 6px 13px; cursor: pointer;
  font-size: 13.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px;
  transition: color .25s, background-color .25s;
}
.seg button small { font: 11px/1 var(--mono); color: var(--ink-3); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg button[aria-pressed="true"] small { color: var(--on-accent); opacity: .75; }
.seg button[aria-pressed="true"] .dot { box-shadow: 0 0 0 1px var(--on-accent); }
.seg button:focus-visible { outline-offset: 0; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 340px; min-width: 0; }
.tags button {
  border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 5px 11px; cursor: pointer;
  font-size: 13px; color: var(--ink-2); transition: color .25s, border-color .25s, background-color .25s;
}
.tags button:hover { color: var(--ink); border-color: var(--line-2); }
.tags button[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
.tags button.more { color: var(--ink-3); }
.tags button.more:hover { color: var(--ink); }
.tags[data-expanded="true"] { max-height: 32vh; overflow-y: auto; align-content: flex-start; }                 /* all 160 chips open: scroll inside, do not cover the pieces under the pinned bar */
.tags[data-expanded="false"] button.extra:not([aria-pressed="true"]) { display: none; }       /* a chosen tag stays visible when the rest is folded */
.count { margin-left: auto; font-size: 13px; color: var(--ink-2); white-space: nowrap; display: flex; gap: 14px; align-items: baseline; }
.count .tc { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.count button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.count button[hidden] { display: none; }
@media (max-width: 899px) { .filters { position: static; } }   /* three rows tall here: not worth pinning */
@media (max-width: 639px) {
  .filters { gap: 10px 16px; }
  .count { margin-left: 0; width: 100%; }
}

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot[data-model="fable"] { background: var(--model-fable); }
.dot[data-model="opus"] { background: var(--model-opus); }
.dot[data-model="sonnet"] { background: var(--model-sonnet); }
.dot[data-model="haiku"] { background: var(--model-haiku); }

/* ---------- grid ---------- */
.reel { padding-top: 44px; padding-bottom: 72px; }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: 1px; column-gap: var(--gap); align-items: start;
}
.piece[hidden] { display: none; }
.card { display: block; text-decoration: none; color: inherit; border-radius: 6px; }
.frame {
  position: relative; margin: 0; overflow: hidden; border-radius: 6px; background: var(--bg-2);
  box-shadow: 0 0 0 1px var(--line) inset;
  transition: box-shadow .4s var(--ease), transform .4s var(--ease);
}
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease); }
.frame .play {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0;
  background: linear-gradient(to top, rgba(7,7,8,.45), rgba(7,7,8,0) 45%);
  transition: opacity .35s var(--ease);
}
.frame .play span {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(7, 7, 8, .55); border: 1px solid rgba(243,239,231,.55); backdrop-filter: blur(6px);
  transform: scale(.9); transition: transform .35s var(--ease);
}
.frame .play svg { width: 18px; height: 18px; fill: #fff; margin-left: 3px; }
.frame .tc {
  position: absolute; right: 10px; bottom: 10px; padding: 3px 7px; border-radius: 4px;
  font: 11px/1 var(--mono); color: #fff; background: rgba(7,7,8,.6); backdrop-filter: blur(4px);
}
.card:hover .frame, .card:focus-visible .frame { box-shadow: 0 0 0 1px var(--line-2) inset, 0 24px 48px -20px rgba(0,0,0,.8); }
.card:hover .frame img, .card:focus-visible .frame img { transform: scale(1.025); }
.card:hover .play, .card:focus-visible .play { opacity: 1; }
.card:hover .play span, .card:focus-visible .play span { transform: none; }
.card:focus-visible { outline-offset: 6px; }
.cap { padding: 14px 2px 0; }
.cap .row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cap h3 { margin: 0; font-size: 17px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.3; }
.cap .sub {
  margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cap .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-3); }
.cap .meta .dim { font-family: var(--mono); font-size: 11.5px; }
.model {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 12px; color: var(--ink-2); padding: 2px 9px 2px 7px; border: 1px solid var(--line); border-radius: 999px;
}
.model .dot { width: 6px; height: 6px; }

.empty { padding: 48px 0 24px; color: var(--ink-2); font-size: 15px; }
.empty button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.error {
  margin: 48px 0; padding: 20px 22px; border: 1px solid var(--line-2); border-radius: 6px; max-width: 64ch; color: var(--ink); line-height: 1.55;
}
.error code { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }

/* ---------- about ---------- */
.about { background-image: linear-gradient(var(--line), var(--line)); background-repeat: no-repeat; background-size: calc(100% - 2 * var(--gutter)) 1px; background-position: center top; padding-top: 56px; padding-bottom: 72px; }
.about .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 24px var(--gap); max-width: 1180px; }
.about h2 { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -0.015em; }
.about p { margin: 0 0 18px; max-width: 64ch; color: var(--ink-2); font-size: 15.5px; line-height: 1.6; }
.about p:last-child { margin-bottom: 0; }
.about a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); transition: text-decoration-color .25s; }
.about a:hover { text-decoration-color: var(--ink); }
.about code { font-family: var(--mono); font-size: 13px; }
@media (max-width: 899px) { .about .cols { grid-template-columns: 1fr; } }

/* ---------- theatre ---------- */
dialog.theatre {
  position: fixed; inset: 0; width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink);
  --bg: #0b0d12; --ink: #eceef2; --ink-2: #a3a9b5; --ink-3: #7f8694; --line: rgba(255,255,255,.11); --line-2: rgba(255,255,255,.2); color-scheme: dark;   /* a dark room in either theme */
  display: none; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}
dialog.theatre[open] { display: flex; }
dialog.theatre::backdrop { background: rgba(4, 4, 5, .9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.th-stage { position: relative; flex: none; display: grid; place-items: center; }
.th-box { position: relative; background: #000; border-radius: 6px; overflow: hidden; box-shadow: 0 40px 120px -20px rgba(0,0,0,.9); }
.th-box img { position: absolute; left: 16px; top: 16px; width: calc(100% - 32px); height: calc(100% - 32px); object-fit: cover; }
.th-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; opacity: 0; transition: opacity .5s ease; }
.th-box.ready iframe { opacity: 1; }
.th-box.ready img { visibility: hidden; transition: visibility 0s .5s; }
.th-play { position: absolute; inset: 0; z-index: 2; display: none; place-items: center; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; color: #fff; cursor: pointer; }
.th-play svg { width: 72px; height: 72px; padding: 22px 18px 22px 26px; box-sizing: border-box; border-radius: 50%; background: rgba(8, 8, 10, .62); border: 1px solid rgba(255, 255, 255, .35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .25s ease, background .25s ease; }
.th-play:hover svg, .th-play:focus-visible svg { transform: scale(1.08); background: rgba(8, 8, 10, .8); }
.th-play:focus-visible { outline: 2px solid #fff; outline-offset: -6px; }
.th-box.armed .th-play { display: grid; }
.th-cap { flex: none; padding: 18px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 24px; align-items: start; }
.th-cap h2 { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.3; }
.th-cap .sub { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.45; max-width: 70ch; }
.th-cap .meta { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12.5px; color: var(--ink-3); }
.th-cap .meta .dim, .th-cap .meta .tc { font-family: var(--mono); font-size: 11.5px; }
.th-cap .meta .tags { gap: 0 8px; flex: none; color: var(--ink-2); }
.th-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.th-count { font: 12px/1 var(--mono); color: var(--ink-3); letter-spacing: .04em; }
.th-links { display: flex; gap: 16px; font-size: 13px; white-space: nowrap; }
.th-links a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); transition: color .25s, text-decoration-color .25s; }
.th-links a:hover { color: var(--ink); text-decoration-color: var(--ink); }
.th-btn {
  border: 1px solid var(--line-2); background: rgba(7,7,8,.6); cursor: pointer; border-radius: 50%;
  width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink);
  transition: background-color .25s, border-color .25s, transform .25s var(--ease);
}
.th-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.th-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.th-close { position: fixed; top: 18px; right: 18px; z-index: 2; }
.th-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 2; }
.th-nav.prev { left: 22px; }
.th-nav.next { right: 22px; }
.th-nav:hover { transform: translateY(-50%); }
.th-mobile-nav { display: none; }
@media (max-width: 899px) {
  dialog.theatre { justify-content: flex-start; padding-top: 64px; }   /* below the close button */
  .th-nav { display: none; }
  .th-mobile-nav { display: flex; gap: 8px; }
  .th-mobile-nav .th-btn { width: 40px; height: 40px; }
  .th-cap { grid-template-columns: 1fr; gap: 10px; padding-top: 14px; }
  .th-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .th-close { top: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-delay: 0s !important; scroll-behavior: auto !important; }
}
