:root {
  --bg: #0b0b0b;
  --panel: #141312;
  --frame: #262321;
  --text: #ece7df;
  --dim: #9a938a;
  --faint: #6b655e;
  --accent: #e8a317;
  --accent-ink: #171004;
  --glow: rgba(232, 163, 23, 0.34);
  --pad: 16px;
  --bar: 52px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --condensed: "Avenir Next Condensed", "Roboto Condensed", "HelveticaNeue-CondensedBold", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.locked { overflow: hidden; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

:focus { outline: none; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ---------- Header ---------- */

.top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  padding: var(--sat) calc(var(--pad) + var(--sar)) 0 calc(var(--pad) + var(--sal));
  background: linear-gradient(to bottom, rgba(11, 11, 11, 0.92), rgba(11, 11, 11, 0.55) 60%, rgba(11, 11, 11, 0));
  transition: background-color 0.2s;
}
.top.solid, .top.searching { background: rgba(11, 11, 11, 0.96); }
.top.solid { box-shadow: 0 1px 0 var(--frame); }

.top-bar {
  height: var(--bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
}
.brand-mark {
  width: 4px;
  height: 20px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--glow);
}
.brand-name {
  font: 700 19px/1 var(--condensed);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
}
.top .icon-btn { margin-right: -10px; }
.icon-btn:hover, .icon-btn:focus-visible { color: var(--accent); }

.search-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 10px;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--frame);
  border-radius: 4px;
  background: var(--panel);
  font-size: 16px; /* stops iOS zoom on focus */
  -webkit-appearance: none;
  appearance: none;
}
.search-bar input::placeholder { color: var(--faint); }
.search-bar input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-bar input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 163, 23, 0.14), 0 0 22px rgba(232, 163, 23, 0.14);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding-top: calc(var(--sat) + var(--bar));
  background: #0f0e0d;
  isolation: isolate;
}
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero-bg.is-blur {
  inset: -18%;
  width: 136%;
  height: 136%;
  filter: blur(30px) saturate(1.35) brightness(0.85);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to right, rgba(11, 11, 11, 0.9) 0%, rgba(11, 11, 11, 0.58) 45%, rgba(11, 11, 11, 0.08) 100%),
    linear-gradient(to top, #0b0b0b 0%, rgba(11, 11, 11, 0.55) 26%, rgba(11, 11, 11, 0) 58%);
}
.hero-bg:not(.is-blur) { object-position: 70% 30%; filter: brightness(0.82); }
.hero-frame {
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 10px calc(var(--pad) + var(--sar)) 18px calc(var(--pad) + var(--sal));
}
.hero-copy { flex: 1; min-width: 0; }
.hero-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: left;
}
.hero-title {
  margin: 0;
  font: 700 clamp(25px, 7.6vw, 54px)/0.98 var(--condensed);
  letter-spacing: 0.005em;
  text-transform: uppercase;
  text-wrap: balance;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.hero-title.is-long { font-size: clamp(20px, 5.8vw, 44px); }
.hero-hook {
  margin: 7px 0 0;
  max-width: 34em;
  color: #cfc8bd;
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.hero-one-sheet {
  flex: none;
  width: 22%;
  max-width: 96px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  background: #000;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--frame);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 600 15px/1.1 var(--sans);
  letter-spacing: 0.01em;
  text-decoration: none;
  text-align: center;
  transition: box-shadow 0.18s, border-color 0.18s, background-color 0.18s;
}
.btn:hover, .btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 22px var(--glow);
}
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover, .btn-primary:focus-visible { background: #f2b232; outline-offset: 3px; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn svg { flex: none; }

.badge {
  display: inline-block;
  padding: 3px 6px 2px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  background: rgba(11, 11, 11, 0.78);
  color: #d9d2c7;
  font: 600 9px/1.2 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-lib { border-color: rgba(232, 163, 23, 0.55); color: var(--accent); }
.hero .badge { font-size: 10px; padding: 4px 7px 3px; }

/* ---------- Rows ---------- */

.row { margin-top: 16px; }
#home > div:first-of-type > .row:first-child { margin-top: 12px; }
.row-title {
  margin: 0 0 9px;
  padding: 0 calc(var(--pad) + var(--sar)) 0 calc(var(--pad) + var(--sal));
  font: 700 17px/1.1 var(--condensed);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.rail {
  --card-w: clamp(104px, 28.5vw, 168px);
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 6px calc(var(--pad) + var(--sar)) 24px calc(var(--pad) + var(--sal));
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-left: calc(var(--pad) + var(--sal));
  scroll-padding-right: calc(var(--pad) + var(--sar));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > li { flex: none; width: var(--card-w); scroll-snap-align: start; }
.rail[data-shape="square"] { --card-w: clamp(112px, 30.5vw, 180px); padding-bottom: 6px; }
.rail[data-shape="wide"] { --card-w: clamp(196px, 56vw, 300px); padding-bottom: 6px; }

.card {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.art {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid var(--frame);
  border-radius: 4px;
  background: #0e0d0c;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
[data-shape="square"] .art { aspect-ratio: 1 / 1; }
[data-shape="wide"] .art { aspect-ratio: 16 / 9; }
.art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
[data-mixed] .art img { object-position: 50% 22%; }

.card:hover .art, .card:focus-visible .art {
  border-color: rgba(232, 163, 23, 0.75);
  box-shadow: 0 0 0 1px rgba(232, 163, 23, 0.25), 0 6px 26px var(--glow);
}
.card:focus-visible { outline: none; }
@media (hover: hover) {
  .card:hover .art { transform: translateY(-2px); }
}

/* Missing art: near-black card, title in serif. */
.art.no-art {
  display: grid;
  place-items: center;
  padding: 12px 10px 22px;
  background: linear-gradient(160deg, #161413, #0c0b0b 70%);
}
.art.no-art::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 18px;
  height: 2px;
  background: var(--accent);
  opacity: 0.8;
}
.no-art-title {
  font: 600 14px/1.15 var(--serif);
  color: #e6dfd3;
  text-align: center;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

.card .badges {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  display: flex;
  flex-wrap: wrap-reverse;
  gap: 3px;
  pointer-events: none;
}
.card .badge { font-size: 8px; padding: 2px 4px 1px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.cap {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.25;
  color: #cfc8bd;
  overflow: hidden;
}
/* Poster rows: title appears under the card on hover or focus only. */
[data-shape="poster"] .cap {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s;
}
[data-shape="poster"] .card:hover .cap,
[data-shape="poster"] .card:focus-visible .cap { opacity: 1; color: var(--text); }
/* Square and wide rows: always a two-line title. */
[data-shape="square"] .cap, [data-shape="wide"] .cap {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  min-height: 2.5em;
}

/* ---------- Search results ---------- */

.results {
  padding: calc(var(--sat) + var(--bar) + 66px) calc(var(--pad) + var(--sar)) 8px calc(var(--pad) + var(--sal));
  min-height: 70vh;
}
.results-count {
  margin: 0 0 12px;
  color: var(--dim);
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.results-empty { margin: 28px 0; color: var(--dim); font-size: 15px; }
.grid {
  display: grid;
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
.grid[data-shape="poster"] { row-gap: 26px; margin-bottom: 34px; }
.grid[data-shape="wide"] { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.status { margin: 0; padding: 40vh var(--pad) 0; color: var(--dim); text-align: center; }

/* ---------- Footer ---------- */

.foot {
  margin-top: 26px;
  padding: 18px calc(var(--pad) + var(--sar)) calc(22px + var(--sab)) calc(var(--pad) + var(--sal));
  border-top: 1px solid #1a1817;
}
.foot p {
  margin: 0;
  max-width: 46em;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- Bottom sheet ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.66);
  opacity: 0;
  transition: opacity 0.22s;
}
.scrim.open { opacity: 1; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 560px;
  max-height: calc(100dvh - var(--sat) - 28px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--frame);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: var(--panel);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.7);
  transform: translateY(102%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { transform: none; }
.sheet:focus-visible { outline: none; }
.sheet-grip {
  flex: none;
  width: 38px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: #3a3632;
}
.sheet-close { position: absolute; top: 8px; right: 8px; z-index: 1; color: var(--dim); }
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px calc(var(--pad) + var(--sar)) calc(18px + var(--sab)) calc(var(--pad) + var(--sal));
}
.sheet-head { display: flex; gap: 14px; align-items: flex-end; padding-right: 36px; }
.sheet-art { flex: none; width: 96px; }
.sheet-art[data-shape="square"] { width: 96px; }
.sheet-art[data-shape="wide"] { width: 136px; }
.sheet-art .no-art-title { font-size: 12px; }
.sheet-head-text { flex: 1; min-width: 0; }
.sheet-title {
  margin: 0;
  font: 700 25px/1.02 var(--condensed);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.sheet-meta { margin: 7px 0 0; color: var(--dim); font-size: 12.5px; line-height: 1.35; }
.sheet-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.sheet-summary { margin: 15px 0 0; color: #d6cfc4; font-size: 14.5px; line-height: 1.45; }
.sheet-note {
  margin: 12px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  color: #c9c1b5;
  font-size: 12.5px;
  line-height: 1.4;
}
.sheet-actions { display: grid; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { width: 100%; min-height: 48px; }

/* ---------- Larger screens ---------- */

@media (min-width: 720px) {
  :root { --pad: 28px; }
  .hero-frame { aspect-ratio: auto; height: min(52vh, 460px); padding-bottom: 30px; }
  .hero-hook { font-size: 16px; }
  .hero-one-sheet { max-width: 120px; margin-right: 4vw; }
  .row-title { font-size: 19px; }
  .rail { gap: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .grid[data-shape="wide"] { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .sheet { bottom: 4vh; border-bottom: 1px solid var(--frame); border-radius: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
