/* Learn section: the guide list (learn.html) and the guides in guides/.
   Builds on css/main.css and css/plot.css. */

/* GUIDE LIST */

.guide-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1.25rem;
    margin: 1.75rem 0 0;
    padding: 0;
    list-style: none;
}

.guide-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.guide-card:focus-within {
    background: var(--surface-hover);
}

@media (hover: hover) {
    .guide-card:hover {
        background: var(--surface-hover);
        box-shadow: var(--shadow), 0 6px 18px rgba(0, 0, 0, 0.08);
    }
}

.guide-number {
    color: var(--accent-strong);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.guide-card h2 {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.3rem;
}

.guide-card h2::after {
    display: none;
}

/* The title link covers the whole card */
.guide-card h2 a {
    color: var(--text);
    text-decoration: none;
}

.guide-card h2 a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
}

.guide-card p {
    margin: 0;
    color: var(--muted);
}

.guide-card .guide-meta {
    margin-top: auto;
    padding-top: 0.75rem;
    font-size: 0.9rem;
}

/* GUIDE ARTICLE */

.guide-header .guide-number {
    display: block;
    margin-bottom: 0.25rem;
}

/* Text, lists and callouts share the text width; plots, tables and photos use
   the full container (see --measure in main.css). */
.article > p,
.article > ul,
.article > ol,
.article > .callout {
    max-width: var(--measure);
}

.article h2 {
    margin-top: 2.5rem;
}

.article .lead {
    font-size: 1.2rem;
}

.callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
}

.callout p:last-child {
    margin-bottom: 0;
}

.callout-title {
    margin-bottom: 0.35rem;
    font-weight: 700;
}

/* Parameter tables */
.table-scroll {
    margin: 1.25rem 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table caption {
    padding: 0.6rem 0.9rem;
    color: var(--muted);
    font-size: 0.875rem;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 0.45rem 0.9rem;
    border-top: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table thead th {
    background: var(--surface-alt);
    font-weight: 600;
    white-space: nowrap;
}

.data-table .unit {
    min-width: 4.5rem;
    white-space: nowrap;
}

.data-table .num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.references {
    padding-left: 1.25rem;
    font-size: 0.95rem;
}

.references li + li {
    margin-top: 0.4rem;
}

.guide-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.guide-nav a {
    display: inline-flex;
    flex-direction: column;
    max-width: 48%;
    text-decoration: none;
}

.guide-nav a span {
    color: var(--muted);
    font-size: 0.85rem;
}

.guide-nav a strong {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.guide-nav .next {
    margin-left: auto;
    text-align: right;
}

/* LAB: an interactive plot with its controls (js/learn/labs.js) */

.lab {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 1.25rem;
    margin: 1.5rem 0 2rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

@media (max-width: 860px) {
    .lab {
        grid-template-columns: minmax(0, 1fr);
        padding: 1rem;
    }
}

/* The white panel only covers the plot, centred beside taller controls */
.lab-figure {
    align-self: center;
    margin: 0;
    padding: 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #18212b;
}

.lab-figure svg {
    display: block;
    width: 100%;
    height: auto;
}

.lab-figure .lab-extra {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #d2dbe5;
}

.lab-caption {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    padding: 0.25rem 0.5rem;
    color: #4a5766;
    font-size: 0.85rem;
}

.lab-controls {
    display: grid;
    align-content: start;
    gap: 1rem;
}

.lab-control label {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-weight: 600;
}

.lab-value {
    color: var(--accent-strong);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.lab-control input[type="range"] {
    width: 100%;
    margin: 0.35rem 0 0;
    accent-color: var(--accent);
}

.lab-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.lab-presets-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.lab-preset {
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.lab-preset:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.lab-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.lab-choice legend {
    width: 100%;
    margin-bottom: 0.4rem;
    padding: 0;
    font-weight: 600;
}

.lab-pill {
    position: relative;
}

.lab-pill input {
    position: absolute;
    opacity: 0;
}

.lab-pill span {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: 0.95rem;
    cursor: pointer;
}

.lab-pill input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

.lab-pill input:focus-visible + span {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.lab-readout {
    margin: 0;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border-radius: 8px;
    font-size: 0.95rem;
}

/* FIGURES */

.guide-figure {
    margin: 1.5rem 0;
}

.guide-figure img {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.guide-figure-small img {
    max-width: 480px;
}

.guide-figure figcaption {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.article h3 {
    margin-top: 2rem;
    font-size: 1.3rem;
}

/* Advantages and drawbacks of a method */
.pros-cons {
    margin: 1rem 0 1.5rem;
    padding: 0;
    list-style: none;
}

.pros-cons li {
    position: relative;
    padding-left: 1.75rem;
}

.pros-cons li + li {
    margin-top: 0.35rem;
}

.pros-cons li::before {
    position: absolute;
    left: 0;
    width: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.pros-cons .pro::before {
    content: "+";
    color: var(--accent-strong);
}

.pros-cons .con::before {
    content: "−";
    color: var(--highlight);
}

/* SIMULATED SPECTROMETER (js/learn/instrument.js) */

.instrument {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 1.25rem;
    margin: 1.5rem 0 2rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.inst-figure {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.75rem;
    margin: 0;
}

.inst-schematic {
    display: block;
    width: 100%;
    height: auto;
}

.inst-box {
    fill: var(--surface-alt);
    stroke: var(--border);
    stroke-width: 1.5;
}

.inst-label {
    fill: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.inst-small {
    fill: var(--muted);
    font-size: 13px;
}

.inst-velocity {
    fill: var(--accent-strong);
    font-size: 13px;
    font-weight: 600;
}

.inst-rod {
    stroke: var(--muted);
    stroke-width: 4;
}

.inst-source {
    fill: var(--highlight);
}

.inst-sample {
    fill: #8a4b2a;
}

.inst-beam {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 6 5;
}

/* Gamma rays travel along the beam while measuring */
.inst-beam.is-running {
    animation: beam 0.6s linear infinite;
}

@keyframes beam {
    to { stroke-dashoffset: -22; }
}

@media (prefers-reduced-motion: reduce) {
    .inst-beam.is-running {
        animation: none;
    }
}

.inst-cable {
    stroke: var(--muted);
    stroke-width: 2;
}

.inst-screen-icon {
    fill: var(--surface);
    stroke: var(--border);
}

/* The computer screen: a white panel like the other plots */
.inst-screen,
.inst-fold-plot {
    padding: 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.inst-screen svg,
.inst-fold-plot svg {
    display: block;
    width: 100%;
    height: auto;
}

.inst-screen-title {
    margin: 0 0.5rem;
    color: #4a5766;
    font-size: 0.85rem;
    font-weight: 600;
}

.plot-dots {
    fill: none;
    stroke: #215f9a;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.plot-text-sub {
    fill: #6b7889;
    font-size: 11px;
}

.inst-controls {
    display: grid;
    gap: 1rem;
}

.inst-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Side box on folding: quieter than the main plot */
.inst-fold {
    display: grid;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface-alt);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    font-size: 0.95rem;
}

.inst-fold p {
    margin: 0;
}

.inst-fold-title {
    font-weight: 700;
}

.inst-fold-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.inst-fold-plot {
    max-width: 420px;
}

/* The diagram and plots shrink on phones, so their text is drawn larger */
@media (max-width: 600px) {
    .inst-label { font-size: 30px; }
    .inst-small,
    .inst-velocity { font-size: 26px; }
    .plot-text-sub { font-size: 14px; }
}

/* CONCEPT DIAGRAMS beside the text (hyperfine parameters guide) */

.concept {
    display: grid;
    /* Text at the text width, the diagram filling the rest of the row */
    grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

@media (max-width: 860px) {
    .concept {
        grid-template-columns: minmax(0, 1fr);
    }

    .concept-figure {
        max-width: 340px;
    }
}

.concept-figure {
    margin: 0.25rem 0 1rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.concept-figure svg {
    display: block;
    width: 100%;
    height: auto;
}

.concept-figure figcaption {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.cf-text {
    fill: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.cf-small {
    fill: var(--muted);
    font-size: 13px;
}

.cf-tiny {
    fill: var(--muted);
    font-size: 10.5px;
}

.cf-guide {
    stroke: var(--muted);
    stroke-dasharray: 2 3;
}

.cf-stick {
    stroke: var(--accent);
    stroke-width: 3;
}

.cf-stop {
    stop-color: var(--accent);
}

.cf-shell {
    fill: none;
    stroke: var(--muted);
    stroke-dasharray: 3 4;
}

.cf-d {
    fill: var(--highlight);
}

.cf-nucleus {
    fill: var(--text);
}

.cf-nucleus-big {
    fill: var(--surface-alt);
    stroke: var(--accent);
    stroke-width: 2;
}

.cf-charge {
    fill: var(--surface);
    stroke: var(--muted);
}

.cf-charge-sign {
    fill: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.cf-bar {
    fill: var(--accent);
}

.cf-bar-alt {
    fill: var(--highlight);
}

.cf-axis {
    stroke: var(--muted);
}

.cf-level {
    stroke: var(--text);
    stroke-width: 2;
}

.cf-arrow {
    stroke: var(--accent);
    stroke-width: 2;
}

.cf-arrowhead {
    fill: var(--accent);
}

/* Sliders that only apply to a doublet or a sextet */
.lab-control[hidden] {
    display: none;
}

@media (max-width: 860px) {
    .instrument {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* SUPERPARAMAGNETISM ANIMATION (js/learn/spins.js) */

.spins-figure {
    display: grid;
    gap: 0.75rem;
}

.spins-particle {
    fill: var(--surface-alt);
    stroke: var(--border);
    stroke-width: 1.5;
}

.spins-arrow line {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
}

.spins-arrow path {
    fill: var(--accent);
}

.spins-flipping .spins-arrow {
    opacity: 0.35;
}

.spins-status-blocked {
    fill: var(--accent-strong);
    font-weight: 600;
}

.spins-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.35rem 0.75rem;
}

.spins-controls label {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    grid-column: 1 / -1;
    font-weight: 600;
}

.spins-controls input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

/* EQUATIONS (MathML, rendered by the browser) */

.article > .equation,
.article > .equation-terms {
    max-width: var(--measure);
}

.equation {
    margin: 1rem 0 1.25rem;
    overflow-x: auto;
}

.equation math {
    font-size: 1.25rem;
}

.equation-terms {
    margin-bottom: 1.25rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.equation-terms li + li {
    margin-top: 0.25rem;
}

/* A choice that does not apply to the current selection */
.lab-pill.is-disabled span {
    opacity: 0.45;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* QUIZ (js/learn/quiz.js) */

.quiz-list {
    display: grid;
    gap: 1.25rem;
    max-width: var(--measure);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: question;
}

.quiz-question {
    counter-increment: question;
    padding: 1.1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: 12px;
}

.quiz-question.is-right {
    border-left-color: var(--accent);
}

.quiz-question.is-wrong-answer {
    border-left-color: var(--highlight);
}

.quiz-question fieldset {
    display: grid;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.quiz-question legend {
    margin-bottom: 0.6rem;
    padding: 0;
    font-weight: 600;
}

.quiz-question legend::before {
    content: counter(question) ". ";
    color: var(--accent-strong);
}

.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.quiz-option:hover {
    background: var(--surface-hover);
}

.quiz-option input {
    margin-top: 0.35rem;
    accent-color: var(--accent);
}

.quiz-option:has(input:disabled) {
    cursor: default;
}

.quiz-letter {
    flex: none;
    width: 1.2em;
    font-weight: 700;
    color: var(--muted);
}

.quiz-option.is-answer {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.quiz-option.is-wrong {
    border-color: var(--highlight);
}

.quiz-feedback:not(:empty) {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border-radius: 8px;
    font-size: 0.95rem;
}

.quiz-feedback p {
    margin: 0 0 0.35rem;
}

.quiz-feedback p:last-child {
    margin-bottom: 0;
}

.quiz-verdict {
    font-weight: 700;
}

.quiz-score {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.15rem;
    font-weight: 700;
}
