:root {
  --bg: #120a24;
  --bg-soft: #1e1636;
  --text: #ffffff;
  --muted: #c9c4da;
  --accent: #ff2e63;
  --card-radius: 10px;
  --row-gap: 0.6rem;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win over element display rules
   (e.g. .overlay/.hero use display:flex). Without this the player
   overlay would stay visible on load and refuse to close. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
  background: #120a24;            /* fallback under the fixed layer below */
  color: var(--text);
  font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Clip stray horizontal overflow WITHOUT turning body into a scroll
   container (which would suppress window scroll events). */
body { overflow-x: clip; }

/* Fixed gradient backdrop (works on iOS, unlike background-attachment:fixed) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255,46,99,0.22), transparent 60%),
    radial-gradient(1000px 700px at 0% 10%, rgba(79,0,224,0.28), transparent 55%),
    linear-gradient(160deg, #1a1030 0%, #120a24 45%, #0c0718 100%);
}

/* ---------- Sticky top wrapper (brand/search + tabs) ---------- */
.topwrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(18,10,36,0.96), rgba(18,10,36,0.78));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background 0.3s, box-shadow 0.3s;
}
.topwrap {
  transition: background 0.3s, box-shadow 0.3s, transform 0.28s ease;
}
.topwrap.scrolled { box-shadow: 0 6px 24px rgba(0,0,0,0.45); }
.topwrap.hide { transform: translateY(-100%); }   /* auto-hide on mobile scroll-down */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 4vw 0.5rem;
}

/* Search toggle (magnifier) — hidden on desktop, shown on mobile */
.search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Colourful category tabs (compact, packs into fewest lines) ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.2rem 4vw 0.7rem;
}
.tab {
  flex: 0 0 auto;                            /* pill is only as wide as its label */
  cursor: pointer;
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  line-height: 1.1;
  /* each inactive pill is faintly tinted with its own colour */
  background: color-mix(in srgb, var(--c1) 20%, rgba(18,10,36,0.65));
  border: 1px solid color-mix(in srgb, var(--c1) 55%, transparent);
  transition: transform 0.15s, filter 0.2s, background 0.2s;
}
.tab:hover { filter: brightness(1.15); }
.tab.active {
  background: linear-gradient(135deg, var(--c1), var(--c2));
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transform: translateY(-1px);
}

.brand {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.brand-logo {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
.brand-name {
  min-width: 0;
  white-space: normal;             /* wrap to 2 lines instead of truncating */
  line-height: 1.05;
  font-weight: 800;
  font-size: clamp(0.95rem, 3.6vw, 1.45rem);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ff2e63, #ff9a3c, #ffd200);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search { flex: 0 1 260px; min-width: 0; display: flex; align-items: center; gap: 0.4rem; }
.search input {
  width: 100%;
  background: rgba(0,0,0,0.6);
  border: 1px solid #333;
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  font-size: 0.9rem;
  outline: none;
  transition: border 0.2s;
}
.search input:focus { border-color: var(--text); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  height: 52vh;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 30%;
}
.hero-fade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(12,7,24,0.96) 0%, rgba(12,7,24,0.55) 42%, rgba(12,7,24,0.05) 78%),
    linear-gradient(0deg, #120a24 0%, rgba(18,10,36,0.25) 38%, rgba(18,10,36,0) 62%);
}
.hero-content {
  position: relative;
  padding: 0 4vw 3.5rem;
  max-width: 640px;
}
.hero-badge {
  display: inline-block;
  margin: 0 0 0.9rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #ff2e63, #ff9a3c, #ffd200);
  box-shadow: 0 4px 16px rgba(255,46,99,0.45);
}
.hero-title { font-size: clamp(1.8rem, 4vw, 3.2rem); margin: 0 0 0.6rem; }
.hero-desc { color: var(--muted); font-size: 1rem; line-height: 1.5; margin: 0 0 1.2rem; }

.play-btn {
  background: #fff;
  color: #000;
  border: none;
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.play-btn:hover { opacity: 0.8; }

/* ---------- Rows ---------- */
main { padding: 1.5rem 0 4rem; }

.row { margin: 0 0 2.2rem; }
.row h2 {
  font-size: 1.45rem;
  margin: 0 0 var(--row-gap);
  padding: 0 4vw;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.3px;
}
.row-scroller { position: relative; }

/* soft fades at the row edges hinting there's more to scroll */
.row-scroller::before,
.row-scroller::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 5vw;
  z-index: 2;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s;
}
.row-scroller::before { left: 0;  background: linear-gradient(90deg, #120a24, transparent); }
.row-scroller::after  { right: 0; background: linear-gradient(270deg, #120a24, transparent); }
.row-scroller.at-start::before { opacity: 0; }
.row-scroller.at-end::after    { opacity: 0; }

.row-track {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.4rem 4vw 1rem;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.row-track::-webkit-scrollbar { display: none; }

/* hover scroll arrows (desktop / pointer devices only) */
.row-arrow {
  position: absolute;
  top: 0.4rem;
  bottom: 1rem;
  width: 4.6vw;
  min-width: 42px;
  z-index: 3;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  background: rgba(10,6,20,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}
.row-arrow.left  { left: 0;  border-radius: 0 8px 8px 0; }
.row-arrow.right { right: 0; border-radius: 8px 0 0 8px; }
.row-arrow:hover { background: rgba(10,6,20,0.82); }
@media (hover: hover) {
  .row:hover .row-arrow { opacity: 1; }
}
.row-scroller.at-start .row-arrow.left  { display: none; }
.row-scroller.at-end   .row-arrow.right { display: none; }

.card {
  position: relative;
  flex: 0 0 auto;
  width: 280px;
  aspect-ratio: 16 / 9;
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-soft);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card-media {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 28%;   /* bias toward the top so faces/subjects stay in frame */
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Auto-generated title cards (no thumbnail supplied) */
.card-media.gen { padding: 0.8rem; }
/* Dark vignette so titles stay legible on bright gradients */
.card-media.gen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 50% 120%, rgba(0,0,0,0.45), rgba(0,0,0,0.08) 60%);
}
.card-media.gen::before {
  content: "\25B6";              /* ▶ */
  position: absolute;
  top: 0.5rem;
  left: 0.7rem;
  font-size: 0.85rem;
  opacity: 0.9;
  z-index: 1;
}
.gen-title {
  position: relative;
  z-index: 1;
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.55);
}
/* Play-button overlay on hover */
.card-play {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.28);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.card-play span {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.94);
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
@media (hover: hover) {
  .card:hover {
    transform: scale(1.08);
    z-index: 2;
    box-shadow: 0 12px 34px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.85);
  }
  .card:hover .card-play { opacity: 1; }
}
/* Touch feedback for phones/tablets (no hover) */
.card:active { transform: scale(0.97); }
.card .label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.2rem 0.7rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: linear-gradient(0deg, rgba(0,0,0,0.85), rgba(0,0,0,0));
}

.empty { text-align: center; color: var(--muted); padding: 4rem 1rem; }

/* ---------- Player overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vw;
  overflow-y: auto;               /* scroll if content is taller than screen */
  -webkit-overflow-scrolling: touch;
}
.overlay-inner {
  position: relative;
  width: min(1100px, 100%);
  margin: auto;                    /* keeps it centered even when scrolling */
  background: var(--bg-soft);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

.player-meta { padding: 1rem 1.4rem 1.6rem; }
.player-meta h2 { margin: 0 0 0.4rem; }
.player-meta p { margin: 0; color: var(--muted); line-height: 1.5; }

.close-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  z-index: 120;                       /* above the player iframe */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.72);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.6);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;         /* snappier, reliable taps on iOS */
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
.close-btn:hover,
.close-btn:active { background: var(--accent); }

/* ---------- Responsive ---------- */

/* Tablets / small laptops */
@media (max-width: 1024px) {
  .card { width: 240px; }
  .hero { height: 52vh; }
}

/* Phones & tablets — app-style single-axis layout */
@media (max-width: 768px) {
  .topbar { padding: 0.6rem 4vw 0.35rem; gap: 0.6rem; }
  .brand-name { display: none; }                 /* logo only, saves space */

  /* search collapses to a magnifier that expands inline when tapped */
  .search { flex: 0 0 auto; }
  .search-toggle { display: flex; }
  .search input { display: none; }
  .search.open { flex: 1 1 auto; }
  .search.open input { display: block; font-size: 0.95rem; padding: 0.5rem 0.8rem; }

  /* category chips on one swipeable, sticky line */
  .tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.15rem 4vw 0.55rem;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 0.42rem 0.8rem; font-size: 0.82rem; }

  /* rows become a 2-column vertical grid — scroll DOWN only, no sideways swiping */
  .row { margin: 0 0 1.6rem; }
  .row h2 { font-size: 1.15rem; padding: 0 4vw; }
  .row-scroller::before,
  .row-scroller::after,
  .row-arrow { display: none; }
  .row-track {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    overflow: visible;
    padding: 0.2rem 4vw 0.2rem;
  }
  .card { width: auto; max-width: none; }
  .gen-title { font-size: 1rem; }

  .hero { height: 44vh; min-height: 240px; }
  .hero-content { padding: 0 5vw 1.6rem; }
  .hero-badge { font-size: 0.7rem; }
  .player-meta { padding: 0.9rem 1.1rem 1.3rem; }

  /* fill the notch/safe area in installed (standalone) mode */
  .topbar { padding-top: max(0.6rem, env(safe-area-inset-top)); }
}

/* Bigger touch screens (large/landscape phones, small tablets): 3 tiles across */
@media (min-width: 600px) and (max-width: 768px) {
  .row-track { grid-template-columns: repeat(3, 1fr); }
}

/* Small phones (portrait) */
@media (max-width: 480px) {
  .brand-logo { width: 38px; height: 38px; border-radius: 10px; }
  .tab { font-size: 0.8rem; padding: 0.4rem 0.7rem; }
  .search input { font-size: 0.8rem; padding: 0.45rem 0.7rem; }
  .hero { height: 42vh; min-height: 220px; }
  .hero-title { font-size: 1.6rem; }
  .hero-desc { font-size: 0.9rem; }
  .gen-title { font-size: 1rem; }
  .play-btn { padding: 0.6rem 1.2rem; font-size: 0.9rem; }
}

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

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 1rem;
  padding: 2.6rem 4vw 3rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
  color: var(--muted);
}
.site-footer .foot-logo {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  margin-bottom: 0.7rem;
}
.site-footer .foot-brand {
  font-weight: 800;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ff2e63, #ff9a3c, #ffd200);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-footer .foot-tag { margin: 0.4rem 0 0; font-size: 0.9rem; }
.site-footer .foot-links {
  display: flex;
  gap: 1.4rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0 0.6rem;
}
.site-footer .foot-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.site-footer .foot-links a:hover { color: #fff; }
.site-footer .copy { font-size: 0.78rem; opacity: 0.65; margin-top: 0.6rem; }
