/* ── ECC Academy — tema oscuro ─────────────────────────────── */
:root {
  --bg: #fff4d6;
  --bg-panel: #fffaf0;
  --bg-card: #ffffff;
  --bg-hover: #ffe0ed;
  --border: #f1b9d0;
  --text: #56324f;
  --text-muted: #8d6a7c;
  --accent: #d946a1;
  --accent-soft: rgba(217, 70, 161, 0.14);
  --green: #22a879;
  --orange: #f59e0b;
  --radius: 16px;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100%; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #fff9eb, #ffe2f0, #efe3ff);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: transform .22s ease;
}
.topbar.is-hidden { transform: translateY(-110%); }

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: 0.2px; }
.tagline { margin: 0; font-size: 12px; color: var(--text-muted); }

.topbar-right { display: none !important; }
.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-link { text-decoration: none; color: var(--accent); }

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  height: calc(100vh - 61px);
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  display: none;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 12px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }

.section-title {
  margin: 18px 6px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.block-item { margin-bottom: 8px; border: 1px solid transparent; border-radius: 9px; }
.block-item:hover { border-color: var(--border); }
.block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}
.block-header:hover { background: var(--bg-hover); }
.block-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.block-copy { display: grid; gap: 1px; flex: 1; min-width: 0; }
.block-title { font-weight: 650; }
.block-subtitle { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { transition: transform 0.15s ease; color: var(--text-muted); font-size: 12px; }
.block-item.open .chevron { transform: rotate(90deg); }

.concept-list { display: none; padding: 1px 6px 7px 34px; }
.block-item.open .concept-list { display: block; }

.concept-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 7px;
}
.concept-link:hover { background: var(--bg-hover); color: var(--text); }
.concept-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.concept-link.explored::after { content: "✓"; float: right; color: var(--green); font-weight: 700; }

/* ── Content ────────────────────────────────────────────── */
.content { overflow-y: auto; padding: 28px 36px 60px; }
.content { max-width: 1080px; width: 100%; min-width: 0; margin: 0 auto; }

.empty-state { max-width: 560px; margin: 22px auto 0; text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-state h2 { color: var(--text); margin: 0 0 8px; }
.dedication { color: #542347; font-weight: 850; margin: 12px 0 0; background: #fff; border: 3px solid #ff8a3d; border-radius: 999px; display: inline-block; padding: 7px 15px; box-shadow: 0 3px 0 #f3b4ad; }
.start-actions { display: grid; gap: 10px; margin: 24px auto 18px; max-width: 330px; }
.start-actions .btn { width: 100%; }
.learning-path { text-align: left; margin: 22px auto 0; max-width: 680px; background: var(--bg-card); border: 2px solid var(--border); border-radius: 22px; padding: 18px; box-shadow: 0 6px 0 #f5dfc3; }
.learning-path p { margin: 0 0 8px; }
.learning-path ol { margin: 0; padding-left: 20px; }
.learning-path li { margin: 5px 0; }
.route-grid { display: grid; grid-template-columns: 1fr; gap: 28px; margin: 18px auto; max-width: 470px; position: relative; }
.route-grid::before { content: ""; position: absolute; top: 58px; bottom: 58px; left: 50%; border-left: 7px dotted #f4b6d4; z-index: 0; }
.route-card { text-align: left; display: grid; grid-template-columns: 72px minmax(0, 1fr); grid-template-areas: "icon title" "icon description" "icon action"; align-items: center; gap: 6px 12px; padding: 12px; border-radius: 22px; border: 2px solid var(--border); background: linear-gradient(145deg, #ffffff, #fff0f7); color: var(--text); cursor: pointer; box-shadow: 0 5px 0 #f5b9d3; transition: transform .15s ease; position: relative; z-index: 1; }
.route-card:nth-child(even) { transform: translateX(34px); }
.route-card:nth-child(odd) { transform: translateX(-34px); }
.route-card:hover { border-color: var(--accent); background: #fff0f8; transform: translateY(-2px); }
.route-card:active { box-shadow: none; transform: translateY(4px); }
.route-card:hover { transform: translateY(-2px); }
.route-card:nth-child(even):hover { transform: translate(34px, -2px); }
.route-card:nth-child(odd):hover { transform: translate(-34px, -2px); }
.route-icon { grid-area: icon; width: 62px; height: 62px; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 6px solid #d946a1; box-shadow: 0 4px 0 #b83280; font-size: 29px; }
.route-card:nth-child(2) .route-icon { border-color: #22a879; box-shadow: 0 4px 0 #0f7b59; }
.route-card:nth-child(3) .route-icon { border-color: #f59e0b; box-shadow: 0 4px 0 #c77800; }
.route-card:nth-child(4) .route-icon { border-color: #7c5ce3; box-shadow: 0 4px 0 #553db0; }
.route-card:nth-child(5) .route-icon { border-color: #ef6f6c; box-shadow: 0 4px 0 #bf4845; }
.route-card strong { grid-area: title; color: var(--accent); font-size: 15px; }
.route-card span { grid-area: description; color: var(--text-muted); font-size: 13px; }
.route-card em { grid-area: action; font-size: 13px; }
.route-card:nth-child(1) { border-color: #d946a1; background: linear-gradient(145deg, #fff, #fff0f8); box-shadow: 0 5px 0 #f0a8cb; }
.route-card:nth-child(1) strong, .route-card:nth-child(1) em { color: #b42378; }
.route-card:nth-child(2) { border-color: #22a879; background: linear-gradient(145deg, #fff, #ebfff5); box-shadow: 0 5px 0 #9fdfc6; }
.route-card:nth-child(2) strong, .route-card:nth-child(2) em { color: #087957; }
.route-card:nth-child(3) { border-color: #f59e0b; background: linear-gradient(145deg, #fff, #fff8d9); box-shadow: 0 5px 0 #f6d27d; }
.route-card:nth-child(3) strong, .route-card:nth-child(3) em { color: #a95c00; }
.route-card:nth-child(4) { border-color: #7c5ce3; background: linear-gradient(145deg, #fff, #f2edff); box-shadow: 0 5px 0 #c7b8f4; }
.route-card:nth-child(4) strong, .route-card:nth-child(4) em { color: #553db0; }
.route-card:nth-child(5) { border-color: #ef6f6c; background: linear-gradient(145deg, #fff, #fff0ed); box-shadow: 0 5px 0 #f3b4ad; }
.route-card:nth-child(5) strong, .route-card:nth-child(5) em { color: #b84240; }
.reset-progress { border: 0; background: transparent; color: var(--text-muted); font-size: 12px; padding: 4px 0; cursor: pointer; text-decoration: underline; }
.reset-progress:hover { color: var(--accent); }
.schema-list { text-align: left; padding-left: 22px; margin-top: 20px; }
.schema-list li { margin: 6px 0; }

.concept-header { margin-bottom: 18px; }
.crumb { color: var(--text-muted); font-size: 13px; margin: 0 0 4px; }
#concept-title { margin: 0 0 10px; font-size: 26px; }
.concept-actions { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 12px; background: #fff0ba; border: 2px solid #f5b928; border-radius: 14px; color: #714900; font-weight: 800; }

.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: #f97316; border-color: #f97316; color: white; font-weight: 800; box-shadow: 0 4px 0 #c2410c; }
.btn-primary:hover { background: #fb923c; }
.btn-icon { padding: 4px 10px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 15.5px;
}
.step-num {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.card-accent { border-color: rgba(88, 166, 255, 0.4); }
.card-short { border-color: rgba(224, 120, 86, 0.55); background: linear-gradient(180deg, rgba(224,120,86,0.10), var(--bg-card)); }
.card-short p { font-size: 16px; line-height: 1.65; margin-bottom: 0; }
.card-exercise { border-color: rgba(63, 185, 80, 0.45); background: linear-gradient(180deg, rgba(63,185,80,0.07), var(--bg-card)); }
.exercise-label { display: block; margin: 16px 0 7px; color: var(--text); font-weight: 800; }
.exercise-answer { box-sizing: border-box; width: 100%; resize: vertical; border: 2px solid #f5b9d3; border-radius: 12px; padding: 10px 12px; background: #fffdf8; color: var(--text); font: inherit; line-height: 1.45; }
.exercise-answer:focus { outline: 3px solid rgba(217, 70, 161, .22); border-color: #d946a1; }
.exercise-complete { width: 100%; margin-top: 10px; padding: 10px 14px; }
.evaluation-feedback { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-weight: 650; }
.evaluation-feedback.pending { background: #fff4c8; color: #745000; }
.evaluation-feedback.approved { background: #e5faed; color: #087957; border: 1px solid #7dd3a6; }
.evaluation-feedback.retry { background: #fff0ed; color: #a33a37; border: 1px solid #f1aaa5; }
.game-bar .btn:disabled { opacity: .58; cursor: not-allowed; box-shadow: none; }

.bullets ul { margin: 0; padding-left: 20px; }
.bullets li { margin: 5px 0; }

.prose p { margin: 8px 0; }
.prose code, .file-list code, #sec-concepto code, #sec-ejercicio code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(110, 118, 129, 0.22);
  padding: 1px 6px;
  border-radius: 5px;
}

.file-list { list-style: none; margin: 8px 0 0; padding: 0; }
.file-list li { margin: 6px 0; }
.file-link {
  display: flex;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
}
.file-link:hover { border-color: var(--accent); background: var(--bg-hover); }
.file-link code { color: var(--accent); word-break: break-all; flex-shrink: 0; max-width: 46%; }
.file-desc { color: var(--text-muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { background: var(--accent-soft); }

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* ── Loading ────────────────────────────────────────────── */
.spinner {
  width: 42px; height: 42px;
  margin: 0 auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-game { margin: 26px auto 0; max-width: 420px; border: 2px dashed #f4b6d4; border-radius: 18px; padding: 13px; background: rgba(255,255,255,.55); }
.loading-game p { margin: 0 0 5px; }
.spark-field { height: 250px; position: relative; overflow: hidden; margin: 8px 0; background: linear-gradient(135deg, rgba(255,255,255,.3), rgba(255,242,183,.65)); border-radius: 13px; }
.spark { position: absolute; border: 0; background: #fff; border-radius: 50%; box-shadow: 0 4px 0 #f5b928; font-size: 25px; width: 48px; height: 48px; cursor: pointer; transition: left .38s ease, top .38s ease; animation: sparkle 1.2s ease-in-out infinite alternate; }
.spark:disabled { cursor: default; box-shadow: none; }
@keyframes sparkle { to { filter: brightness(1.14); scale: 1.11; } }

/* ── Modal visor de archivos ────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1, 4, 9, 0.7); backdrop-filter: blur(2px); }
.modal-panel {
  position: relative;
  width: min(860px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.file-title { font-family: var(--mono); font-size: 13px; color: var(--accent); word-break: break-all; }
.file-body {
  margin: 0;
  padding: 16px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .topbar { padding: 9px 14px; }
  .topbar .logo { font-size: 22px; }
  .topbar h1 { font-size: 16px; }
  .topbar .tagline { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 42vh; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 20px 16px 50px; }
  .empty-state { margin: 14px auto 0; }
  .layout { height: auto; min-height: 100vh; }
  .topbar-right { gap: 5px; }
  .badge-link { display: none; }
  .concept-actions { justify-content: flex-start; flex-wrap: wrap; }
  .route-grid { grid-template-columns: 1fr; }
  .route-grid { max-width: 340px; }
  .route-card:nth-child(even), .route-card:nth-child(odd) { transform: none; }
  .route-card:nth-child(even):hover, .route-card:nth-child(odd):hover { transform: translateY(-2px); }
  #regen-btn { display: none; }
  .card, .learning-path { width: 100%; overflow-wrap: anywhere; }
  .content, .empty-state, .explanation { max-width: 100%; box-sizing: border-box; overflow-x: clip; }
  .game-bar { align-items: stretch; flex-direction: column; }
  .dedication { font-size: 14px; padding: 6px 11px; }
  .file-link { align-items: flex-start; flex-wrap: wrap; }
  .file-link code { max-width: 100%; }
}
