/* The Metabolic Map — Vol. VI of the Learning Library.
   Identity: a laboratory pathway wall chart. Same brass/paper library
   family, but the working surface is a laminated biochem chart — a warm
   chart-paper panel over a viridian lab wall, metabolites drawn as rounded
   wells, enzyme arrows in teal, energy notes in ATP-gold. Printed, not
   handwritten (that keeps it clearly distinct from the orgo notebook). */

:root {
    color-scheme: only light;

    /* the lab wall (library family, shifted green) */
    --wall: #163430;
    --wall-deep: #0e211e;
    --brass: #c6a15b;
    --brass-bright: #dcbd7d;
    --brass-deep: #9c7c40;
    --brass-soft: rgba(198, 161, 91, 0.5);

    /* the chart panel */
    --paper: #f4efe0;
    --paper-bright: #fdfaf0;
    --grid-ink: rgba(45, 110, 100, 0.12);
    --ink: #21322f;
    --ink-soft: #557069;
    --pencil: #7b8c86;

    /* accents */
    --enzyme: #227d74;         /* teal — arrows & enzyme names */
    --enzyme-deep: #185c55;
    --enzyme-soft: rgba(34, 125, 116, 0.12);
    --atp: #bd7f2b;            /* gold — energy notes */

    /* marking inks */
    --correct-ink: #2b7a4b;
    --correct-soft: rgba(43, 122, 75, 0.12);
    --wrong-ink: #b34a44;
    --wrong-soft: rgba(179, 74, 68, 0.12);
    --trap-ink: #9a6b1f;
    --trap-soft: rgba(154, 107, 31, 0.14);

    --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --font-ui: 'Archivo', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    color: var(--ink);
    min-height: 100svh;
    background-color: var(--wall);
    background-image:
        radial-gradient(ellipse 120% 90% at 50% -10%, rgba(220, 189, 125, 0.07), transparent 60%),
        linear-gradient(var(--wall-deep), var(--wall) 30%, var(--wall) 70%, var(--wall-deep));
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 16px;
}

.screen { width: min(1150px, 100%); }
.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

.btn {
    border: 1.5px solid var(--ink);
    border-radius: 7px;
    background: var(--paper-bright);
    color: var(--ink);
    font-size: 14.5px;
    font-weight: 600;
    padding: 10px 18px;
    box-shadow: 0 2px 0 rgba(14, 33, 30, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(14, 33, 30, 0.35); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(14, 33, 30, 0.35); }
.btn.primary {
    background: linear-gradient(var(--brass-bright), var(--brass));
    border-color: var(--brass-deep);
    color: #2a2110;
    letter-spacing: 0.02em;
}
.btn.ghost { background: transparent; border-color: rgba(33, 50, 47, 0.45); box-shadow: none; }
.btn.ghost:hover { background: rgba(33, 50, 47, 0.06); }
.btn.small { padding: 8px 14px; font-size: 13.5px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ============================== start screen ============================== */

#startScreen { display: flex; justify-content: center; padding-top: 6svh; }

.library-link {
    position: fixed;
    top: 16px;
    left: 20px;
    z-index: 50;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--brass);
    opacity: 0.85;
}

@media (hover: hover) {
    .library-link:hover {
        opacity: 1;
        text-decoration: underline;
        text-underline-offset: 4px;
    }
}

.cover-card {
    width: min(680px, 100%);
    background: var(--paper);
    border: 1px solid rgba(14, 33, 30, 0.6);
    border-radius: 4px;
    padding: 44px 46px 38px;
    box-shadow:
        inset 0 0 0 1px rgba(33, 50, 47, 0.12),
        inset 0 0 0 6px var(--paper),
        inset 0 0 0 7px rgba(33, 50, 47, 0.28),
        0 16px 40px rgba(0, 0, 0, 0.4);
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--brass-deep);
    text-align: center;
    margin-bottom: 14px;
}

.cover-card h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(34px, 5.5vw, 46px);
    text-align: center;
    line-height: 1.08;
}

.cover-rule {
    display: flex; align-items: center; gap: 12px;
    width: min(300px, 70%);
    margin: 18px auto 14px;
    color: var(--brass-deep); font-size: 9px;
}
.cover-rule::before, .cover-rule::after { content: ''; flex: 1; height: 1px; background: var(--brass-soft); }

.subtitle { text-align: center; color: var(--ink-soft); font-size: 15px; margin-bottom: 32px; line-height: 1.5; }

.setup-row { display: flex; gap: 16px; margin-bottom: 16px; align-items: flex-end; flex-wrap: wrap; }
.field { flex: 1; min-width: 200px; }

.field label {
    display: block;
    font-family: var(--font-mono);
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 7px;
}

.field select {
    width: 100%;
    font-family: inherit; font-size: 14.5px;
    color: var(--ink);
    padding: 10px 12px;
    border: 1.5px solid rgba(33, 50, 47, 0.5);
    border-radius: 7px;
    background: var(--paper-bright);
}

#startBtn { flex: 1; min-width: 200px; padding: 12px 18px; font-size: 15.5px; }

.drill-blurb {
    font-family: var(--font-ui);
    font-size: 14.5px;
    font-style: italic;
    color: var(--ink-soft);
    text-align: center;
    min-height: 24px;
    margin-top: 4px;
}

/* ============================== the chart panel ============================== */

.page {
    background:
        repeating-linear-gradient(transparent 0 31px, var(--grid-ink) 31px 32px),
        repeating-linear-gradient(90deg, transparent 0 31px, var(--grid-ink) 31px 32px),
        var(--paper);
    border: 1px solid rgba(14, 33, 30, 0.6);
    border-radius: 4px;
    box-shadow:
        inset 0 0 0 1px rgba(33, 50, 47, 0.1),
        0 16px 40px rgba(0, 0, 0, 0.4);
    padding: 20px 26px 18px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    border-bottom: 1.5px solid rgba(33, 50, 47, 0.28);
    padding-bottom: 10px;
}

.prompt-eyebrow {
    font-family: var(--font-mono);
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--enzyme-deep);
    margin-bottom: 4px;
}

.prompt-main {
    font-family: var(--font-display);
    font-size: clamp(22px, 3vw, 29px);
    font-weight: 600;
    line-height: 1.14;
    color: var(--ink);
}

.prompt-tag {
    font-family: var(--font-ui);
    font-size: 14px;
    font-style: italic;
    color: var(--ink-soft);
    margin-top: 2px;
}

.stats-block {
    display: flex; gap: 16px; flex-wrap: wrap;
    justify-content: flex-end;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink-soft);
    padding-top: 6px;
    white-space: nowrap;
}
.stat b { color: var(--ink); font-weight: 700; }

.feedback-line {
    font-family: var(--font-ui);
    font-size: 15.5px;
    font-weight: 500;
    min-height: 26px;
    padding: 6px 2px 0;
    transition: color 0.15s ease;
}
.feedback-line.correct { color: var(--correct-ink); }
.feedback-line.incorrect { color: var(--wrong-ink); }
.feedback-line.trap { color: var(--trap-ink); font-size: 14.5px; }

.answer-bar { display: flex; gap: 10px; margin: 6px 0 8px; }

.answer-bar input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 15.5px;
    color: var(--ink);
    background: var(--paper-bright);
    border: 1.5px solid rgba(33, 50, 47, 0.5);
    border-radius: 7px;
    padding: 10px 13px;
}
.answer-bar input::placeholder { color: var(--pencil); }
.answer-bar input.shake { animation: shake 0.35s; border-color: var(--wrong-ink); }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

/* roll-call checklist chips */
.gaz-checklist { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 8px; }

.gaz-chip {
    font-family: var(--font-mono);
    font-size: 12px;
    border: 1.2px dashed rgba(33, 50, 47, 0.42);
    border-radius: 6px;
    color: var(--pencil);
    padding: 5px 10px;
    background: rgba(253, 250, 240, 0.6);
}
.gaz-chip.found {
    border-style: solid;
    border-color: var(--correct-ink);
    color: var(--correct-ink);
    background: var(--correct-soft);
}
.gaz-chip.revealed {
    border-style: solid;
    border-color: var(--wrong-ink);
    color: var(--wrong-ink);
    background: var(--wrong-soft);
}

/* ============================== the map ============================== */

.map-container { width: 100%; }
.map-container svg { display: block; width: 100%; height: auto; }

/* nodes (metabolite wells) */
.node rect {
    fill: var(--paper-bright);
    stroke: var(--ink);
    stroke-width: 1.6;
    transition: fill 0.15s ease, stroke 0.15s ease, stroke-width 0.15s ease;
}
.node .label {
    font-family: var(--font-ui);
    font-size: 15px; font-weight: 600;
    fill: var(--ink);
    text-anchor: middle;
    pointer-events: none;
}
.node .sublabel {
    font-family: var(--font-mono);
    font-size: 10.5px; font-weight: 500;
    fill: var(--ink-soft);
    text-anchor: middle;
    pointer-events: none;
}
.node.hub rect { fill: var(--wall); stroke: var(--brass-deep); stroke-width: 2; }
.node.hub .label { fill: var(--brass-bright); font-size: 17px; font-weight: 700; letter-spacing: 0.02em; }
.node.hub .sublabel { fill: var(--brass-soft); }

/* edges (enzyme arrows) */
.edge .line { fill: none; stroke: var(--enzyme); stroke-width: 1.9; opacity: 0.72; transition: stroke 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease; }
.edge .head { fill: var(--enzyme); opacity: 0.72; transition: fill 0.15s ease, opacity 0.15s ease; }
.edge .hit { fill: none; stroke: transparent; stroke-width: 22; }

/* question focus: gold marching ants on the asked arrow, everything else recedes */
.mode-recall .edge:not(.target) .line,
.mode-recall .edge:not(.target) .head { opacity: 0.22; }
.mode-recall .node:not(.hub) rect { fill: var(--paper); }

.edge.target .line {
    stroke: var(--brass-deep);
    stroke-width: 3.4;
    opacity: 1;
    stroke-dasharray: 9 5;
    animation: march 1.1s linear infinite;
}
.edge.target .head { fill: var(--brass-deep); opacity: 1; }

@keyframes march { to { stroke-dashoffset: -14; } }

/* answered states */
.edge.correct .line { stroke: var(--correct-ink); stroke-width: 3; opacity: 1; stroke-dasharray: none; animation: none; }
.edge.correct .head { fill: var(--correct-ink); opacity: 1; }
.edge.found .line { stroke: var(--correct-ink); stroke-width: 2.6; opacity: 1; }
.edge.found .head { fill: var(--correct-ink); opacity: 1; }
.edge.revealed .line { stroke: var(--wrong-ink); stroke-width: 2.6; opacity: 1; stroke-dasharray: none; animation: none; }
.edge.revealed .head { fill: var(--wrong-ink); opacity: 1; }

.node.flash-correct rect { fill: var(--correct-soft); stroke: var(--correct-ink); stroke-width: 2.6; }
.node.flash-wrong rect { fill: var(--wrong-soft); stroke: var(--wrong-ink); stroke-width: 2.6; }
.node.flash-trap rect { fill: var(--trap-soft); stroke: var(--trap-ink); stroke-width: 2.6; }
.node.highlight rect { stroke: var(--enzyme-deep); stroke-width: 2.6; }
.node.hub.highlight rect { stroke: var(--brass-deep); }

/* click mode */
.mode-click .node { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
    .mode-click .node:hover rect { stroke-width: 2.6; fill: var(--paper-bright); }
    .mode-click .node.hub:hover rect { fill: var(--wall); }
}
.mode-click .edge .hit { pointer-events: none; }

/* ============================== controls & hints ============================== */

.head-right {
    display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.page-controls {
    display: flex; gap: 8px; justify-content: flex-end;
}

.hint-line {
    font-family: var(--font-ui);
    font-size: 14.5px;
    font-style: italic;
    color: var(--trap-ink);
    padding: 0 2px 6px;
}

/* ============================== completion overlay ============================== */

.overlay {
    position: fixed; inset: 0;
    background: rgba(14, 33, 30, 0.72);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    z-index: 10;
}

.report-card {
    width: min(440px, 100%);
    background: var(--paper);
    border: 1px solid rgba(14, 33, 30, 0.6);
    border-radius: 4px;
    padding: 34px 36px 30px;
    text-align: center;
    box-shadow:
        inset 0 0 0 1px rgba(33, 50, 47, 0.12),
        inset 0 0 0 6px var(--paper),
        inset 0 0 0 7px rgba(33, 50, 47, 0.28),
        0 20px 48px rgba(0, 0, 0, 0.5);
}

.report-card h2 {
    font-family: var(--font-display);
    font-size: 30px; font-weight: 800;
    margin-bottom: 18px;
}

.report-stats {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--ink-soft);
    display: grid; gap: 8px;
    margin-bottom: 26px;
}
.report-stats b { color: var(--ink); }

.report-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============================== small screens ============================== */

@media (max-width: 640px) {
    body { padding: 12px 8px; }
    .page { padding: 14px 14px 12px; }
    .page-header { flex-direction: column; gap: 6px; }
    .head-right { align-items: flex-start; }
    .stats-block { justify-content: flex-start; }
    .page-controls { justify-content: flex-start; }
    .cover-card { padding: 30px 24px 26px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
    .edge.target .line { animation: none; stroke-dasharray: none; }
}
