/* Year 9 Science home: the "See it" card at the top of each section's media
 * column, and the dialog that opens it large.
 *
 * The pictures are drawn by science/unit_visuals.py from the shared diagram
 * kit and carry their own atom colours. Everything else here (text, graph
 * lines, arrows) takes the page's tokens through classes, so nothing in the
 * generated SVG needs a hex value.
 *
 * Complete without JavaScript: the card is the picture and its caption. The
 * Enlarge button and the stepper controls are `.suv-js-only` and only appear
 * once unit-visuals.js has marked the card `.suv-ready`. */

.suv-card {
    position: relative;
    margin: 0;
    padding: 10px 12px 11px;
    min-width: 0;
    border: 1px solid var(--line);
    border-left: 4px solid var(--strand, var(--teal));
    border-radius: 14px;
    background: var(--paper);
    box-shadow: var(--shadow);
    font-size: 0.8rem;
    line-height: 1.4;
}

.suv-eyebrow {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 78px 6px 0;
    min-width: 0;
    line-height: 1.3;
}
.suv-eyebrow span {
    flex: none;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--strand-soft, var(--cream));
    color: var(--strand-ink, var(--teal-deep));
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.suv-eyebrow b {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 0.82rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.suv-fig { max-height: 118px; overflow: hidden; }
.suv-k-molecules .suv-fig { max-height: 136px; }
.suv-k-trend .suv-fig { max-height: 128px; }
/* Four periods of dot diagrams plus the transfer row; 118px showed two and a half. */
.suv-k-lewis .suv-fig { max-height: 236px; }
.suv-box { display: block; }
.suv-box svg, .suv-frame svg { display: block; width: 100%; height: auto; }

.suv-cap { margin: 6px 0 0; color: var(--ink); }
.suv-link {
    margin-left: 4px;
    font-weight: 700;
    color: var(--teal-deep);
    white-space: nowrap;
}

.suv-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ----------------------------------------------- script-only controls */

.suv-js-only { display: none; }
.suv-open {
    position: absolute;
    top: 8px;
    right: 10px;
    min-height: 30px;
    padding: 2px 12px;
    border: 1px solid var(--strand, var(--teal));
    border-radius: 999px;
    background: var(--paper);
    color: var(--strand-ink, var(--teal-deep));
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
}
.suv-open:hover { background: var(--strand-soft, var(--cream)); }
.suv-ready .suv-open { display: inline-flex; align-items: center; }
.suv-ready .suv-step-controls { display: flex; }
.suv-ready .suv-fig { cursor: zoom-in; }
.suv-ready .suv-step-controls, .suv-ready .suv-link { cursor: auto; }
.suv-card :focus-visible, .suv-overlay :focus-visible {
    outline: 3px solid var(--teal-deep);
    outline-offset: 2px;
    border-radius: 6px;
}

/* --------------------------------------------- generated SVG classes */

.suv-t { fill: var(--ink); font-family: inherit; }
.suv-t-muted { fill: var(--muted); }
.suv-t-fast { fill: color-mix(in srgb, var(--tangerine) 62%, var(--ink)); font-weight: 700; }
.suv-t-slow { fill: var(--teal-deep); font-weight: 700; }
.suv-axis { stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; }
.suv-plateau { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.suv-curve { fill: none; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.suv-curve-fast { stroke: var(--tangerine); }
.suv-curve-slow { stroke: var(--teal); }
.suv-reach { stroke: var(--tangerine); stroke-width: 2; stroke-dasharray: 4 3; stroke-linecap: round; }
.suv-arrow { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------- per kind (card) */

.suv-pairs, .suv-mols { display: grid; margin: 0; padding: 0; list-style: none; gap: 6px; }
.suv-pairs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.suv-pair { display: grid; align-content: start; gap: 3px; min-width: 0; text-align: center; }
.suv-photo {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    object-fit: cover;
    background: var(--cream);
}
.suv-name { font-size: 0.7rem; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.suv-group {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}
.suv-credit { display: none; }

.suv-mols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.suv-mol { display: grid; grid-template-rows: auto auto auto; justify-items: center; min-width: 0; text-align: center; }
.suv-mol .suv-box { width: 90px; }
.suv-formula { font-size: 0.95rem; font-weight: 800; line-height: 1.2; }
.suv-counts { font-size: 0.66rem; line-height: 1.2; color: var(--muted); }

.suv-bohr { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 12px; }
.suv-key { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 0.74rem; line-height: 1.3; }
.suv-key li { padding-left: 9px; border-left: 3px solid var(--strand, var(--teal)); }
.suv-key li:nth-child(2) { border-left-color: var(--gold); }
.suv-key li:nth-child(3) { border-left-color: var(--tangerine); }

.suv-step { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 12px; }
.suv-frame[hidden] { display: none; }
.suv-step-side { display: grid; gap: 6px; min-width: 0; }
.suv-step-label { margin: 0; font-size: 0.95rem; font-weight: 800; line-height: 1.25; }
.suv-step-controls { display: none; align-items: center; gap: 6px; }
.suv-step-btn {
    flex: none;
    width: 34px;
    height: 34px;
    border: 1px solid var(--strand, var(--teal));
    border-radius: 999px;
    background: var(--paper);
    color: var(--strand-ink, var(--teal-deep));
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.suv-step-btn:hover:not(:disabled) { background: var(--strand-soft, var(--cream)); }
.suv-step-btn:disabled { opacity: 0.4; cursor: default; }
.suv-range { flex: 1 1 auto; min-width: 0; height: 34px; accent-color: var(--strand-ink, var(--teal-deep)); }

.suv-k-map .suv-box, .suv-k-trend .suv-box, .suv-k-reaction .suv-box, .suv-k-graph .suv-box { margin: 0 auto; }
.suv-k-map .suv-box { width: 78%; }
.suv-k-trend .suv-box { width: 72%; }
.suv-k-reaction .suv-box { width: 92%; }
.suv-k-graph .suv-box { width: 62%; }

/* ---------------------------------------------------------------- dialog */

body.suv-lock { overflow: hidden; }
.suv-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: color-mix(in srgb, var(--ink) 62%, transparent);
}
.suv-overlay[hidden] { display: none; }
.suv-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 940px;
    max-height: min(92vh, 860px);
    overflow: hidden;
    border-radius: 18px;
    background: var(--paper);
    color: var(--ink);
    font-size: 1rem;
    box-shadow: 0 30px 70px -20px color-mix(in srgb, var(--ink) 70%, transparent);
}
.suv-dialog-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 12px 8px 20px;
    border-bottom: 1px solid var(--line);
}
.suv-dialog-bar h2 { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.suv-dialog-close {
    min-height: 44px;
    padding: 6px 20px;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.suv-dialog-close:hover { background: var(--teal-deep); }
.suv-dialog-body { flex: 1 1 auto; min-height: 0; padding: 18px 22px 24px; overflow-y: auto; }

.suv-large {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-size: 1rem;
    line-height: 1.55;
}
.suv-large .suv-eyebrow, .suv-large .suv-open, .suv-large .suv-link:empty { display: none; }
.suv-large .suv-fig { max-height: none; overflow: visible; cursor: auto; }
.suv-large .suv-cap { margin-top: 14px; font-size: 1rem; }

.suv-large .suv-pairs { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.suv-large .suv-pair { gap: 6px; }
.suv-large .suv-name { font-size: 1.02rem; }
.suv-large .suv-group {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--strand-ink, var(--teal-deep));
}
.suv-large .suv-credit { display: block; font-size: 0.68rem; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }

.suv-large .suv-mols { gap: 18px; }
.suv-large .suv-mol .suv-box { width: min(100%, 210px); }
.suv-large .suv-formula { font-size: 1.5rem; }
.suv-large .suv-counts { font-size: 0.95rem; }

.suv-large .suv-bohr { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; }
.suv-large .suv-key { gap: 10px; font-size: 1.05rem; }
.suv-large .suv-key li { padding-left: 14px; border-left-width: 5px; }

.suv-large .suv-step { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 28px; }
.suv-large .suv-step-label { font-size: 1.5rem; }
.suv-large .suv-step-controls { gap: 10px; }
.suv-large .suv-step-btn { width: 44px; height: 44px; font-size: 1.2rem; }
.suv-large .suv-range { height: 44px; }

.suv-large .suv-k-map .suv-box, .suv-large .suv-k-trend .suv-box,
.suv-large.suv-k-map .suv-box, .suv-large.suv-k-trend .suv-box,
.suv-large.suv-k-reaction .suv-box { width: 100%; max-width: 800px; }
.suv-large.suv-k-graph .suv-box { width: 100%; max-width: 560px; }

.suv-isotopes { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.suv-isotopes h3 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 700; }
.suv-isotopes p { margin: 12px 0 0; }
.suv-iso-row { display: flex; flex-wrap: wrap; gap: 24px; }
.suv-iso { margin: 0; width: min(100%, 220px); text-align: center; }
.suv-iso figcaption { margin-top: 6px; font-weight: 700; }

@media (max-width: 560px) {
    .suv-overlay { padding: 0; }
    .suv-dialog { height: 100%; max-width: none; max-height: none; border-radius: 0; }
    .suv-dialog-body { padding: 14px 16px 22px; }
    .suv-large .suv-bohr, .suv-large .suv-step { grid-template-columns: minmax(0, 1fr); }
    .suv-large .suv-bohr .suv-box, .suv-large .suv-step .suv-frames { width: min(100%, 280px); margin: 0 auto; }
    .suv-large .suv-pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .suv-large .suv-mols { grid-template-columns: minmax(0, 1fr); justify-items: center; }
}

@media print {
    .suv-open, .suv-step-controls, .suv-overlay { display: none !important; }
    .suv-card { break-inside: avoid; box-shadow: none; }
}
