/* ==========================================================
   Python — estilos (versión en español de España)
   Paleta: azul profundo, azul claro y acento amarillo.
   Temas claro y oscuro. Los bloques de código son siempre oscuros.
   ========================================================== */

:root {
  --bg: #f5f8fc;
  --bg-alt: #e8eef7;
  --surface: #ffffff;
  --text: #14212f;
  --text-muted: #53617a;
  --accent: #2b5f92;
  --accent-strong: #1e4872;
  --border: #d3deec;
  --btn-bg: #2b5f92;
  --btn-fg: #ffffff;
  --btn-secondary-bg: #14263f;
  --btn-secondary-fg: #f5f8fc;
  --good: #1f7a4d;
  --bad: #b3372f;
  --shadow: 0 10px 30px rgba(20, 38, 63, 0.08);
  --header-bg: rgba(245, 248, 252, 0.9);

  --code-bg: #0f1a2b;
  --code-fg: #e6edf7;
  --output-bg: #0a1320;
  --output-fg: #b7f0c8;

  --font-serif: Georgia, "Times New Roman", "Liberation Serif", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  --radius: 14px;
  --container: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1623;
    --bg-alt: #132033;
    --surface: #192840;
    --text: #e8eef7;
    --text-muted: #a3b3c9;
    --accent: #ffd43b;
    --accent-strong: #ffe27a;
    --border: #27384f;
    --btn-bg: #ffd43b;
    --btn-fg: #14263f;
    --btn-secondary-bg: #e8eef7;
    --btn-secondary-fg: #14263f;
    --good: #5fcf98;
    --bad: #ff8a80;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --header-bg: rgba(14, 22, 35, 0.9);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1623;
  --bg-alt: #132033;
  --surface: #192840;
  --text: #e8eef7;
  --text-muted: #a3b3c9;
  --accent: #ffd43b;
  --accent-strong: #ffe27a;
  --border: #27384f;
  --btn-bg: #ffd43b;
  --btn-fg: #14263f;
  --btn-secondary-bg: #e8eef7;
  --btn-secondary-fg: #14263f;
  --good: #5fcf98;
  --bad: #ff8a80;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(14, 22, 35, 0.9);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.2;
  margin: 0 0 0.6em;
  font-weight: 700;
}

h1 { font-size: clamp(2rem, 3.8vw, 3rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1.1em; }

a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.1em 0.4em;
  background: var(--bg-alt);
  border-radius: 5px;
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.container.narrow { max-width: 780px; }
.center { text-align: center; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 200;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* ---------- Cabecera ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand img { border-radius: 8px; }

.site-nav ul {
  display: flex;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.93rem;
  transition: background-color 0.2s, color 0.2s;
}

.site-nav a:hover { background: var(--bg-alt); }
.site-nav a.active { color: var(--accent); font-weight: 600; }

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.icon-btn:hover { background: var(--bg-alt); }

.nav-toggle { display: none; }

/* ---------- Portada ---------- */

.hero {
  position: relative;
  min-height: min(88vh, 760px);
  display: flex;
  align-items: center;
  color: #f5f8fc;
  background: #0c1422 url("images/hero.svg") center / cover no-repeat;
  overflow: hidden;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(8, 14, 26, 0.88) 0%, rgba(8, 14, 26, 0.6) 48%, rgba(8, 14, 26, 0.05) 100%);
}

.hero-content {
  position: relative;
  padding-top: 60px;
  padding-bottom: 60px;
}

.hero h1 { max-width: 15em; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffd43b;
  margin-bottom: 1rem;
}

.lead {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  max-width: 30em;
  color: #e3eaf5;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

/* ---------- Botones ---------- */

.btn {
  display: inline-block;
  padding: 12px 24px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s, color 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { color: var(--btn-fg); filter: brightness(1.08); }

/* En la portada el botón es siempre amarillo, sea cual sea el tema */
.hero .btn-primary { background: #ffd43b; color: #14263f; }

.btn-ghost { color: #f5f8fc; border-color: rgba(245, 248, 252, 0.7); background: transparent; }
.btn-ghost:hover { background: rgba(245, 248, 252, 0.14); color: #fff; }

.btn-ghost-dark { color: var(--text); border-color: var(--border); background: transparent; }
.btn-ghost-dark:hover { background: var(--bg-alt); color: var(--text); }

.btn-small { padding: 9px 18px; font-size: 0.95rem; }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------- Secciones ---------- */

.section { padding: clamp(56px, 8vw, 96px) 0; }
.section-alt { background: var(--bg-alt); }
.section-alt code { background: var(--surface); }

.section-intro {
  max-width: 40em;
  margin: -0.2em auto 2.2rem;
  color: var(--text-muted);
}

.pullquote {
  margin: 2rem 0;
  padding: 1.2rem 1.6rem;
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
}
.pullquote p {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-style: italic;
  margin: 0 0 0.4em;
}
.pullquote footer { color: var(--text-muted); font-size: 0.95rem; }

.note { color: var(--text-muted); font-size: 0.88rem; margin: 14px 0 0; }

/* ---------- Ruta de aprendizaje ---------- */

.history-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
  margin-top: 2rem;
}

.history-figure { margin: 0; position: sticky; top: 90px; }
.history-figure img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
}
.history-figure figcaption {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 28px;
  border-left: 2px solid var(--border);
}

.timeline li { position: relative; padding-bottom: 28px; }
.timeline li:last-child { padding-bottom: 0; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -37px;
  top: 6px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 3px solid var(--bg-alt);
  border-radius: 50%;
}

.timeline-date {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.timeline h3 { margin-bottom: 0.3em; }
.timeline p { margin: 0; color: var(--text-muted); }

/* ---------- Código ---------- */

.code-block { position: relative; margin: 0 0 1rem; }

pre.code,
pre.output {
  margin: 0;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  tab-size: 4;
  border-radius: 10px;
  overflow-x: auto;
  text-align: left;
}

pre.code { background: var(--code-bg); color: var(--code-fg); }

pre.output {
  background: var(--output-bg);
  color: var(--output-fg);
  border-left: 4px solid #51cf66;
}

pre.code code,
pre.output code {
  font-size: inherit;
  padding: 0;
  background: none;
  color: inherit;
  border-radius: 0;
  overflow-wrap: normal;
}

.output-label {
  margin: 6px 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.78rem;
  color: #e6edf7;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.22); }

/* resaltado de sintaxis */
.tok-kw  { color: #ff79c6; }
.tok-str { color: #ffd43b; }
.tok-com { color: #8397b3; font-style: italic; }
.tok-num { color: #bd93f9; }
.tok-bi  { color: #8be9fd; }

.narrow-block { max-width: 560px; margin: 0 auto 1.4rem; }

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 1.6rem;
}
.code-title { font-size: 1.05rem; margin-bottom: 0.5rem; }

/* ---------- Tarjetas ---------- */

.cards {
  display: grid;
  gap: 22px;
}
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover { transform: translateY(-4px); }

.card img { margin: 0 auto 16px; }
.card h3 { margin-bottom: 0.25em; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.97rem; }

.mono-hint {
  font-family: var(--font-mono);
  color: var(--accent) !important;
  font-size: 0.9rem !important;
  font-weight: 600;
  margin-bottom: 0.7em !important;
}
.mono-hint code { background: transparent; padding: 0; color: inherit; }

/* ---------- Acordeón ---------- */

.accordion { display: grid; gap: 12px; }

.idea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.idea summary {
  position: relative;
  padding: 16px 52px 16px 20px;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.idea summary::-webkit-details-marker { display: none; }

.idea summary::after {
  content: "+";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--accent);
}
.idea[open] summary::after { content: "−"; }
.idea summary:hover { background: var(--bg-alt); }

.idea-body { padding: 4px 20px 18px; }
.idea-note { margin: 14px 0 0; color: var(--text-muted); font-size: 0.97rem; }

/* ---------- Práctica ---------- */

.practice-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}

.steps {
  counter-reset: step;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.steps li {
  position: relative;
  counter-increment: step;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 18px 68px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 18px;
  top: 16px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border-radius: 50%;
}

.tool-column { display: grid; gap: 22px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.panel h3 { margin-bottom: 0.7em; }

.quote-text {
  margin: 0 0 0.4em;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  min-height: 4.2em;
}
.quote-author { color: var(--accent); font-weight: 600; margin-bottom: 1.1em; min-height: 1.5em; }

.journal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.checklist {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 10px;
}
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  line-height: 1.45;
}
.checklist input[type="checkbox"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checklist input:checked + * { text-decoration: line-through; }

.progress {
  height: 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress-text { color: var(--text-muted); font-size: 0.95rem; }

/* ---------- Cuestionario ---------- */

.game {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 36px);
  box-shadow: var(--shadow);
}

.game-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 16px;
}
.game-score { color: var(--accent); font-weight: 700; }

.quiz-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.option-btn {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-align: left;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.option-btn:hover:not(:disabled) { border-color: var(--accent); }
.option-btn:disabled { cursor: default; }
.option-btn.correct { border-color: var(--good); }
.option-btn.correct::after { content: "  ✓"; color: var(--good); font-weight: 700; }
.option-btn.wrong { border-color: var(--bad); }
.option-btn.wrong::after { content: "  ✗"; color: var(--bad); font-weight: 700; }

.game-feedback {
  min-height: 3.2em;
  margin: 18px 0 10px;
  font-size: 1rem;
}
.game-feedback.correct { color: var(--good); }
.game-feedback.wrong { color: var(--bad); }

.game-result { margin-top: 12px; text-align: center; }
.game-result p { font-family: var(--font-serif); font-size: 1.3rem; }

/* ---------- Lecturas ---------- */

.reading {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 14px;
}
.reading li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 18px;
}

/* ---------- Pie de página ---------- */

.site-footer {
  padding: 32px 0;
  color: #bccbe0;
  background: #0b1320;
  font-size: 0.95rem;
}
.site-footer p { margin: 0; }
.site-footer a { color: #ffd43b; }

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Aparición al hacer scroll ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal.visible { opacity: 1; transform: none; }

/* ---------- Diseño adaptable ---------- */

@media (max-width: 1060px) {
  .nav-toggle { display: inline-grid; }

  .site-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    display: none;
    padding: 8px 20px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { padding: 12px 8px; }
}

@media (max-width: 1000px) {
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .cards-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .history-grid,
  .practice-grid,
  .two-cols { grid-template-columns: 1fr; }

  .history-figure { position: static; }

  .hero { background-position: 72% center; }
  .hero-overlay {
    background: linear-gradient(to bottom, rgba(8, 14, 26, 0.88), rgba(8, 14, 26, 0.8));
  }
}

@media (max-width: 560px) {
  .cards-4,
  .cards-3 { grid-template-columns: 1fr; }
  .hero-buttons .btn { flex: 1 1 100%; text-align: center; }
  pre.code, pre.output { font-size: 0.85rem; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Teclado español y accesibilidad ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.55em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 6px;
  white-space: nowrap;
}

.keys-block { margin-top: 2.4rem; max-width: 640px; }
.keys-intro { color: var(--text-muted); }

.key-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.key-table th,
.key-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.key-table thead th {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-alt);
}
.key-table tbody tr:last-child td { border-bottom: 0; }
.key-table td:first-child { width: 30%; }
.key-table code { font-size: 1.05rem; background: var(--bg-alt); }

.footer-note {
  margin-top: 14px;
  font-size: 0.85rem;
  color: #93a6c0;
}
