/* ============================================================
   aprenDELE — identidad «Hoja de examen» (ver DISEÑO.md)
   Se carga DESPUÉS de style.css y redefine variables y componentes.
   Para probar sin ella, quitar su <link>.
   ============================================================ */

@font-face { font-family: 'Spectral'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/spectral-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Spectral'; font-weight: 400; font-style: italic; font-display: swap; src: url('/fonts/spectral-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Spectral'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/spectral-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Spectral'; font-weight: 800; font-style: normal; font-display: swap; src: url('/fonts/spectral-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-600-normal.woff2') format('woff2'); }

:root {
  --bg: #f2eddf;
  --bg-elevated: #faf6ea;
  --text: #1c2030;
  --text-muted: #5d5c55;
  --primary: #1d3a8c;
  --primary-light: #2c4fb0;
  --accent: #b3261e;
  --good: #2b6a45;
  --bad: #b3261e;
  --border: #bdb59d;
  --radius: 2px;
  --shadow: 4px 4px 0 rgba(28, 32, 48, 0.14);
  --ink: #1c2030;
  --serif: 'Spectral', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}
/* El papel sigue siendo papel de noche: solo se atenúa */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #e3ddca;
    --bg-elevated: #ece6d4;
    --text: #1c2030;
    --text-muted: #55544d;
    --primary: #1d3a8c;
    --primary-light: #2c4fb0;
    --accent: #b3261e;
    --good: #2b6a45;
    --bad: #b3261e;
    --border: #aaa28a;
    --shadow: 4px 4px 0 rgba(28, 32, 48, 0.16);
    color-scheme: light;
  }
}

body { font-family: var(--serif); font-size: 17px; line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 800; letter-spacing: -0.005em; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
button, input, textarea, select { font-family: inherit; }
strong { font-weight: 700; }

/* ---------- Cabecera ---------- */
.topbar { background: var(--bg-elevated); color: var(--ink); border-bottom: 3px double var(--ink); }
.topbar-inner .page-title { font-family: var(--serif); font-size: 22px; font-weight: 800; text-align: left; padding-left: 4px; }
.icon-btn { color: var(--ink); border-radius: 2px; }
.icon-btn:active { background: rgba(28, 32, 48, 0.1); }
.streak {
  font-family: var(--mono); font-weight: 600; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  background: transparent; color: var(--ink); border: 1.5px solid var(--ink); border-radius: 2px; padding: 4px 8px;
}

/* ---------- Barra inferior: la casilla ---------- */
.tabbar { background: var(--bg-elevated); border-top: 3px double var(--ink); }
.tabbar { scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar .tab-item { min-width: 58px; flex: 1 0 58px; }
.tab-item {
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: uppercase;
  color: var(--text-muted); gap: 5px;
}
.tab-item::before {
  content: ''; position: static; display: block; width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 0;
  background: transparent; left: auto; right: auto; top: auto;
}
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-item.active::before {
  position: static; width: 12px; height: 12px; border-radius: 0; border-color: var(--primary); background: var(--primary);
}

/* ---------- Hojas (tarjetas) ---------- */
.card {
  background: var(--bg-elevated); border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: var(--shadow);
  padding: 16px 16px 16px; margin-bottom: 18px;
}
.card-tap:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(28, 32, 48, 0.14); }

/* ---------- Títulos de sección: epígrafe con línea de puntos ---------- */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary); margin: 28px 0 12px;
}
.section-title::after { content: ''; flex: 1; border-bottom: 1.5px dotted var(--text-muted); transform: translateY(1px); }
.section-title:first-child { margin-top: 0; }

/* ---------- Botones ---------- */
.btn {
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  background: var(--primary); color: var(--bg-elevated); border: 2px solid var(--ink); border-radius: 2px;
  box-shadow: 3px 3px 0 var(--ink); padding: 11px 16px;
  transition: transform .06s, box-shadow .06s;
}
.btn { text-decoration: none; }
.btn:active { background: var(--primary); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.secondary { background: var(--bg-elevated); color: var(--ink); border: 2px solid var(--ink); }
.btn.good { background: var(--good); color: var(--bg-elevated); }
.btn.bad { background: var(--bad); color: var(--bg-elevated); }
.btn.small { font-size: 15px; padding: 7px 12px; box-shadow: 2px 2px 0 var(--ink); }
.btn.small:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn[disabled] { opacity: 0.45; box-shadow: none; }
.link-btn { font-family: var(--serif); font-weight: 700; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Sellos (pastillas) ---------- */
.pill {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  background: transparent; color: var(--text-muted); border: 1.5px solid currentColor; border-radius: 2px; padding: 2px 7px;
}
.pill.accent { background: transparent; color: var(--accent); }
.pill.good { background: transparent; color: var(--good); border-width: 2px; transform: rotate(-3deg); }
.pill.bad { background: transparent; color: var(--bad); border-width: 2px; transform: rotate(-3deg); }

/* ---------- Regla de progreso ---------- */
.progress-bar {
  height: 12px; margin: 8px 0; border: 1.5px solid var(--ink); border-radius: 0; background-color: var(--bg-elevated);
  background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(28, 32, 48, 0.28) calc(10% - 1px), rgba(28, 32, 48, 0.28) 10%);
  overflow: hidden;
}
.progress-bar > div { background: var(--primary); border-radius: 0; }

.stat-row { align-items: baseline; }
.stat-num { font-family: var(--serif); font-weight: 800; color: var(--primary); }
.stat-label { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }

/* ---------- Listas numeradas ---------- */
.list-item {
  counter-increment: fila;
  justify-content: flex-start; gap: 12px;
  background: var(--bg-elevated); border: 1.5px solid var(--ink); border-radius: 2px;
  padding: 12px 14px 12px 12px; margin-bottom: 8px; font-size: 18px; font-weight: 700;
}
:not(.list-item) + .list-item, .list-item:first-child { counter-reset: fila; }
.list-item::before {
  content: counter(fila, decimal-leading-zero);
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--primary);
  padding-right: 12px; border-right: 1.5px dotted var(--text-muted); align-self: stretch; display: flex; align-items: center;
}
.list-item > :first-child { flex: 1; min-width: 0; }
.list-item .chev { margin-left: auto; font-family: var(--mono); color: var(--ink); }
.list-item .meta { font-family: var(--serif); font-weight: 400; font-style: italic; font-size: 14px; }
.list-item:active { transform: translate(1px, 1px); }

/* ---------- Ejercicios tipo test: letras en casilla ---------- */
.quiz-q { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.4; }
.quiz-opt {
  counter-increment: opcion;
  position: relative; display: block; text-align: left;
  font-family: var(--serif); font-size: 17px; line-height: 1.4;
  background: var(--bg-elevated); border: 1.5px solid var(--ink); border-radius: 2px; padding: 11px 14px 11px 50px;
}
:not(.quiz-opt) + .quiz-opt, .quiz-opt:first-child { counter-reset: opcion; }
.quiz-opt::before {
  content: counter(opcion, upper-alpha);
  position: absolute; left: 11px; top: 9px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 0; background: transparent;
}
.quiz-opt.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--bg-elevated)); }
.quiz-opt.correct::before { background: var(--good); border-color: var(--good); color: var(--bg-elevated); }
.quiz-opt.incorrect {
  border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--bg-elevated));
  text-decoration: line-through; text-decoration-color: var(--bad); text-decoration-thickness: 2px;
}
.quiz-opt.incorrect::before { background: var(--bad); border-color: var(--bad); color: var(--bg-elevated); text-decoration: none; }
.quiz-explain {
  font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg-elevated);
  border: 0; border-left: 4px solid var(--primary); border-radius: 0; padding: 10px 12px;
}
.quiz-explain strong:first-child {
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--primary);
}

/* ---------- Campos para rellenar ---------- */
.cloze-input, .conjugate-row input, .field-input, .auth-form input {
  background: var(--bg-elevated); color: var(--text); font-family: var(--serif); font-size: 17px;
  border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; padding: 9px 8px;
}
.cloze-input:focus, .conjugate-row input:focus, .field-input:focus, .auth-form input:focus { outline: 2px solid var(--primary-light); outline-offset: 1px; }
input.field-correct { border-bottom-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--bg-elevated)); }
input.field-incorrect { border-bottom-color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--bg-elevated)); }
.field-label, .conjugate-row label { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

/* El área de escritura es papel con renglones y margen rojo */
textarea.writing-area {
  font-family: var(--serif); font-size: 18px; line-height: 30px; padding: 0 14px 0 18px;
  background-color: var(--bg-elevated);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 29px, #cdc5ac 29px, #cdc5ac 30px);
  background-attachment: local;
  border: 1.5px solid var(--ink); border-left: 4px double var(--bad); border-radius: 2px;
}
.wordcount { font-family: var(--mono); font-size: 12px; }

/* ---------- Lista de comprobación: casillas que se marcan ---------- */
.checklist-item { border-bottom: 1.5px dotted var(--border); }
.checklist-item input {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 0;
  background: var(--bg-elevated); margin-top: 2px; cursor: pointer;
}
.checklist-item input:checked {
  background-image:
    linear-gradient(45deg, transparent 44%, var(--primary) 44%, var(--primary) 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--primary) 44%, var(--primary) 56%, transparent 56%);
}

.chip { font-family: var(--mono); font-size: 11.5px; background: transparent; border: 1.5px solid var(--text-muted); border-radius: 2px; color: var(--text); }
.readtext { font-size: 18px; line-height: 1.7; }
.flashcard .word { font-family: var(--serif); font-size: 32px; font-weight: 800; }
.flashcard .example { font-size: 16px; }
.score-hero .big { font-family: var(--serif); font-size: 56px; color: var(--primary); }
.empty-state { font-style: italic; }

/* ---------- Avisos y ventanas ---------- */
.install-toast { background: var(--ink); color: var(--bg-elevated); border-radius: 2px; box-shadow: 4px 4px 0 rgba(28, 32, 48, 0.3); font-family: var(--serif); font-size: 14px; }
.install-toast button.btn { background: var(--bg-elevated); color: var(--ink); border-color: var(--bg-elevated); box-shadow: none; }
.motivation-card {
  background: var(--bg-elevated); border: 2px solid var(--ink); border-radius: 2px; box-shadow: 6px 6px 0 rgba(28, 32, 48, 0.3);
}
.motivation-card p { font-size: 18px; }
.motivation-overlay { background: rgba(28, 32, 48, 0.55); }

/* ---------- Entrada y landing ---------- */
.auth-logo { font-family: var(--serif); font-weight: 800; color: var(--primary); letter-spacing: -0.01em; }
.auth-divider::before, .auth-divider::after { height: 0; background: none; border-top: 1.5px dotted var(--text-muted); }
.google-btn { background: var(--bg-elevated); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.landing-hero .auth-logo { font-size: 40px; border-bottom: 3px double var(--ink); display: inline-block; padding: 0 10px 4px; }
.landing-tagline { font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.4; }
.landing-section-alt { background: var(--bg-elevated); border-top: 3px double var(--ink); border-bottom: 3px double var(--ink); }
.landing-step-num { border-radius: 0; background: var(--primary); font-family: var(--mono); }
.landing-feature { border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: var(--shadow); background: var(--bg-elevated); }
.landing-section-alt .landing-feature { background: var(--bg); }
.landing-feature-num {
  width: 30px; height: 30px; border-radius: 0; background: transparent; color: var(--primary); border: 1.5px solid var(--primary);
  font-family: var(--mono); font-weight: 600; font-size: 14px;
}
.landing-feature h3 { font-size: 16px; }
.landing-feature p { font-size: 14px; }
.landing-price-featured { border: 3px double var(--ink); box-shadow: var(--shadow); }
.landing-price { font-family: var(--serif); font-size: 36px; }
.landing-faq details { border: 1.5px solid var(--ink); border-radius: 2px; background: var(--bg-elevated); }
.landing-faq summary { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.landing-blog-list li { border-bottom: 1.5px dotted var(--text-muted); }
.landing-blog-list a { font-family: var(--serif); font-weight: 700; }
.landing-footer { font-family: var(--mono); font-size: 12px; }

/* ---------- Tablas y legales ---------- */
.tense-table thead th { font-family: var(--mono); letter-spacing: .08em; color: var(--primary); }
.tense-table th, .tense-table td { border-bottom: 1.5px dotted var(--border); }
.legal-page h2 { color: var(--primary); }
.legal-page .fill-in { border-radius: 0; }

/* ---------- Selector de idioma de la landing (es / en) ---------- */
.landing-lang { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-align: right; margin: 0 0 18px; color: var(--text-muted); }
.landing-lang a { color: var(--primary); }
.landing-lang .sep { margin: 0 8px; }
.landing-lang [aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- Precios: tarjetas a la misma altura (la etiqueta «Ahorras» ya no empuja el contenido) ---------- */
.landing-price-card { position: relative; display: flex; flex-direction: column; }
.landing-price-card .btn { margin-top: auto; }
.landing-price-card .meta { margin-bottom: 12px; }
.price-badge-row { min-height: 26px; margin-bottom: 6px; display: flex; align-items: center; justify-content: center; }
.landing-price-card .section-title { margin-top: 0 !important; }

/* ---------- Demo de la landing y lista de avisos previos al registro ---------- */
#demoRoot { max-width: 560px; margin: 0 auto; }
#demoRoot .readtext { margin: 8px 0; }
#demoRoot .quiz-opt { width: 100%; margin-top: 8px; cursor: pointer; }
#demoRoot .btn { margin-top: 12px; }
#demoRoot a.btn { text-decoration: none; }
.landing-notes { max-width: 560px; margin: 0 auto; padding-left: 22px; color: var(--text); }
.landing-notes li { margin-bottom: 8px; line-height: 1.5; }

@media (max-width: 500px) { .price-badge-row:empty { display: none; } }

/* ---------- Textos largos: nada se sale de su cuadro ---------- */
.card, .list-item, .btn, .pill, .section-title, .meta, .stat-row, h1, h2, h3, h4 { overflow-wrap: anywhere; }
.grid-2 > *, .card > * { min-width: 0; }
.stat-row { gap: 10px; }
.stat-row > :first-child { flex: 1 1 auto; min-width: 0; }
.stat-row > .pill { flex: none; white-space: nowrap; }
.btn { text-align: center; }
.section-title { min-width: 0; }

/* ---------- Título de la barra superior: cabe siempre (2 líneas máx.) ---------- */
.topbar-inner .page-title {
  min-width: 0; overflow-wrap: anywhere; hyphens: auto;
  font-size: clamp(15px, 4.4vw, 22px); line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.quiz-q, .quiz-opt, .readtext, .quiz-explain, .checklist-item, .flashcard .word, .landing-price { overflow-wrap: anywhere; min-width: 0; }
.flashcard .word { font-size: clamp(22px, 7vw, 32px); }
.stat-row { flex-wrap: wrap; }
.stat-row > strong, .stat-row > span:not(.pill) { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Texto consultable durante las preguntas ---------- */
.passage { margin-bottom: 10px; }
.passage summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.passage .readtext { margin-top: 10px; white-space: pre-line; }
.gap { font-family: var(--mono); color: var(--primary); border-bottom: 2px solid var(--primary); }
