/* Mundo Posible Labs — Lectura
   Design tokens (mismos que el resto del proyecto) y estilos del curso. */

:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-soft: #fafafa;
    --ink: #0f0f10;
    --ink-soft: #6b6b70;
    --line: #d4d4d4;
    --line-strong: #c0c0c0;
    --accent: #2f4ad0;
    --accent-soft: #eef1fc;
    --ok: #1f9d55;
    --ok-soft: #e7f6ec;
    --bad: #c53030;
    --bad-soft: #fdecec;
    --shadow-card: 0 8px 24px -12px rgba(15, 15, 16, 0.18);
    --shadow-focus: 0 0 0 4px rgba(15, 15, 16, 0.06);
    --shadow-toplink: 0 4px 14px -6px rgba(15, 15, 16, 0.12);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c0c0e;
    --surface: #141418;
    --surface-soft: #1c1c21;
    --ink: #f5f5f7;
    --ink-soft: #9b9ba3;
    --line: #2e2e35;
    --line-strong: #44444c;
    --accent: #7c8fff;
    --accent-soft: #1c2244;
    --ok: #4ade80;
    --ok-soft: #102a1a;
    --bad: #f87171;
    --bad-soft: #2c1414;
    --shadow-card: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
    --shadow-focus: 0 0 0 4px rgba(124, 143, 255, 0.18);
    --shadow-toplink: 0 4px 14px -6px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    letter-spacing: -0.005em;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
}

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.05;
    margin: 0;
}

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

.eyebrow {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 600;
    color: var(--accent);
    margin: 0 0 8px;
}

.page, .page-shell, .practice-shell {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 20px 0 80px;
}
.practice-shell { max-width: 880px; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ink);
    color: var(--bg);
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    text-decoration: none;
}
.skip-link:focus { left: 0; }

/* Nav */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--ink);
    color: var(--bg);
    font-size: 14px;
}
.brand-name { font-size: 1rem; }
.nav-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.nav-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--ink-soft);
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
}
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--ink);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
}
.theme-toggle:hover, .theme-toggle:focus-visible {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    outline: 0;
}
.theme-toggle-icon { display: none; }
[data-theme="dark"] .theme-toggle-icon-light { display: inline-block; }
:root:not([data-theme="dark"]) .theme-toggle-icon-dark { display: inline-block; }

/* Breadcrumb */
.breadcrumb { margin-bottom: 16px; }
.breadcrumb a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.9rem;
}
.breadcrumb a:hover, .breadcrumb a:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
    outline: 0;
}

/* Hero / practice-hero */
.hero { padding: 16px 0 56px; max-width: 880px; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 5rem); margin-bottom: 12px; }
.hero p { color: var(--ink-soft); font-size: 1.1rem; }
.practice-hero { padding: 16px 0 24px; }
.practice-hero h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); margin: 8px 0 8px; }
.practice-hero p { color: var(--ink-soft); }
.practice-hero-center { text-align: center; }

/* Search */
.search-wrap { display: flex; justify-content: center; margin-bottom: 32px; }
.hero-search {
    position: relative;
    width: 100%;
    max-width: 520px;
}
.hero-search-input {
    width: 100%;
    height: 56px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    padding: 10px 18px 10px 52px;
}
.hero-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-soft);
}
.hero-search-input:focus { border-color: var(--ink); box-shadow: var(--shadow-focus); outline: 0; }

/* Cards grid (course index) */
.projects-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.projects-head h2 { font-size: clamp(1.3rem, 2vw, 1.6rem); }
.projects-count { color: var(--ink-soft); font-size: 0.9rem; }
.grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    padding: 22px;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card a { text-decoration: none; color: inherit; display: block; }
.card:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: var(--shadow-card); }
.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-icon {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 18px;
}
.card:hover .card-icon { background: var(--accent); color: var(--bg); }
.card-num { color: var(--ink-soft); font-size: 0.85rem; font-weight: 600; }
.card-arrow { margin-left: auto; color: var(--ink-soft); }
.card-tag {
    display: inline-block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 6px;
}
.card-title { font-size: clamp(1.5rem, 2.5vw, 1.85rem); margin: 0 0 8px; }
.card-desc { color: var(--ink-soft); margin: 0 0 16px; }
.card-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--ink-soft);
    font-size: 0.9rem;
}
.empty { color: var(--ink-soft); text-align: center; padding: 32px 0; }

/* Practice card + summary card */
.practice-card {
    display: grid;
    gap: 24px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    padding: clamp(20px, 4vw, 32px);
    margin-bottom: 16px;
}
.practice-card[hidden] { display: none; }
.practice-status {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--ink-soft);
    font-size: 0.9rem;
}
.practice-status p { margin: 0; }
.practice-question h2, .practice-question h3 {
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    margin: 0;
}

/* Reading passage (nuevo) */
.reading-passage {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
    padding: clamp(16px, 3vw, 24px);
    display: grid;
    gap: 8px;
}
.reading-title { font-size: 1.25rem; margin: 0; color: var(--ink); }
.reading-text { margin: 0; font-size: 1.1rem; line-height: 1.6; color: var(--ink); }

/* Step dots */
.step-dots {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 6px;
}
.step-dot {
    flex: 1;
    min-width: 10px;
    max-width: 24px;
    height: 6px;
    border-radius: 3px;
    background: var(--line);
}
.step-dot.current { background: var(--accent); }
.step-dot.done.correct { background: var(--ok); }
.step-dot.done.incorrect { background: var(--bad); }

/* Answer options / buttons */
.answer-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.answer-button, .restart-button, .next-button {
    min-height: 56px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 18px;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.answer-button:hover, .answer-button:focus-visible,
.restart-button:hover, .restart-button:focus-visible,
.next-button:hover, .next-button:focus-visible {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    outline: 0;
    box-shadow: var(--shadow-focus);
}
.answer-button:disabled { cursor: default; }
.answer-button.correct,
.answer-button.correct:hover,
.answer-button.correct:focus-visible {
    background: var(--ok-soft);
    border-color: var(--ok);
    color: var(--ok);
    box-shadow: none;
}
.answer-button.incorrect,
.answer-button.incorrect:hover,
.answer-button.incorrect:focus-visible {
    background: var(--bad-soft);
    border-color: var(--bad);
    color: var(--bad);
    box-shadow: none;
}
.next-button {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.next-button:hover, .next-button:focus-visible {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

/* Feedback */
.feedback { color: var(--ink-soft); margin: 0; min-height: 1.4em; }

/* Summary badge */
.summary-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 24px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 6px solid var(--line);
    background: var(--surface);
    transition: border-color 0.4s ease, background 0.4s ease;
}
.summary-badge.perfect { border-color: var(--ok); background: var(--ok-soft); }
.summary-badge.good { border-color: var(--accent); background: var(--accent-soft); }
.summary-badge.needs-practice { border-color: var(--bad); background: var(--bad-soft); }
.summary-score {
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}
.summary-icon { font-size: 1.6rem; }
.summary-badge.perfect .summary-icon { color: var(--ok); }
.summary-badge.good .summary-icon { color: var(--accent); }
.summary-badge.needs-practice .summary-icon { color: var(--bad); }

/* Summary banner */
.summary-banner {
    margin: 0 0 24px;
    padding: 16px 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.5;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    transition: background 0.4s ease, border-color 0.4s ease;
}
.summary-banner.perfect { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.summary-banner.good { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.summary-banner.needs-practice { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

/* Summary list cards */
.summary-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    display: grid;
    gap: 10px;
}
.summary-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    animation: fadeInUp 0.35s ease-out both;
}
.summary-item:nth-child(1) { animation-delay: 0.05s; }
.summary-item:nth-child(2) { animation-delay: 0.10s; }
.summary-item:nth-child(3) { animation-delay: 0.15s; }
.summary-item:nth-child(4) { animation-delay: 0.20s; }
.summary-item:nth-child(5) { animation-delay: 0.25s; }
.summary-item:nth-child(6) { animation-delay: 0.30s; }
.item-icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 14px;
}
.item-icon.correct { background: var(--ok-soft); color: var(--ok); }
.item-icon.incorrect { background: var(--bad-soft); color: var(--bad); }
.item-icon.unanswered { background: var(--surface-soft); color: var(--ink-soft); }
.item-body { flex: 1; display: grid; gap: 2px; }
.item-title { font-weight: 600; font-size: 1rem; color: var(--ink); }
.item-detail { font-size: 0.9rem; color: var(--ink-soft); line-height: 1.4; }
.summary-item.correct .item-title { color: var(--ok); }
.summary-item.incorrect .item-title { color: var(--bad); }
.summary-item.unanswered .item-title { color: var(--ink-soft); }

/* Footer */
.foot {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
    margin-top: 48px;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

/* Sequence activity (ordenar cuento) */
.sequence-slots {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}
.slot {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 64px;
    border: 2px dashed var(--line);
    border-radius: 12px;
    padding: 12px 16px;
    background: var(--surface-soft);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.slot:hover, .slot:focus-visible {
    border-color: var(--accent);
    outline: 0;
}
.slot.filled {
    border-style: solid;
    border-color: var(--line);
    background: var(--surface);
}
.slot.filled:hover,
.slot.filled:focus-visible {
    border-color: var(--accent);
}
.slot.correct {
    border-color: var(--ok);
    background: var(--ok-soft);
}
.slot.incorrect {
    border-color: var(--bad);
    background: var(--bad-soft);
}
.slot-number {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    flex-shrink: 0;
}
.slot.correct .slot-number {
    background: var(--ok);
    color: var(--ok-soft);
}
.slot.incorrect .slot-number {
    background: var(--bad);
    color: var(--bad-soft);
}
.slot-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 8px;
}
.slot-correct-hint {
    display: block;
    margin-top: 8px;
    width: 100%;
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-style: italic;
}
.pool {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 8px;
}
.panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 12px 16px;
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 56px;
}
.panel:hover {
    border-color: var(--accent);
}
.slot .panel {
    cursor: pointer;
    border-style: dashed;
}
.slot .panel:hover,
.slot .panel:focus-visible {
    border-color: var(--accent);
    border-style: solid;
}
.sequence-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    60%      { transform: translateX(-2px); }
    80%      { transform: translateX(2px); }
}
@keyframes pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* Slot panel placement animation */
.slot .panel {
    animation: fadeInDown 0.25s ease-out;
}

/* Pool panel return animation */
.pool .panel {
    animation: fadeIn 0.2s ease-out;
}

/* Check result animations */
.slot.correct {
    animation: pop 0.35s ease-out;
}
.slot.incorrect {
    animation: shake 0.4s ease-out;
}

/* Summary reveal animation */
.summary-card {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.summary-card.summary-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Question transition (lectura-comprensiva) */
.question-area {
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.question-area.question-exit {
    opacity: 0;
    transform: translateY(-6px);
}
.question-area.question-enter {
    opacity: 0;
    transform: translateY(6px);
}

/* AlertifyJS custom theme overrides */
.alertify .ajs-dialog {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    max-width: 480px;
}

.alertify .ajs-header {
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    margin: -24px -24px 0 -24px;
    padding: 16px 24px;
    border-radius: 16px 16px 0 0;
}

.alertify .ajs-body {
    color: var(--ink);
    font-size: 1rem;
}

.alertify .ajs-body .ajs-content {
    padding: 16px 24px;
}

.alertify .ajs-footer {
    background: var(--surface);
    border-top: 1px solid var(--line);
    margin: 0 -24px;
    padding: 12px 24px;
    border-radius: 0 0 16px 16px;
}

.alertify .ajs-footer .ajs-buttons .ajs-button,
.alertify .ajs-footer .ajs-buttons .ajs-button.ajs-ok {
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    min-height: 48px;
    min-width: 120px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.alertify .ajs-footer .ajs-buttons .ajs-button:hover,
.alertify .ajs-footer .ajs-buttons .ajs-button.ajs-ok:hover,
.alertify .ajs-footer .ajs-buttons .ajs-button:focus,
.alertify .ajs-footer .ajs-buttons .ajs-button.ajs-ok:focus {
    background: var(--accent);
    opacity: 0.9;
    outline: 0;
    box-shadow: var(--shadow-focus);
    transform: translateY(-1px);
}

.alertify .ajs-dimmer {
    background-color: var(--ink);
    opacity: 0.4;
}

/* Dark mode overrides for AlertifyJS */
[data-theme="dark"] .alertify .ajs-dialog {
    background: var(--surface);
    border-color: var(--line);
}

[data-theme="dark"] .alertify .ajs-header {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}

[data-theme="dark"] .alertify .ajs-body {
    color: var(--ink);
}

[data-theme="dark"] .alertify .ajs-footer {
    background: var(--surface);
    border-color: var(--line);
}

[data-theme="dark"] .alertify .ajs-dimmer {
    background-color: var(--bg);
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 760px) {
    .grid { grid-template-columns: 1fr; }
    .answer-options { grid-template-columns: 1fr; }
    .hero-search-input { height: 52px; }
    .foot { flex-direction: column; }
}
