/* ==========================================================
   App CFCX · estilos base
   Tema oscuro por defecto; claro por preferencia del sistema
   o por elección del usuario (data-theme en <html>).
   ========================================================== */

:root {
  --bg: #0E0F13;
  --surface: #18191E;
  --surface-2: #24252B;
  --line: #2A2B31;
  --text: #F2F0EA;
  --muted: #A8A6A0;
  --accent: #FFB020;        /* acento para texto/íconos */
  --accent-fill: #FFB020;   /* fondo de botones principales */
  --on-accent: #0E0F13;
  --live: #E5484D;
  --ok: #7CFC9A;
  --radius: 14px;
  --tabbar-h: 68px;
  --font-body: 'Work Sans', system-ui, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Work Sans', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F6F4EF;
    --surface: #FFFFFF;
    --surface-2: #ECE9E2;
    --line: #E2DED5;
    --text: #17181C;
    --muted: #5E5C57;
    --accent: #A35F00;
    --accent-fill: #FFB020;
    --on-accent: #17181C;
    --ok: #1F7A4D;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #ECE9E2;
  --line: #E2DED5;
  --text: #17181C;
  --muted: #5E5C57;
  --accent: #A35F00;
  --accent-fill: #FFB020;
  --on-accent: #17181C;
  --ok: #1F7A4D;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--accent-fill); color: var(--on-accent); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  max-width: 720px; margin: 0 auto;
}
.wordmark { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.wordmark span { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--muted);
}
.icon-btn:hover { color: var(--text); }

.pill {
  min-height: 36px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  font-weight: 600; font-size: 13px; background: transparent;
}
.pill .avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-fill); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }

/* ---------- Contenedor de vistas ---------- */
#view { display: block; max-width: 720px; margin: 0 auto; padding: 4px 0 28px; outline: none; }
.section { padding: 0 16px; margin-top: 22px; }
.section:first-child { margin-top: 6px; }
.eyebrow { margin: 0 0 12px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.h1 { font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1.05; margin: 0; }
.h2 { font-family: var(--font-display); font-weight: 800; font-size: 21px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 8px 0 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* ---------- Monitor TV ---------- */
.tv {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 10px 10px 12px;
}
.tv-screen {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  background: #000; border-radius: 14px; overflow: hidden;
  color: #F2F0EA;
}
.tv-screen video, .tv-screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.tv-osd {
  position: absolute; top: 8px; right: 12px; z-index: 3;
  font-family: var(--font-mono); font-weight: 700; font-size: 18px;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  pointer-events: none;
}
.tv-live {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  background: rgba(0,0,0,.55); padding: 4px 8px; border-radius: 6px;
  pointer-events: none;
}
.tv-live[hidden] { display: none; }
.tv-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.tv-msg {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 16px;
  background: #000;
}
.tv-msg strong { font-family: var(--font-display); font-size: 17px; }
.tv-msg span { font-size: 12px; color: #A8A6A0; }
.tv-static {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  background-image: repeating-radial-gradient(circle at 17% 32%, #fff 0 1px, transparent 1px 3px), repeating-radial-gradient(circle at 73% 61%, #888 0 1px, transparent 1px 4px);
  background-color: #222;
}
.tv-static.on { animation: static 420ms steps(6) forwards; }
@keyframes static {
  0% { opacity: .95; background-position: 0 0, 0 0; }
  50% { opacity: .8; background-position: 7px 3px, -5px 9px; }
  100% { opacity: 0; background-position: -4px 8px, 6px -2px; }
}
.tv-controls { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.tv-btn {
  width: 44px; height: 44px; border-radius: 10px; border: none;
  background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.tv-btn.on { background: var(--accent-fill); color: var(--on-accent); }
.tv-now { flex: 1; min-width: 0; padding-left: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-now b { color: var(--text); font-weight: 600; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; min-height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .mono { margin-right: 4px; }

.link-arrow { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; font-size: 14px; color: var(--accent); }

/* ---------- Accesos rápidos ---------- */
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick a {
  min-height: 84px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px; font-weight: 500;
}
.quick a svg { width: 22px; height: 22px; stroke-width: 1.6; }
.quick a:hover { border-color: var(--muted); }

/* ---------- Franja de flyers ---------- */
.flyers { position: relative; }
.flyer-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; gap: 10px; scrollbar-width: none; }
.flyer-track::-webkit-scrollbar { display: none; }
.flyer {
  flex: 0 0 100%; scroll-snap-align: start;
  min-height: 92px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
}
.flyer-img { width: 64px; height: 64px; border-radius: 10px; background: var(--surface-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); overflow: hidden; }
.flyer-img img { width: 100%; height: 100%; object-fit: cover; }
.flyer small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.flyer strong { display: block; font-size: 14px; font-weight: 600; }
.dots { display: flex; gap: 5px; justify-content: center; margin-top: 8px; }
.dots span { width: 4px; height: 4px; border-radius: 2px; background: var(--line); transition: width .2s; }
.dots span.on { width: 16px; background: var(--text); }

/* ---------- Listas y tarjetas ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  text-align: left; width: 100%;
}
.row .thumb { width: 84px; aspect-ratio: 4/3; border-radius: 10px; background: var(--surface-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); overflow: hidden; }
.row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .meta { min-width: 0; flex: 1; }
.row .kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.row .title { font-weight: 600; line-height: 1.3; }
.row .chev { color: var(--muted); }

.space-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.space-card { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-height: 104px; }
.space-card strong { font-family: var(--font-display); font-size: 18px; }
.space-card span { font-size: 12px; color: var(--muted); }
.space-card .mono { color: var(--text); font-size: 12px; }

.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--muted); font-size: 14px; font-weight: 500; }

.tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.tabs button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.talents { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px; }
.talent { flex: 0 0 104px; text-align: center; font-size: 13px; font-weight: 600; }
.talent .face { width: 104px; height: 104px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 8px; }

.box { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.box p { margin: 6px 0 0; color: var(--muted); }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: none;
  background: var(--accent-fill); color: var(--on-accent);
  font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.search {
  width: 100%; min-height: 48px; padding: 0 14px 0 42px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
}
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 14px; top: 14px; color: var(--muted); }

/* ---------- Arcade ---------- */
.game {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line);
}
.game[aria-pressed="true"] { border-color: var(--text); }
.game .tag { width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 700; font-size: 18px; flex-shrink: 0; }
.game strong { display: block; font-family: var(--font-display); font-size: 17px; }
.game span { font-size: 13px; color: var(--muted); }
.pick-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Cupones ---------- */
.coupon { display: flex; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.coupon .value { width: 88px; flex-shrink: 0; background: var(--accent-fill); color: var(--on-accent); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px; text-align: center; }
.coupon .value b { font-family: var(--font-display); font-size: 24px; line-height: 1; }
.coupon .value small { font-size: 10px; font-weight: 600; letter-spacing: .06em; margin-top: 4px; }
.coupon .body { flex: 1; min-width: 0; padding: 12px 14px; border-left: 2px dashed var(--bg); display: flex; flex-direction: column; gap: 4px; }
.coupon .body strong { font-weight: 600; }
.coupon .body .code { font-family: var(--font-mono); font-size: 12px; color: var(--accent); word-break: break-all; }
.coupon .btn { min-height: 40px; font-size: 13px; padding: 0 14px; align-self: flex-start; margin-top: 4px; }

/* ---------- Mi CFCX ---------- */
.idcard {
  border-radius: 20px; padding: 20px; min-height: 200px;
  background: var(--accent-fill); color: #17181C;
  display: flex; flex-direction: column; justify-content: space-between; gap: 16px;
}
.idcard .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.idcard small { font-size: 10px; letter-spacing: .2em; font-weight: 600; display: block; }
.idcard .brand { font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.idcard .qr { width: 76px; height: 76px; border-radius: 10px; background: #fff; border: 2px solid #17181C; padding: 6px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.idcard .qr i { background: #17181C; border-radius: 1px; }
.idcard .qr i.off { background: transparent; }
.idcard .name { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.idcard .foot { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-mono); font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; }
.field input { min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }

.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.segmented button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 13px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.note { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- Reproductor modal (videoteca) ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-inner { width: 100%; max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; color: #F2F0EA; margin-bottom: 10px; gap: 12px; }
.modal-head strong { font-family: var(--font-display); font-size: 18px; }
.modal .frame { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.modal iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.modal .icon-btn { color: #F2F0EA; }

/* ---------- Barra inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabbar a {
  min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; color: var(--muted); max-width: 180px; margin: 0 auto; width: 100%;
}
.tabbar a[aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- Aviso breve ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 45;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 500; max-width: calc(100vw - 32px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Pantallas amplias: el monitor gana espacio */
@media (min-width: 720px) {
  .quick { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .space-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .tv-static.on { animation: none; }
  .flyer-track { scroll-behavior: auto; }
}
