/* ─── PFP Quiz — WCAG 2.1 AA Compliant Styles ─── */

/* ─── Reset & Base ─── */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Respect the `hidden` HTML attribute on all elements, including those
   with an explicit display value. Without this, `.btn { display: inline-block }`
   (and similar rules) silently override `[hidden]` and leave elements visible. */
[hidden] {
    display: none !important;
}

/* Auth controls live inside .app-header-inner; margin-left:auto pushes
   them to the right edge of the header without a second bar. */
.auth-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    color: #fff;
    font-size: 0.9rem;
}

.auth-bar-label {
    font-weight: 500;
}

.auth-bar-btn {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}

.auth-bar-btn:hover,
.auth-bar-btn:focus-visible {
    background: rgba(255, 255, 255, 0.25);
}

.auth-error-banner {
    padding: 10px 16px;
    background: #fde2e2;
    color: #7a1a1a;
    border-left: 4px solid #c0392b;
    font-size: 0.95rem;
}

:root {
    --primary: #2271a8;
    --primary-hover: #1a5a87;
    --secondary: #6c757d;
    --secondary-hover: #545b62;
    --danger: #c0392b;
    --success: #27ae60;
    --warning: #d4a017;
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #212529;
    --text-muted: #495057;
    --border: #dee2e6;
    --focus-ring: #2271a8;
    --header-bg: #343a40;
    --institution-accent: #CC0033; /* Rutgers scarlet; swap per institution */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --radius: 0.5rem;
}

html {
    font-size: 100%; /* Respects browser zoom (WCAG 1.4.4) */
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    /* Disable iOS Safari's double-tap-to-zoom gesture so rapid taps on
       small controls (avatar picker arrows/swatches especially) don't
       accidentally zoom. Pinch-zoom is preserved for accessibility. */
    touch-action: manipulation;
}

/* ─── Skip Link (WCAG 2.4.1) ─── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    background: var(--primary);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    z-index: 9999;
    text-decoration: none;
    font-weight: 600;
}

.skip-link:focus {
    top: 0.5rem;
}

/* ─── Screen Reader Only ─── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Focus Visible (WCAG 2.4.7) ─── */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Headings and non-interactive scroll targets receive focus only so
   screen readers announce them on screen change (WCAG 2.4.3). There's
   no keyboard action to perform there, so suppress the focus ring. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
    outline: none;
}

/* ─── App header (logo + wordmark) ─── */
.app-header {
    background: var(--header-bg);
    color: #fff;
    border-bottom: 3px solid var(--institution-accent);
}

.app-header-inner {
    max-width: 52rem;
    margin: 0 auto;
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    /* On narrow widths the netid + Admin Dashboard + Log out group
       can't fit on the same line as the logo. Wrapping is gentler
       than overflow — the auth controls drop to a second visual row
       inside the same header. */
    flex-wrap: wrap;
}

.app-header-logo {
    flex-shrink: 0;
    display: block;
    height: 3rem;
    width: auto;
}

@media (max-width: 420px) {
    .app-header-logo {
        height: 2.5rem;
    }
}

/* ─── Container ─── */
.container {
    max-width: 52rem;
    margin: 0 auto;
    padding: 1rem;
}

/* ─── Section Nav ─── */
.section-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-tab {
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    font-size: 0.9rem;
}

.nav-tab:hover {
    color: var(--primary);
}

.nav-tab[aria-current="page"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.nav-tab.locked {
    color: var(--secondary);
    opacity: 0.6;
    cursor: not-allowed;
}

.nav-tab.locked::after {
    content: ' \1F512';
    font-size: 0.75em;
}

/* ─── Screens ─── */
.screen {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Headings ─── */
h1, h2, h3, h4 {
    color: var(--text);
    margin-top: 0;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; }

/* ─── Buttons ─── */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn.secondary:hover {
    background: var(--bg);
    border-color: var(--secondary);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.disabled:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ─── Welcome Screen ─── */
#screen-welcome {
    text-align: center;
    padding: 3rem 1rem;
}

#screen-welcome h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

#screen-welcome p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 36rem;
    margin: 0.5rem auto;
}

#screen-welcome .welcome-logo {
    display: block;
    max-width: 22rem;
    width: 80%;
    height: auto;
    margin: 0 auto 1.5rem;
}

#screen-welcome .btn {
    margin-top: 2rem;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

/* ─── Quiz Screen ─── */
.progress {
    width: 100%;
    height: 0.5rem;
    background: var(--border);
    border-radius: 0.25rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
    border-radius: 0.25rem;
}

.question-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

#question-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.question {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.answers {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.answer-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}

.answer-btn:hover {
    border-color: var(--primary);
    background: #f0f7fc;
}

.answer-btn.selected {
    border-color: var(--primary);
    background: #e3f0fa;
    font-weight: 600;
}

.quiz-nav {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
}

.quiz-nav #quiz-back-btn {
    margin-right: auto;
}

/* ─── Avatar Builder ─── */
.avatar-builder {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
    margin: 1.5rem 0;
}

#avatar-canvas {
    border-radius: 50%;
    border: 3px solid var(--border);
    max-width: 100%;
    height: auto;
}

.avatar-controls {
    flex: 1;
    min-width: 14rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.avatar-control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.avatar-control-label {
    flex: 1;
    font-weight: 500;
    text-align: center;
    min-width: 5rem;
}

.avatar-arrow {
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.avatar-arrow:hover {
    border-color: var(--primary);
}

.avatar-swatches {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.avatar-swatch {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s;
}

.avatar-swatch:hover {
    border-color: var(--text-muted);
}

.avatar-swatch.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}

/* ─── About You Overview ─── */
.aboutyou-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1.5rem 0;
}

.aboutyou-avatar canvas {
    border-radius: 50%;
    border: 3px solid var(--border);
}

.edit-avatar-link {
    margin-top: 0.5rem;
    color: var(--primary);
    font-size: 0.9rem;
}

.traits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 2rem 0.5rem;
    background-image: url('images/cloud-0.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.trait-card {
    display: block;
    padding: 1rem;
    text-align: center;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.trait-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.trait-card.viewed {
    border-color: var(--success);
    background: #f0faf4;
}

.trait-card.viewed::after {
    content: ' \2713';
    color: var(--success);
}

/* ─── Spectrum Bars ─── */
.spectrums {
    margin: 1.5rem 0;
}

.spectrum-bar {
    margin-bottom: 1.5rem;
}

.spectrum-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.spectrum-label-low {
    color: var(--text-muted);
}

.spectrum-label-high {
    color: var(--text-muted);
}

.spectrum-track {
    position: relative;
    height: 1rem;
    background: linear-gradient(to right, #e8f4fd, var(--primary));
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.spectrum-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 1.25rem;
    height: 1.25rem;
    background: var(--text);
    border: 3px solid var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ─── Trait Detail Page ─── */
#screen-aboutyou-trait {
    position: relative;
}

.trait-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.trait-illustration {
    display: block;
    max-width: 18rem;
    width: 100%;
    height: auto;
    margin: 0.5rem auto 1rem;
}

.trait-sections {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.trait-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.trait-section h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.trait-sidebar {
    background: #f0f7fc;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1.5rem 0;
}

.trait-sidebar h4 {
    margin-bottom: 0.5rem;
}

.trait-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.trait-sidebar li {
    margin-bottom: 0.25rem;
}

.trait-sidebar a {
    color: var(--primary);
    text-decoration: none;
}

.trait-sidebar a:hover {
    text-decoration: underline;
}

.trait-sidebar a.current-trait {
    font-weight: 700;
}

.trait-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ─── Brain Train ─── */
/* Non-interactive progress indicator (page dots removed per Maia 2026-04-16) */
.braintrain-page-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin: 1rem auto 1.5rem;
    max-width: 24rem;
}

.page-progress-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.page-progress-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.page-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.braintrain-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ─── Checkboxes (Brain Train, ANTS) ─── */
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.checkbox-item input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checkbox-item label {
    cursor: pointer;
    line-height: 1.4;
}

.checkbox-with-text {
    flex-wrap: wrap;
}

.other-text {
    flex: 1;
    min-width: 10rem;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

.braintrain-label {
    display: block;
    font-weight: 500;
    margin: 1rem 0 0.25rem;
}

.braintrain-textarea {
    display: block;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 1rem;
    resize: vertical;
    margin-top: 0.25rem;
}

.braintrain-input {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-top: 0.25rem;
}

.summary-section {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.summary-section h4 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.braintrain-train-img {
    display: block;
    max-width: 22rem;
    width: 100%;
    height: auto;
    margin: 0.5rem auto 1.5rem;
}

.braintrain-resources-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.braintrain-resources-list .checkbox-item label {
    flex: 1;
}

.braintrain-resources-list a {
    color: var(--primary);
    text-decoration: none;
}

.braintrain-resources-list a:hover {
    text-decoration: underline;
}

/* Blocker highlight — set when the student clicks Continue while a
   field is missing, cleared when they engage with the field. */
.bt-invalid {
    outline: 2px solid var(--danger);
    outline-offset: 3px;
    border-radius: var(--radius);
    background: #fdecea;
}
textarea.bt-invalid,
input.bt-invalid {
    border-color: var(--danger);
}

/* ─── Substance Use ─── */
.su-preamble {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.su-question {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    background: var(--surface);
}

.su-question legend {
    font-weight: 600;
    padding: 0 0.25rem;
    color: var(--text);
}

.su-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.su-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 0.3rem;
    cursor: pointer;
    transition: background 0.15s;
}

.su-option:hover {
    background: #f0f7fc;
}

.su-option input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.su-nav {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.su-nav #su-back-btn {
    margin-right: auto;
}

.su-feedback-section {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.su-feedback-header {
    font-weight: 600;
    margin: 0 0 1rem;
    line-height: 1.5;
}

.su-feedback-summary {
    margin: 1rem 0 0;
    font-style: italic;
    color: var(--text-muted);
    text-align: center;
}

.su-chart {
    margin-top: 1rem;
}

.su-chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 220px;
    gap: 0.5rem;
    padding: 4rem 0.5rem 0;
    border-bottom: 2px solid var(--border);
    position: relative;
}

.su-chart-labels {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 0;
    align-items: flex-start;
}

.su-chart-labels .su-bar-label {
    flex: 1;
    min-width: 0;
}

.su-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    position: relative;
    min-width: 0;
}

.su-bar-avatar {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translate(-50%, -100%);
    z-index: 2;
}

.su-bar-avatar canvas {
    display: block;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.su-bar-pct {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-muted);
}

.su-bar-col {
    width: 100%;
    max-width: 60px;
    background: linear-gradient(to top, var(--primary), #4a9fd1);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: background 0.2s;
}

.su-bar.selected .su-bar-col {
    background: linear-gradient(to top, #d4a017, #f0c040);
    box-shadow: 0 0 0 2px #d4a017;
}

.su-bar.selected .su-bar-pct {
    color: #8a6a00;
    font-weight: 700;
}

.su-bar-label {
    font-size: 0.75rem;
    text-align: center;
    margin-top: 6px;
    color: var(--text-muted);
    line-height: 1.2;
    word-break: break-word;
}

.su-bar-label.selected {
    color: var(--text);
    font-weight: 600;
}

.su-balancing {
    margin: 2rem 0;
    padding: 1.25rem;
    background: #fff3cd;
    border-left: 4px solid #d4a017;
    border-radius: 0 var(--radius) var(--radius) 0;
    line-height: 1.6;
}

.su-balancing ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.su-strategies {
    margin: 2rem 0;
    padding: 1.25rem;
    background: #f0f7fc;
    border-radius: var(--radius);
}

.su-strategies h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.su-strategies ul {
    padding-left: 1.25rem;
}

.su-strategies li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

@media (max-width: 600px) {
    .su-chart-bars {
        height: 180px;
    }
    .su-bar-avatar canvas {
        width: 36px !important;
        height: 36px !important;
    }
    .su-bar-label {
        font-size: 0.65rem;
    }
}

/* ─── Adventure ─── */
.adventure-description {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.adventure-scene {
    display: block;
    max-width: 24rem;
    width: 100%;
    height: auto;
    margin: 0.5rem auto 1.5rem;
}

.adventure-prompt {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.adventure-choices {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.adventure-choice {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s;
}

.adventure-choice:hover:not(:disabled) {
    border-color: var(--primary);
}

.adventure-choice.selected {
    border-color: var(--primary);
    background: #e3f0fa;
    font-weight: 600;
}

.adventure-choice:disabled {
    cursor: default;
    opacity: 0.8;
}

.adventure-outcome {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: #f0faf4;
    border: 1px solid #c3e6cb;
    border-radius: var(--radius);
    line-height: 1.6;
}

.adventure-abcs {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius);
}

.adventure-abcs h4 {
    margin-bottom: 0.75rem;
}

.adventure-abcs p {
    margin: 0.25rem 0;
}

.adventure-nav {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Back button flushes left, Continue stays right */
.adventure-nav .btn.secondary:first-child {
    margin-right: auto;
}

.goal-progress {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.goal-progress h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.goal-progress-status {
    font-weight: 600;
    margin: 0.25rem 0 1rem;
}

.goal-progress-status.advances {
    color: #176b3a; /* darkened from var(--success) for AA contrast on white (6.56:1) */
}

.goal-progress-status.stays {
    color: var(--text-muted);
}

.goal-progress-track {
    position: relative;
    height: 8px;
    background: linear-gradient(to right, #e8f4fd, #c8e4f6);
    border-radius: 4px;
    margin: 3rem 5rem 1rem;
}

.goal-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(to right, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.6s ease-out;
}

.goal-progress-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: left 0.6s ease-out;
    z-index: 2;
}

.goal-progress-marker canvas {
    display: block;
    border-radius: 50%;
    border: 3px solid var(--primary);
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.goal-progress-end {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.goal-progress-start-label {
    right: calc(100% + 0.5rem);
}

.goal-progress-goals-label {
    left: calc(100% + 0.5rem);
    color: var(--primary);
}

.goal-progress-goals-header {
    font-weight: 600;
    margin: 1rem 0 0.25rem;
    font-size: 0.95rem;
}

.goal-progress-goals-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.95rem;
}

.goal-progress-goals-list li {
    margin-bottom: 0.25rem;
}

.goal-progress-nogoals {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.75rem 0 0;
}

@media (max-width: 600px) {
    .goal-progress-track {
        margin: 3rem 3.5rem 1rem;
    }
    .goal-progress-end {
        font-size: 0.75rem;
    }
}

/* ─── ANTS ─── */
#ants-educational-content {
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

#ants-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

#ants-question {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.ants-expanded-section {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.6;
}

.ants-expanded-section:empty {
    display: none;
}

.ants-expanded-section h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.ants-expanded-section ol {
    padding-left: 1.5rem;
    margin: 0.75rem 0;
}

.ants-expanded-section ol > li {
    margin-bottom: 0.75rem;
}

.ants-expanded-section ul {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.ants-nav {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ─── Certification gate ─── */
.certification-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

#certification-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
}

/* ─── Thank You ─── */
#screen-thankyou {
    text-align: center;
}

#thankyou-content {
    text-align: left;
    line-height: 1.6;
    margin: 1.5rem 0;
}

.thankyou-revisit {
    text-align: left;
    margin: 2rem 0;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.thankyou-revisit h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.thankyou-revisit-aboutyou {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.thankyou-revisit-aboutyou > a {
    display: block;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

.thankyou-revisit-aboutyou > a:hover {
    text-decoration: underline;
}

.thankyou-revisit-aboutyou h4 {
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.thankyou-revisit-aboutyou ul {
    list-style: none;
    padding: 0 0 0 1rem;
    margin: 0 0 0.75rem;
}

.thankyou-revisit-aboutyou li {
    margin-bottom: 0.15rem;
}

.thankyou-revisit-aboutyou a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.thankyou-revisit-aboutyou a:hover {
    text-decoration: underline;
}

.thankyou-section-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.thankyou-section-links li {
    margin-bottom: 0.5rem;
}

.thankyou-section-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
}

.thankyou-section-links a:hover {
    text-decoration: underline;
}

/* ─── Resource links — pending URL state ─── */
/* Visual hint that this link is awaiting a real URL from the URL audit.
   Kept subtle so the content still reads cleanly during client review. */
a.resource-tbd {
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

/* ─── Popovers ─── */
.popover-trigger {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-style: inherit;
    display: inline;
}

.popover-trigger:hover,
.popover-trigger:focus-visible {
    color: var(--primary-hover);
    text-decoration-style: solid;
}

.popover {
    position: absolute;
    z-index: 500;
    max-width: 28rem;
    width: calc(100vw - 2rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f0f7fc;
    border-radius: var(--radius) var(--radius) 0 0;
}

.popover-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    color: var(--text-muted);
}

.popover-body {
    padding: 1rem;
    line-height: 1.6;
    font-size: 0.95rem;
    max-height: 60vh;
    overflow-y: auto;
}

.popover-body p {
    margin: 0.5rem 0;
}

.popover-body p:first-child {
    margin-top: 0;
}

/* ─── Adventure Intro ─── */
.adventure-intro {
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.adventure-intro ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.adventure-intro li {
    margin-bottom: 0.4rem;
}

.adventure-abcs-intro {
    margin-bottom: 2rem;
}

/* ─── Modals ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 30rem;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.25rem;
    line-height: 1.6;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.warning-modal .modal-header {
    background: #fff3cd;
    border-bottom-color: #ffc107;
}

.warning-modal .modal-body {
    background: #fffdf5;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .container {
        padding: 0.5rem;
    }

    .section-nav {
        flex-wrap: wrap;
    }

    .nav-tab {
        flex: 1;
        text-align: center;
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }

    .avatar-builder {
        flex-direction: column;
        align-items: center;
    }

    #avatar-canvas {
        width: 250px;
        height: 250px;
    }

    .avatar-controls {
        min-width: unset;
        width: 100%;
    }

    .traits-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .thankyou-traits {
        flex-direction: column;
        gap: 1rem;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
}
