/* =============================================================
   SopaLetras — hoja de estilos única
   1. Tokens · 2. Reset · 3. Utilidades · 4. Tipografía
   5. Componentes · 6. Secciones · 7. Anuncios · 8. Responsive
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f3f6fc;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --ink: #14233d;
  --ink-soft: #33456a;
  --muted: #5f6f8d;
  --line: #dde5f2;
  --line-strong: #c6d3e8;
  --brand: #2f6fed;
  --brand-dark: #1c4fd1;
  --brand-tint: #eaf1ff;
  --accent: #ff9f1c;
  --accent-tint: #fff4e2;
  --ok: #11a86b;
  --danger: #d94b4b;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(20, 35, 61, .06), 0 2px 8px rgba(20, 35, 61, .05);
  --shadow: 0 2px 6px rgba(20, 35, 61, .06), 0 14px 34px rgba(20, 35, 61, .09);

  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --gutter: clamp(1rem, 4vw, 2rem);

  /* Tipografía del pasatiempo (la cambia data-font en .sheet) */
  --puzzle-font: Arial, Helvetica, sans-serif;
  --puzzle-weight: 700;
  --puzzle-scale: 0.58;
  --cellpx: 22px;
}

/* Tipografía OpenDyslexic — solo se descarga si el usuario la elige */
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.2.5/files/opendyslexic-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.2.5/files/opendyslexic-latin-700-normal.woff2") format("woff2");
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.015em; font-weight: 800; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* =============================================================
   3. Utilidades
   ============================================================= */
.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }
.wrap--narrow { max-width: 800px; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--brand); color: #fff; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 1rem; }
.linklike { color: var(--brand-dark); text-decoration: underline; padding: 0; font-weight: 700; }

/* =============================================================
   4. Cabecera
   ============================================================= */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-block: .75rem;
}
.logo { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; }
.logo-text { font-weight: 600; font-size: 1.18rem; letter-spacing: -.02em; }
.logo-text strong { font-weight: 800; color: var(--brand-dark); }
.header-claim { margin-left: auto; color: var(--muted); font-size: .88rem; display: none; }

/* =============================================================
   5. Hero + tarjeta de herramienta
   ============================================================= */
.hero { padding-block: clamp(1.4rem, 3vw, 2.4rem) 1.6rem; }
.hero h1 { font-size: clamp(1.55rem, 4.2vw, 2.5rem); }
.hero-sub {
  margin-top: .6rem; max-width: 62ch; color: var(--ink-soft);
  font-size: clamp(.98rem, 1.6vw, 1.08rem);
}

.tool-card {
  margin-top: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2.4vw, 1.6rem);
}
.tool-grid { display: grid; gap: clamp(1.2rem, 2.5vw, 2rem); }
.noscript-note {
  background: var(--accent-tint); border: 1px solid #f2d9ae; color: #6b4a10;
  padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .95rem;
}

/* --- Formulario --- */
.field { display: block; margin-bottom: 1rem; }
.field > label, .label-as-legend {
  display: block; font-weight: 700; font-size: .93rem; margin-bottom: .35rem; color: var(--ink);
}
.field-hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
input[type="text"], textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .62rem .8rem;
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%235f6f8d' d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .65rem center; background-size: 16px; padding-right: 2rem; }
textarea { resize: vertical; min-height: 7.5rem; line-height: 1.55; }
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); background: #fff;
}
.counter { font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.field-row { display: grid; gap: 1rem; }

/* --- Segmentado (radios) --- */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.segmented--sm { grid-template-columns: repeat(2, 1fr); max-width: 22rem; }
.seg { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span {
  display: block; text-align: center; padding: .5rem .4rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); font-weight: 700; font-size: .9rem; line-height: 1.25;
  transition: all .18s var(--ease-out);
}
.seg small { display: block; font-weight: 400; font-size: .72rem; color: var(--muted); margin-top: .12rem; }
.seg input:checked + span {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 4px 12px rgba(47, 111, 237, .28);
}
.seg input:checked + span small { color: rgba(255,255,255,.85); }
.seg input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.seg:hover input:not(:checked) + span { border-color: var(--brand); }

.font-note {
  font-size: .84rem; color: #6b4a10; background: var(--accent-tint);
  border: 1px solid #f2d9ae; padding: .5rem .7rem; border-radius: var(--radius-sm); margin-bottom: .9rem;
}

/* --- Botones --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .78rem 1.25rem; border-radius: 999px; font-weight: 800; font-size: 1rem;
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(47,111,237,.32); }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); text-decoration: none; }
.btn-primary[disabled] { opacity: .6; pointer-events: none; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line-strong); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn-inline { margin-top: .4rem; }
.tool-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .3rem; }
.tool-actions .btn-primary { flex: 1 1 14rem; }

.privacy-badge {
  margin-top: .85rem; font-size: .85rem; color: var(--muted); line-height: 1.5;
}
.limits-note { margin-top: .8rem; font-size: .85rem; color: var(--muted); }

/* --- Vista previa --- */
.preview-tabs { display: flex; gap: .35rem; margin-bottom: .7rem; }
.ptab {
  padding: .45rem .9rem; border-radius: 999px; font-weight: 700; font-size: .88rem;
  background: var(--surface-2); border: 1.5px solid var(--line-strong); color: var(--ink-soft);
  transition: all .18s var(--ease-out);
}
.ptab.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.sheet {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: clamp(.9rem, 2.2vw, 1.4rem);
}
.sheet-title { text-align: center; font-weight: 800; font-size: clamp(1.05rem, 2.4vw, 1.3rem); line-height: 1.25; }
.sheet-kicker { text-align: center; color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.grid-wrap { position: relative; margin: .9rem auto 0; width: 100%; }
.grid {
  position: relative; z-index: 2;
  display: grid; width: 100%; aspect-ratio: 1 / 1;
  border: 2px solid var(--ink); border-radius: 8px; overflow: hidden;
  font-family: var(--puzzle-font); font-weight: var(--puzzle-weight);
  line-height: 1;
}
.grid span {
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.grid-overlay { position: absolute; inset: 2px; z-index: 1; pointer-events: none; }
.cap {
  position: absolute; border-radius: 999px; opacity: .42;
  transform-origin: 0 50%;
}
.sheet[data-view="alumno"] .grid-overlay { display: none; }

.wordlist {
  list-style: none; padding: 0; margin: .9rem 0 0;
  display: flex; flex-wrap: wrap; gap: .35rem .45rem; justify-content: center;
}
.wordlist li {
  font-size: .82rem; font-weight: 700; letter-spacing: .01em;
  padding: .2rem .6rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: .35rem;
}
.wordlist li.is-missing { background: #fdecec; border-color: #f3c4c4; color: var(--danger); text-decoration: line-through; }
.wordlist .dot { width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.sheet[data-view="alumno"] .wordlist .dot { display: none; }
.sheet-foot { text-align: center; color: #9aa8bf; font-size: .72rem; margin-top: .8rem; }

.preview-msg { margin-top: .6rem; font-size: .86rem; min-height: 1.2rem; color: var(--muted); }
.preview-msg.is-warn { color: var(--danger); font-weight: 700; }
.preview-msg.is-ok { color: var(--ok); font-weight: 700; }

/* Tipografías del pasatiempo */
.sheet[data-font="clasica"] { --puzzle-font: Arial, Helvetica, sans-serif; --puzzle-weight: 700; --puzzle-scale: .58; }
.sheet[data-font="escolar"] { --puzzle-font: "Andika", "Trebuchet MS", sans-serif; --puzzle-weight: 700; --puzzle-scale: .58; }
.sheet[data-font="ligada"]  { --puzzle-font: "Dancing Script", "Segoe Script", cursive; --puzzle-weight: 700; --puzzle-scale: .74; }
.sheet[data-font="dislexia"]{ --puzzle-font: "OpenDyslexic", Verdana, Tahoma, sans-serif; --puzzle-weight: 400; --puzzle-scale: .50; }

/* =============================================================
   6. Secciones de contenido
   ============================================================= */
section { padding-block: clamp(2rem, 5vw, 3.2rem); }
.hero { padding-bottom: 1.6rem; }
section h2 { font-size: clamp(1.35rem, 3.2vw, 1.95rem); }
section h3 { font-size: clamp(1.05rem, 2.2vw, 1.2rem); margin-top: 1.6rem; }
.section-lead { margin-top: .7rem; color: var(--ink-soft); max-width: 70ch; }

.pasos { background: var(--surface); border-block: 1px solid var(--line); }
.pasos-list { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: 1.2rem; }
.pasos-list li {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.2rem 1.3rem; position: relative;
}
.paso-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 800; margin-bottom: .55rem;
}
.pasos-list h3 { margin-top: 0; font-size: 1.08rem; }
.pasos-list p { margin-top: .35rem; color: var(--ink-soft); font-size: .95rem; }

.cards { display: grid; gap: 1rem; margin-top: 1.4rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin-top: 0; font-size: 1.03rem; color: var(--brand-dark); }
.card p { margin-top: .35rem; color: var(--ink-soft); font-size: .93rem; }

.texto-seo p { margin-top: .9rem; color: var(--ink-soft); }
.lista { margin: .8rem 0 0 1.1rem; color: var(--ink-soft); }
.lista li { margin-bottom: .45rem; }

.faq { background: var(--surface); border-block: 1px solid var(--line); }
.qa { border-bottom: 1px solid var(--line); }
.qa summary {
  cursor: pointer; list-style: none; padding: .95rem 2rem .95rem 0;
  font-weight: 700; position: relative; font-size: 1rem;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after {
  content: "+"; position: absolute; right: .2rem; top: 50%; transform: translateY(-50%);
  font-size: 1.5rem; font-weight: 400; color: var(--brand); line-height: 1;
}
.qa[open] summary::after { content: "−"; }
.qa-body { padding-bottom: 1rem; color: var(--ink-soft); font-size: .95rem; }

.cierre { text-align: center; }
.cierre p { margin-top: .7rem; color: var(--ink-soft); }

/* =============================================================
   7. Huecos de anuncio (placeholders — sin scripts de terceros)
   ============================================================= */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, #fbfcfe, #fbfcfe 12px, #f4f7fc 12px, #f4f7fc 24px);
  color: #93a2ba; text-align: center;
}
.ad-label { font-weight: 800; letter-spacing: .16em; font-size: .82rem; color: #8a99b2; }
.ad-size { font-size: .72rem; }
.ad-slot--leaderboard { min-height: 110px; margin-block: .4rem 1.4rem; }
.ad-slot--incontent { min-height: 250px; margin-block: 1.2rem; }
.ad-slot--modal { min-height: 250px; width: 100%; }
.ad-slot--toast { min-height: 84px; width: 100%; border-radius: var(--radius-sm); }

/* Pop-up (se abre DESPUÉS de que empiece la descarga, nunca la bloquea) */
.ad-modal {
  border: 0; padding: 0; border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(20,35,61,.3); max-width: min(92vw, 360px); width: 100%;
  background: var(--surface); color: var(--ink);
}
.ad-modal::backdrop { background: rgba(15, 25, 45, .55); }
.ad-modal-inner { padding: 1.1rem 1.1rem 1rem; position: relative; }
.ad-modal-close {
  position: absolute; top: .35rem; right: .5rem; font-size: 1.7rem; line-height: 1;
  color: var(--muted); width: 2rem; height: 2rem; border-radius: 50%;
}
.ad-modal-close:hover { background: var(--surface-2); color: var(--ink); }
.ad-modal-status { font-weight: 800; font-size: .95rem; margin-bottom: .7rem; padding-right: 1.6rem; }
.ad-modal-foot { margin-top: .7rem; font-size: .78rem; color: var(--muted); text-align: center; }

/* Aviso sticky en esquina */
.ad-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  width: min(88vw, 300px);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .55rem;
  animation: toastIn .45s var(--ease-out) both;
}
.ad-toast[hidden] { display: none; }
.ad-toast-close {
  position: absolute; top: -.6rem; right: -.6rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 1.1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* =============================================================
   8. Pie
   ============================================================= */
.site-footer { background: var(--ink); color: #c8d4e8; padding-block: 2rem; }
.footer-inner { display: grid; gap: .7rem; }
.footer-brand { font-size: 1.05rem; color: #fff; font-weight: 600; }
.footer-brand strong { font-weight: 800; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.footer-nav a { color: #9fc0ff; font-weight: 700; font-size: .92rem; }
.footer-note { font-size: .8rem; color: #8fa0bd; max-width: 70ch; }

/* =============================================================
   9. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 719px) {
  .hero { padding-block: 1rem 1.2rem; }
  .hero-sub { font-size: .95rem; line-height: 1.5; }
  textarea { min-height: 5.4rem; }
  .field { margin-bottom: .85rem; }
  .tool-card { margin-top: .9rem; }
}
@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .pasos-list { grid-template-columns: repeat(3, 1fr); }
  .ad-slot--leaderboard { min-height: 180px; }
  .header-claim { display: block; }
}
@media (min-width: 960px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); align-items: start; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .ad-slot--leaderboard { min-height: 250px; }
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
  .footer-note { grid-column: 1 / -1; }
}

/* =============================================================
   10. Movimiento reducido (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-toast { animation: none; }
}

/* =============================================================
   11. Páginas legales
   ============================================================= */
.legal { background: var(--surface); }
.legal h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.legal h2 { font-size: 1.15rem; margin-top: 1.8rem; }
.legal p, .legal li { color: var(--ink-soft); margin-top: .7rem; }
.legal ul { margin-left: 1.1rem; }
.legal .todo {
  background: var(--accent-tint); border: 1px solid #f2d9ae; color: #6b4a10;
  padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .9rem;
}


/* =============================================================
   12. Página de contacto
   ============================================================= */
.contact-box {
  margin-top: 1.4rem; padding: 1.3rem 1.2rem;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius); text-align: center;
}
.contact-label { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0; }
.contact-mail { margin-top: .3rem !important; font-size: clamp(1.05rem, 3.4vw, 1.5rem); font-weight: 800; word-break: break-all; }
.contact-mail a { color: var(--brand-dark); }
.contact-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1rem; }
.contact-actions .btn { font-size: .95rem; }
.contact-note { color: var(--ok); font-weight: 700; font-size: .9rem; margin-top: .8rem !important; }
.contact-note[hidden] { display: none; }


/* =============================================================
   13. Páginas temáticas (sopas ya hechas)
   ============================================================= */
.migas { background: var(--surface); border-bottom: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.migas .wrap { padding-block: .6rem; }
.migas a { font-weight: 700; }
.kicker-linea {
  display: inline-block; margin-top: .8rem;
  background: var(--brand-tint); color: var(--brand-dark);
  font-weight: 700; font-size: .88rem;
  padding: .35rem .8rem; border-radius: 999px;
}
.personalizar {
  margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: .9rem;
}
.personalizar > summary {
  cursor: pointer; list-style: none; font-weight: 700; font-size: .95rem;
  color: var(--brand-dark); padding: .35rem 0 .35rem 1.5rem; position: relative;
}
.personalizar > summary::-webkit-details-marker { display: none; }
.personalizar > summary::before {
  content: "+"; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 1.15rem; height: 1.15rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: .85rem; line-height: 1.15rem;
  text-align: center; font-weight: 800;
}
.personalizar[open] > summary::before { content: "−"; }
.personalizar .tool-form { margin-top: .9rem; }
.lista--enlaces { list-style: none; margin-left: 0; }
.lista--enlaces li { margin-bottom: .55rem; }
.lista--enlaces a { font-weight: 700; }
.cierre .lista--enlaces { text-align: left; display: inline-block; }

/* En las páginas temáticas la vista previa manda: va centrada y más ancha */
.tool-card .tool-preview { max-width: 620px; margin-inline: auto; }
.tool-card > .tool-actions { max-width: 620px; margin-inline: auto; margin-top: 1rem; }
.tool-card > .privacy-badge { max-width: 620px; margin-inline: auto; text-align: center; }

/* hero de las páginas temáticas: más estrecho para que el texto y la ficha
   formen un bloque compacto en pantallas grandes */
.migas + .hero .wrap { max-width: 880px; }
.migas + .hero .hero-sub { max-width: none; }
