/* ==========================================================================
   ReyTV public pages (T3): home, changelog, terms, privacy, 404, 500, sign-in handoff.
   Loaded after style.css. Colours only through --rf-* tokens; layout uses logical
   properties so it holds in fa (rtl) and en (ltr). Class prefix: tvh-.
   ========================================================================== */

.tvh-icon { width: 1.25em; height: 1.25em; flex: none; }
.tvh-wrap { width: min(100% - 2 * var(--rf-gutter), var(--container-w)); margin-inline: auto; }
.tvh-link { color: var(--rf-accent-text); text-decoration: underline; text-underline-offset: 3px; }
.tvh-link:hover { text-decoration-thickness: 2px; }


/* ---------- Home v3 (Direction B) ---------- */
.tvstatus { display: inline-flex; align-items: center; gap: 12px; padding: 10px 18px; border-radius: 999px; width: max-content; max-width: 100%; }
.tvh-head { grid-template-columns: minmax(0, 1fr) auto; align-items: end; justify-items: stretch; gap: 16px 32px; }
.tvh-watch { display: grid; gap: 6px; min-width: 0; width: min(100%, 360px); }
.tvh-watch label { color: var(--rf-muted); font-size: var(--rf-fs-sm); font-weight: 600; }
.tvh-watch__row { display: flex; gap: 8px; }
.tvh-watch__row .rf-input { flex: 1; min-width: 0; }
.live-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.cards3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.faq-wrap { max-width: 860px; display: grid; gap: 24px; }
.tvh-lavatar { position: relative; z-index: 1; width: 42%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 2px solid var(--rf-line-strong); align-self: center; justify-self: center; }
.tvh-obs { margin-top: 24px; }
.tvh-obs .rf-btn { gap: 8px; }
.rf-empty { border: 1px dashed var(--rf-line-strong); border-radius: 20px; }
.tvh-empty { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 24px 16px; color: var(--rf-muted); }
.tvh-empty__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--rf-accent-dim); color: var(--rf-accent-text); }
.rf-step, .rf-faq details { transition: border-color var(--rf-dur-2) var(--rf-ease-out), transform var(--rf-dur-2) var(--rf-ease-out); }
@media (max-width: 1023px) { .live-grid, .cards3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) {
  .live-grid, .cards3 { grid-template-columns: 1fr; }
  .tvh-head { grid-template-columns: 1fr; }
  .tvh-watch { width: 100%; }
  .tvstatus { flex-wrap: wrap; border-radius: 20px; }
}

/* ---------- Changelog: timeline ---------- */
.tvh-page { width: min(100% - 2 * var(--rf-gutter), 1280px); margin-inline: auto; padding-block: var(--sp-6) var(--sp-7); }
.tvh-page__head { margin-bottom: var(--sp-5); max-width: 820px; }
.tvh-page .tvh-timeline { max-width: 820px; }
.tvh-page__head h1 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--rf-fs-2xl); }
.tvh-page__head h1 .tvh-icon { color: var(--rf-accent-text); width: 1.1em; height: 1.1em; }
.tvh-page__head p { margin-top: 0.4rem; color: var(--text-dim); }

.tvh-timeline { --meta-w: 8.5rem; --rail: 28px; position: relative; list-style: none; margin: 0; padding: 0; }
.tvh-entry { position: relative; display: grid; grid-template-columns: var(--meta-w) var(--rail) minmax(0, 1fr); column-gap: var(--sp-2); }
.tvh-entry__meta { padding-block-start: var(--sp-3); text-align: end; }
.tvh-entry__node { position: relative; display: block; }
.tvh-entry__node::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: calc(50% - 1px); width: 2px; background: var(--border-strong); }
.tvh-entry:first-child .tvh-entry__node::before { inset-block-start: 26px; }
.tvh-entry:last-child .tvh-entry__node::before { inset-block-end: calc(100% - 26px); }
.tvh-entry__node::after { content: ""; position: absolute; inset-block-start: 20px; inset-inline-start: calc(50% - 7px); width: 14px; height: 14px; box-sizing: border-box; border-radius: 50%; background: var(--bg); border: 3px solid var(--rf-accent); transition: background-color var(--rf-dur-2) var(--rf-ease-out); }
.tvh-entry--latest .tvh-entry__node::after { background: var(--rf-accent); }
@media (hover: hover) { .tvh-entry:hover .tvh-entry__node::after { background: var(--rf-accent); } }
.tvh-entry__body { padding: var(--sp-3) var(--sp-3) var(--sp-4); border-radius: var(--rf-radius-md); }
.tvh-entry--latest .tvh-entry__body { background: var(--bg-panel-2); }
.tvh-entry__version { display: block; font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; }
.tvh-entry__date { display: block; margin-top: 0.15rem; color: var(--text-dim); font-size: var(--rf-fs-xs); font-variant-numeric: tabular-nums; }
.tvh-entry__body .tvh-badge { margin-bottom: var(--sp-1); }
.tvh-entry h2 { font-size: var(--rf-fs-lg); margin-bottom: 0.3rem; }
.tvh-entry ul { margin: 0; padding-inline-start: 1.1rem; }
.tvh-entry li { color: var(--text-dim); font-size: var(--rf-fs-sm); line-height: 1.7; }
.tvh-entry li::marker { color: var(--rf-accent-text); }

/* Badges: accent-dim fill, accent text (ink on Bone). Category is also carried by the icon. */
.tvh-badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem; border: 1px solid color-mix(in srgb, var(--rf-accent) 45%, transparent); border-radius: var(--rf-radius-xs); background: var(--rf-accent-dim); color: var(--rf-accent-text); font-size: var(--rf-fs-xs); font-weight: 700; line-height: 1.4; }
.tvh-badge .tvh-icon { width: 14px; height: 14px; }
.tvh-badge[data-cat="breaking"] { border-style: dashed; }
.tvh-empty-note { padding: var(--sp-5); border: 1px dashed var(--border-strong); border-radius: var(--rf-radius-md); color: var(--text-dim); text-align: center; }

/* ---------- Terms and privacy: narrow column ---------- */
.tvh-legal { width: min(100% - 2 * var(--rf-gutter), 66ch); margin-inline: auto; }
.tvh-toc { display: none; }
.tvh-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.tvh-toc li { counter-increment: toc; }
.tvh-toc a { display: flex; gap: var(--sp-2); padding: 0.45rem var(--sp-2); border-inline-start: 2px solid var(--border); color: var(--text-dim); font-size: var(--rf-fs-sm); text-decoration: none; transition: color var(--rf-dur-2) var(--rf-ease-out), border-color var(--rf-dur-2) var(--rf-ease-out), background-color var(--rf-dur-2) var(--rf-ease-out); }
.tvh-toc a::before { content: counter(toc, decimal-leading-zero); font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--rf-accent-text); }
@media (hover: hover) { .tvh-toc a:hover { color: var(--text); border-color: var(--rf-accent); background: var(--rf-hover); } }
.tvh-toc a:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: 2px; }
.tvh-doc { width: 100%; min-width: 0; padding-block: var(--sp-6) var(--sp-7); }
.tvh-doc__head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-3); align-items: center; padding-block-end: var(--sp-4); margin-bottom: var(--sp-4); border-bottom: 1px solid var(--border); }
.tvh-doc__tile { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--rf-radius-md); background: var(--rf-accent-dim); color: var(--rf-accent-text); }
.tvh-doc__tile .tvh-icon { width: 26px; height: 26px; }
.tvh-doc h1 { font-size: var(--rf-fs-2xl); line-height: 1.2; }
.tvh-doc__updated { margin-top: 0.2rem; color: var(--text-dim); font-size: var(--rf-fs-sm); }
.tvh-doc__body { counter-reset: sec; }
.tvh-doc__sec { counter-increment: sec; padding-block: var(--sp-3); }
.tvh-doc h2 { display: flex; align-items: baseline; gap: var(--sp-2); font-size: var(--rf-fs-xl); margin-bottom: var(--sp-1); scroll-margin-top: calc(var(--rf-header-h) + 16px); }
.tvh-doc h2::before { content: counter(sec, decimal-leading-zero); font-family: var(--font-mono); font-size: var(--rf-fs-sm); color: var(--rf-accent-text); font-variant-numeric: tabular-nums; }
.tvh-doc p, .tvh-doc li { color: var(--text-dim); line-height: 1.9; }
.tvh-doc ul { margin: var(--sp-1) 0; padding-inline-start: 1.25rem; }
.tvh-doc li::marker { color: var(--rf-accent-text); }
.tvh-doc .notice { margin-block: var(--sp-2); align-items: flex-start; gap: var(--sp-1); }
.tvh-doc .notice .tvh-icon { margin-top: 0.2rem; }

/* ---------- 404 / 500 ---------- */
.tvh-err { width: min(100% - 2 * var(--rf-gutter), var(--container-w)); margin-inline: auto; padding-block: var(--sp-7); display: grid; gap: var(--sp-6); align-items: center; }
.tvh-err__main { display: grid; justify-items: start; gap: var(--sp-3); min-width: 0; }
.tvh-err__num { font-family: var(--font-mono); font-size: clamp(5rem, 3rem + 12vw, 10rem); font-weight: 700; line-height: 0.95; letter-spacing: -0.04em; color: transparent; -webkit-text-stroke: 2px var(--rf-accent-text); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.tvh-err--danger .tvh-err__num { -webkit-text-stroke-color: var(--live); }
.tvh-err__bars { display: flex; align-items: center; gap: 6px; height: 12px; }
.tvh-err__bars span { width: 28px; height: 2px; border-radius: var(--r-full); background: var(--border-strong); }
.tvh-err h1 { font-size: var(--rf-fs-2xl); text-wrap: balance; }
.tvh-err__main p { color: var(--text-dim); max-width: 40ch; }
.tvh-err__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-1); }
.tvh-err__actions .btn { min-height: 48px; }
.tvh-err__live { padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--rf-radius-lg); background: var(--bg-panel); min-width: 0; }
.tvh-err__live h2 { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); font-size: var(--rf-fs-lg); }
.tvh-err__live .tvh-empty { padding: var(--sp-3) 0 0; border: 0; background: none; }
.tvh-err__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); }
.tvh-err__row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2); min-height: 56px; padding: var(--sp-1) var(--sp-2); border-radius: var(--rf-radius-md); color: inherit; text-decoration: none; transition: background-color var(--rf-dur-2) var(--rf-ease-out); }
@media (hover: hover) { .tvh-err__row:hover { background: var(--rf-hover); } }
.tvh-err__row:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: 2px; }
.tvh-err__who { display: grid; min-width: 0; }
.tvh-err__who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Sign-in handoff ---------- */
.tvh-handoff { width: min(100% - 2 * var(--rf-gutter), 420px); margin-inline: auto; padding-block: var(--sp-7); min-height: 50dvh; display: grid; align-content: center; gap: var(--sp-3); }
.tvh-handoff__card { display: grid; gap: var(--sp-3); padding: var(--sp-5); border: 1px solid var(--border-strong); border-radius: var(--rf-radius-lg); background: var(--bg-panel); }
.tvh-handoff__head { display: flex; align-items: center; gap: var(--sp-3); }
.tvh-handoff__ring { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--rf-accent-dim); color: var(--rf-accent-text); }
.tvh-handoff__card[data-state="failed"] .tvh-handoff__ring::after { animation: none; }
.tvh-handoff h1 { font-size: var(--rf-fs-lg); }
.tvh-handoff p { color: var(--text-dim); font-size: var(--rf-fs-sm); }
.tvh-handoff__card .btn { justify-self: start; min-height: 44px; }
.tvh-handoff__card .btn[hidden] { display: none; }
.tvh-handoff__skel { display: grid; gap: var(--sp-1); }
.tvh-handoff__skel[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (min-width: 1024px) {
  .tvh-legal { width: min(100% - 2 * var(--rf-gutter), calc(220px + var(--sp-6) + 68ch)); display: grid; grid-template-columns: 220px minmax(0, 68ch); gap: var(--sp-6); align-items: start; }
  .tvh-toc { display: block; position: sticky; top: calc(var(--rf-header-h) + var(--sp-4)); padding-block: var(--sp-6); }
  .tvh-err { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); }
}
@media (max-width: 1023px) {
}
@media (max-width: 639px) {
  .tvh-timeline { --rail: 24px; }
  .tvh-entry { grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-areas: "node meta" "node body"; column-gap: var(--sp-1); }
  .tvh-entry__node { grid-area: node; }
  .tvh-entry__meta { grid-area: meta; display: flex; align-items: baseline; gap: var(--sp-2); text-align: start; padding-inline: var(--sp-3); }
  .tvh-entry__date { margin-top: 0; }
  .tvh-entry__body { grid-area: body; padding-block-start: var(--sp-1); }
}
@media (max-width: 479px) {
}

h1.panel-header { font-size: var(--rf-fs-base); }
