/* =====================================================================
   LAYOUT & COMPONENTS — colours come from theme.css, so you should
   not need to edit colours here. Load theme.css BEFORE this file.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--page-glow) top center / 100% 420px no-repeat, var(--bg-page); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
}
img { max-width: 100%; }
a { color: var(--accent-text); }
a:hover { color: var(--accent-text-hover); }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute; 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: 12px; top: -60px; background: var(--text); color: var(--bg-card); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip-link:focus { top: 12px; color: var(--bg-card); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--text-muted); }

/* ============ Header (400x70 logo slot) ============ */
.site-header { background: var(--bg-card); border-bottom: 1px solid var(--border); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 98px; padding-top: 14px; padding-bottom: 14px;
}
.logo { display: block; flex: 0 1 400px; min-width: 0; line-height: 0; }
.logo img { display: block; width: 400px; max-width: 100%; height: auto; aspect-ratio: 400 / 70; }
.main-nav { display: flex; gap: 6px; }
.main-nav a {
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: 8px 14px; border-radius: 999px;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-text); }

/* ============ Headings (font set in theme.css) ============ */
h1, h2, h3, .card-title { font-family: var(--font-heading); }

/* ============ Hero ============ */
.hero { padding: 36px 0 8px; }
h1 {
  font-size: clamp(1.75rem, 3.6vw, 2.6rem); line-height: 1.12; letter-spacing: -0.01em;
  font-weight: 700; margin: 0 0 10px;
}
h2 { font-size: 1.35rem; letter-spacing: -0.015em; margin: 0; }
.lead { font-size: 1.05rem; color: var(--text-muted); max-width: 70ch; margin: 0; }

/* ============ Form controls ============ */
.field input, .field select {
  font: inherit; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 14px; min-height: 44px;
}
.btn {
  display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 10px 18px;
  background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 700; text-decoration: none;
  border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.btn:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-outline { background: var(--bg-card); color: var(--accent-text); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-tint); color: var(--accent-text-hover); }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: .92rem; }

/* ============ Layout: tag sidebar (LEFT) + results ============ */
.layout {
  display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 28px; align-items: start; padding-top: 22px;
}
.layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  grid-column: 1; grid-row: 1;               /* always the left column */
  position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 32px); padding: 16px 12px 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
#results { grid-column: 2; grid-row: 1; min-width: 0; }
.layout.no-sidebar #results { grid-column: 1; }
.sidebar[hidden] { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px; }
.side-title { font-size: 1.05rem; margin: 0; }
.side-close {
  display: none; font: inherit; font-size: 1.6rem; line-height: 1; width: 40px; height: 40px;
  border: 0; border-radius: 999px; background: none; color: var(--text); cursor: pointer;
}
.side-close:hover { background: var(--accent-tint); color: var(--accent-text); }
.sidebar .field input { width: 100%; }
.tag-list {
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -4px; padding: 0 4px;
}
.tag-link {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none;
  font-weight: 600; font-size: .93rem; overflow-wrap: anywhere;
}
.tag-link .n { color: var(--text-muted); font-weight: 500; font-size: .85rem; flex: none; }
.tag-link:hover { background: var(--accent-tint); color: var(--accent-text); }
.tag-link[aria-current="true"] { background: var(--accent); color: var(--on-accent); }
.tag-link[aria-current="true"] .n { color: var(--on-accent-soft); }
.side-empty { margin: 6px 8px; font-size: .92rem; }
.scrim { display: none; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.field.sort { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: .92rem; color: var(--text-muted); }
.field.sort select { padding-right: 10px; }
.active { display: flex; align-items: center; gap: 8px; }
.active[hidden] { display: none; }
.active-label { font-weight: 600; font-size: .92rem; }
.pill {
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--accent-text);
  background: var(--accent-tint); border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 14px;
}
.pill:hover { border-color: var(--accent); }

/* ============ Results ============ */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.results-head p { margin: 0; color: var(--text-muted); font-size: .95rem; }
.status {
  padding: 18px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text-muted); margin-bottom: 16px;
}
.status[hidden] { display: none; }
.status.error { border-style: solid; border-color: var(--error-border); background: var(--error-bg); color: var(--error-text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card:hover { border-color: var(--border-strong); }
.thumb { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--bg-subtle); line-height: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; line-height: 1; }
.badge { font-size: .72rem; font-weight: 800; padding: 5px 8px; border-radius: 6px; letter-spacing: .02em; }
.badge-live { background: var(--badge-live); color: var(--on-badge-live); }
.badge-new { background: var(--badge-new); color: var(--on-badge-new); }
.badge-hd { background: var(--badge-hd); color: var(--on-badge-hd); }
.viewers {
  position: absolute; right: 10px; bottom: 10px; line-height: 1; font-size: .78rem; font-weight: 600;
  color: var(--on-overlay); background: var(--overlay); padding: 6px 9px; border-radius: 999px;
}
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 16px; flex: 1; }
.card-title { margin: 0; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent-text); text-decoration: underline; }
.stats { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--text-muted); }
.loc { margin: 0; font-size: .85rem; color: var(--text-muted); }
.subject {
  margin: 2px 0 0; font-size: .92rem; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 8px; }
.tag { font-size: .85rem; font-weight: 600; color: var(--accent-text); text-decoration: none; padding: 2px 0; }
.tag:hover { text-decoration: underline; }
.card .btn { margin-top: auto; }
.more-wrap { display: flex; justify-content: center; padding: 26px 0 8px; }
.more-wrap [hidden] { display: none; }

.skeleton { pointer-events: none; }
.skeleton .thumb { background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-shine) 50%, var(--skeleton) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton .line { height: 12px; border-radius: 6px; background: var(--skeleton); margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============ Player page ============ */
.crumbs { padding: 22px 0 0; font-size: .9rem; color: var(--text-muted); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.player-layout { padding: 18px 0 8px; }
.player-frame {
  position: relative; aspect-ratio: 16 / 9; background: var(--player-bg); border-radius: var(--radius);
  overflow: hidden; margin-top: 16px;
  max-width: min(100%, calc(60vh * 16 / 9));
}
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--on-player);
}
.player-fallback p { margin: 0; max-width: 42ch; }
.player-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 16px 0; }
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  margin: 0 0 20px; padding: 0; list-style: none;
}
.facts li { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.facts b { display: block; font-size: 1.2rem; letter-spacing: -0.01em; }
.facts span { color: var(--text-muted); font-size: .85rem; }
.about-stream { max-width: 72ch; }
.about-stream p { margin: 0 0 12px; }
.about-stream .tags { margin-top: 10px; }
.related { padding-top: 28px; }
.related h2 { margin-bottom: 14px; }

/* ============ Text pages ============ */
.prose { max-width: 74ch; padding: 34px 0 20px; }
.prose h1 { margin-bottom: 14px; }
.prose h2 { margin: 30px 0 8px; }
.prose p, .prose li { color: var(--text-body); }
.prose ul, .prose ol { padding-left: 1.3em; }
.notice {
  border: 1px solid var(--notice-border); background: var(--notice-bg); color: var(--notice-text);
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 22px; font-size: .95rem;
}

/* ============ SEO copy + footer ============ */
.seo-copy { max-width: 80ch; margin: 44px 0 10px; padding-top: 28px; border-top: 1px solid var(--border); }
.seo-copy h2 { margin-bottom: 10px; }
.seo-copy p { color: var(--text-body); margin: 0 0 12px; }
.site-footer { margin-top: 48px; background: var(--bg-card); border-top: 1px solid var(--border); }
.footer-inner { padding: 30px 20px 36px; display: grid; gap: 18px; }
.site-footer h3 { margin: 0 0 6px; font-size: 1.05rem; }
.site-footer p { margin: 0; color: var(--text-muted); font-size: .92rem; max-width: 80ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.footer-links a { font-weight: 600; font-size: .92rem; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* ============ Responsive ============ */
/* Tablets / small laptops: sidebar stays on the LEFT, just narrower. */
@media (max-width: 900px) {
  .layout { grid-template-columns: 224px minmax(0, 1fr); gap: 18px; }
  .layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
}
/* Phones: the tag list slides in as a panel from the LEFT edge. */
@media (max-width: 639px) {
  .layout, .layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }
  #results, .layout.no-sidebar #results { grid-column: 1; }
  .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); max-height: none;
    border-radius: 0 var(--radius) var(--radius) 0; border-left: 0; padding-top: 12px;
    box-shadow: 0 0 40px var(--shadow);
  }
  .side-close { display: block; }
  .scrim.is-on { display: block; position: fixed; inset: 0; z-index: 20; background: var(--scrim); }
  .header-inner { flex-direction: column; justify-content: center; gap: 10px; min-height: 0; }
  .logo { flex: 0 0 auto; width: 100%; max-width: 400px; }
  .field.sort { margin-left: 0; width: 100%; }
  .field.sort select { flex: 1; }
  .toolbar .btn-sm { flex: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card-body { padding: 10px 10px 12px; }
  .badge { font-size: .66rem; padding: 4px 6px; }
  .viewers { font-size: .7rem; padding: 5px 7px; right: 6px; bottom: 6px; }
  .badges { top: 6px; left: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .skeleton .thumb { animation: none; }
}
