/**
 * @file
 * TV4ever – design tokens, reset and typography.
 *
 * Multilingual notes:
 * - Only logical properties (margin-inline, padding-block, inset-inline …)
 *   are used, so the theme works for RTL languages (ar, he, fa) without
 *   separate RTL stylesheets.
 * - The font stack is the platform's own UI font. It covers Latin, Cyrillic,
 *   Greek, Arabic, Hebrew, CJK, Thai, Devanagari … with no downloads and no
 *   third-party font requests (GDPR-friendly).
 * - No text-transform: uppercase and no letter-spacing on running text;
 *   both break or look wrong in many scripts.
 */

:root {
  /* Brand – taken from the TV4ever promo video: warm orange-to-coral
     sunsets, sunny yellow accents, violet/purple scenes and navy ink. */
  --tv-sun: #ff8f2e;
  --tv-amber: #ffd23f;
  --tv-flame: #ff5277;
  --tv-ember: #c02a52;
  --tv-night: #1f1d3d;
  --tv-night-2: #2e2a6b;
  --tv-plum: #5a4fc7;
  --tv-violet: #6c6ff0;
  --tv-purple: #a45de0;
  --tv-teal: #3ecfb5;

  /* Surfaces & text (light). */
  --tv-bg: #fffaf6;
  --tv-surface: #ffffff;
  --tv-surface-2: #fff0ea;
  --tv-border: #f3dcd4;
  --tv-text: #25233f;
  --tv-text-muted: #605d7b;
  --tv-link: #c02a52;
  --tv-link-hover: #8f1d3d;
  --tv-focus: #ff8f2e;

  --tv-success: #1f7a4d;
  --tv-success-bg: #e5f6ec;
  --tv-warning: #8a5a00;
  --tv-warning-bg: #fff4d6;
  --tv-error: #b3261e;
  --tv-error-bg: #fde8e6;

  --tv-gradient-sun: linear-gradient(135deg, var(--tv-amber) 0%, var(--tv-sun) 38%, var(--tv-flame) 100%);
  --tv-gradient-night: radial-gradient(120% 90% at 85% 10%, #8a6cf0 0%, var(--tv-plum) 42%, var(--tv-night-2) 100%);

  /* Typography. */
  --tv-font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --tv-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --tv-fs-sm: 0.9rem;
  --tv-fs-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --tv-fs-lg: clamp(1.125rem, 1.05rem + 0.35vw, 1.3rem);
  --tv-fs-h3: clamp(1.2rem, 1.1rem + 0.45vw, 1.45rem);
  --tv-fs-h2: clamp(1.6rem, 1.3rem + 1.2vw, 2.4rem);
  --tv-fs-h1: clamp(2rem, 1.5rem + 2.2vw, 3.5rem);
  --tv-lh: 1.65;
  --tv-lh-tight: 1.2;

  /* Spacing, shape, depth. */
  --tv-space-1: 0.25rem;
  --tv-space-2: 0.5rem;
  --tv-space-3: 0.75rem;
  --tv-space-4: 1rem;
  --tv-space-5: 1.5rem;
  --tv-space-6: 2rem;
  --tv-space-7: 3rem;
  --tv-space-8: clamp(3rem, 2rem + 4vw, 6rem);
  --tv-radius-sm: 8px;
  --tv-radius: 14px;
  --tv-radius-lg: 24px;
  --tv-radius-pill: 999px;
  --tv-shadow-sm: 0 1px 2px rgb(37 35 63 / 0.06), 0 1px 3px rgb(37 35 63 / 0.08);
  --tv-shadow: 0 4px 10px rgb(37 35 63 / 0.06), 0 12px 32px rgb(37 35 63 / 0.08);
  --tv-shadow-glow: 0 10px 30px rgb(255 143 46 / 0.35);

  /* Layout. */
  --tv-container: 76rem;
  --tv-container-narrow: 46rem;
  --tv-gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);
  --tv-header-h: 4.5rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tv-bg: #15142b;
    --tv-surface: #1f1d3d;
    --tv-surface-2: #292652;
    --tv-border: #3b3768;
    --tv-text: #f2f1fb;
    --tv-text-muted: #b4b1d4;
    --tv-link: #ffa36b;
    --tv-link-hover: #ffd23f;
    --tv-success-bg: #103a26;
    --tv-success: #7fe0aa;
    --tv-warning-bg: #3d2c05;
    --tv-warning: #ffd36b;
    --tv-error-bg: #43130f;
    --tv-error: #ff9d94;
    --tv-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --tv-shadow: 0 8px 28px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}

/* Reset ------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-block-start: calc(var(--tv-header-h) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-family: var(--tv-font);
  font-size: var(--tv-fs-base);
  line-height: var(--tv-lh);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

img,
svg,
video,
iframe {
  max-width: 100%;
}

img,
video {
  height: auto;
}

/* Typography ------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-block: 0 0.6em;
  line-height: var(--tv-lh-tight);
  font-weight: 750;
  color: inherit;
  text-wrap: balance;
  /* Long compound words (de, fi, nl, sv, da) must never overflow. */
  hyphens: auto;
  overflow-wrap: break-word;
}

h1 { font-size: var(--tv-fs-h1); letter-spacing: -0.02em; }
h2 { font-size: var(--tv-fs-h2); letter-spacing: -0.015em; }
h3 { font-size: var(--tv-fs-h3); }
h4 { font-size: var(--tv-fs-lg); }

/* Negative tracking only makes sense for Latin/Cyrillic/Greek. */
:lang(ar) :is(h1, h2),
:lang(fa) :is(h1, h2),
:lang(he) :is(h1, h2),
:lang(ja) :is(h1, h2),
:lang(ko) :is(h1, h2),
:lang(zh) :is(h1, h2),
:lang(th) :is(h1, h2),
:lang(hi) :is(h1, h2) {
  letter-spacing: 0;
}

/* CJK and Arabic scripts need a little more air. */
:lang(ja),
:lang(ko),
:lang(zh),
:lang(ar),
:lang(fa),
:lang(th) {
  --tv-lh: 1.8;
  --tv-lh-tight: 1.35;
}

p,
ul,
ol,
dl,
blockquote,
pre,
table,
figure {
  margin-block: 0 1.1em;
}

p {
  text-wrap: pretty;
}

ul,
ol {
  padding-inline-start: 1.4em;
}

li + li {
  margin-block-start: 0.3em;
}

a {
  color: var(--tv-link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--tv-link-hover);
}

:focus-visible {
  outline: 3px solid var(--tv-focus);
  outline-offset: 3px;
  border-radius: 4px;
}

strong,
b {
  font-weight: 700;
}

small {
  font-size: var(--tv-fs-sm);
}

hr {
  border: 0;
  border-block-start: 1px solid var(--tv-border);
  margin-block: var(--tv-space-6);
}

blockquote {
  margin-inline: 0;
  padding: var(--tv-space-4) var(--tv-space-5);
  border-inline-start: 4px solid var(--tv-sun);
  background: var(--tv-surface-2);
  border-radius: 0 var(--tv-radius-sm) var(--tv-radius-sm) 0;
}

[dir="rtl"] blockquote {
  border-radius: var(--tv-radius-sm) 0 0 var(--tv-radius-sm);
}

code,
kbd,
pre,
samp {
  font-family: var(--tv-font-mono);
  font-size: 0.92em;
}

code {
  padding: 0.1em 0.35em;
  background: var(--tv-surface-2);
  border-radius: 5px;
}

pre {
  padding: var(--tv-space-4);
  overflow-x: auto;
  background: var(--tv-night);
  color: #f2f1fb;
  border-radius: var(--tv-radius-sm);
}

pre code {
  padding: 0;
  background: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

th,
td {
  padding: 0.6em 0.8em;
  text-align: start;
  border-block-end: 1px solid var(--tv-border);
  vertical-align: top;
}

th {
  font-weight: 700;
  background: var(--tv-surface-2);
}

::selection {
  background: var(--tv-amber);
  color: var(--tv-night);
}

/* Utilities -------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px;
  height: 1px;
  word-wrap: normal;
}

.visually-hidden.focusable:is(:active, :focus) {
  position: static !important;
  overflow: visible;
  clip: auto;
  width: auto;
  height: auto;
}

.hidden {
  display: none;
}

.lead {
  font-size: var(--tv-fs-lg);
  color: var(--tv-text-muted);
}
