/* Chooni.ir — Browse page layout. Consumes tokens.css + base.css.
   Fluid: filter rail (inline-end / right in RTL) + editorial results.
   Rail collapses above the results under 900px behind a "فیلترها" disclosure. */

/* ---- Page header: H1 is generated from the active filters (SEO) ---- */
.browse-head { position: relative; overflow: hidden; padding-block: 20px 16px; border-bottom: 1px solid var(--line-2); }
.browse-head__glow { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(900px 400px at 85% 0%, rgb(var(--amber-rgb) / 0.10) 0%, rgb(var(--bg-rgb) / 0) 70%); }
.browse-head__row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: clamp(20px, 4vw, 40px); flex-wrap: wrap; }
.browse-head__titles { display: flex; flex-direction: column; gap: 8px; max-width: 900px; }

/* Breadcrumb: چونی › ویدیو › ... — plain and muted, the H1 below carries the weight. */
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--amber); }
.crumb-sep { color: var(--dim); }
.browse-head h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
.browse-head p { margin: 0; color: var(--muted); font-size: clamp(15px, 2vw, 17px); line-height: 1.8; }
.sortbox { display: flex; flex-direction: column; gap: 8px; }
.sortbox__chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Section switch: kept in the DOM for browse.js (reads active section from it),
   hidden from view — the navbar already carries the four sections. ---- */
.sectionswitch { display: flex; gap: 8px; flex-wrap: wrap; margin-block: 8px 4px; }
.sectionswitch[hidden] { display: none; }
.sectionswitch .seg { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); font-size: 15px; font-weight: 600; cursor: pointer; }
.sectionswitch .seg:hover { border-color: var(--amber-line); color: var(--ink); }
.sectionswitch .seg.is-on { border-color: var(--amber); background: var(--amber); color: var(--on-amber); }
.sectionswitch .seg .count { color: inherit; opacity: 0.7; font-weight: 500; }

/* ---- Body grid ---- */
.browse-body { display: grid; grid-template-columns: clamp(240px, 24vw, 300px) 1fr; gap: clamp(28px, 5vw, 64px); align-items: start; }

/* ---- Filter rail ----
   One scroll area for the whole rail (sticky, capped to the viewport) instead of a
   scrollbar per group — the page itself never has to scroll to reach a filter. */
.rail { display: flex; flex-direction: column; position: sticky; top: 20px; align-self: start; max-height: calc(100vh - 40px); }
.rail__panel { padding: 0 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
.rail__panel::-webkit-scrollbar { width: 8px; }
.rail__panel::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }
.rail__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 0 8px; }
.rail__head .display { font-size: 28px; line-height: 1; }
/* Accordion group: header row + a body whose height animates (grid 0fr ↔ 1fr), so opening and
   closing slide instead of jumping. A collapsed body is also `visibility: hidden` — its links
   leave the tab order — switched only after the slide ends. Transitions are on only once
   browse.js has applied the remembered open/closed state (.rail.is-ready), so a page load
   never animates. */
.f-group { display: grid; grid-template-rows: auto 1fr; padding: 16px 0; border-bottom: 1px solid var(--line); }
.f-group.is-last, .f-group--flat { border-bottom: 0; }
.f-group.is-collapsed { grid-template-rows: auto 0fr; }
.f-body { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 12px; }
.f-body > :first-child { margin-top: 14px; }
.f-group.is-collapsed .f-body { visibility: hidden; }
.rail.is-ready .f-group { transition: grid-template-rows .24s cubic-bezier(.2, .7, .2, 1); }
.rail.is-ready .f-body { transition: visibility 0s; }
.rail.is-ready .f-group.is-collapsed .f-body { transition: visibility 0s .24s; }
@media (prefers-reduced-motion: reduce) { .rail.is-ready .f-group { transition: none; } }

/* Header: a real <button> — the whole row toggles; the pick count and chevron sit at the end. */
.f-title { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; user-select: none; }
.f-title:hover .eyebrow { color: var(--ink); }
.f-title .chev { margin-inline-start: auto; color: var(--dim); flex-shrink: 0; transition: transform .2s ease; }
.f-title[aria-expanded="false"] .chev { transform: rotate(90deg); }
.f-picked { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--amber); color: var(--on-amber); font-size: 11px; font-weight: 700; line-height: 1; }
.f-list { display: flex; flex-direction: column; gap: 2px; }
.f-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.count { color: var(--dim); font-size: 12px; }

/* Keyboard focus is always visible in the rail (links and buttons alike). */
.rail :is(a, button, input):focus-visible, .results__head a:focus-visible, .sortbox a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* checkbox / radio option rows */
.f-opt { display: flex; align-items: center; justify-content: space-between; min-height: 36px; padding-inline: 6px; margin-inline: -6px; border-radius: 4px; color: var(--muted); font-size: 15px; cursor: pointer; transition: background-color .12s ease, color .12s ease; }
.f-opt:hover { background: rgb(var(--ink-rgb) / 0.04); color: var(--ink); }
.f-opt .lead { display: flex; align-items: center; gap: 12px; }
.f-opt.is-on { color: var(--ink); font-weight: 600; }
.f-opt .box, .f-opt .radio { transition: background-color .12s ease, border-color .12s ease, border-width .12s ease; }

/* Long option lists (publishers): the rest behind a native disclosure, same row style inside. */
.f-more > summary { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--teal); font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; }
.f-more > summary::-webkit-details-marker { display: none; }
.f-more > summary:hover { color: var(--amber); }
.f-more[open] > summary { margin-bottom: 6px; }
.f-opt .publisher-mark { width: 38px; height: 24px; padding: 2px 4px; }

/* Toggle chips (genre, decade): label + its count; on = filled amber. */
.f-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .12s ease, border-color .12s ease, color .12s ease; }
.f-chip:hover { border-color: var(--amber-line); color: var(--ink); }
.f-chip__n { color: var(--dim); font-size: 11px; font-weight: 500; }
.f-chip.is-on { border-color: var(--amber); background: var(--amber); color: var(--on-amber); font-weight: 700; }
.f-chip.is-on .f-chip__n { color: inherit; opacity: .75; }

/* Active-filter pills above the results: label + ✕, removed with one click. */
.pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--amber-line); background: rgb(var(--amber-rgb) / 0.10); color: var(--amber); font-size: 12px; font-weight: 600; white-space: nowrap; transition: opacity .12s ease, background-color .12s ease; }
.pill:hover { background: rgb(var(--amber-rgb) / 0.18); color: var(--amber); }
.pill.is-leaving { opacity: 0; pointer-events: none; }

/* While a filter change loads: results dim after a short delay (no flash on a fast answer). */
.results > :not(.results__head) { transition: opacity .2s ease; }
.results[aria-busy="true"] > :not(.results__head) { opacity: .45; transition-delay: .12s; pointer-events: none; }
/* Game modes: a row = "require it" (the option) + "بدون" (exclude it). */
.f-mode { display: flex; align-items: center; gap: 10px; }
.f-mode .f-opt { flex: 1; min-width: 0; }
.f-mode__not { flex: none; height: 24px; padding: 0 8px; display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; font-size: 11px; color: var(--dim); text-decoration: none; }
.f-mode__not:hover { color: var(--ink); border-color: var(--ink); }
.f-mode__not.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 700; }
.f-mode.is-excluded .f-opt .lead { text-decoration: line-through; color: var(--dim); }
.box { width: 18px; height: 18px; border-radius: 2px; border: 1px solid rgb(var(--ink-rgb) / 0.30); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.f-opt.is-on .box { background: var(--amber); border-color: var(--amber); }
.box svg { opacity: 0; color: #0E0B08; font-size: 11px; }
.pill__x { font-size: 10px; }
.f-opt.is-on .box svg { opacity: 1; }
.radio { width: 18px; height: 18px; border-radius: 999px; border: 1px solid rgb(var(--ink-rgb) / 0.30); box-sizing: border-box; flex-shrink: 0; }
.f-opt.is-on .radio { border: 5px solid var(--amber); }
.chip.is-on { border-color: var(--amber); background: var(--amber); color: var(--on-amber); font-weight: 700; }
.chip, .sectionswitch .seg, .f-opt, .sort-chip { cursor: pointer; }
.f-mode__not, .sort-chip { transition: background-color .12s ease, border-color .12s ease, color .12s ease; }

/* score slider */
.f-slider { width: 100%; accent-color: var(--amber); }
.f-scale { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; }

/* mobile filters disclosure — hidden on desktop */
.rail-toggle { display: none; }

/* ---- Results ---- */
.results { display: flex; flex-direction: column; min-width: 0; scroll-margin-top: 16px; }
.results__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px 0 8px; flex-wrap: wrap; }
.active-chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result { display: grid; grid-template-columns: clamp(110px, 12vw, 160px) 1fr auto; gap: clamp(16px, 3vw, 32px); align-items: start; padding: 28px 0; border-bottom: 1px solid var(--line); color: inherit; }
.result.is-hidden, .result-feature.is-hidden { display: none; }
.still { position: relative; aspect-ratio: 2 / 3; width: 100%; border-radius: 4px; overflow: hidden; background: var(--panel-2); }
.still .cover-img { position: absolute; inset: 0; }
.result__body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* Card text hierarchy, no badges: title → facts (year · platforms · length · language)
   → genres → lead review → where to watch / game modes. Each line is plain text with one
   separator style; what the active filter matched is ordered first and set in ink. */
.result__title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.result__title .display { font-size: clamp(26px, 4vw, 38px); line-height: 1.05; }
/* The English name: large and high-contrast (--muted is dark on light, light on dark). */
.result__title .latin { color: var(--muted); font-size: clamp(17px, 1.6vw, 20px); font-style: italic; font-weight: 500; }
.result__facts { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; line-height: 1.6; }
.result__facts .sep, .result__modes .sep { color: var(--dim); }
.result__lang { display: inline-flex; align-items: center; gap: 6px; }
.result__genres { margin: -4px 0 0; color: var(--dim); font-size: 14px; line-height: 1.6; }
.result .is-match { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--amber); }
.result__line { margin: 4px 0 0; font-size: 16px; line-height: 1.8; color: var(--muted); max-width: 560px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.result__foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result__modes { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--dim); font-size: 13px; }
.result__score { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }

/* feature (lead) result — a photo-backed card: pin it dark regardless of the page
   theme (its own scrim gradient is already a literal near-black, so the light-on-dark
   text must stay fixed too, or a light theme would flip the ink dark and make it
   unreadable against the still-dark scrim). */
.result-feature {
  --ink: #F4EEE4; --muted: #B9AE9E; --dim: #7A6F62;
  --line: rgba(244, 238, 228, 0.10); --line-2: rgba(244, 238, 228, 0.22);
  --panel-2: #1B1620;
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(20px, 4vw, 40px); align-items: end; min-height: 380px; margin: 20px 0 8px; padding: clamp(24px, 4vw, 40px); border-radius: 4px; overflow: hidden; color: inherit;
  background: linear-gradient(90deg, rgba(14,11,8,0.96) 0%, rgba(14,11,8,0.7) 50%, rgba(14,11,8,0.1) 100%), radial-gradient(700px 400px at 20% 30%, rgba(111,168,166,0.36) 0%, rgba(20,16,25,0) 70%), var(--panel-2); }
.result-feature__body { position: relative; display: flex; flex-direction: column; gap: 14px; }
.result-feature__body .display { font-size: clamp(40px, 6vw, 64px); line-height: 1; }
.result-feature__aside { position: relative; display: flex; flex-direction: column; gap: 18px; align-self: end; }

.results__more { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 40px 0 0; }
.btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 52px; padding: 0 28px; border-radius: 2px; border: 1px solid var(--line-2); color: var(--ink); font-size: 16px; font-weight: 600; }
.empty { padding: 48px 0; color: var(--muted); font-size: 16px; }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 900px) {
  .browse-body { grid-template-columns: 1fr; }
  .rail-toggle { display: inline-flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 0 18px; margin-top: 8px; border: 1px solid var(--line-2); border-radius: 4px; background: transparent; color: var(--ink); font-size: 16px; font-weight: 600; cursor: pointer; }
  .rail { position: static; max-height: none; }
  .rail__panel { display: none; overflow-y: visible; }
  .rail.is-open .rail__panel { display: block; }
  .result-feature { grid-template-columns: 1fr; min-height: 0; }
}
@media (max-width: 620px) {
  .result { grid-template-columns: 96px 1fr; }
  .result__score { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
}
