/*
 * base.css — tokens globais do Grupo Base (mobile-first, tema por atributo)
 *
 * Camadas:
 *  1. primitivos  (paleta crua, nunca usada direto pelos componentes)
 *  2. semânticos  (--bg, --fg, --accent…: é O QUE os componentes consomem)
 *  3. overrides   ([data-season], prefers-color-scheme, [data-input])
 *
 * Breakpoints (em, base 16px): 600→37.5em · 900→56.25em · 1200→75em · 1920→120em · 3840→240em
 * 360px é a base (sem media query).
 */

/* ===== 1. primitivos ===== */
:root {
  --c-ink-950: #0b0f14; --c-ink-900: #111827; --c-ink-700: #374151; --c-ink-500: #6b7280;
  --c-paper-50: #fafaf9; --c-paper-100: #f3f2ef; --c-paper-200: #e5e3dd;
  --c-amber-700: #b45309; --c-amber-500: #f59e0b; --c-amber-300: #fcd34d;   /* verão */
  --c-rust-700:  #b4410c; --c-rust-500:  #ea580c; --c-rust-300:  #fdba74;   /* outono */
  --c-ice-700:   #0e7490; --c-ice-500:   #06b6d4; --c-ice-300:   #67e8f9;   /* inverno */
  --c-leaf-700:  #15803d; --c-leaf-500:  #22c55e; --c-leaf-300:  #86efac;   /* primavera */
}

/* ===== 2. semânticos (padrão = claro, primavera) ===== */
:root {
  color-scheme: light dark;

  --bg: var(--c-paper-50);        /* fundo da página */
  --bg-2: var(--c-paper-100);     /* superfícies (cards, player) */
  --line: var(--c-paper-200);     /* bordas */
  --fg: var(--c-ink-900);         /* texto */
  --fg-2: var(--c-ink-700);       /* texto secundário */

  --accent: var(--c-leaf-700);    /* botões/realces — contraste ≥4.5:1 com --on-accent */
  --on-accent: #ffffff;
  --accent-text: var(--c-leaf-700); /* acento usado COMO texto sobre --bg */
  --accent-soft: var(--c-leaf-300); /* halos, gradientes, fundos leves */
  --focus: var(--c-ink-900);        /* anel de foco: sempre alto contraste */

  /* espaçamento e forma (rem = escala com a fonte do aparelho) */
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-12: 3rem;
  --radius: .75rem; --radius-lg: 1.25rem;
  --shadow: 0 .25rem 1rem rgba(0, 0, 0, .12);

  /* tipografia fluida */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --step--1: clamp(.85rem, .8rem + .25vw, 1rem);
  --step-0: clamp(1rem, .95rem + .3vw, 1.2rem);
  --step-1: clamp(1.2rem, 1.05rem + .7vw, 1.6rem);
  --step-2: clamp(1.5rem, 1.2rem + 1.4vw, 2.4rem);

  --hit: 2.75rem;                 /* alvo mínimo de toque (44px) */
  --dur: .2s;                     /* duração padrão de transições */
}

/* ===== 3a. estações (só remapeiam semânticos) ===== */
[data-season="verao"]     { --accent: var(--c-amber-700); --accent-text: var(--c-amber-700); --accent-soft: var(--c-amber-300); }
[data-season="outono"]    { --accent: var(--c-rust-700);  --accent-text: var(--c-rust-700);  --accent-soft: var(--c-rust-300); }
[data-season="inverno"]   { --accent: var(--c-ice-700);   --accent-text: var(--c-ice-700);   --accent-soft: var(--c-ice-300); }
[data-season="primavera"] { --accent: var(--c-leaf-700);  --accent-text: var(--c-leaf-700);  --accent-soft: var(--c-leaf-300); }

/* ===== 3b. escuro: preferência do sistema (ou data-theme="dark" manual) ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--c-ink-950); --bg-2: var(--c-ink-900); --line: var(--c-ink-700);
    --fg: var(--c-paper-50); --fg-2: #cbd5e1; --focus: #ffffff;
    --shadow: 0 .25rem 1rem rgba(0, 0, 0, .5);
  }
  /* no escuro o acento sobe de tom para continuar legível como texto */
  :root:not([data-theme="light"])[data-season="verao"]     { --accent-text: var(--c-amber-300); --on-accent: #ffffff; }
  :root:not([data-theme="light"])[data-season="outono"]    { --accent-text: var(--c-rust-300); }
  :root:not([data-theme="light"])[data-season="inverno"]   { --accent-text: var(--c-ice-300); }
  :root:not([data-theme="light"])[data-season="primavera"] { --accent-text: var(--c-leaf-300); }
}
:root[data-theme="dark"] {
  --bg: var(--c-ink-950); --bg-2: var(--c-ink-900); --line: var(--c-ink-700);
  --fg: var(--c-paper-50); --fg-2: #cbd5e1; --focus: #ffffff;
}

/* ===== base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--font); font-size: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: var(--step-0); line-height: 1.5; }
img, svg, video, iframe { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; } /* vence qualquer display: de componente */

/* foco visível grande — obrigatório para D-pad e teclado; nunca só-hover */
:focus { outline: none; }
:focus-visible { outline: .25rem solid var(--focus); outline-offset: .2rem; border-radius: var(--radius); }
[data-input="tv"] :focus-visible {
  outline-width: .375rem; outline-offset: .3rem;
  box-shadow: 0 0 0 .75rem var(--accent-soft);
}
/* navegadores sem :focus-visible (TVs antigas): foco sempre visível */
@supports not selector(:focus-visible) { :focus { outline: .25rem solid var(--focus); outline-offset: .2rem; } }

/* mais espaço e alvos maiores quando a leitura é a 3 m (TV) */
[data-input="tv"] { --hit: 3.5rem; --space-4: 1.25rem; --space-6: 2rem; }

/* ===== utilitários mínimos ===== */
.container { width: min(100% - 2 * var(--space-4), 75rem); margin-inline: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--hit); padding: var(--space-2) var(--space-6);
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--radius);
  text-decoration: none; cursor: pointer; transition: transform var(--dur), filter var(--dur);
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* moldura 16:9 para vídeo/iframe: aspect-ratio com fallback padding-top */
.frame-16x9 { position: relative; width: 100%; background: var(--bg-2); border-radius: var(--radius-lg); overflow: hidden; }
.frame-16x9 > * { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@supports (aspect-ratio: 16 / 9) {
  .frame-16x9 { aspect-ratio: 16 / 9; }
}
@supports not (aspect-ratio: 16 / 9) {
  .frame-16x9::before { content: ""; display: block; padding-top: 56.25%; }
}

/* ===== breakpoints (mobile-first) ===== */
@media (min-width: 37.5em)  { :root { --space-4: 1.25rem; } }               /* 600  */
@media (min-width: 56.25em) { :root { --radius-lg: 1.5rem; } }              /* 900  */
@media (min-width: 75em)    { html { font-size: 106.25%; } }                /* 1200 → 17px */
@media (min-width: 120em)   { html { font-size: 125%; } }                   /* 1920 → 20px: sofá/TV */
@media (min-width: 240em)   { html { font-size: 200%; } :root { --hit: 4rem; } } /* 3840 → 4K */

/* ===== movimento: respeitar preferência e poupar TV/celular fraco ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) { :root { --line: currentColor; } }
