/* Instant Video Site – default theme
   Mobile-first, light/dark via prefers-color-scheme, no framework. */

:root {
  --bg: #f5f5fa;
  --surface: #ffffff;
  --ink: #1c1a2b;
  --ink-soft: #5d5a73;
  --line: #e2e1ec;
  --accent: #5b3df5;
  --accent-ink: #ffffff;
  --live: #ffb224;
  --focus: #5b3df5;
  --radius-media: 12px;
  --radius-ui: 999px;
  --wrap: 1320px;
  --gutter: clamp(16px, 3vw, 32px);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

/* Dark mode: follows the system unless the visitor chose a theme
   (data-theme is set before paint by an inline script in layout.tpl). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15131f;
    --surface: #1f1c2d;
    --ink: #ece9ff;
    --ink-soft: #a6a2bf;
    --line: #2f2b42;
    --accent: #8e78ff;
    --accent-ink: #15131f;
    --focus: #b3a6ff;
  }
}
:root[data-theme="dark"] {
  --bg: #15131f;
  --surface: #1f1c2d;
  --ink: #ece9ff;
  --ink-soft: #a6a2bf;
  --line: #2f2b42;
  --accent: #8e78ff;
  --accent-ink: #15131f;
  --focus: #b3a6ff;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* Light/dark toggle */
.theme-toggle {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  font-variation-settings: "wdth" 100;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.15; margin: 0; font-variation-settings: "wdth" 118; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.5rem, 1.1rem + 2vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); border-radius: 8px; }
.skip-link:focus { top: 8px; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

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

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-bar { display: flex; align-items: center; gap: 16px; min-height: 64px; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand:hover { color: inherit; }
.brand-name { font-weight: 800; font-size: 1.15rem; font-variation-settings: "wdth" 125; letter-spacing: -0.02em; }

/* The signature element: a tiny equalizer that "plays" once on load. */
.brand-eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.brand-eq i { display: block; width: 4px; background: var(--accent); border-radius: 2px; transform-origin: bottom; }
.brand-eq i:nth-child(1) { height: 45%; }
.brand-eq i:nth-child(2) { height: 100%; }
.brand-eq i:nth-child(3) { height: 65%; }
.brand-eq i:nth-child(4) { height: 85%; }

@media (prefers-reduced-motion: no-preference) {
  .brand-eq i { animation: eq 1.1s ease-in-out 3; }
  .brand-eq i:nth-child(2) { animation-delay: -0.3s; }
  .brand-eq i:nth-child(3) { animation-delay: -0.6s; }
  .brand-eq i:nth-child(4) { animation-delay: -0.15s; }
  .brand:hover .brand-eq i { animation: eq 1.1s ease-in-out infinite; }
}
@keyframes eq { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.35); } }

.brand-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-group .brand { min-width: 0; overflow: hidden; }
.brand-group .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-section {
  flex-shrink: 0; padding: 3px 10px; font-size: .85rem; font-weight: 700; text-decoration: none;
  color: var(--accent-ink); background: var(--accent); border-radius: var(--radius-ui);
}
.brand-section:hover { color: var(--accent-ink); filter: brightness(1.08); }

.search { flex: 1; display: flex; max-width: 560px; margin-left: auto; }
.search input {
  flex: 1; min-width: 0; height: 42px; padding: 0 16px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-right: 0; border-radius: var(--radius-ui) 0 0 var(--radius-ui);
}
.search input::placeholder { color: var(--ink-soft); }
.search input:focus-visible { outline-offset: -2px; border-radius: var(--radius-ui) 0 0 var(--radius-ui); }
.search button {
  width: 52px; height: 42px; display: grid; place-items: center; cursor: pointer;
  color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 0 var(--radius-ui) var(--radius-ui) 0;
}

@media (max-width: 560px) {
  .header-bar { flex-wrap: wrap; gap: 10px; padding-block: 10px; }
  .search { flex-basis: 100%; max-width: none; order: 3; }
  .brand-group { flex: 1 1 0; overflow: hidden; }
  .brand-group .brand { flex: 0 1 auto; }
  .theme-toggle { order: 2; width: 36px; height: 36px; }
  .brand-group .brand-name { font-size: 1rem; }
}

.topics { overflow: hidden; }
.topic-list {
  display: flex; gap: 8px; margin: 0 auto; padding-block: 0 12px; list-style: none;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.topic-list::-webkit-scrollbar { display: none; }
.topic-list li { flex-shrink: 0; scroll-snap-align: start; }
.topic-list a {
  display: block; padding: 6px 14px; font-size: .9rem; font-weight: 500; text-decoration: none; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-ui);
}
.topic-list a:hover { border-color: var(--accent); color: var(--ink); }
.topic-menu a { border-color: transparent; background: none; font-weight: 600; padding-inline: 8px; }
.topic-sep { width: 1px; align-self: stretch; margin: 4px 4px; background: var(--line); }
.topic-list a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Page layout ---------- */

.page { padding-block: 24px 48px; }
.page-watch { display: grid; gap: 32px; }
@media (min-width: 1080px) {
  .page-watch { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
}

.intro { margin-bottom: 28px; max-width: 70ch; }
.intro h1 { font-size: clamp(2rem, 1.2rem + 4vw, 3.6rem); font-variation-settings: "wdth" 125; letter-spacing: -0.03em; }
.intro p { margin: 8px 0 0; color: var(--ink-soft); font-size: 1.1rem; }

.section-title { margin: 0 0 16px; }
.section-title .count { color: var(--ink-soft); font-weight: 500; }

.list-head { margin-bottom: 24px; }
.list-head p { margin: 6px 0 0; color: var(--ink-soft); }
.list-head .scope-note {
  max-width: 70ch; margin-top: 12px; padding: 10px 14px; font-size: .925rem; color: var(--ink);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
}

.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 16px; padding: 0; list-style: none; font-size: .875rem; color: var(--ink-soft); }
.breadcrumbs li + li::before { content: "/"; margin: 0 8px; opacity: .6; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ---------- Video grid & cards ---------- */

.grid {
  display: grid; gap: 28px 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

.vcard { min-width: 0; }
.vcard-thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius-media); background: var(--line);
}
.vcard-thumb img { width: 100%; height: 100%; object-fit: cover; color: transparent; font-size: 0; }
.player-facade img, .channel-avatar, .channel-banner img { color: transparent; font-size: 0; }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 6px;
  font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: #fff; background: rgba(15, 12, 28, .82); border-radius: 6px;
}
.badge-live { background: var(--live); color: #1c1a2b; }

.vcard-body { padding-top: 10px; }
.vcard-title { font-size: 1rem; font-variation-settings: "wdth" 100; letter-spacing: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vcard-title a { text-decoration: none; }
.vcard-author, .vcard-stats { margin: 4px 0 0; font-size: .875rem; color: var(--ink-soft); }
.vcard-author a { text-decoration: none; }
.vcard-author a:hover { text-decoration: underline; }
.vcard-stats { display: flex; flex-wrap: wrap; gap: 0 12px; }

.vcard-compact { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 12px; }
.vcard-compact .vcard-thumb { border-radius: 8px; }
.vcard-compact .vcard-body { padding-top: 0; }
.vcard-compact .vcard-title { font-size: .925rem; }
.vcard-compact .vcard-author, .vcard-compact .vcard-stats { font-size: .8rem; }

.related { display: grid; gap: 14px; }

.empty { padding: 48px 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius-media); color: var(--ink-soft); }
.empty p:first-child { color: var(--ink); font-weight: 600; font-size: 1.1rem; }

/* ---------- Pagination ---------- */

.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 40px; }
.pager-current { color: var(--ink-soft); font-size: .9rem; }
.pager-link {
  justify-self: start; padding: 10px 20px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius-ui); background: var(--surface);
}
.pager-link[rel="next"] { justify-self: end; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pager-link:hover { border-color: var(--accent); }
.pager-link[rel="next"]:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Watch page ---------- */

.player { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-media); overflow: hidden; background: #000; }
@media (max-width: 640px) { .player { margin-inline: calc(var(--gutter) * -1); border-radius: 0; } }
.player iframe, .player-facade, .player-facade img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-facade { display: block; cursor: pointer; }
.player-facade img { object-fit: cover; }
.player-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: rgba(28, 26, 43, .85); transition: color .15s ease;
}
.player-facade:hover .player-play, .player-facade:focus-visible .player-play { color: var(--accent); }

.watch-title { margin-top: 18px; font-size: clamp(1.25rem, 1rem + 1.2vw, 1.75rem); font-variation-settings: "wdth" 110; }

.watch-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-top: 12px; }
.watch-channel { margin: 0; font-weight: 700; font-size: 1.05rem; }
.watch-channel a { text-decoration: none; }
.watch-channel a:hover { text-decoration: underline; }
.watch-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; }
.watch-stats div { display: flex; flex-direction: column; }
.watch-stats dt { font-size: .75rem; color: var(--ink-soft); }
.watch-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.description { margin-top: 20px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-media); }
.description-text, .channel-about { max-width: 75ch; overflow-wrap: anywhere; font-size: .95rem; }

[data-collapsible].is-collapsed { max-height: 7.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.toggle-more { margin-top: 8px; padding: 0; font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; cursor: pointer; }

.tags ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.tags a { display: block; padding: 4px 12px; font-size: .85rem; text-decoration: none; border: 1px solid var(--line); border-radius: var(--radius-ui); }
.tags a:hover { border-color: var(--accent); color: var(--ink); }

.comments { margin-top: 36px; }
.comment-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 20px; }
.comment { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
.comment-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--line); font-weight: 700; color: var(--ink-soft); }
.comment-head { margin: 0; font-size: .875rem; }
.comment-head time { color: var(--ink-soft); margin-left: 6px; }
.comment-text { margin: 4px 0 0; overflow-wrap: anywhere; max-width: 75ch; }
.comment-likes { margin: 4px 0 0; font-size: .8rem; color: var(--ink-soft); }

.page-aside .section-title { font-size: 1.05rem; }
@media (min-width: 1080px) { .page-aside { position: sticky; top: 130px; } }

/* ---------- Channel ---------- */

.channel-head { margin-bottom: 28px; }
.channel-banner { aspect-ratio: 6 / 1; overflow: hidden; border-radius: var(--radius-media); background: var(--line); margin-bottom: 20px; }
.channel-banner img { width: 100%; height: 100%; object-fit: cover; }
.channel-id { display: flex; align-items: center; gap: 18px; }
.channel-avatar { width: 80px; height: 80px; border-radius: 50%; flex-shrink: 0; }
@media (min-width: 640px) { .channel-avatar { width: 96px; height: 96px; } }
.channel-stats { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 6px 0 0; color: var(--ink-soft); font-size: .9rem; }
.channel-about { margin-top: 16px; color: var(--ink-soft); }

.tabs { display: flex; gap: 24px; margin-top: 20px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 0; font-weight: 600; text-decoration: none; color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--accent); }

/* ---------- Ads ---------- */

.ad { display: flex; justify-content: center; overflow: hidden; }
.ad-top { padding-top: 16px; }
.ad-inlist { grid-column: 1 / -1; }
.ad-player { margin-top: 16px; }
.ad-sidebar { margin-bottom: 20px; }

/* ---------- Error ---------- */

.error-page { padding: 64px 0; max-width: 60ch; }
.error-code { margin: 0 0 8px; font-size: clamp(4rem, 3rem + 6vw, 8rem); font-weight: 800; line-height: 1; font-variation-settings: "wdth" 125; color: var(--accent); }
.error-page h1 + p { color: var(--ink-soft); }
.button { display: inline-block; margin-top: 12px; padding: 10px 22px; font-weight: 600; text-decoration: none; color: var(--accent-ink); background: var(--accent); border-radius: var(--radius-ui); }
.button:hover { color: var(--accent-ink); filter: brightness(1.08); }

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

.site-footer { border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .875rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-block: 24px; }
.footer-inner p { margin: 0; max-width: 75ch; }
