/* ==========================================================================
   Padampetti — "Onn Color akiyalo?" (the visual mode)

   A second, opt-in presentation. Everything is scoped to [data-ui="visual"],
   so the austere monospace system in app.css is completely untouched.

   This mode deliberately breaks the minimal contract on purpose: colour,
   imagery, gradients, shadows and rounded corners are allowed here. Two hard
   rules still hold:
     · No inline styles — the CSP has no 'unsafe-inline' for style-src, so
       every image is an <img> and every position is a class.
     · Text on an image sits on a scrim, so it stays WCAG AA.
   ========================================================================== */

[data-ui="visual"] {
  /* Deep cinema canvas — posters pop against it. */
  --ink: #f8f5ff;
  --ink-deep: #ffffff;
  --canvas: #14121a;
  --surface-soft: #1c1826;
  --surface-card: #251f33;
  --surface-dark: #0d0b12;
  --surface-dark-elevated: #251f33;
  --hero-scrim: rgba(13, 11, 18, 0.86);

  --charcoal: #251f33;
  --body: #d9d3e8;
  --mute: #b6adc9;
  --stone: #9c92b3;
  --ash: #8f859f;

  --on-dark: #f8f5ff;
  --on-dark-mute: #b6adc9;

  --hairline: rgba(255, 255, 255, 0.12);
  --hairline-strong: #b6adc9;

  /* Vivid, but tuned for the dark canvas so every pair clears AA. */
  --accent: #ff5c8a;
  --warning: #ffb020;
  --danger: #ff6b6b;
  --success: #3ddc84;
  --warning-text: #ffc45c;
  --danger-text: #ff9090;
  --success-text: #6ee7a8;

  --r-sm: 10px;
  --r-card: 14px;
}

[data-ui="visual"] body {
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(255, 92, 138, 0.16), transparent 60%),
    radial-gradient(900px 500px at 92% 4%, rgba(96, 78, 255, 0.18), transparent 62%),
    var(--canvas);
  background-attachment: fixed;
}

/* ------------------------------------------------------------------- nav --- */

[data-ui="visual"] .nav {
  background: rgba(13, 11, 18, 0.72);
  backdrop-filter: blur(10px);
  border-bottom-color: var(--hairline);
}
[data-ui="visual"] .nav-links a[aria-current="page"] { color: var(--accent); }
[data-ui="visual"] .ui-toggle { color: var(--accent); }
[data-ui="visual"] .ui-toggle:hover { color: var(--ink); }

/* ------------------------------------------------------------------ hero --- */

[data-ui="visual"] .hero {
  position: relative;
  overflow: hidden;
  border-radius: 0 0 24px 24px;
  background: linear-gradient(135deg, #2a1330 0%, #161226 45%, #0d0b12 100%);
  border: 0;
}
[data-ui="visual"] .film-hero { border-radius: var(--r-card); margin-top: 24px; }

/* A backdrop still behind the hero, dimmed by a scrim so the text stays AA. */
[data-ui="visual"] .hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
[data-ui="visual"] .hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.34;
  filter: saturate(1.15);
}
[data-ui="visual"] .hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(13, 11, 18, 0.94) 0%, rgba(13, 11, 18, 0.72) 55%, rgba(13, 11, 18, 0.9) 100%);
}
[data-ui="visual"] .hero-frame { position: relative; z-index: 1; }

[data-ui="visual"] .hero-frame { display: grid; gap: 14px; }
[data-ui="visual"] .film-hero .hero-frame {
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
[data-ui="visual"] .film-hero .hero-frame > :not(.film-poster) { grid-column: 2; }
[data-ui="visual"] .film-poster {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
  width: 168px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--r-card);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  background: var(--surface-card);
}
@media (max-width: 640px) {
  [data-ui="visual"] .film-hero .hero-frame { grid-template-columns: 1fr; }
  [data-ui="visual"] .film-hero .hero-frame > :not(.film-poster) { grid-column: 1; }
  [data-ui="visual"] .film-poster { grid-row: auto; width: 132px; }
}

[data-ui="visual"] .section-head .marker { color: var(--accent); }
[data-ui="visual"] .hero-lede { color: var(--accent); }
[data-ui="visual"] .film-hero .film-title { font-size: 44px; }
[data-ui="visual"] .tag {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--hairline);
}

/* --------------------------------------------------------------- buttons --- */

[data-ui="visual"] .btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0710;
  border-radius: 999px;
  font-weight: 700;
}
[data-ui="visual"] .btn:hover,
[data-ui="visual"] .btn:active { background: #ff7ba1; border-color: #ff7ba1; }
[data-ui="visual"] .btn.secondary {
  background: transparent;
  border-color: var(--hairline-strong);
  color: var(--ink);
}
[data-ui="visual"] .btn.secondary:hover { background: rgba(255, 255, 255, 0.08); }

/* ------------------------------------------------------------ film rows --- */

[data-ui="visual"] .film-rows { border-top: 0; }

[data-ui="visual"] .row {
  grid-template-columns: 46px 5ch minmax(0, 1fr) 22ch 9ch 12ch;
  grid-template-areas: "poster mark title meta community gross";
  align-items: center;
  gap: 6px 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  transition: background 120ms ease, transform 120ms ease;
}
[data-ui="visual"] .row:hover {
  background: var(--surface-soft);
  transform: translateX(2px);
}
[data-ui="visual"] .row-poster {
  grid-area: poster;
  display: block;
  width: 46px;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-card);
}
[data-ui="visual"] .row-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
[data-ui="visual"] .row-head { display: none; }

/* A poster-less film still needs a tidy placeholder, not a collapsed cell. */
[data-ui="visual"] .row-poster.is-empty::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(45deg, #241f33, #241f33 6px, #2b2440 6px, #2b2440 12px);
}

/* --------------------------------------------------------- poster grid --- */

[data-ui="visual"] .poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
[data-ui="visual"] .film-card { display: grid; gap: 8px; text-decoration: none; color: var(--body); }
[data-ui="visual"] .film-card .poster {
  width: 100%;
  /* `height: auto` is load-bearing: the <img> carries a height ATTRIBUTE to
     reserve space, and a presentational hint is a definite height — which stops
     aspect-ratio from ever applying and stretches the poster instead. */
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--r-card);
  background: var(--surface-card);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  transition: transform 160ms ease;
}
[data-ui="visual"] .film-card:hover .poster { transform: translateY(-4px); }
[data-ui="visual"] .film-card .poster-empty {
  display: block;
  background: repeating-linear-gradient(45deg, #241f33, #241f33 6px, #2b2440 6px, #2b2440 12px);
}
[data-ui="visual"] .film-card .card-name { color: var(--ink); font-weight: 700; line-height: 1.35; }
[data-ui="visual"] .film-card .card-meta { color: var(--mute); font-size: 13px; }

/* --------------------------------------------------------- cast strip --- */

[data-ui="visual"] .cast-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 116px;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: thin;
}
[data-ui="visual"] .cast-card { display: grid; gap: 6px; }
[data-ui="visual"] .cast-photo {
  width: 116px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--r-card);
  background: var(--surface-card);
}
[data-ui="visual"] .cast-photo.is-empty {
  background: repeating-linear-gradient(45deg, #241f33, #241f33 6px, #2b2440 6px, #2b2440 12px);
}
[data-ui="visual"] .cast-card .cast-name { color: var(--ink); font-size: 13px; line-height: 1.35; }
[data-ui="visual"] .cast-card .cast-role { color: var(--mute); font-size: 12px; }

/* -------------------------------------------------------------- stills ---
   A deck of cards. At rest the stills sit packed on top of each other; while
   the pointer is over the deck it fans out into a coverflow; a few idle seconds
   later it packs itself away.

   Each card carries a distance class (`d0`, `d1`, `d-1`, `d2`, `d-2`, `dfar-r`,
   `dfar-l`) assigned by film.js. Positioning is a closed set of classes rather
   than inline transforms, because the CSP has no 'unsafe-inline' for style-src. */
[data-ui="visual"] .stills { position: relative; }

[data-ui="visual"] .still-deck {
  position: relative;
  height: 330px;
  /* The cards are absolutely positioned and fan out well past the deck. Without
     clipping they extend the DOCUMENT width, which on a phone shoves the whole
     page sideways. Clip at the deck, so the coverflow bleeds off its own edges
     instead of the viewport's. */
  overflow: hidden;
}

[data-ui="visual"] .still {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 300px;
  height: 169px; /* 16:9 */
  margin: -84px 0 0 -150px;
  padding: 0;
  border: 0;
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--surface-card);
  cursor: zoom-in;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  transition: transform 460ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 460ms ease;
}
[data-ui="visual"] .still img { display: block; width: 100%; height: 100%; object-fit: cover; }
[data-ui="visual"] .still:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Fanned out: the current still steps forward, the rest fall away behind it. */
[data-ui="visual"] .stills.is-open .still.d0 { transform: translateX(0) scale(1.22); z-index: 30; opacity: 1; }
[data-ui="visual"] .stills.is-open .still.d1 { transform: translateX(52%) scale(0.92); z-index: 20; opacity: 0.72; }
[data-ui="visual"] .stills.is-open .still.d-1 { transform: translateX(-52%) scale(0.92); z-index: 20; opacity: 0.72; }
[data-ui="visual"] .stills.is-open .still.d2 { transform: translateX(94%) scale(0.78); z-index: 10; opacity: 0.42; }
[data-ui="visual"] .stills.is-open .still.d-2 { transform: translateX(-94%) scale(0.78); z-index: 10; opacity: 0.42; }
[data-ui="visual"] .stills.is-open .still.dfar-r { transform: translateX(124%) scale(0.66); z-index: 5; opacity: 0; }
[data-ui="visual"] .stills.is-open .still.dfar-l { transform: translateX(-124%) scale(0.66); z-index: 5; opacity: 0; }

/* Packed: a tidy stack with just the corners showing. */
[data-ui="visual"] .stills:not(.is-open) .still.d0 { transform: translate(0, 0) scale(1); z-index: 30; opacity: 1; }
[data-ui="visual"] .stills:not(.is-open) .still.d1 { transform: translate(9px, -9px) scale(0.985); z-index: 29; opacity: 0.9; }
[data-ui="visual"] .stills:not(.is-open) .still.d-1 { transform: translate(-9px, -9px) scale(0.985); z-index: 29; opacity: 0.9; }
[data-ui="visual"] .stills:not(.is-open) .still.d2 { transform: translate(18px, -18px) scale(0.97); z-index: 28; opacity: 0.7; }
[data-ui="visual"] .stills:not(.is-open) .still.d-2 { transform: translate(-18px, -18px) scale(0.97); z-index: 28; opacity: 0.7; }
[data-ui="visual"] .stills:not(.is-open) .still.dfar-r,
[data-ui="visual"] .stills:not(.is-open) .still.dfar-l { transform: translate(0, -24px) scale(0.96); z-index: 1; opacity: 0; }

[data-ui="visual"] .still-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
[data-ui="visual"] .still-nav {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-card);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
[data-ui="visual"] .still-nav:hover { background: var(--accent); border-color: var(--accent); color: #1a0710; }

/* In the colour mode the cast is shown as portraits (the Cast strip), so the
   plain name list in "Cast and crew" is redundant. The `cast-imaged` class is
   only set when portrait rows actually exist, so a film without them keeps its
   names in both modes. */
[data-ui="visual"] body.cast-imaged .cast-text { display: none; }

/* Phones: a 300px card makes the fan mostly off-screen, so shrink the deck. The
   fan offsets are percentages of the card, so they scale with it. */
@media (max-width: 700px) {
  [data-ui="visual"] .still-deck { height: 250px; }
  [data-ui="visual"] .still {
    width: 220px;
    height: 124px; /* 16:9 */
    margin: -62px 0 0 -110px;
  }
  [data-ui="visual"] .stills:not(.is-open) .still.d1 { transform: translate(7px, -7px) scale(0.985); }
  [data-ui="visual"] .stills:not(.is-open) .still.d-1 { transform: translate(-7px, -7px) scale(0.985); }
  [data-ui="visual"] .stills:not(.is-open) .still.d2 { transform: translate(14px, -14px) scale(0.97); }
  [data-ui="visual"] .stills:not(.is-open) .still.d-2 { transform: translate(-14px, -14px) scale(0.97); }
}

/* ------------------------------------------------------- stills lightbox ---
   Opened from the deck. Unscoped: it is created on demand and uses tokens that
   resolve per theme, so it reads correctly in either mode. */
.still-dialog {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-card);
  background: var(--canvas);
  color: var(--body);
}
.still-dialog::backdrop { background: rgba(0, 0, 0, 0.74); }
.still-dialog img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  background: #000;
}
.still-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
}
.still-dialog-count { color: var(--stone); font-size: 14px; }
.still-attrib { margin: 0; padding: 10px 14px 0; color: var(--stone); font-size: 13px; }
.still-dialog-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px 16px;
}

/* ------------------------------------------------------------- surfaces --- */

[data-ui="visual"] .entry,
[data-ui="visual"] .notice,
[data-ui="visual"] .data-row {
  border-radius: var(--r-sm);
}
[data-ui="visual"] .entry { border-color: var(--hairline); }
[data-ui="visual"] .ascii-chart { color: var(--body); }
[data-ui="visual"] .toast {
  background: var(--surface-card);
  border-color: var(--accent);
  border-radius: var(--r-sm);
}
[data-ui="visual"] .toast .marker { color: var(--accent); }

/* ------------------------------------------------------- TMDB attribution ---
   Quiet, but present in both modes: the API terms require it wherever the
   data is shown, and the same records render in the minimal mode. */
.tmdb-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ash);
}
.tmdb-note a { color: inherit; text-decoration: underline; }

/* ============================================================ profile/list ===
   The profile tabs (reviews, diary, watchlist, lists) and the list detail page
   were still rendering as the minimal hairline rows in colour mode. These turn
   the tab bar into pills and the rows into cards with artwork, so the mode is
   consistent rather than merely recoloured.

   `.thumb` is only ever SHOWN here. In the minimal mode it is display:none, and
   a display:none lazy image is never fetched — so the minimal pages stay
   image-free even though the markup carries the poster.
   ============================================================ */

.thumb { display: none; }

[data-ui="visual"] .tabs { border-bottom: 0; gap: 8px; margin-bottom: 22px; }
[data-ui="visual"] .tab {
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 8px 18px;
  color: var(--mute);
}
[data-ui="visual"] .tab:hover { color: var(--ink); border-color: var(--hairline-strong); }
[data-ui="visual"] .tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0710;
  font-weight: 700;
}

/* --- reviews ---------------------------------------------------------- */
[data-ui="visual"] .entry-list { display: grid; gap: 12px; }
[data-ui="visual"] .entry {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--surface-soft);
}
[data-ui="visual"] .entry + .entry { border-top: 1px solid var(--hairline); }
[data-ui="visual"] .entry-main { flex: 1 1 auto; min-width: 0; }
[data-ui="visual"] .entry .thumb {
  display: block;
  flex: 0 0 auto;
  width: 64px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-card);
}

/* --- diary / watchlist / lists ---------------------------------------- */
[data-ui="visual"] .data-row {
  grid-template-columns: 46px 11ch minmax(0, 1fr) 12ch;
  align-items: center;
  gap: 6px 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--surface-soft);
}
[data-ui="visual"] .data-row:hover { background: var(--surface-card); }
[data-ui="visual"] .data-row .thumb {
  display: block;
  width: 46px;
  height: 69px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-card);
}
[data-ui="visual"] .thumb-empty {
  display: block;
  width: 46px;
  height: 69px;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, #241f33, #241f33 6px, #2b2440 6px, #2b2440 12px);
}
[data-ui="visual"] .list-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 69px;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-card);
}
[data-ui="visual"] .list-badge-n { color: var(--accent); font-size: 20px; font-weight: 700; }

/* The star row and dates sit on a lighter card now, so give them room. */
[data-ui="visual"] .data-sub { color: var(--mute); }
/* -------------------------------------------------------- list pages (visual) --- */
[data-ui="visual"] .list-cover { display: block; }
[data-ui="visual"] .list-meta-card { display: none; }
[data-ui="visual"] .lrow {
  grid-template-columns: 46px 64px minmax(0, 1fr) auto;
  grid-template-areas: "poster rank main val";
  align-items: center;
}
[data-ui="visual"] .lposter { grid-area: poster; display: block; width: 46px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--surface-card); }
[data-ui="visual"] .lposter img { width: 100%; height: 100%; object-fit: cover; display: block; }
[data-ui="visual"] .lposter.is-empty::after { content: ""; display: block; width: 100%; height: 100%; background: repeating-linear-gradient(45deg, #241f33, #241f33 6px, #2b2440 6px, #2b2440 12px); }

/* list hub: show the covers in the colour mode */
[data-ui="visual"] .lcard { border-color: transparent; padding: 0; gap: 8px; }
[data-ui="visual"] .lcard-cover { display: block; border-color: transparent; }
[data-ui="visual"] .lcard-name { font-size: 15px; }
