/* assessment-v3.css — paginated pre-assessment layout.
   Lovable UI/UX port: this file now consumes the design tokens defined in
   lovable-theme.css (loaded first via head.ejs) so the active pre-assessment
   matches the Lovable look. Structural/behavioral rules (one-step-at-a-time
   show/hide, sticky footer, fade, a11y) are unchanged — only the visual layer
   was retargeted to the tokens. The av3-* class/id hooks that assessment-v3.js
   relies on are all preserved. */

#av3-app {
    font-family: var(--lv-font);
    color: var(--body);
    max-width: 672px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

/* Step heading (bold, below the teal eyebrow) — matches Lovable's per-step title. */
.av3-step-heading {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--heading);
    margin: 0 0 20px;
}

/* Field labels — medium weight, heading color (Lovable's Field label treatment). */
#av3-app .form-group > label,
#av3-app .form-check-label {
    font-weight: 500;
    color: var(--heading);
    margin-bottom: 6px;
}

/* Per-screener instruction line under the eyebrow (e.g. "rate how often…"). */
.av3-section-help {
    font-size: 0.875rem;
    color: var(--muted-foreground) !important;
    margin-bottom: 16px;
}

.av3-topbar {
    padding: 24px 0 8px;
}

/* Lovable logo is a near-square stacked mark — size it by height, not width. */
#av3-logo {
    height: 64px;
    width: auto;
    max-width: 100%;
    user-select: none;
}
@media (min-width: 640px) {
    #av3-logo { height: 80px; }
}

/* one step visible at a time; JS toggles display + .av3-step--active for fade-in */
.av3-step {
    display: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.av3-step.av3-step--active {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .av3-step { transition: none; transform: none; }
}

/* The white card surface each step lives in — the Lovable card. */
.av3-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--lv-shadow-card);
    padding: 24px;
    margin-top: 8px;
}
@media (min-width: 768px) {
    .av3-card { padding: 32px; }
}

.av3-card h2,
.av3-card h3 {
    color: var(--heading);
}

/* Screener intro/disclaimer interstitial screens (ASRS / BDEFS "past 6 months"). */
.av3-screener-intro .av3-card {
    padding-top: 40px;
    padding-bottom: 40px;
}
.av3-screener-intro .lv-eyebrow {
    margin-bottom: 12px;
}
.av3-screener-intro h2 {
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.av3-section-intro {
    margin-bottom: 16px;
}
.av3-section-intro h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}
.av3-section-intro .text-muted {
    color: var(--muted-foreground) !important;
    font-size: 0.875rem;
}

/* BDEFS visual subsection header — sits above the first question of a subsection */
.av3-subsection-header {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--heading);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.av3-fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.av3-timeframe {
    margin-bottom: 12px;
}

.av3-question-label {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--heading);
    line-height: 1.4;
    margin-bottom: 20px;
}

/* Likert options — Lovable option grid (2 tiles per row on mobile; one row of
   tiles on desktop, sized by instrument: ASRS has 5 options, BDEFS has 4). The
   native radio is visually hidden and the checked label gets the teal state. */
.av3-likert {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr; /* phone-first: tiles stack full width; wider screens go to a row below */
    gap: 0.5rem;
    border-bottom: 0;
}
.av3-likert::before { content: none; }
@media (min-width: 640px) {
    [data-tool="asrs"] .av3-likert { grid-template-columns: repeat(5, 1fr); }
    [data-tool="bdefs"] .av3-likert { grid-template-columns: repeat(4, 1fr); }
}

.av3-likert li {
    display: flex; /* even-height option cards when a label wraps (callout #5) */
    width: auto;
    margin: 0;
}

.av3-likert input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.av3-likert label {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-height: 44px;
    padding: 12px 8px;
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.av3-likert input[type="radio"]:checked + label {
    border-color: var(--primary);
    background: var(--tag-teal);
    color: var(--primary);
    font-weight: 600;
}

/* Nav footer — moved INTO the active card by assessment-v3.js so Back/Continue read
   as part of the card (Lovable), not a detached viewport bar. Sits at the bottom of
   the card content with a subtle divider above. */
.av3-footer {
    display: flex;
    justify-content: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
}

.av3-footer-inner {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.av3-footer .btn {
    min-height: 44px;
    min-width: 110px;
}

/* Back button — understated ghost, matching Lovable's secondary/back action. */
#av3Back.btn {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    box-shadow: none;
}
#av3Back.btn:hover,
#av3Back.btn:focus {
    background: transparent;
    color: var(--foreground);
}

/* Radio groups (contact method, age Yes/No) as card-only selection — no visible
   native control, matching Lovable. Label is associated with the input so the
   whole card toggles it. */
.av3-step .form-check {
    position: relative;
    display: block;
    margin-bottom: 0.5rem;
    padding: 0; /* padding moved to the label so the whole box is clickable */
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.av3-step .form-check:hover { border-color: var(--muted-foreground); background: var(--muted); }
.av3-step .form-check:has(input:checked),
.av3-step .form-check.is-selected {
    border-color: var(--primary);
    background: var(--tag-teal);
    box-shadow: inset 0 0 0 1px var(--primary);
}
.av3-step .form-check:has(input:checked)::after,
.av3-step .form-check.is-selected::after {
    content: "\2713";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1;
}
.av3-step .form-check-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
}
.av3-step .form-check-label {
    display: block;
    width: 100%;
    cursor: pointer;
    font-weight: 500;
    color: var(--heading);
    padding: 0.875rem 2.75rem 0.875rem 1rem; /* click target fills the whole card */
    margin: 0;
}

/* when Back is hidden, Next stays right-aligned (visibility:hidden keeps slot) */
.av3-back {
    visibility: hidden;
}

/* per-field validation styling */
.av3-error {
    display: block;
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 6px;
    min-height: 1em;
}

.av3-legend {
    font-size: 1rem;
    font-weight: 500;
    color: var(--heading);
    margin-bottom: 8px;
}

.req {
    color: var(--danger);
}

/* "Optional" field hint next to a label (Lovable's Field hint) — light, muted, inline. */
.av3-hint {
    font-weight: 400;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-left: 4px;
}

/* Disqualification screens (screener-fail + under-18) — Lovable's shared framing:
   a soft "Care match" pill, a reassuring heading, then left-aligned explanatory copy. */
.av3-dq {
    text-align: left;
}
.av3-dq-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(201, 42, 42, 0.10);
    color: var(--danger);
    margin-bottom: 16px;
}
.av3-dq-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--heading);
    margin: 0 0 16px;
}
.av3-dq p {
    margin-bottom: 12px;
    line-height: 1.6;
}
.av3-dq-contact {
    margin-top: 4px;
}
.av3-dq-list {
    padding-left: 1.25rem;
    margin: 0 0 12px;
}
.av3-dq-list li {
    margin-bottom: 6px;
    line-height: 1.6;
}
.av3-dq-list a {
    color: var(--primary);
    text-decoration: underline;
}
.av3-dq-signoff {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* Small muted field hint below an input (e.g. the email privacy note). */
.av3-field-hint {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    line-height: 1.45;
    margin-top: 6px;
}

/* Preview mode (admin copy editor). Slim fixed bar so it never disturbs the card layout. */
.av3-preview-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: var(--heading);
    color: #fff;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 8px 12px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.12);
}
body.av3-preview #av3-app { padding-bottom: 56px; }
body.av3-preview .av3-footer .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Confirm-info dialog (Lovable "double-check your information"). */
.av3-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.av3-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}
.av3-modal-card {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 24px;
    max-width: 440px;
    width: 100%;
}
.av3-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--heading);
    margin: 0 0 12px;
}
.av3-confirm-summary {
    border: 1px solid var(--card-border);
    background: var(--muted);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 0.875rem;
    margin: 16px 0;
}
.av3-confirm-summary > div { margin-bottom: 6px; }
.av3-confirm-summary > div:last-child { margin-bottom: 0; }
.av3-confirm-key { font-weight: 600; color: var(--heading); }
.av3-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}
.av3-modal-actions .btn { min-height: 44px; }
@media (max-width: 480px) {
    .av3-modal-actions { flex-direction: column-reverse; }
    .av3-modal-actions .btn { width: 100%; }
}

[aria-invalid="true"] {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 1px var(--danger) inset;
}

/* visible focus ring for keyboard users */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
.av3-step:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* progress indicator */
.av3-progress {
    max-width: 672px;
    margin: 8px auto 0;
}

.av3-progress-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 4px;
}

.av3-progress-bar {
    height: 8px;
    background: var(--card-border);
    border-radius: 9999px;
    overflow: hidden;
}

.av3-progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.2s ease;
}

.av3-spinner {
    width: 36px;
    height: 36px;
    margin: 24px auto;
    border: 4px solid var(--card-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: av3-spin 0.8s linear infinite;
}

@keyframes av3-spin {
    to { transform: rotate(360deg); }
}

/* narrow phones: tighten paddings + keep the question label legible */
@media (max-width: 380px) {
    #av3-app { padding: 0 12px 40px; }
    .av3-card { padding: 20px 16px; }
    .av3-question-label { font-size: 1.15rem; }
    .av3-footer .btn { min-width: 96px; padding: 8px 10px; }
}

/* Feedback 3 (Josh): the DOB Month/Day/Year selects truncated on narrow phones
   ("Ju", "19"). Trim the horizontal padding and font so the selected value fits. */
@media (max-width: 480px) {
  #mobSelect, #dobInput, #yobInput {
    padding-left: 6px;
    padding-right: 6px;
    font-size: 0.9rem;
  }
}
