/* ==========================================================================
   SopasYNumeros — estilos base compartidos por todos los juegos
   Tokens de color (claro/oscuro), tipografía, botones, layout y slots de anuncios.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --text: #1c2033;
  --muted: #5b6478;
  --border: #dde1ec;
  --primary: #5b5bd6;
  --primary-hover: #4a4ac2;
  --primary-contrast: #ffffff;
  --success: #1f9d6b;
  --radius: 14px;
  --shadow: 0 2px 12px rgb(20 25 60 / 0.08);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12141f;
  --surface: #1b1e2e;
  --text: #eceef7;
  --muted: #9aa2b8;
  --border: #2d3248;
  --primary: #8b8bff;
  --primary-hover: #a3a3ff;
  --primary-contrast: #12141f;
  --success: #3ecf98;
  --shadow: 0 2px 12px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

/* Sin preferencia explícita, sigue al sistema. Debe repetir los tokens de arriba. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141f;
    --surface: #1b1e2e;
    --text: #eceef7;
    --muted: #9aa2b8;
    --border: #2d3248;
    --primary: #8b8bff;
    --primary-hover: #a3a3ff;
    --primary-contrast: #12141f;
    --success: #3ecf98;
    --shadow: 0 2px 12px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

/* ---------- Reset mínimo ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }
a { color: var(--primary); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin-inline: auto;
  padding: 12px 16px;
}

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--text);
}
.brand span { color: var(--primary); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
  padding-bottom: 48px;
}

@media (min-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- Botones (mínimo 48px de alto: cómodo con el pulgar) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 2px solid var(--primary);
  border-radius: 12px;
  background: var(--primary);
  color: var(--primary-contrast);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, select:focus-visible, .segmented input:focus-visible + span {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn--secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--bg); border-color: var(--primary); }

.btn--icon { padding: 0; width: 48px; font-size: 1.2rem; }
.btn--block { width: 100%; }

/* ---------- Espacios publicitarios ----------
   Altura mínima reservada => sin saltos de layout (CLS) al cargar el anuncio. */
.ad-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  margin-block: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
}
.ad-slot::before {
  content: "Publicidad";
  position: absolute;
  top: 4px;
  left: 10px;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ad-slot:has(ins), .ad-slot:has(.ad-card) { border-style: none; }

/* Tarjeta de afiliado: distinta a un anuncio de AdSense y con etiqueta propia.
   Cabe en el min-height del slot para no generar saltos de layout. */
.ad-card {
  position: relative;
  display: flex;
  gap: 10px;
  align-self: stretch;
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
}
.ad-card:hover { border-color: var(--primary); }
.ad-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ad-card__img { flex: none; width: 72px; height: 72px; object-fit: contain; border-radius: 8px; }
.ad-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ad-card__tag { font-size: 0.65rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ad-card__title, .ad-card__desc {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-card__desc { color: var(--muted); font-size: 0.8rem; }
.ad-card__price { font-weight: 700; }
.ad-card__cta { flex: none; align-self: center; min-height: 0; padding: 8px 12px; font-size: 0.85rem; }
.ad-slot--banner .ad-card__desc { display: none; }
.ad-slot--rect .ad-card, .ad-slot--side .ad-card { flex-direction: column; }
.ad-slot--rect .ad-card__img, .ad-slot--side .ad-card__img { width: 100%; height: 120px; }
.ad-slot--rect .ad-card__desc, .ad-slot--side .ad-card__desc { -webkit-line-clamp: 3; }
.ad-slot--rect .ad-card__cta, .ad-slot--side .ad-card__cta { align-self: stretch; text-align: center; }

.ad-slot--banner { min-height: 100px; }
.ad-slot--rect { min-height: 250px; }
.ad-slot--side { display: none; }

@media (min-width: 768px) {
  .ad-slot--banner { min-height: 90px; }
}
@media (min-width: 1100px) {
  .ad-slot--side {
    display: flex;
    position: sticky;
    top: 16px;
    min-height: 600px;
    margin-top: 0;
  }
}

/* ---------- Texto de contenido (SEO / AdSense) ---------- */
.prose { color: var(--muted); }
.prose h2 { color: var(--text); font-size: 1.15rem; }

.site-footer {
  max-width: 1200px;
  margin-inline: auto;
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
