/* ==========================================================================
   POP CULTURE  ::  nkhola.github.io/popculture
   Cinematheque dark + paper light. Editorial modernism, newspaper structure,
   cubist geometry. No glassmorphism, no gradient mush.
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  /* Light: paper cinema. Defined on bare :root so it is always the base. */
  --bg:          #FAF7F0;
  --bg-deep:     #F2EDE1;
  --surface:     #FFFFFF;
  --surface-2:   #F4F0E6;
  --ink:         #16213E;
  --ink-2:       #3A445E;
  --ink-dim:     #6E7589;
  --ink-faint:   #A3A8B6;
  --rule:        rgba(22, 33, 62, 0.16);
  --rule-soft:   rgba(22, 33, 62, 0.08);
  --rule-strong: rgba(22, 33, 62, 0.42);

  --accent:      #C2552F;   /* terracotta, editorial */
  --accent-soft: rgba(194, 85, 47, 0.10);
  --ochre:       #A8761F;
  --teal:        #2A7575;

  --shadow-1: 0 1px 2px rgba(22, 33, 62, .06), 0 4px 14px rgba(22, 33, 62, .06);
  --shadow-2: 0 2px 6px rgba(22, 33, 62, .08), 0 18px 44px rgba(22, 33, 62, .12);
  --grain-opacity: 0;

  /* Type */
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Rhythm */
  --measure: clamp(320px, 92vw, 1320px);
  --measure-tight: clamp(320px, 92vw, 860px);
  --gap: clamp(1rem, 2.4vw, 2rem);
  --nav-h: 58px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.4, 0, .2, 1);

  color-scheme: light;
}

/* Dark: system preference, unless the user explicitly picked light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0A0A0C;
    --bg-deep:     #050506;
    --surface:     #121216;
    --surface-2:   #1A1A21;
    --ink:         #EFEBE3;
    --ink-2:       #C9C4B9;
    --ink-dim:     #928D82;
    --ink-faint:   #5E5A53;
    --rule:        rgba(239, 235, 227, 0.14);
    --rule-soft:   rgba(239, 235, 227, 0.07);
    --rule-strong: rgba(239, 235, 227, 0.40);

    --accent:      #E2703F;
    --accent-soft: rgba(226, 112, 63, 0.14);
    --ochre:       #D9A343;
    --teal:        #4FA8A3;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 18px rgba(0, 0, 0, .42);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .55), 0 24px 60px rgba(0, 0, 0, .58);
    --grain-opacity: .045;

    color-scheme: dark;
  }
}

/* Dark: explicit choice always wins. */
:root[data-theme="dark"] {
  --bg:          #0A0A0C;
  --bg-deep:     #050506;
  --surface:     #121216;
  --surface-2:   #1A1A21;
  --ink:         #EFEBE3;
  --ink-2:       #C9C4B9;
  --ink-dim:     #928D82;
  --ink-faint:   #5E5A53;
  --rule:        rgba(239, 235, 227, 0.14);
  --rule-soft:   rgba(239, 235, 227, 0.07);
  --rule-strong: rgba(239, 235, 227, 0.40);

  --accent:      #E2703F;
  --accent-soft: rgba(226, 112, 63, 0.14);
  --ochre:       #D9A343;
  --teal:        #4FA8A3;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 18px rgba(0, 0, 0, .42);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .55), 0 24px 60px rgba(0, 0, 0, .58);
  --grain-opacity: .045;

  color-scheme: dark;
}

/* --- 2. Reset ------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color .5s var(--ease-io), color .5s var(--ease-io);
}

img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--accent); color: var(--bg); }

/* --- 3. Film grain ------------------------------------------------------- */

.grain {
  position: fixed;
  inset: -50%;
  z-index: 9998;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: var(--grain-url);
  background-repeat: repeat;
  transition: opacity .6s var(--ease-io);
  will-change: transform;
}

/* --- 4. Scroll progress -------------------------------------------------- */

.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  z-index: 9999;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: var(--accent);
  pointer-events: none;
}

/* --- 5. Typography helpers ---------------------------------------------- */

.kicker {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.display {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: "SOFT" 0, "WONK" 0, "opsz" 120;
  line-height: .92;
  letter-spacing: -.025em;
}

.serif { font-family: var(--display); }
.mono  { font-family: var(--mono); }

.rule    { border: 0; border-top: 1px solid var(--rule); }
.rule-2  { border: 0; border-top: 3px double var(--rule-strong); height: 0; }

/* --- 6. Nav -------------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--rule);
}

.nav-inner {
  width: var(--measure);
  margin-inline: auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: clamp(.5rem, 2vw, 1.6rem);
  padding-inline: clamp(.85rem, 2vw, 1.5rem);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-shrink: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  flex-shrink: 0;
  align-self: center;
}
.brand-mark svg { width: 100%; height: 100%; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .15rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Fades the right edge so a clipped link reads as "scroll me", not "broken". */
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.nav-links::-webkit-scrollbar { display: none; }

/* Only needed while the row actually overflows. */
@media (min-width: 900px) {
  .nav-links { -webkit-mask-image: none; mask-image: none; }
}

.nav-link {
  position: relative;
  padding: .42rem .62rem;
  border-radius: 3px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-dim);
  white-space: nowrap;
  transition: color .22s var(--ease-io);
}
.nav-link::after {
  content: "";
  position: absolute;
  left: .62rem; right: .62rem; bottom: .18rem;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform .32s var(--ease);
}
.nav-link:hover { color: var(--ink); }
.nav-link:hover::after,
.nav-link[aria-current="page"]::after { transform: scaleX(1); }
.nav-link[aria-current="page"] { color: var(--ink); }

.nav-tools { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 3px;
  color: var(--ink-dim);
  border: 1px solid transparent;
  transition: color .2s, border-color .2s, background-color .2s;
}
.icon-btn:hover {
  color: var(--ink);
  border-color: var(--rule);
  background: var(--surface-2);
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: .5rem;
  height: 34px;
  padding: 0 .55rem 0 .6rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink-dim);
  font-size: .8rem;
  transition: border-color .2s, color .2s;
}
.search-trigger:hover { border-color: var(--rule-strong); color: var(--ink); }
.search-trigger .kbd {
  font-family: var(--mono);
  font-size: .64rem;
  padding: .12rem .3rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink-faint);
}
.search-trigger .label { display: none; }

[data-theme="dark"] .icon-sun,  .icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
.icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* --- 7. Shell ------------------------------------------------------------ */

.wrap {
  width: var(--measure);
  margin-inline: auto;
  padding-inline: clamp(.85rem, 2vw, 1.5rem);
}

.view { min-height: 60vh; padding-bottom: clamp(4rem, 10vh, 8rem); }

/* --- 8. Masthead --------------------------------------------------------- */

.masthead {
  position: relative;
  padding: clamp(2.5rem, 9vh, 6rem) 0 clamp(1.5rem, 4vh, 2.5rem);
  border-bottom: 3px double var(--rule-strong);
  overflow: hidden;
}

.masthead-kicker {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: clamp(1rem, 3vh, 2rem);
}
.masthead-kicker .line { flex: 1; height: 1px; background: var(--rule); }

.masthead-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(3.2rem, 15vw, 12rem);
  line-height: .84;
  letter-spacing: -.045em;
  text-transform: uppercase;
}
.masthead-title .l2 { display: block; color: var(--accent); }

/* letters animate in on load */
.masthead-title .ch {
  display: inline-block;
  transform: translateY(.9em) rotate(2deg);
  opacity: 0;
  animation: chIn .9s var(--ease) forwards;
  animation-delay: calc(var(--i) * 34ms);
}
@keyframes chIn { to { transform: none; opacity: 1; } }

.masthead-sub {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
  margin-top: clamp(1.4rem, 4vh, 2.4rem);
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}
@media (min-width: 760px) {
  .masthead-sub { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 2.5rem; }
}

.standfirst {
  font-family: var(--display);
  font-size: clamp(1.02rem, 1.9vw, 1.32rem);
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 54ch;
}
.standfirst::first-letter {
  float: left;
  font-size: 3.05em;
  line-height: .82;
  padding: .06em .1em 0 0;
  font-weight: 700;
  color: var(--accent);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  align-self: start;
}
.stat {
  background: var(--bg);
  padding: .7rem .6rem;
  text-align: center;
}
.stat .n {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.3rem, 3.4vw, 1.85rem);
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat .k {
  display: block;
  margin-top: .25rem;
  font-family: var(--mono);
  font-size: .55rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* --- 9. Ticker ----------------------------------------------------------- */

.ticker {
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
  padding: .55rem 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.ticker-track {
  display: flex;
  width: max-content;
  gap: 2.2rem;
  animation: slide 64s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes slide { to { transform: translateX(-50%); } }
.ticker a {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
  transition: color .2s;
}
.ticker a:hover { color: var(--accent); }
.ticker .dot { color: var(--ink-faint); }

/* --- 10. Section headers ------------------------------------------------- */

.sec { padding-top: clamp(2.4rem, 7vh, 4.5rem); }

.sec-head {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding-bottom: .7rem;
  margin-bottom: 1.6rem;
  border-bottom: 1px solid var(--rule-strong);
}
.sec-num {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--accent);
  padding-bottom: .3rem;
}
.sec-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.2vw, 2.5rem);
  line-height: 1;
  letter-spacing: -.03em;
}
.sec-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-dim);
  white-space: nowrap;
  padding-bottom: .3rem;
}
.sec-more {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: .3rem;
  white-space: nowrap;
}
.sec-more:hover { text-decoration: underline; text-underline-offset: 3px; }

.sec-lede {
  max-width: 62ch;
  margin: -.7rem 0 1.7rem;
  color: var(--ink-dim);
  font-size: .93rem;
}

/* --- 11. Now panels ------------------------------------------------------ */

.now-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
@media (min-width: 800px) { .now-grid { grid-template-columns: 1fr 1fr; } }

.now-panel {
  background: var(--bg);
  padding: clamp(1.1rem, 2.6vw, 1.9rem);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.now-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--rule);
}
.now-head .pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2.4s var(--ease-io) infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.now-head h3 {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.now-item {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}
.now-item .art-frame { width: 78px; }
.now-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.2rem, 2.8vw, 1.6rem);
  line-height: 1.05;
  letter-spacing: -.025em;
}
.now-by {
  margin-top: .25rem;
  font-size: .82rem;
  color: var(--ink-dim);
}
.now-note {
  margin-top: .6rem;
  font-family: var(--display);
  font-size: .95rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.now-empty {
  font-size: .88rem;
  color: var(--ink-faint);
  font-style: italic;
}

/* --- 12. Art frames ------------------------------------------------------ */

.art-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  isolation: isolate;
}
.art-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .7s var(--ease), filter .5s var(--ease-io);
}
.art-frame .gen { width: 100%; height: 100%; }

/* generated fallback plate */
.art-gen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10%;
  text-align: center;
}
.art-gen .gen-title {
  position: relative;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(.7rem, 1.5vw, .98rem);
  line-height: 1.12;
  letter-spacing: -.02em;
  text-transform: uppercase;
  color: var(--ink);
  mix-blend-mode: normal;
}

/* --- 13. Poster grid ----------------------------------------------------- */

.grid {
  display: grid;
  gap: clamp(1rem, 2.2vw, 1.7rem) clamp(.8rem, 1.6vw, 1.2rem);
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
}

.card {
  position: relative;
  display: block;
  transform-style: preserve-3d;
}
.card .art-frame {
  transition: transform .5s var(--ease), box-shadow .5s var(--ease), border-color .3s;
  will-change: transform;
}
.card:hover .art-frame {
  box-shadow: var(--shadow-2);
  border-color: var(--rule-strong);
}
.card:hover .art-frame img { transform: scale(1.055); }

.card-rank {
  position: absolute;
  top: -.42rem; left: -.42rem;
  z-index: 3;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .06em;
  padding: .18rem .34rem;
  background: var(--accent);
  color: var(--bg);
  pointer-events: none;
}

.card-body { padding-top: .62rem; }
.card-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.18;
  letter-spacing: -.015em;
  transition: color .2s;
}
.card:hover .card-title { color: var(--accent); }
.card-meta {
  margin-top: .2rem;
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .04em;
  color: var(--ink-dim);
  display: flex;
  flex-wrap: wrap;
  gap: .34rem;
  align-items: center;
}
.card-meta .sep { color: var(--ink-faint); }

/* badge on the poster */
.art-badge {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: 1.4rem .5rem .42rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s var(--ease-io), transform .35s var(--ease);
}
.card:hover .art-badge, .card:focus-visible .art-badge { opacity: 1; transform: none; }
.art-badge .s {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .04em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .22rem;
}
.art-badge .s b { font-weight: 600; }
.art-badge .s.imdb b { color: #F5C518; }
.art-badge .s.rt   b { color: #FA5F55; }
.art-badge .s.mc   b { color: #7ED321; }

/* --- 14. Rating dots ----------------------------------------------------- */

.dots {
  display: inline-flex;
  gap: 2.5px;
  align-items: center;
  vertical-align: middle;
}
.dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: block;
}
.dots i.on { background: currentColor; }
.r-essential { color: var(--accent); }
.r-strong    { color: var(--ochre); }
.r-decent    { color: var(--ink-dim); }
.r-unrated   { color: var(--ink-faint); }

.rating-tag {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* --- 15. Chips / filters -------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .38rem;
  margin-bottom: 1.6rem;
}

.chip {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: .34rem .62rem;
  border: 1px solid var(--rule);
  color: var(--ink-dim);
  background: transparent;
  /* clipped corner, cubist DNA */
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%);
  transition: color .2s, border-color .2s, background-color .2s;
  white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--rule-strong); }
.chip[aria-pressed="true"], .chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.chip .c { opacity: .6; margin-left: .3rem; }

/* --- 15b. Three at random ------------------------------------------------ */

.dice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
@media (min-width: 720px)  { .dice-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .dice-grid { grid-template-columns: repeat(3, 1fr); } }

.dice-card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  background: var(--bg);
  padding: clamp(1rem, 2vw, 1.4rem);
  transition: background-color .3s var(--ease-io);
}
.dice-card:hover { background: var(--surface-2); }
.dice-card .art-frame { width: 84px; transition: box-shadow .4s var(--ease); }
.dice-card:hover .art-frame { box-shadow: var(--shadow-2); }

.dice-kind {
  display: block;
  font-family: var(--mono);
  font-size: .56rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .3rem;
}
.dice-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.08rem;
  line-height: 1.12;
  letter-spacing: -.022em;
  transition: color .2s;
}
.dice-card:hover .dice-title { color: var(--accent); }
.dice-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .34rem;
  margin-top: .3rem;
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--ink-dim);
}
.dice-meta .sep { color: var(--ink-faint); }
.dice-note {
  margin-top: .6rem;
  font-family: var(--display);
  font-size: .9rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.dice-roll {
  margin-top: 1.1rem;
  cursor: pointer;
}
.dice-roll::before { content: "\2684"; margin-right: .45rem; font-size: .95em; }

/* --- 16. Person / director groups ---------------------------------------- */

.person {
  padding: clamp(1.3rem, 3vw, 2.1rem) 0;
  border-bottom: 1px solid var(--rule);
}
.person:last-child { border-bottom: 0; }

.person-head {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.person-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.35rem, 3.6vw, 2.1rem);
  line-height: 1;
  letter-spacing: -.032em;
}
.person-count {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.person-line { flex: 1; height: 1px; background: var(--rule); min-width: 20px; }

.rail {
  display: flex;
  gap: clamp(.7rem, 1.6vw, 1.1rem);
  overflow-x: auto;
  padding-bottom: .8rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}
.rail::-webkit-scrollbar { height: 5px; }
.rail::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }
.rail::-webkit-scrollbar-thumb:hover { background: var(--rule-strong); }
.rail > * {
  flex: 0 0 clamp(126px, 30vw, 172px);
  scroll-snap-align: start;
}

/* --- 17. Ledger table ---------------------------------------------------- */

.ledger-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.ledger-search {
  flex: 1 1 220px;
  min-width: 0;
  height: 36px;
  padding: 0 .7rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: .78rem;
}
.ledger-search:focus { outline: none; border-color: var(--accent); }

.table-scroll { overflow-x: auto; border: 1px solid var(--rule); }

table.ledger {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  font-size: .82rem;
  table-layout: fixed;
}
/* No position:sticky here. The table lives inside an overflow-x container,
   which becomes the containing block for sticky and drops the header below
   the first row. A plain header is correct. */
table.ledger th {
  background: var(--bg);
  text-align: left;
  padding: .6rem .7rem;
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--rule-strong);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
table.ledger th:hover { color: var(--ink); }
table.ledger th .arrow { opacity: .45; margin-left: .2rem; }
table.ledger td {
  padding: .58rem .7rem;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
table.ledger tbody tr { transition: background-color .15s; }
table.ledger tbody tr:hover { background: var(--surface-2); }
table.ledger .t-title { font-weight: 500; }
table.ledger .t-title a:hover { color: var(--accent); }
table.ledger .t-note { color: var(--ink-dim); font-size: .78rem; }

/* Clamp on an inner div, never on the td itself: changing a td's display
   takes it out of the table layout and collapses the column. */
.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Fixed layout needs explicit widths, otherwise the note column eats the table.
   These must sum to exactly 100 or the browser rescales and starves the tail. */
table.ledger th:nth-child(1),  table.ledger td:nth-child(1)  { width: 17%; }  /* title  */
table.ledger th:nth-child(2),  table.ledger td:nth-child(2)  { width: 5%; }   /* kind   */
table.ledger th:nth-child(3),  table.ledger td:nth-child(3)  { width: 6%; }   /* region */
table.ledger th:nth-child(4),  table.ledger td:nth-child(4)  { width: 13%; }  /* by     */
table.ledger th:nth-child(5),  table.ledger td:nth-child(5)  { width: 5%; }   /* year   */
table.ledger th:nth-child(6),  table.ledger td:nth-child(6)  { width: 11%; }  /* rating */
table.ledger th:nth-child(7),  table.ledger td:nth-child(7)  { width: 4%; }   /* must   */
table.ledger th:nth-child(8),  table.ledger td:nth-child(8)  { width: 4%; }   /* imdb   */
table.ledger th:nth-child(9),  table.ledger td:nth-child(9)  { width: 4%; }   /* rt     */
table.ledger th:nth-child(10), table.ledger td:nth-child(10) { width: 4%; }   /* mc     */
table.ledger th:nth-child(11), table.ledger td:nth-child(11) { width: 11%; }  /* tags   */
table.ledger th:nth-child(12), table.ledger td:nth-child(12) { width: 16%; }  /* note   */
table.ledger .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: .74rem;
  white-space: nowrap;
}
table.ledger .t-tags {
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--ink-faint);
  overflow-wrap: anywhere;
}
table.ledger .t-title { overflow-wrap: anywhere; }

/* --- 18. Entry detail ---------------------------------------------------- */

.detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.4rem, 4vw, 3rem);
  padding-top: clamp(1.6rem, 5vh, 3rem);
}
@media (min-width: 760px) {
  .detail { grid-template-columns: minmax(180px, 270px) minmax(0, 1fr); }
}
.detail .art-frame { box-shadow: var(--shadow-2); }

.detail-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 6.5vw, 4rem);
  line-height: .95;
  letter-spacing: -.04em;
  margin-bottom: .6rem;
}
.detail-by {
  font-family: var(--display);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--ink-dim);
  margin-bottom: 1.2rem;
}
.detail-note {
  font-family: var(--display);
  font-size: clamp(1.08rem, 2.4vw, 1.4rem);
  line-height: 1.52;
  color: var(--ink);
  padding: 1.2rem 0 1.4rem;
  border-top: 3px double var(--rule-strong);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.4rem;
}
.detail-note::before {
  content: "“";
  font-size: 2.4em;
  line-height: 0;
  vertical-align: -.35em;
  color: var(--accent);
  margin-right: .06em;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-bottom: 1.4rem;
}
.fact { background: var(--bg); padding: .65rem .75rem; }
.fact .k {
  display: block;
  font-family: var(--mono);
  font-size: .55rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: .22rem;
}
.fact .v { font-size: .9rem; font-weight: 500; }

.scorebar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.4rem; }
.score {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  padding: .45rem .7rem;
  border: 1px solid var(--rule);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}
.score .src {
  font-family: var(--mono);
  font-size: .56rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.score .val {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
}
.score.link { transition: border-color .2s, color .2s; }
.score.link:hover { border-color: var(--accent); color: var(--accent); }
.score.link .val { font-size: .92rem; }
.score.imdb .val { color: #D9A343; }
.score.rt   .val { color: #E2703F; }
.score.mc   .val { color: var(--teal); }

.flagnote {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ochre);
  border-left: 2px solid var(--ochre);
  padding: .4rem .7rem;
  background: var(--surface-2);
  margin-bottom: 1.2rem;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 1rem;
}
.backlink:hover { color: var(--accent); }

/* --- 19. Command palette ------------------------------------------------- */

.palette-back {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  align-items: start;
  justify-items: center;
  padding: clamp(3rem, 12vh, 9rem) 1rem 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease-io);
}
.palette-back.open { opacity: 1; pointer-events: auto; }

.palette {
  width: min(660px, 100%);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-10px) scale(.985);
  transition: transform .28s var(--ease);
  display: flex;
  flex-direction: column;
  max-height: min(560px, 74vh);
}
.palette-back.open .palette { transform: none; }

.palette input {
  width: 100%;
  height: 54px;
  padding: 0 1rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--display);
  font-size: 1.08rem;
}
.palette input:focus { outline: none; }
.palette input::placeholder { color: var(--ink-faint); }

.palette-list { overflow-y: auto; padding: .3rem; }
.palette-group {
  font-family: var(--mono);
  font-size: .56rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: .7rem .7rem .3rem;
}
.p-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  padding: .5rem .7rem;
  text-align: left;
  border-radius: 2px;
}
.p-item[aria-selected="true"] { background: var(--accent-soft); }
.p-item[aria-selected="true"] .p-title { color: var(--accent); }
.p-item .p-thumb {
  width: 26px; height: 39px;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--rule);
  background: var(--surface-2);
}
.p-item .p-title { font-size: .88rem; font-weight: 500; }
.p-item .p-sub {
  font-family: var(--mono);
  font-size: .6rem;
  color: var(--ink-dim);
  margin-top: .1rem;
}
.p-item .p-kind {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .56rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.palette-empty { padding: 2rem 1rem; text-align: center; color: var(--ink-dim); font-size: .88rem; }
.palette-foot {
  display: flex;
  gap: 1rem;
  padding: .5rem .8rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .58rem;
  color: var(--ink-faint);
  letter-spacing: .06em;
}

/* --- 20. Reveal on scroll ------------------------------------------------ */

.rv {
  opacity: 0;
  transform: translateY(18px);
}
.rv.in {
  opacity: 1;
  transform: none;
  transition: opacity .7s var(--ease-io), transform .7s var(--ease);
  transition-delay: calc(var(--d, 0) * 42ms);
}

/* --- 21. Footer ---------------------------------------------------------- */

.foot {
  border-top: 3px double var(--rule-strong);
  margin-top: clamp(3rem, 8vh, 6rem);
  padding: clamp(1.6rem, 4vh, 2.6rem) 0 clamp(2.4rem, 6vh, 4rem);
}
.foot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  justify-content: space-between;
}
.foot a { color: var(--ink-dim); font-size: .82rem; }
.foot a:hover { color: var(--accent); }
.foot .mono { font-size: .64rem; color: var(--ink-faint); letter-spacing: .08em; }

/* --- 22. Empty / loading ------------------------------------------------- */

.loading, .empty {
  padding: clamp(3rem, 12vh, 7rem) 1rem;
  text-align: center;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.loading::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: dots 1.4s steps(4) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* --- 23. Responsive tweaks ---------------------------------------------- */

@media (min-width: 620px) { .search-trigger .label { display: inline; } }

@media (max-width: 760px) {
  .nav-links { gap: 0; }
  .nav-link { padding: .42rem .45rem; font-size: .78rem; }
  .brand span.long { display: none; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  table.ledger .t-note, table.ledger .t-tags { display: none; }
  table.ledger { min-width: 480px; }
}

@media (max-width: 420px) {
  .now-item { grid-template-columns: 62px minmax(0, 1fr); gap: .8rem; }
  .now-item .art-frame { width: 62px; }
}

/* --- 24. Motion preferences --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .rv { opacity: 1; transform: none; }
  .masthead-title .ch { opacity: 1; transform: none; }
  .grain { display: none; }
}

@media print {
  .nav, .grain, .progress, .ticker, .palette-back { display: none !important; }
}
