/* The Masterpiece Gallery — museum-grade UI
   Design system per website/DESIGN.md (Stitch taste-design standards): night-lit
   museum wing, Fraunces + Outfit, gallery-black surfaces, single muted-gold accent,
   asymmetric editorial masthead, salon-hang grid. Light + dark aware, reduced-motion
   respected, WCAG-AA contrast. */

:root {
  /* surfaces — gallery wall, never pure black (avoids OLED smear) */
  --bg:        #0d0d10;
  --bg-2:      #131318;
  --surface:   #17171d;
  --surface-2: #1e1e26;
  --border:    #2a2a33;
  --border-2:  #3a3a45;
  /* ink */
  --ink:       #ede9e2;   /* ivory/parchment */
  --ink-soft:  #b6b1a8;
  --ink-mute:  #837e75;
  /* accent — muted museum gold */
  --gold:      #c9a961;
  --gold-2:    #e0c688;
  --gold-dim:  rgba(201,169,97,.18);
  /* geometry */
  --maxw: 1400px;
  --radius: 3px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lift: 0 4px 12px rgba(0,0,0,.5), 0 24px 60px rgba(0,0,0,.55);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --serif: "Fraunces", "Iowan Old Style", ui-serif, serif;
  --sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

/* light mode — a bright museum hall */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:#f4f1ea; --bg-2:#efece4; --surface:#fffdf8; --surface-2:#f7f4ec;
    --border:#e2ddd0; --border-2:#d2ccbc;
    --ink:#1c1a15; --ink-soft:#4c4740; --ink-mute:#867f72;
    --gold:#9c7d34; --gold-2:#b8934a; --gold-dim:rgba(156,125,52,.14);
    --shadow-card:0 1px 2px rgba(60,50,30,.08), 0 10px 30px rgba(60,50,30,.10);
    --shadow-lift:0 8px 24px rgba(60,50,30,.14), 0 30px 70px rgba(60,50,30,.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -280px, rgba(201,169,97,.06), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 340px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

/* ---------------- ambient backdrop (all pages) ----------------
   #ambient sits at z-index -1: body's background propagates to the canvas (html
   sets none), so the canvas paints first, then this, then all content. ambient.js
   drops two .amb-layer children in and crossfades blurred paintings between them;
   the ::after scrim pulls everything back toward the wall colour so text contrast
   is never touched. Without JS the div is empty and the wall looks as before. */

.ambient {
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden; pointer-events: none;
}
.amb-layer {
  position: absolute; inset: -12%;          /* hide blurred edge fringing */
  background: center / cover no-repeat;
  filter: blur(52px) saturate(1.45) brightness(.95);
  opacity: 0;
  transition: opacity 4.5s var(--ease);
  will-change: opacity, transform;
  animation: amb-drift 80s ease-in-out infinite alternate;
}
.amb-layer.on { opacity: .68; }
.ambient::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 700px at 50% -280px, rgba(201,169,97,.05), transparent 70%),
    linear-gradient(180deg,
      color-mix(in srgb, var(--bg) 42%, transparent),
      color-mix(in srgb, var(--bg) 70%, transparent) 34%,
      color-mix(in srgb, var(--bg) 80%, transparent));
}
@keyframes amb-drift {
  from { transform: scale(1.03) translateY(-1.2%); }
  to   { transform: scale(1.12) translateY(1.2%); }
}
@media (prefers-reduced-motion: reduce) {
  .amb-layer { animation: none; transition: none; }
}

/* ---------------- staggered card reveal (ambient.js) ---------------- */

.grid.js-reveal .card {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s var(--ease), transform .55s var(--ease);
}
.grid.js-reveal .card.seen { opacity: 1; transform: none; }
.grid.js-reveal .card.seen:hover { transform: translateY(-4px); }

/* ---------------- back-to-top (ambient.js) ---------------- */

.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  color: var(--gold);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border-2); border-radius: 50%;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease),
              border-color .2s var(--ease), color .2s var(--ease);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { color: var(--gold-2); border-color: var(--gold); }
.to-top:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .grid.js-reveal .card { opacity: 1; transform: none; transition: none; }
  .to-top { transition: none; }
}

/* ---------------- hero (main page) ----------------
   The painting is one of the collection's own 1920px web images, passed in from
   index.html as --hero so the CSS stays collection-agnostic. Ink tokens are
   re-pinned to ivory INSIDE the hero for both color schemes: the text always
   sits on the dark-scrimmed painting, never on the light wall. */

.hero {
  position: relative;
  /* the scrim must hold its own against a BRIGHT painting (Aivazovsky skies) in
     light mode too — the ink inside the hero is pinned to ivory, so the backing
     stays dark until the very bottom, where it dissolves into the page wall */
  background:
    linear-gradient(100deg,
      color-mix(in srgb, #0d0d10 46%, transparent) 0%,
      color-mix(in srgb, #0d0d10 20%, transparent) 52%,
      transparent 78%),
    linear-gradient(180deg,
      color-mix(in srgb, #0d0d10 72%, transparent) 0%,
      color-mix(in srgb, #0d0d10 58%, transparent) 55%,
      color-mix(in srgb, #0d0d10 72%, transparent) 82%,
      var(--bg) 99%),
    var(--hero, none) center 38% / cover no-repeat #0d0d10;
  border-bottom: 1px solid var(--border);
  --ink:      #f2eee7;
  --ink-soft: #d8d2c7;
  --ink-mute: #b6afa2;
}
.hero .masthead h1 { text-shadow: 0 2px 18px rgba(0,0,0,.55); }
.hero .stats,
.hero .overline    { text-shadow: 0 1px 10px rgba(0,0,0,.6); }
.hero .collection-link {
  background: rgba(13,13,16,.55);
  border-color: rgba(255,255,255,.22);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hero-credit {
  margin: 26px 0 0;
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--ink-mute);
  text-shadow: 0 1px 8px rgba(0,0,0,.6);
}

/* ---------------- masthead ---------------- */

/* left-aligned editorial block (DESIGN.md §5 — centered composition banned);
   the painting gets the right half of the hero to breathe in */
.masthead {
  text-align: left;
  padding: clamp(48px, 8vw, 110px) 24px clamp(26px, 4vw, 44px);
  max-width: var(--maxw);
  margin: 0 auto;
}
.overline {
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--gold);
}
.masthead h1 {
  margin: 0;
  max-width: 14ch;
  font-family: var(--serif);
  font-weight: 480;
  font-size: clamp(42px, 7vw, 88px);
  line-height: 1.0;
  letter-spacing: -.018em;
  color: var(--ink);
  font-variation-settings: "opsz" 100;
}
.gold-rule {
  width: 132px; height: 1px; margin: 26px 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  position: relative;
  overflow: visible;
}
.gold-rule::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 5px; height: 5px; transform: translate(-50%,-50%) rotate(45deg);
  background: var(--gold);
}
/* perpetual micro-motion: a slow light sweep along the gilt rule (opacity-safe) */
.gold-rule::before {
  content: ""; position: absolute; inset: -1px 0;
  background: linear-gradient(90deg, transparent, var(--gold-2), transparent);
  opacity: 0;
  animation: gilt-sweep 7s var(--ease) infinite;
}
@keyframes gilt-sweep {
  0%, 62%, 100% { opacity: 0; transform: translateX(-30%) scaleX(.4); }
  78%           { opacity: .9; transform: translateX(0) scaleX(1); }
  94%           { opacity: 0; transform: translateX(30%) scaleX(.4); }
}
.gold-rule.small { width: 72px; margin: 16px 0; }
.gold-rule.small.left { margin-left: 0; }
/* centered contexts (empty state, colophon) keep their centered rules */
.empty .gold-rule, .colophon .gold-rule { margin-left: auto; margin-right: auto; }
.stats {
  margin: 0; font-size: 14px; letter-spacing: .06em;
  color: var(--ink-soft); font-variant-numeric: tabular-nums;
}

/* ---------------- sibling collections ---------------- */

.collections {
  margin: 22px 0 0;
  display: flex; justify-content: flex-start; flex-wrap: wrap; gap: 10px;
}
.collection-link {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 18px;
  font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); text-decoration: none;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
  transition: color .22s var(--ease), border-color .22s var(--ease),
              background .22s var(--ease), box-shadow .22s var(--ease);
}
.collection-link svg { width: 15px; height: 15px; color: var(--gold); }
.collection-link .collection-arrow { transition: transform .22s var(--ease); }
.collection-link:hover {
  color: var(--ink); border-color: var(--gold);
  background: var(--gold-dim); box-shadow: 0 6px 18px var(--gold-dim);
}
.collection-link:hover .collection-arrow { transform: translateX(3px); }
.collection-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .collection-link, .collection-link .collection-arrow { transition: none; }
  .collection-link:hover .collection-arrow { transform: none; }
}

/* ---------------- controls ---------------- */

.controls {
  position: sticky; top: 0; z-index: 40;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.controls-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.search {
  flex: 1 1 280px; min-width: 200px;
  height: 46px; padding: 0 16px;
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.search::placeholder { color: var(--ink-mute); }
.search:focus, select:focus, .sync-btn:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
select {
  height: 46px; padding: 0 34px 0 14px;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink-soft);
  background: var(--surface);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23c9a961' stroke-width='1.4'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  border: 1px solid var(--border); border-radius: var(--radius);
  -webkit-appearance: none; appearance: none; cursor: pointer;
  max-width: 220px; transition: border-color .2s var(--ease);
  /* flex items default to min-width:auto, so an option as long as
     "Jean-Auguste-Dominique Ingres (54)" sets the min-content width and the row
     blows past the viewport on phones. Let them shrink instead. */
  min-width: 0;
  text-overflow: ellipsis;
}
select:hover { border-color: var(--border-2); }
/* TV-safe filter dropdowns: the main-page selects are hidden behind these
   triggers + in-page lists (native select popups are dead on Google-TV) */
.flt-sel {
  position: relative; height: 46px; padding: 0 34px 0 14px; text-align: left;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; max-width: 220px; min-width: 132px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color .2s var(--ease);
}
.flt-sel::after {
  content: "\25BE"; position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); color: var(--gold); pointer-events: none;
}
.flt-sel:hover { border-color: var(--border-2); }
.flt-sel.open, .flt-sel:focus-visible {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim);
}
.flt-dd {
  position: fixed; z-index: 200; max-height: min(340px, 55vh); overflow-y: auto;
  min-width: 180px; max-width: min(380px, 92vw);
  padding: 6px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 6px; box-shadow: var(--shadow-lift);
}
.flt-dd button {
  display: block; width: 100%; padding: 9px 12px; text-align: left; cursor: pointer;
  font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
  background: transparent; border: 0; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flt-dd button:hover, .flt-dd button:focus { background: var(--surface-2); color: var(--ink); }
.flt-dd button.on { color: var(--gold); }
.sync-btn {
  height: 46px; padding: 0 22px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: #14110a; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border: 1px solid var(--gold); border-radius: var(--radius);
  transition: transform .12s var(--ease), box-shadow .2s var(--ease), opacity .2s;
  white-space: nowrap;
}
.sync-btn:hover { box-shadow: 0 6px 18px var(--gold-dim); transform: translateY(-1px); }
.sync-btn:active { transform: translateY(1px) scale(.98); box-shadow: none; }
.sync-btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }

.sync-strip {
  max-width: var(--maxw); margin: 10px auto 0;
  display: flex; align-items: center; gap: 11px;
  font-size: 12.5px; letter-spacing: .04em; color: var(--ink-soft);
}
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-mute); flex: none;
}
.sync-dot.running {
  background: var(--gold);
  box-shadow: 0 0 0 0 var(--gold);
  animation: pulse 1.6s var(--ease) infinite;
}
.sync-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(201,169,97,.5); }
  70%  { box-shadow: 0 0 0 7px rgba(201,169,97,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,169,97,0); }
}

/* ---------------- main / grid ---------------- */

main {
  max-width: var(--maxw);
  margin: 0 auto; padding: 30px 24px 64px;
}
.result-count {
  margin: 4px 2px 22px;
  font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-mute); font-variant-numeric: tabular-nums;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  grid-auto-flow: dense;
  gap: clamp(20px, 2.4vw, 38px) clamp(16px, 2vw, 30px);
}
/* salon hang (DESIGN.md §5): every 9th canvas is featured at 2×2, breaking the
   uniform wall at a slow rhythm. dense flow backfills so no holes open up. */
@media (min-width: 621px) {
  .grid .card:nth-child(9n + 1) { grid-column: span 2; grid-row: span 2; }
  /* the frame flexes to fill the 2-row track exactly — no slack under the caption */
  .grid .card:nth-child(9n + 1) .frame { aspect-ratio: auto; flex: 1; min-height: 0; }
  .grid .card:nth-child(9n + 1) .sk-img { aspect-ratio: auto; flex: 1; min-height: 0; }
  .grid .card:nth-child(9n + 1) .caption .title { font-size: 19px; }
  .grid .card:nth-child(9n + 1) .caption .artist { font-size: 14px; }
}

.card {
  cursor: pointer;
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  transition: transform .3s var(--ease);
}
.card:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; }
.frame {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.frame::after {                       /* inner gold hairline on hover */
  content: ""; position: absolute; inset: 0;
  border: 1px solid transparent; border-radius: var(--radius);
  transition: border-color .3s var(--ease);
  pointer-events: none;
}
.frame img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; opacity: 0;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.frame img[src] { opacity: 1; }
.card:hover { transform: translateY(-4px); }
.card:hover .frame { box-shadow: var(--shadow-lift); border-color: var(--border-2); }
.card:hover .frame::after { border-color: var(--gold); }
.card:hover .frame img { transform: scale(1.035); }

.caption { padding: 13px 3px 2px; }
.caption .title {
  font-family: var(--serif); font-weight: 500; font-size: 16px;
  line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.caption .artist {
  margin-top: 4px; font-size: 13px; color: var(--gold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.caption .meta {
  margin-top: 3px; font-size: 11px; letter-spacing: .04em;
  color: var(--ink-mute); font-variant: small-caps;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* skeleton shimmer */
.card.skeleton { cursor: default; pointer-events: none; }
.shimmer {
  position: relative; overflow: hidden;
  background: var(--surface-2); border-radius: 2px;
}
.shimmer::before {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  animation: slide 1.4s infinite;
}
.sk-img { width: 100%; aspect-ratio: 16/10; border-radius: var(--radius); }
.sk-line { height: 11px; margin-top: 10px; }
.sk-line.w60 { width: 60%; } .sk-line.w40 { width: 40%; }
@keyframes slide { 100% { transform: translateX(100%); } }

/* ---------------- empty ---------------- */

.empty { text-align: center; padding: 90px 24px; }
.empty-title { font-family: var(--serif); font-size: 25px; color: var(--ink); margin: 6px 0; }
.empty-sub { font-size: 14px; color: var(--ink-mute); margin: 0; }
.link-btn {
  margin-top: 18px; padding: 9px 20px;
  font-family: var(--sans); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); background: transparent;
  border: 1px solid var(--gold); border-radius: var(--radius);
  cursor: pointer; transition: background .2s var(--ease);
}
.link-btn:hover { background: var(--gold-dim); }

/* ---------------- pager ---------------- */

.pager {
  display: flex; justify-content: center; align-items: center; gap: 22px;
  margin-top: 52px;
}
.pager-btn {
  padding: 10px 22px;
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .08em;
  color: var(--ink-soft); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all .2s var(--ease);
}
.pager-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--ink); }
.pager-btn:disabled { opacity: .34; cursor: default; }
.pager-info { font-size: 13px; color: var(--ink-soft); letter-spacing: .04em; }
.pager-info input {
  width: 58px; height: 34px; margin: 0 4px; padding: 0 8px; text-align: center;
  font-family: var(--sans); font-size: 13px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.pager-info input:focus { outline: none; border-color: var(--gold); }

/* ---------------- colophon ---------------- */

.colophon { text-align: center; padding: 40px 24px 60px; }
.colophon p {
  margin: 0; font-family: var(--serif); font-style: italic;
  font-size: 14px; color: var(--ink-mute);
}

/* ---------------- lightbox ---------------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,6,8,.93);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fade .28s var(--ease);
  /* the overlay is near-black in BOTH themes — pin every ink/chrome token to the
     dark palette, or light mode paints its near-black ink on it (invisible title) */
  --ink:       #ede9e2;
  --ink-soft:  #b6b1a8;
  --ink-mute:  #918c82;
  --gold:      #c9a961;
  --gold-2:    #e0c688;
  --gold-dim:  rgba(201,169,97,.18);
  --surface:   #17171d;
  --surface-2: #1e1e26;
  --border:    #2a2a33;
  --border-2:  #3a3a45;
}
.lightbox[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lb-body {
  display: grid; grid-template-columns: minmax(0,1fr) 320px;
  gap: 26px; align-items: center;
  width: 100%; max-width: 1760px; height: 100%;
  padding: 2.5vh 2.5vw; box-sizing: border-box;
}
.lb-stage {
  margin: 0; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.lb-stage img {
  max-width: 100%; max-height: 94vh; object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 20px 70px rgba(0,0,0,.7);
  animation: rise .4s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
.lb-panel { align-self: center; max-height: 94vh; overflow-y: auto; }
.lb-panel .overline { text-align: left; margin-bottom: 12px; }
.lb-title {
  font-family: var(--serif); font-weight: 500; font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.14; color: var(--ink); margin: 0 0 8px;
}
.lb-artist { font-size: 16px; color: var(--gold); margin: 0; }
.lb-meta { margin: 4px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; }
.lb-meta dt {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-mute); padding-top: 3px;
}
.lb-meta dd {
  margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft);
}
.lb-link {
  display: inline-block; margin-top: 26px;
  font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); text-decoration: none;
  border-bottom: 1px solid var(--gold-dim); padding-bottom: 3px;
  transition: border-color .2s var(--ease);
}
.lb-link:hover { border-color: var(--gold); }

.lb-close, .lb-nav {
  position: fixed; z-index: 101;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border); border-radius: 50%;
  cursor: pointer; transition: all .2s var(--ease);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.lb-close { top: 22px; right: 24px; width: 46px; height: 46px; font-size: 26px; line-height: 1; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 30px; }
.lb-prev { left: 22px; } .lb-next { right: 22px; }
.lb-close:hover, .lb-nav:hover:not(:disabled) {
  color: #14110a; background: var(--gold); border-color: var(--gold);
}
.lb-nav:disabled { opacity: .25; cursor: default; }

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  .lb-body { grid-template-columns: 1fr; gap: 18px; padding: 4vh 5vw; height: auto; overflow-y: auto; }
  .lb-stage img { max-height: 62vh; }
  .lb-panel { max-height: none; overflow: visible; }
  .lb-nav { top: auto; bottom: 20px; transform: none; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 14px; }
  select, .flt-sel { flex: 1 1 44%; max-width: none; }
  .search { flex-basis: 100%; }
  .sync-btn { flex: 1 1 100%; }
  .caption .title { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
  .card:hover .frame img { transform: none; }
}

/* ================= Slideshow ================= */

/* trigger button in the controls bar */
.slideshow-btn {
  height: 46px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); background: transparent; cursor: pointer;
  border: 1px solid var(--gold); border-radius: var(--radius);
  transition: background .2s var(--ease), box-shadow .2s var(--ease);
  white-space: nowrap;
}
.slideshow-btn:hover { background: var(--gold-dim); box-shadow: 0 6px 18px var(--gold-dim); }
.slideshow-btn:active { transform: translateY(1px) scale(.98); }
.slideshow-btn svg { width: 13px; height: 13px; }

/* setup dialog */
.ss-modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,6,8,.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade .25s var(--ease);
}
.ss-modal[hidden] { display: none; }
.ss-dialog {
  width: min(440px, 92vw); padding: 34px 34px 28px;
  max-height: calc(100dvh - 24px); overflow-y: auto;  /* short phone-landscape screens */
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 6px; box-shadow: var(--shadow-lift);
}
.ss-dialog .overline { text-align: left; }
.ss-h { font-family: var(--serif); font-weight: 500; font-size: 26px; color: var(--ink); margin: 2px 0 0; }
.ss-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 16px 0; font-size: 14px; color: var(--ink-soft);
}
.ss-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-mute); font-size: 12px; }
.ss-row input[type=number] {
  width: 66px; height: 40px; text-align: center; padding: 0 8px;
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.ss-row select {
  height: 40px; max-width: 230px; min-width: 200px;
  color: var(--ink); background-color: var(--surface-2);
}
/* in-page dropdown replacing the native select popup (dead on Google-TV browsers) */
.ss-sel {
  position: relative; height: 40px; max-width: 230px; min-width: 200px;
  padding: 0 32px 0 12px; text-align: left; cursor: pointer;
  font-family: var(--sans); font-size: 13px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-sel::after {
  content: "\25BE"; position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); color: var(--ink-mute); pointer-events: none;
}
.ss-sel:hover, .ss-sel.open { border-color: var(--gold); }
.ss-dd {
  position: absolute; z-index: 130; max-height: min(260px, 46vh); overflow-y: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 6px; box-shadow: var(--shadow-lift);
}
.ss-dd button {
  display: block; width: 100%; padding: 9px 12px; text-align: left; cursor: pointer;
  font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
  background: transparent; border: 0; border-radius: 4px; white-space: nowrap;
}
.ss-dd button:hover, .ss-dd button:focus { background: var(--surface-2); color: var(--ink); }
.ss-dd button.on { color: var(--gold); }
.ss-check {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0; font-size: 14px; color: var(--ink-soft); cursor: pointer;
}
.ss-check input { width: 16px; height: 16px; accent-color: var(--gold); }
.ss-scope { display: flex; gap: 10px; margin: 22px 0 8px; }
.ss-scope-btn {
  flex: 1; padding: 13px 10px; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .04em; line-height: 1.3;
  color: var(--ink-soft); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .2s var(--ease);
}
.ss-scope-btn b { display: block; color: var(--ink-mute); font-weight: 400; font-size: 11px; margin-top: 3px;
  font-variant-numeric: tabular-nums; }
.ss-scope-btn.active { border-color: var(--gold); color: var(--ink); background: var(--gold-dim); }
.ss-scope-btn.active b { color: var(--gold); }
.ss-actions { display: flex; gap: 12px; margin-top: 24px; }
.ss-btn {
  flex: 1; height: 46px; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .2s var(--ease);
}
.ss-btn:hover { border-color: var(--border-2); color: var(--ink); }
.ss-btn.primary {
  color: #14110a; border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
}
.ss-btn.primary:hover { box-shadow: 0 6px 18px var(--gold-dim); }
.ss-btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.ss-btn:disabled { opacity: .5; cursor: default; }

/* fullscreen player */
.ss-player {
  position: fixed; inset: 0; z-index: 130;
  background: #060608; overflow: hidden; cursor: none;
  touch-action: manipulation;       /* no double-tap zoom; swipe nav still works */
  overscroll-behavior: contain;
}
/* persistent exit — the reliable way back to the page on phones (no Esc key).
   Mouse: rides the auto-hide UI. Touch: always faintly there. */
.ss-x {
  position: absolute; z-index: 5;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: #efece4; cursor: pointer;
  background: rgba(20,20,24,.5); border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .4s var(--ease); pointer-events: none;
}
.ss-player.show-ui .ss-x { opacity: 1; pointer-events: auto; }
@media (pointer: coarse) {
  .ss-x { opacity: .8; pointer-events: auto; }
}
.ss-player[hidden] { display: none; }
.ss-player.show-ui { cursor: default; }
.ss-stage { position: absolute; inset: 0; }
.ss-img {
  position: absolute; inset: 0; margin: auto;
  max-width: 100%; max-height: 100%; width: 100%; height: 100%;
  object-fit: contain;
  opacity: 0; will-change: transform, opacity;
}
.ss-img.show { opacity: 1; z-index: 1; }  /* incoming paints above outgoing (caption is z:2) */
/* transitions */
.ss-img.trans-fade { transition: opacity 1.1s var(--ease); }
.ss-img.trans-none { transition: none; }
.ss-img.trans-kenburns { transition: opacity 1.1s var(--ease);
  animation-timing-function: ease-out; animation-fill-mode: both; }
.ss-img.trans-slide { transition: opacity .9s var(--ease), transform .9s var(--ease); transform: translateX(6%); }
.ss-img.trans-slide.show { transform: translateX(0); }
/* fade through black — the outgoing fades on the base rule (no delay); the
   incoming's .show rule waits for that beat of darkness before rising */
.ss-img.trans-black { transition: opacity .7s var(--ease); }
.ss-img.trans-black.show { transition: opacity .8s var(--ease) .75s; }
/* blur dissolve — arrives soft-focus and sharpens */
.ss-img.trans-blur { transition: opacity 1.2s var(--ease), filter 1.2s var(--ease), transform 1.2s var(--ease);
  filter: blur(16px); transform: scale(1.05); }
.ss-img.trans-blur.show { filter: blur(0); transform: scale(1); }
/* push in — settles from slightly enlarged */
.ss-img.trans-zoom { transition: opacity 1s var(--ease), transform 1.25s var(--ease); transform: scale(1.12); }
.ss-img.trans-zoom.show { transform: scale(1); }
/* drift up */
.ss-img.trans-rise { transition: opacity 1s var(--ease), transform 1s var(--ease); transform: translateY(4.5%); }
.ss-img.trans-rise.show { transform: translateY(0); }
/* wipe + iris are COVER transitions: opacity snaps (transition lives only on the
   .show rule and animates clip-path alone) and the incoming, z-lifted by .show,
   is revealed over the still-visible outgoing — slideshow.js delays hiding the
   outgoing layer until the sweep has passed */
.ss-img.trans-wipe { clip-path: inset(0 100% 0 0); }
.ss-img.trans-wipe.show { transition: clip-path 1.15s var(--ease); clip-path: inset(0 0 0 0); }
.ss-img.trans-iris { clip-path: circle(0% at 50% 50%); }
.ss-img.trans-iris.show { transition: clip-path 1.3s var(--ease); clip-path: circle(75% at 50% 50%); }

@keyframes ss-kb1 { from { transform: scale(1) translate(0,0); } to { transform: scale(1.09) translate(-2.2%,-1.6%); } }
@keyframes ss-kb2 { from { transform: scale(1.09) translate(1.8%,1.4%); } to { transform: scale(1) translate(0,0); } }
@keyframes ss-kb3 { from { transform: scale(1) translate(1.6%,-1.4%); } to { transform: scale(1.08) translate(-1.6%,1.6%); } }
@keyframes ss-kb4 { from { transform: scale(1.08) translate(-1.8%,1.2%); } to { transform: scale(1) translate(1.4%,-1.2%); } }

/* caption */
.ss-caption {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 90px clamp(28px,6vw,90px) clamp(30px,5vh,60px);
  background: linear-gradient(0deg, rgba(0,0,0,.72), rgba(0,0,0,.30) 55%, transparent);
  pointer-events: none;
}
.ss-player.no-caption .ss-caption { display: none; }
.ss-title { font-family: var(--serif); font-weight: 500; font-size: clamp(24px,3.4vw,46px);
  line-height: 1.1; color: #f3efe7; text-shadow: 0 2px 20px rgba(0,0,0,.6); }
.ss-artist { margin-top: 8px; font-size: clamp(15px,1.6vw,21px); color: var(--gold-2);
  letter-spacing: .02em; }
.ss-cmeta { margin-top: 6px; font-size: clamp(12px,1.1vw,14px); letter-spacing: .1em;
  color: #cfc9bd; font-variant: small-caps; }

/* progress bar */
.ss-progress { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: 3px;
  background: rgba(255,255,255,.10); }
.ss-bar { display: block; height: 100%; width: 0; background: var(--gold); }

/* controls (auto-hide) */
.ss-bar-controls {
  position: absolute; z-index: 4; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 40px;
  background: rgba(20,20,24,.62); border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .4s var(--ease); pointer-events: none;
}
.ss-player.show-ui .ss-bar-controls { opacity: 1; pointer-events: auto; }
.ss-c {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--ink); background: transparent;
  border: none; border-radius: 50%; cursor: pointer; transition: background .2s var(--ease);
  touch-action: manipulation;
}
.ss-c:hover { background: rgba(255,255,255,.12); color: var(--gold-2); }
.ss-counter { padding: 0 12px; font-size: 13px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums; letter-spacing: .04em; }

@media (prefers-reduced-motion: reduce) {
  .ss-img.trans-kenburns { animation: none !important; }
}

/* ================= Collection bar (base) =================
   The themed skins (napoleon.css / roman.css) restate these with their own
   tints; this base copy lets the MAIN page carry the same bar for its link
   up to kokit.com. Identical structure, neutral colours. */

.collection-bar {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 14px; flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 24px 0;
  font-family: var(--sans);
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
}
.collection-back, .collection-here {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.collection-back { color: var(--ink-mute); }
.collection-back svg { width: 13px; height: 13px; }
.collection-back:hover { color: var(--gold); background: var(--gold-dim); }
.collection-back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.collection-here {
  color: var(--ink-soft);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
/* on the main page the bar floats over the hero painting */
.hero .collection-bar { position: relative; z-index: 2; }
.hero .collection-here {
  border-color: rgba(255,255,255,.22);
  background: rgba(13,13,16,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

/* ================= Gallery music =================
   music.js drops a pill bottom-left (mirror of .to-top) that opens a small
   radio panel: channel pills, play/pause, next-station, volume. */

.music-pill {
  position: fixed; left: 22px; bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  color: var(--gold);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border-2); border-radius: 50%;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.music-pill:hover { color: var(--gold-2); border-color: var(--gold); }
.music-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.music-pill .mp-eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.music-pill .mp-eq i {
  width: 3px; border-radius: 1px; background: var(--gold);
  animation: mp-eq 1s ease-in-out infinite;
}
.music-pill .mp-eq i:nth-child(1) { height: 60%; animation-delay: 0s; }
.music-pill .mp-eq i:nth-child(2) { height: 100%; animation-delay: .25s; }
.music-pill .mp-eq i:nth-child(3) { height: 45%; animation-delay: .5s; }
@keyframes mp-eq {
  0%, 100% { transform: scaleY(.5); }
  50%      { transform: scaleY(1); }
}
.music-pill.playing .mp-note { display: none; }
.music-pill.playing .mp-eq { display: inline-flex; }

.music-panel {
  position: fixed; left: 18px; bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 61;
  width: min(320px, calc(100vw - 36px));
  padding: 18px 18px 14px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border-2); border-radius: 8px;
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.mp-overline { text-align: left; margin: 0 0 12px; }
.mp-channels { display: flex; gap: 7px; flex-wrap: wrap; }
.mp-ch {
  flex: 1 1 auto; padding: 8px 10px; cursor: pointer;
  font-family: var(--sans); font-size: 11.5px; letter-spacing: .07em;
  text-transform: uppercase; white-space: nowrap;
  color: var(--ink-soft); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
  transition: all .2s var(--ease);
}
.mp-ch:hover { border-color: var(--border-2); color: var(--ink); }
.mp-ch.active { border-color: var(--gold); color: var(--ink); background: var(--gold-dim); }
.mp-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
}
.mp-play {
  flex: none; width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 15px; color: #14110a; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border: 1px solid var(--gold); border-radius: 50%;
  transition: box-shadow .2s var(--ease), transform .12s var(--ease);
}
.mp-play:hover { box-shadow: 0 6px 18px var(--gold-dim); }
.mp-play:active { transform: scale(.96); }
.mp-station {
  flex: 1; min-width: 0;
  font-size: 13px; color: var(--ink-soft); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mp-station:hover { color: var(--gold); }
.mp-skip {
  flex: none; width: 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 16px; color: var(--ink-mute); cursor: pointer;
  background: transparent; border: 1px solid var(--border); border-radius: 50%;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.mp-skip:hover { color: var(--gold); border-color: var(--gold); }
.mp-vol-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 13px; color: var(--ink-mute);
}
.mp-volume {
  flex: 1; height: 22px;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.mp-volume::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: var(--border-2);
}
.mp-volume::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -5.5px;
  border-radius: 50%; background: var(--gold); border: none;
}
.mp-volume::-moz-range-track { height: 3px; border-radius: 2px; background: var(--border-2); }
.mp-volume::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: none; }
.mp-note-line { margin: 10px 0 0; font-size: 12px; color: var(--ink-mute); }
.mp-credit {
  margin: 12px 0 0; font-size: 10.5px; letter-spacing: .05em;
  color: var(--ink-mute); opacity: .8;
}

/* ================= Mobile / touch refinements ================= */

button, .card, a { -webkit-tap-highlight-color: transparent; }

@media (pointer: coarse) {
  /* iOS zooms the page when a focused input's font is under 16px */
  .search, select, .pager-info input, .ss-row input[type=number] { font-size: 16px; }
  /* iOS repaints background-attachment:fixed on every scroll frame */
  body { background-attachment: scroll; }
}

@media (max-width: 620px) {
  /* the stacked search + filter rows would pin a half-screen bar to the top */
  .controls { position: static; }
  .masthead { padding-top: clamp(30px, 6vw, 48px); }
  .to-top { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .music-pill { left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .music-panel { left: 12px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .lb-close { top: 14px; right: 14px; }
}

/* slideshow chrome clears the iPhone home indicator + notch */
.ss-bar-controls { bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
.ss-caption { padding-bottom: calc(clamp(30px, 5vh, 60px) + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 620px) {
  /* five buttons + counter must fit a 320px screen */
  .ss-c { width: 40px; height: 40px; font-size: 15px; }
  .ss-counter { padding: 0 6px; font-size: 12px; }
  .ss-bar-controls { gap: 2px; padding: 6px 10px; max-width: calc(100vw - 16px); }
}
