/* System design — Hub (uso personal, modo Operate/consumo)
   Tokens semánticos primero; los componentes solo usan var(--*). */
:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #14171c;
  --text-muted: #5b6370;
  --border: #dde1e7;
  --accent: #0b6bcb;
  --accent-text: #ffffff;
  --live: #d92d20;
  --live-soft: #fde8e7;
  --danger: #b42318;
  --focus: #0b6bcb;
  --shadow: 0 8px 32px rgb(15 17 21 / 0.18);
  --player-bg: #000000;

  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 20px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --gutter: 16px;
  --tabs-h: 64px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 0.75rem;
  --fs-s: 0.875rem;
  --fs-m: 1rem;
  --fs-l: 1.25rem;
  --fs-xl: 1.75rem;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-in: 280ms;
  --dur-out: 180ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #eef0f3;
    --text-muted: #9aa3b0;
    --border: #2c313a;
    --accent: #5aa9ff;
    --accent-text: #0b1220;
    --live: #ff6b5e;
    --live-soft: #3a1714;
    --danger: #ff8a7f;
    --focus: #5aa9ff;
    --shadow: 0 8px 32px rgb(0 0 0 / 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #181b21; --surface-2: #22262e; --text: #eef0f3;
  --text-muted: #9aa3b0; --border: #2c313a; --accent: #5aa9ff; --accent-text: #0b1220;
  --live: #ff6b5e; --live-soft: #3a1714; --danger: #ff8a7f; --focus: #5aa9ff;
  --shadow: 0 8px 32px rgb(0 0 0 / 0.5);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- botones ---- */
.btn, .icon-btn, .tab, .seg__btn, .card, .chip-link {
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-out) var(--ease-out), opacity var(--dur-out) var(--ease-out);
}
.btn:active, .icon-btn:active, .tab:active, .seg__btn:active, .card:active, .chip-link:active { transform: scale(0.97); }
.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 44px; padding: 0 var(--space-5);
  border-radius: var(--radius-m); font-weight: 600;
}
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--ghost { background: var(--surface-2); color: var(--text); }
.icon-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; color: var(--text-muted);
}
.icon-btn svg { width: 22px; height: 22px; }
@media (pointer: fine) {
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .card:hover { border-color: var(--text-muted); }
  .btn--primary:hover { opacity: 0.9; }
}

/* ---- puerta ---- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); }
.gate__card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-l);
  padding: var(--space-6) var(--space-5); display: grid; gap: var(--space-4);
}
.gate__title { margin: 0; font-size: var(--fs-xl); }
.gate__text { margin: 0; color: var(--text-muted); font-size: var(--fs-s); }
.gate__error { margin: 0; color: var(--danger); font-size: var(--fs-s); }
.field { display: grid; gap: var(--space-2); }
.field__label { font-size: var(--fs-s); color: var(--text-muted); }
.field__input, .search__input {
  width: 100%; min-height: 44px; padding: 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--surface-2); color: var(--text); font: inherit;
}

/* ---- shell ---- */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--gutter) var(--space-3);
  background: var(--bg);
}
.top__title { margin: 0; font-size: var(--fs-xl); }
.toolbar { display: grid; gap: var(--space-3); padding: 0 var(--gutter) var(--space-3); }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: var(--radius-m); padding: 3px; justify-self: start; }
.seg__btn { appearance: none; border: 0; background: transparent; cursor: pointer; min-height: 36px; padding: 0 var(--space-4); border-radius: 9px; color: var(--text-muted); font-weight: 600; font-size: var(--fs-s); }
.seg__btn[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

.content { padding: 0 var(--gutter) var(--space-6); max-width: 960px; margin: 0 auto; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 2px;
  color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }

/* ---- secciones y tarjetas ---- */
.group { margin-top: var(--space-5); }
.group__title { margin: 0 0 var(--space-2); font-size: var(--fs-s); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.list { display: grid; gap: var(--space-2); }
.card {
  appearance: none; text-align: left; width: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: var(--space-3) var(--space-4);
}
.match { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-3); align-items: center; }
.match__team { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match__score { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-l); text-align: right; }
.match__meta { grid-column: 1 / -1; display: flex; gap: var(--space-2); align-items: center; color: var(--text-muted); font-size: var(--fs-xs); }
.badge-live {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--live-soft); color: var(--live);
  padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: var(--fs-xs);
}
.badge-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.channel { display: grid; gap: var(--space-2); justify-items: start; min-height: 96px; align-content: space-between; }
.channel__logo { width: 48px; height: 48px; object-fit: contain; border-radius: var(--radius-s); background: var(--surface-2); }
.channel__name { font-weight: 600; font-size: var(--fs-s); }
.channel__kind { font-size: var(--fs-xs); color: var(--text-muted); }

.poster-card { padding: 0; overflow: hidden; display: grid; }
.poster { aspect-ratio: 2 / 3; width: 100%; object-fit: cover; background: var(--surface-2); }
.poster--empty { display: grid; place-items: center; color: var(--text-muted); font-size: var(--fs-xs); padding: var(--space-2); text-align: center; }
.poster-card__body { padding: var(--space-2) var(--space-3) var(--space-3); display: grid; gap: 2px; }
.poster-card__title { font-weight: 600; font-size: var(--fs-s); line-height: 1.3; }
.poster-card__meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---- estados ---- */
.state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-muted); display: grid; gap: var(--space-3); justify-items: center; }
.state__title { margin: 0; color: var(--text); font-weight: 600; }
.state__text { margin: 0; font-size: var(--fs-s); max-width: 36ch; }
.skeleton { background: var(--surface-2); border-radius: var(--radius-m); height: 72px; animation: pulse 1.2s var(--ease-out) infinite alternate; }
.grid .skeleton { height: auto; aspect-ratio: 2 / 3; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }
.note { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-5); }

/* ---- hoja ---- */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.5); opacity: 0; transition: opacity var(--dur-in) var(--ease-out); }
.sheet__panel {
  position: relative; background: var(--surface); width: 100%;
  max-height: 92dvh; overflow: auto; border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding-bottom: env(safe-area-inset-bottom); box-shadow: var(--shadow);
  transform: translateY(24px); opacity: 0;
  transition: transform var(--dur-in) var(--ease-out), opacity var(--dur-in) var(--ease-out);
}
.sheet.is-open .sheet__backdrop { opacity: 1; }
.sheet.is-open .sheet__panel { transform: none; opacity: 1; }
.sheet.is-closing .sheet__backdrop, .sheet.is-closing .sheet__panel { transition-duration: var(--dur-out); }
@media (min-width: 720px) {
  .sheet { align-items: center; justify-items: center; padding: var(--space-5); }
  .sheet__panel { max-width: 640px; border-radius: var(--radius-l); }
}
.sheet__head { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-2) var(--space-5); z-index: 1; }
.sheet__title { margin: 0; font-size: var(--fs-l); }
.sheet__body { padding: 0 var(--space-5) var(--space-5); display: grid; gap: var(--space-4); }
.detail-hero { display: grid; grid-template-columns: 110px 1fr; gap: var(--space-4); align-items: start; }
.detail-hero .poster { border-radius: var(--radius-s); }
.kv { display: grid; gap: var(--space-1); font-size: var(--fs-s); color: var(--text-muted); }
.kv strong { color: var(--text); font-weight: 600; }
.synopsis { margin: 0; font-size: var(--fs-s); }
.links { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-link {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--space-3);
  border-radius: 999px; background: var(--surface-2); color: var(--text);
  text-decoration: none; font-size: var(--fs-s); font-weight: 600;
}
.player { width: 100%; aspect-ratio: 16 / 9; background: var(--player-bg); border-radius: var(--radius-m); }
.scoreline { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-3); text-align: center; }
.scoreline img { width: 56px; height: 56px; object-fit: contain; margin: 0 auto var(--space-2); }
.scoreline__score { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; }
}
