/* ============================================================================
   chcd design system — "warm evening television"
   Subject: ჩემი ცოლის დაქალები, a long-running Georgian family sitcom people
   binge in the living room. The look is warm, nostalgic, honey-lit — the
   opposite of a cold black/Netflix-red streaming grid.

   Files: base.css (this — tokens + shared components) is loaded on every page.
   Pages add home.css / watch.css after it. Never restyle another page's
   layout classes from here.
   ========================================================================== */

:root {
  /* — palette matched to kinoqartulad.org production (dark theme) — */
  --bg:        #0d0d0d;   /* --bg-primary */
  --bg-elev:   #151515;   /* raised panels */
  --surface:   #1a1a1a;   /* --bg-card */
  --surface-2: #2a2a2a;   /* hover / inset */
  --ink:       #ffffff;   /* --text-primary */
  --ink-dim:   #b3b3b3;   /* --text-secondary */
  --muted:     #888888;   /* --text-muted */
  --line:      rgba(255,255,255,.10);   /* --border-color */
  --line-2:    rgba(255,255,255,.20);

  /* — accent: kinoqartulad red (--accent #e50914). Var names kept as --honey*
       so page CSS needn't change; values are now the brand red. — */
  --honey:     #e50914;
  --honey-hi:  #f6121d;   /* brighter red for gradient tops */
  --honey-ink: #ffffff;   /* text on red fills is white */
  --ember:     #e50914;
  --ember-hi:  #b2071050;

  --radius:    14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow:    0 10px 34px rgba(0,0,0,.46);
  --shadow-sm: 0 3px 12px rgba(0,0,0,.35);
  --maxw:      1180px;

  --serif: "Noto Serif Georgian", Georgia, "Times New Roman", serif;
  --sans:  "Noto Sans Georgian", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* sticky-header clearance for in-page anchor jumps. Base = header only (~64px).
     The home page adds a sticky season sub-bar, so it overrides:
       body.home { --sticky-pad: 110px; }  (set from home.css) */
  --sticky-pad: 64px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win — component display rules like
   `.ep-card{display:block}` otherwise override the UA `[hidden]` rule (equal
   specificity, later cascade) and break JS search/section toggling. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--sticky-pad);
}

/* warm honey text selection — a small nod to the accent everywhere */
::selection { background: rgba(229,9,20,.32); color: var(--ink); }

body {
  margin: 0;
  background: var(--bg);
  /* faint warm vignette so the dark never feels flat/cold */
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(229,9,20,.07), transparent 60%),
    radial-gradient(900px 600px at 88% 4%, rgba(255,255,255,.02), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

/* ── type scale ─────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
.h-hero  { font-size: clamp(1.8rem, 4.6vw, 3rem); }
.h-sec   { font-size: clamp(1.25rem, 2.6vw, 1.7rem); }
.eyebrow { font-family: var(--sans); font-weight: 700; font-size: .72rem;
           letter-spacing: .16em; text-transform: uppercase; color: var(--honey); }
.muted   { color: var(--muted); }

/* ── layout helpers ─────────────────────────────────────────────────────── */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: var(--stack-gap, 1rem); }

/* ── header ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: rgba(23,16,18,.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink); font-family: var(--serif);
  font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em;
}
.site-header .brand .logo { height: 30px; width: 30px; border-radius: 8px; object-fit: cover; }
.site-header .brand .dim { color: var(--muted); font-family: var(--sans); font-size: .74rem; font-weight: 600; }
.site-header .spacer { flex: 1; }
.site-header .h-link {
  text-decoration: none; color: var(--ink-dim); font-size: .86rem; font-weight: 600;
  padding: 7px 13px; border-radius: var(--radius-pill); border: 1px solid transparent;
}
.site-header .h-link:hover { color: var(--ink); background: var(--surface); border-color: var(--line); }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--sans); font-weight: 700; font-size: .92rem;
  padding: .62rem 1.15rem; border-radius: var(--radius-pill);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--honey-hi), var(--honey)); color: var(--honey-ink); border-color: transparent; box-shadow: 0 6px 18px rgba(229,9,20,.32); }
.btn-primary:hover { background: linear-gradient(180deg, #ffd587, var(--honey-hi)); }
.btn-ember { background: linear-gradient(180deg, #f6121d, var(--ember)); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; }

/* ── shared episode tile ────────────────────────────────────────────────────
   Numbered tile (no per-episode thumbnails exist). Season order is real
   information for a serial, so the episode number IS the hero of the card.
   Used by BOTH home grid and watch "more episodes" list.
   -------------------------------------------------------------------------- */
.ep-card {
  position: relative; display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .14s ease, border-color .15s ease, box-shadow .15s ease;
}
/* ★ signature move: on hover the tile lifts and casts a warm honey "lamp glow"
   underneath — the whole grid feels like a wall of lit screens in a dim room,
   not a cold catalogue. Kept to one place so it reads as intentional. */
.ep-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-2);
  box-shadow: 0 10px 26px rgba(0,0,0,.42), 0 6px 22px rgba(229,9,20,.22);
}
.ep-card:focus-visible { outline: 2px solid var(--honey); outline-offset: 3px; }

.ep-tile {
  position: relative; aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
  /* Season-tinted gradient. Templates pass a raw 0–360 hue via --tile-h
     (= (season*33)%360), which alone would give cold blue/green/purple seasons.
     We COMPRESS that full circle into a warm ember→amber band (~12°–59°) so
     every season stays "evening TV" warm while remaining visually distinct,
     and pin lightness dark (24%→15%) + moderate saturation so the white
     episode number keeps ≥ 4.5:1 contrast on ALL hues (measured ≈6.1:1). */
  --tile-warm: calc(12 + var(--tile-h, 20) * 0.13);
  background:
    radial-gradient(120% 120% at 20% 12%, rgba(255,255,255,.06), transparent 45%),
    linear-gradient(150deg,
      #262626 0%,
      #171717 100%);
}
.ep-tile .epno { font-family: var(--serif); font-weight: 700; font-size: 2.4rem; color: #fff; opacity: .96; text-shadow: 0 2px 10px rgba(0,0,0,.4); line-height: 1; }
.ep-tile .epno small { display: block; font-family: var(--sans); font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .7; margin-bottom: 3px; }
.ep-tile .badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: .04em; backdrop-filter: blur(2px); }
.ep-tile .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s ease; font-size: 2rem; color: #fff; }
.ep-card:hover .ep-tile .play { opacity: .95; }
.ep-card:hover .ep-tile .epno { opacity: .25; }

/* watched check + resume progress bar (driven by kq-progress.js) */
.ep-tile .watched { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--honey); color: var(--honey-ink); display: none; align-items: center; justify-content: center; font-size: .8rem; font-weight: 800; }
.ep-card[data-watched="1"] .ep-tile .watched { display: flex; }
.ep-card[data-watched="1"] .ep-tile { filter: saturate(.7) brightness(.82); }
.ep-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.4); }
.ep-progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--honey), var(--honey-hi)); transition: width .3s ease; }
.ep-meta { padding: 9px 11px 11px; }
.ep-meta .t { font-size: .86rem; font-weight: 600; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── skeleton loading ───────────────────────────────────────────────────── */
.skeleton { position: relative; overflow: hidden; background: var(--surface); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); animation: sk 1.3s infinite; }
@keyframes sk { 100% { transform: translateX(100%); } }

/* ── footer ─────────────────────────────────────────────────────────────── */
.site-footer { margin-top: 3rem; padding: 2rem 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink-dim); }

/* ── shared interactive components (used across home + watch) ───────────────
   Kept here so every page reads as one system. Page CSS may extend, not fork. */

/* horizontal scroller (continue-watching, episode strips) */
.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent; }
.rail::-webkit-scrollbar { height: 7px; }
.rail::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 4px; }
.rail > * { scroll-snap-align: start; flex: 0 0 auto; }

/* chip nav (season selector / jump links) */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; text-decoration: none; white-space: nowrap;
  font-size: .86rem; font-weight: 600; color: var(--ink-dim);
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: var(--radius-pill); cursor: pointer; transition: all .15s ease; }
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip[aria-current="true"], .chip.is-active { background: linear-gradient(180deg, var(--honey-hi), var(--honey)); color: var(--honey-ink); border-color: transparent; }

/* small count pill */
.count-pill { font-family: var(--sans); font-size: .72rem; font-weight: 700; color: var(--muted);
  background: var(--bg-elev); border: 1px solid var(--line); padding: 2px 9px; border-radius: var(--radius-pill); }

/* search input */
.search { position: relative; }
.search input { width: 100%; font-family: var(--sans); font-size: .95rem; color: var(--ink);
  background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: var(--radius-pill);
  padding: .68rem 1rem .68rem 2.5rem; outline: none; }
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--honey); box-shadow: 0 0 0 3px rgba(229,9,20,.18); }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* empty state */
.empty-state { text-align: center; color: var(--muted); padding: 2.4rem 1rem; }
.empty-state .em { font-size: 1.8rem; display: block; margin-bottom: .5rem; }

/* toast (resume notice, autoplay-next countdown) */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(8px);
  z-index: 60; max-width: min(92vw, 460px);
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem .8rem .7rem 1rem;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast .msg { flex: 1; font-size: .88rem; line-height: 1.35; }
.toast .msg b { color: var(--honey-hi); font-weight: 700; }
.toast .t-btn { font-family: var(--sans); font-weight: 700; font-size: .82rem; white-space: nowrap;
  border: none; cursor: pointer; padding: .45rem .8rem; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--honey-hi), var(--honey)); color: var(--honey-ink); }
.toast .t-x { background: transparent; color: var(--muted); border: none; cursor: pointer; font-size: 1.1rem; padding: 0 .3rem; }

/* ── shared additive niceties ───────────────────────────────────────────────
   New in the polish pass — additive only, safe to reuse from any page:
   .divider   — a hairline warm rule between sections
   .scroll-top — floating "back to top" button (pages toggle .show) */
.divider { height: 1px; border: 0; margin: 1.6rem 0;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent); }

.scroll-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 55;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; cursor: pointer;
  background: linear-gradient(180deg, var(--honey-hi), var(--honey));
  color: var(--honey-ink); border: 1px solid transparent;
  box-shadow: 0 6px 18px rgba(229,9,20,.32), var(--shadow-sm);
  font-size: 1.15rem; line-height: 1;
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}
.scroll-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-top:hover { transform: translateY(-2px); }

/* ── accessibility / motion ─────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; }
.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; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
      transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { padding: 0 14px; }
  .site-header { padding: 10px 14px; gap: 10px; }
  .site-header .brand span:not(.dim) { font-size: .98rem; }
  .site-header .brand .dim { display: none; }
  .h-hero { font-size: clamp(1.6rem, 7vw, 2.2rem); }
  .scroll-top { right: 12px; bottom: 12px; width: 40px; height: 40px; }
}

/* hard guard: nothing may cause horizontal page overflow on small screens */
html, body { overflow-x: hidden; }
.wrap { width: 100%; }
