/* ════════════════════════════════════════════════════════════════════
   TM Live for Fire TV — card grid.
   Design tokens and card construction carried over from TMLive's app.css.
   Sizes are scaled up for a 10-foot viewing distance; the layout is authored
   against a fixed 1920x1080 stage that index.html scales to the panel.
   ════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/Inter-VF.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-display: block;
}

:root {
  /* Brand — exact Figma value rgb(236,105,26) */
  --tm-orange:        #EC691A;
  --tm-orange-glow:   rgba(236, 105, 26, 0.32);

  --bg-base:          #080808;
  --bg-surface:       #111111;
  --bg-card:          #141414;

  --text-100:         #FFFFFF;
  --text-60:          rgba(255, 255, 255, 0.60);
  --text-35:          rgba(255, 255, 255, 0.35);

  --border-1:         rgba(255, 255, 255, 0.06);

  --live-red:         #FF3B3B;
  --live-red-dim:     rgba(255, 59, 59, 0.16);

  --nav-h:            72px;

  /* 5% of 1920. Tighter than that puts the left live card in the Fire TV
     overscan crop, which is what made it look sliced off. */
  --pad-x:            96px;
  --pad-safe:         56px;
  --card-gap:         28px;
  --card-radius:      24px;
  --shelf-height:     112px;

  --ease-spring:      cubic-bezier(0.34, 1.3, 0.64, 1);
  --ease-out:         cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color-scheme: dark;
}

html:has(body.is-native-player),
body.is-native-player {
  background: transparent !important;
}

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text-100);
  /* A TV remote has no pointer; suppress any tap highlight artefacts. */
  -webkit-tap-highlight-color: transparent;
  cursor: none;
  user-select: none;
}

body.is-pointer {
  cursor: default;
}

body.is-pointer .course-card,
body.is-pointer .setup-btn,
body.is-pointer .chrome-btn,
body.is-pointer .app-tab,
body.is-pointer .app-back,
body.is-pointer .browse-btn {
  cursor: pointer;
}

*[hidden] { display: none !important; }
/* transition.js toggles a `hidden` class rather than the attribute, matching
   My TML's feed markup, so both spellings have to hide. */
.hidden { display: none !important; }

/* The whole UI is authored at 1920x1080 and scaled, so layout is identical
   regardless of the WebView viewport or device density. */
#stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  overflow: hidden;
  background: var(--bg-base);
  z-index: 1;
}

/* Transparent so TextureViews / soft tiles / the black root show through.
   Raising z-index here only reorders inside the WebView — it cannot cover
   a TextureView. Menu chrome still needs overlayReserve() to shrink video. */
body.is-playing #stage {
  background: transparent;
}

body.is-playing.is-overlay #stage,
body.is-playing.is-transitioning #stage {
  z-index: 12;
}

.view {
  position: absolute;
  inset: 0;
}

.app-back {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-60);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  z-index: 40;
  opacity: 0.42;
  pointer-events: none;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease,
    transform 0.18s ease;
}

.app-back.is-ready {
  opacity: 1;
  pointer-events: auto;
}

.app-back img {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

#appBack {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 40;
}

body.is-pointer.is-playing #appBack {
  display: flex;
  opacity: 0;
  pointer-events: none;
  background: rgba(8, 8, 8, 0.72);
  border-color: #34302d;
  color: var(--text-100);
}

body.is-pointer.is-playing.is-player-back #appBack {
  opacity: 1;
  pointer-events: auto;
}

body.is-pointer.is-playing.is-player-back #appBack:active {
  border-color: var(--tm-orange);
}

.app-back.is-focused,
.app-back:focus-visible {
  color: var(--text-100);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(236, 105, 26, 0.45);
  box-shadow: 0 0 0 1px rgba(236, 105, 26, 0.18);
  transform: translateX(-2px);
}

body.is-pointer .app-back {
  cursor: pointer;
}

/* ---------- Grid view ---------- */

.grid-view {
  display: flex;
  flex-direction: column;
  padding: var(--nav-h) var(--pad-x) var(--pad-safe);
  overflow: visible;
  background: var(--bg-base);
}

body.is-live-home .grid-view,
body.is-live-home #stage {
  background: transparent;
}

/* ── Home tab dropdown (replaces top bar) ── */

.home-tab-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 55;
  pointer-events: auto;
  transform-origin: top left;
}

body.is-discover .home-tab-menu,
body.is-proposal .home-tab-menu {
  z-index: 60;
}

body.is-playing .home-tab-menu,
body.is-proposal .home-tab-menu[hidden] {
  display: none;
}

body.is-pointer:not(.is-tab-menu-unlocked) .home-tab-menu {
  display: none;
}

body.is-pointer .grid-view > .section-label {
  display: none;
}

.home-tab-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 8, 8, 0.82);
  backdrop-filter: blur(10px);
  color: var(--text-100);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.home-tab-trigger.is-focused,
.home-tab-trigger:focus-visible,
.home-tab-menu.is-open .home-tab-trigger {
  border-color: rgba(236, 105, 26, 0.45);
  background: rgba(17, 17, 17, 0.94);
  box-shadow: 0 0 0 1px rgba(236, 105, 26, 0.16);
}

.home-tab-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 24px;
}

.home-tab-chevron {
  width: 12px;
  height: 12px;
  opacity: 0.65;
  transform: rotate(-90deg);
  transition: transform 0.2s ease;
}

.home-tab-menu.is-open .home-tab-chevron {
  transform: rotate(90deg);
}

.home-tab-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 168px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-1);
  background: rgba(8, 8, 8, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.home-tab-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-60);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.home-tab-option.is-current {
  color: var(--text-100);
}

.home-tab-option.is-focused {
  color: var(--text-100);
  background: rgba(255, 255, 255, 0.08);
}

.home-tab-option--proposal span {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.home-tab-option--proposal em {
  font-style: normal;
  font-weight: 700;
}

.home-tab-option--proposal span span {
  font-size: 11px;
  color: var(--text-60);
  font-weight: 500;
}

.home-tab-option img {
  width: 16px;
  height: 16px;
  opacity: 0.9;
}

/* Legacy top bars — hidden; home-tab-menu replaces them. */
.app-nav,
.discover-nav,
.browse-nav,
#stage > .app-back,
.app-nav .app-back,
.discover-nav .app-back,
.browse-nav .app-back {
  display: none !important;
}

.app-nav,
.discover-nav,
.browse-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

body.is-top-nav .app-nav,
body.is-top-nav-peek .app-nav,
body.is-top-nav .discover-nav,
body.is-top-nav-peek .discover-nav,
body.is-top-nav .browse-nav,
body.is-top-nav-peek .browse-nav,
body.is-discover .discover-nav,
/* Web / TM Browser — nav must stay visible; peek-only hid it with no way out. */
body.is-html-player.is-live-home .app-nav,
body.is-html-player .browse-nav {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

body.is-discover .discover-nav .nav-inner {
  background: rgba(8, 8, 8, 0.88);
  border-color: var(--border-1);
}

.nav-inner {
  display: flex;
  align-items: center;
  min-height: var(--nav-h);
  padding: 0 var(--pad-x);
  gap: 28px;
  background: linear-gradient(
    180deg,
    rgba(8, 8, 8, 0.97) 0%,
    rgba(8, 8, 8, 0) 100%
  );
  border-bottom: 1px solid transparent;
  transition: background 0.35s ease, border-color 0.35s ease;
}

body.is-top-nav .nav-inner,
body.is-top-nav-peek .nav-inner {
  background: rgba(8, 8, 8, 0.94);
  border-color: var(--border-1);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.nav-icon-img {
  height: 38px;
  width: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.nav-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 0;
  padding-top: 2px;
}

.nav-word-live {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.38em;
  color: var(--tm-orange);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-nav .app-back,
.discover-nav .app-back {
  position: static;
  flex: 0 0 auto;
}

.app-wordmark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
  z-index: 6;
}

.app-wordmark .tm-icon {
  height: 30px;
  width: 30px;
  border-radius: 8px;
  opacity: 0.5;
  object-fit: cover;
}

.masthead {
  display: flex;
  align-items: center;
  gap: 26px;
  padding-bottom: 20px;
  padding-left: 72px;
  flex: 0 0 auto;
}

.masthead-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.masthead-mark .tm-icon { height: 40px; }
.masthead-mark .tm-letters { height: 26px; }

.app-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-tab {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-60);
  border: none;
  background: transparent;
  transition: color 0.18s ease, background 0.18s ease;
}

.app-tab.is-current,
.app-tab.is-focused {
  color: var(--text-100);
  background: rgba(255, 255, 255, 0.07);
  font-weight: 600;
  border: none;
  box-shadow: none;
}

.masthead-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.masthead-title span {
  display: block;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-35);
  letter-spacing: 0.02em;
  margin-top: 4px;
}

.masthead-divider {
  width: 2px;
  height: 52px;
  background: var(--border-1);
}

.masthead-hint {
  margin-left: auto;
  font-size: 22px;
  color: var(--text-60);
  letter-spacing: 0.02em;
}

.setup-btn,
.nav-spotify-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-60);
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.nav-spotify-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-spotify-btn img {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  opacity: 0.9;
}

.setup-btn.is-focused,
.nav-spotify-btn.is-focused {
  color: var(--text-100);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(236, 105, 26, 0.35);
  box-shadow: none;
}

.setup-overlay,
.agents-picker-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.agents-picker-overlay[hidden] {
  display: none;
}

.agents-picker-card {
  width: 920px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px 36px;
  border-radius: 24px;
  background: rgba(8, 8, 8, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.agents-picker-note {
  font-size: 18px;
  color: var(--text-60);
  line-height: 1.45;
}

.agents-picker-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agents-picker-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-60);
}

.agents-picker-input {
  font: inherit;
  font-size: 22px;
  color: var(--text-100);
  background: #191817;
  border: 1px solid var(--border-1);
  border-radius: 12px;
  padding: 12px 14px;
}

.agents-picker-actions {
  margin-top: 4px;
}

.agents-from-badge {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-60);
  flex: 0 0 auto;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.setup-card {
  width: 1040px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 36px 40px;
  border-radius: 24px;
  background: rgba(8, 8, 8, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.setup-account {
  font-size: 32px;
  font-weight: 700;
}

.setup-note {
  font-size: 20px;
  color: var(--text-60);
  line-height: 1.45;
}

.setup-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.setup-pair[hidden] {
  display: none;
}

.setup-qr {
  width: 440px;
  height: 440px;
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  box-sizing: border-box;
}

.setup-pair-url {
  font-size: 22px;
  color: var(--text-60);
  word-break: break-all;
  text-align: center;
}

.setup-pair .tm-loading-pct {
  font-size: 36px;
}

.setup-pair .tm-loading-copy {
  font-size: 22px;
  text-align: center;
}

.setup-error {
  font-size: 20px;
  color: #ffb4a2;
}

.pick-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 0 16px;
  font-size: 22px;
  font-weight: 600;
}

.pick-bar-hint {
  margin-left: auto;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-35);
}

body.is-pick-mode .masthead-hint {
  color: var(--tm-orange);
}

.course-card .pick-mark {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 7;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tm-orange);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.course-card.is-picked {
  box-shadow: 0 0 0 3px rgba(236, 105, 26, 0.55);
}

.section-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-35);
  padding-bottom: 16px;
  flex: 0 0 auto;
}

.scroll-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
  /* Room for a 30% lift without clipping the ring or the orange glow. */
  padding: 52px 56px 36px;
}

.coming-soon-label {
  padding-top: 22px;
  padding-bottom: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(160px, 1fr));
  gap: var(--card-gap);
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 0;
  overflow: visible;
  position: relative;
}

/* Five selectable cards: 3 on top, 2 centered below, Olympic-rings silhouette. */
.card-grid.is-rings {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: auto auto;
  align-content: center;
  justify-content: center;
  gap: 40px 36px;
}

.card-slot {
  position: relative;
  overflow: visible;
  min-width: 0;
  min-height: 0;
}

.card-grid.is-rings .card-slot:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
.card-grid.is-rings .card-slot:nth-child(2) { grid-column: 3 / 5; grid-row: 1; }
.card-grid.is-rings .card-slot:nth-child(3) { grid-column: 5 / 7; grid-row: 1; }
.card-grid.is-rings .card-slot:nth-child(4) { grid-column: 2 / 4; grid-row: 2; }
.card-grid.is-rings .card-slot:nth-child(5) { grid-column: 4 / 6; grid-row: 2; }

.card-grid.is-rings .card-slot {
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 0;
}

.card-grid.is-rings .card-slot .course-card {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
}

.card-grid .card-slot .course-card,
.card-grid .course-card {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  min-height: 160px;
}

.card-grid.is-placeholders {
  flex: 0 0 auto;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: none;
  gap: 16px;
  padding-top: 0;
}

.card-grid.is-placeholders .course-card {
  aspect-ratio: auto;
  width: 100%;
  height: var(--shelf-height);
  border-radius: 16px;
}

/* ---------- Course card ---------- */

.course-card {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: #0d0d0d;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
  transition:
    transform  0.35s var(--ease-spring),
    box-shadow 0.35s ease;
  outline: none;
  z-index: 1;
}

/* Home grid lift — one card, centered in its slot (TMCardLift sets .is-lifted). */
#siteGrid .course-card.is-lifted {
  transform: translateY(-8px) scale(1.3);
  transform-origin: center center;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.82);
  z-index: 6;
}

/* Don't scale HTML while native video owns the card box. */
body:not(.is-playing) #siteGrid .course-card.has-card-video.is-lifted {
  transform: none;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}

/* Shot loop — video stack with optional side-swipe between clips. */
/* Shot video is a native TextureView above the WebView. These elements stay
   in the card only as layout placeholders; they must not take a decoder. */
.card-media {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.card-video,
.card-still {
  display: none !important;
}

.card-swipe-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #080808;
  transform: translateX(100%);
  pointer-events: none;
  will-change: transform;
}

.card-swipe-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 45%,
    rgba(236, 105, 26, 0.09) 0%,
    rgba(236, 105, 26, 0) 55%
  );
  pointer-events: none;
}

.card-swipe-panel.is-in {
  animation: cardSwipeIn 450ms var(--ease-out) forwards;
}

.card-swipe-panel.is-out {
  animation: cardSwipeOut 450ms var(--ease-out) forwards;
}

@keyframes cardSwipeIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes cardSwipeOut {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

body.is-html-player .course-card.has-html-card-video .card-video {
  display: none !important;
}

/* Decode size stays in the width/height attributes (card-videos.js). Paint
   full-bleed here — scaling a fixed 426×240 box with transform left a ~78%
   wide inset whenever --tm-card-scale was still 1. */
body.is-html-player .course-card.has-html-card-video.is-html-playing .card-video {
  display: block !important;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  pointer-events: none;
}

body.is-html-player .course-card.has-html-card-still .card-still {
  display: block !important;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

body.is-html-player .course-card.has-html-card-video .card-bg,
body.is-html-player .course-card.has-html-card-still .card-bg {
  opacity: 0;
}

body.is-html-player .course-card.is-html-playing .card-still {
  visibility: hidden;
  opacity: 0;
}

.card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: 320% 320%;
  animation: bgPan 14s ease infinite;
}

.card-grid .card-slot:nth-child(2) .card-bg,
.card-grid .course-card:nth-child(2) .card-bg { animation-duration: 16s; animation-delay: -3s; }
.card-grid .card-slot:nth-child(3) .card-bg,
.card-grid .course-card:nth-child(3) .card-bg { animation-duration: 11s; animation-delay: -6s; }
.card-grid .card-slot:nth-child(4) .card-bg,
.card-grid .course-card:nth-child(4) .card-bg { animation-duration: 14s; animation-delay: -4s; }
.card-grid .card-slot:nth-child(5) .card-bg,
.card-grid .course-card:nth-child(5) .card-bg { animation-duration: 12s; animation-delay: -8s; }
.card-grid .card-slot:nth-child(6) .card-bg,
.card-grid .course-card:nth-child(6) .card-bg { animation-duration: 17s; animation-delay: -2s; }

@keyframes bgPan {
  0%   { background-position: 0% 0%; }
  25%  { background-position: 100% 0%; }
  50%  { background-position: 100% 100%; }
  75%  { background-position: 0% 100%; }
  100% { background-position: 0% 0%; }
}

.card-wash {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(236, 105, 26, 0.42);
  mix-blend-mode: multiply;
}

/* Wash + logo + footer are drawn on the native video overlay. Hide the HTML
   copies only after a loop is actually attached, so an empty DEV card still
   shows its title on the gradient. */
body:not(.is-playing) #siteGrid .course-card.has-card-video .card-wash {
  background: transparent;
  mix-blend-mode: normal;
}

body:not(.is-playing) #siteGrid .course-card.has-card-video .card-footer {
  visibility: hidden;
}

.card-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.0)  0%,
    rgba(0, 0, 0, 0.0)  45%,
    rgba(0, 0, 0, 0.65) 100%
  );
}

.card-logo {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.card-logo-img {
  max-width: 56%;
  max-height: 36%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 2px 18px rgba(0, 0, 0, 0.7));
  opacity: 0;
  transition: opacity 320ms ease;
}

.card-logo-img.loaded { opacity: 1; }

.card-logo-img.is-color-logo {
  filter: drop-shadow(0 2px 18px rgba(0, 0, 0, 0.7));
}

.card-wordmark {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-100);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

.card-footer {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

#siteGrid .card-footer {
  justify-content: flex-start;
}

.card-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* Home cards: logo + wash at rest, title/subtitle when lifted. */
#siteGrid .course-card:has(.card-logo) .card-footer .card-meta {
  opacity: 1;
  transition: opacity 320ms ease;
}

#siteGrid .course-card:has(.card-logo) .card-logo {
  transition: opacity 320ms ease;
}

#siteGrid .course-card.is-lifted:has(.card-logo) .card-footer .card-meta {
  opacity: 1;
}

#siteGrid .course-card.is-lifted:has(.card-logo) .card-logo {
  opacity: 0;
  pointer-events: none;
}

.live-admin-logo {
  position: absolute;
  z-index: 30;
  top: 12px;
  left: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  color: var(--bay-text, #f6f6f6);
  background: rgba(0, 0, 0, .52);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 9px;
  font: 700 16px Inter, sans-serif;
  cursor: pointer;
}
.live-admin-logo img { width: 25px; height: 25px; object-fit: contain; }
body.is-playing .live-admin-logo { display: none; }
.feed-settings-trigger {
  display: none;
  position: absolute;
  z-index: 15;
  top: 9px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 9px;
  background: #232323;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
body.feed-admin-open #siteGrid .feed-settings-trigger { display: block; }

@media (max-width: 600px) {
  body.is-phone-home #stage {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
  }
  body.is-phone-home .grid-view {
    min-height: 100vh;
    height: auto;
    padding: 72px 16px 28px;
  }
  body.is-phone-home .scroll-body {
    display: block;
    flex: none;
    padding: 0;
  }
  body.is-phone-home #siteGrid.is-rings {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 14px;
  }
  body.is-phone-home #siteGrid.is-rings .card-slot {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 16 / 9;
  }
  body.is-phone-home #siteGrid .course-card {
    min-height: 0;
    border-radius: 15px;
  }
  body.is-phone-home #siteGrid .course-card.is-lifted { transform: none; }
  body.is-phone-home #siteGrid .card-footer {
    left: 14px;
    right: 14px;
    bottom: 12px;
    visibility: visible;
  }
  body.is-phone-home #siteGrid .card-title { font-size: 18px; }
  body.is-phone-home #siteGrid .card-subtitle { font-size: 12px; }
  body.is-phone-home .live-admin-logo { top: 14px; left: 16px; }
  body.is-phone-home .app-wordmark { display: none; }
}
.feed-tenant {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .7);
  color: var(--bay-text, #fff);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.card-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  hyphens: none;
}

.card-subtitle {
  font-size: 17px;
  font-weight: 400;
  color: var(--text-60);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.env-badge {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(236, 105, 26, 0.22);
  border: 1px solid rgba(236, 105, 26, 0.55);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.card-badges .env-badge,
.card-badges .live-badge,
.card-badges .agents-from-badge {
  flex: 0 0 auto;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.live-badge::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--live-red);
  box-shadow: 0 0 12px rgba(255, 59, 59, 0.9);
  animation: livePulse 1800ms ease-in-out infinite;
}

.live-badge.is-replay::before {
  background: rgba(255, 255, 255, 0.55);
  box-shadow: none;
  animation: none;
}

.course-card.is-last-wall .card-footer::after {
  content: 'Last';
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(236, 105, 26, 0.22);
  border: 1px solid rgba(236, 105, 26, 0.45);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- Placeholder cards ---------- */

.course-card.is-placeholder {
  opacity: 0.45;
  box-shadow: none;
}

.course-card.is-placeholder .card-wash {
  background: rgba(90, 90, 90, 0.35);
}

.card-grid.is-placeholders .card-logo {
  padding: 0 10% 28%;
}

.card-grid.is-placeholders .card-footer {
  left: 12px;
  right: 12px;
  bottom: 10px;
  gap: 8px;
}

.card-grid.is-placeholders .card-meta { gap: 2px; }

.card-grid.is-placeholders .card-title {
  font-size: 18px;
  line-height: 1.15;
  -webkit-line-clamp: 1;
}

.card-grid.is-placeholders .card-subtitle {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Boot / fatal states ---------- */

.boot-screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: radial-gradient(circle at 50% 45%, #16110d 0%, #050505 70%);
  text-align: center;
  padding: 0 160px;
}

.boot-screen .boot-mark { display: flex; align-items: center; gap: 16px; }
.boot-screen .boot-mark .tm-icon { height: 44px; }
.boot-screen .boot-mark .tm-letters { height: 30px; }

.boot-message {
  font-size: 26px;
  color: var(--text-60);
  line-height: 1.5;
  max-width: 1200px;
}

.boot-message strong { color: var(--tm-orange); font-weight: 700; }

.setup-redirect {
  margin: 12px 0 0;
  max-width: 52rem;
  color: #f3b23e;
  font-size: 18px;
  line-height: 1.4;
  word-break: break-all;
}
