/* ---------- Pages publiques (patients) et authentification ---------- */

.stack { display: flex; flex-direction: column; gap: .6rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.6rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.hidden { display: none !important; }

.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.5rem);
    box-shadow: var(--shadow); margin-bottom: 0.8rem;
}

/* Page patient */
body.public {
    min-height: 100vh; display: flex; flex-direction: column;
    background:
        radial-gradient(900px 400px at 100% -10%, var(--brand-100), transparent 70%),
        radial-gradient(700px 360px at -10% 0%, var(--accent-100), transparent 65%),
        var(--bg);
}
.pub-header { padding: 1rem 1.2rem; }
.pub-header-inner { display: flex; align-items: center; justify-content: space-between; gap: .8rem; max-width: 760px; margin: 0 auto; }
.pub-main { width: 100%; max-width: 760px; margin: 0 auto; padding: .5rem 1.2rem 2rem; flex: 1; }
.pub-footer { text-align: center; padding: 1.2rem; font-size: .82rem; color: var(--muted); }
.pub-footer p { margin: 0 0 .3rem; }

.hero { text-align: center; padding: 1.2rem .5rem 1.6rem; }
.hero h1 { margin-bottom: .5rem; }
.hero p { color: var(--ink-soft); max-width: 34em; margin: 0 auto; font-size: 1.05rem; }
.hero-compact { padding-bottom: 1rem; }

/* Cards de parcours */
.parcours-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin-top: .4rem; }
.parcours-card { display: block; cursor: pointer; position: relative; }
.parcours-card input { position: absolute; z-index: 1; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.parcours-card-body {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem;
    height: 100%; padding: 1.2rem .9rem; text-align: center;
    background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
    transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.parcours-card-body strong { font-size: 1.02rem; color: var(--brand-900); }
.parcours-card-body small { color: var(--muted); font-size: .8rem; line-height: 1.3; }
.parcours-icon {
    display: grid; place-items: center; width: 3.4rem; height: 3.4rem; font-size: 1.9rem;
    background: var(--brand-50); border-radius: 50%;
}
.parcours-check {
    position: absolute; top: .6rem; right: .6rem;
    display: grid; place-items: center; width: 1.5rem; height: 1.5rem;
    font-size: .85rem; font-weight: 700; color: #fff;
    background: var(--brand-700); border-radius: 50%;
    opacity: 0; transform: scale(.5); transition: opacity .15s, transform .15s;
}
.parcours-card:hover .parcours-card-body { border-color: var(--brand-500); transform: translateY(-2px); box-shadow: var(--shadow); }
.parcours-card input:focus-visible + .parcours-card-body { outline: 3px solid var(--accent-500); outline-offset: 2px; }
.parcours-card input:checked + .parcours-card-body { border-color: var(--brand-700); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }
.parcours-card input:checked + .parcours-card-body .parcours-check { opacity: 1; transform: scale(1); }

/* Questionnaire */
.stepper-head { margin-bottom: 1rem; }
.stepper-bar { height: 8px; background: var(--brand-100); border-radius: 999px; overflow: hidden; }
.stepper-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-600), var(--accent-500)); border-radius: 999px; transition: width .3s; }
.stepper-label { margin: .5rem 0 0; font-size: .85rem; font-weight: 600; color: var(--muted); }

.step-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.2rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--line); }
.step-head h2 { margin: 0; font-size: 1.3rem; }
.step-head p { margin: .2rem 0 0; }

.q { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: 0; }
.q-title { font-weight: 700; margin-bottom: .7rem; color: var(--brand-900); }
.q .req { color: var(--danger); margin-left: .2em; }
.q .opt { font-weight: 400; font-size: .8rem; color: var(--muted); margin-left: .4em; }
.q.has-error { padding-left: .9rem; margin-left: -.9rem; border-left: 4px solid var(--danger); background: linear-gradient(90deg, var(--danger-bg), transparent 60%); border-radius: 4px; }

.choices { display: flex; flex-wrap: wrap; gap: .55rem; }
.choice { cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
    display: inline-flex; align-items: center; min-height: 2.8rem;
    padding: .55em 1.1em; font-weight: 500;
    background: var(--surface); border: 2px solid var(--line); border-radius: 999px;
    transition: border-color .15s, background .15s, color .15s;
}
.choice:hover span { border-color: var(--brand-500); }
.choice input:focus-visible + span { outline: 3px solid var(--accent-500); outline-offset: 2px; }
.choice input:checked + span { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.choice input[type='checkbox']:checked + span::before { content: '✓'; margin-right: .45em; font-weight: 700; }

.survey-actions { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin: 1.2rem 0 1.6rem; }
.survey-actions .btn:only-of-type { margin-left: auto; }
.survey-actions [data-survey-stepper-target='next'], .survey-actions [data-survey-stepper-target='submit'] { margin-left: auto; }
.survey { min-width: 0; }
.survey .step { min-width: 0; }
.survey .q textarea { width: 100%; max-width: 100%; }

.thanks { padding-block: 2.5rem; }
.thanks-mark { margin-bottom: .5rem; }
.thanks-mark img { width: 5rem; height: 5rem; object-fit: contain; }
.thanks-reference { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; margin: .5rem 0; padding: .7rem 1rem; color: var(--brand-900); background: var(--brand-50); border: 1px solid var(--brand-200); border-radius: var(--radius-sm); }
.thanks-reference strong { font-family: var(--font-mono); font-size: 1.1rem; letter-spacing: .04em; }

/* Authentification */
body.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
    background:
        radial-gradient(800px 420px at 90% -10%, var(--brand-200), transparent 70%),
        radial-gradient(600px 380px at 0% 100%, var(--accent-100), transparent 70%),
        var(--bg);
}
.auth-shell { width: 100%; max-width: 430px; }
.auth-theme-toggle { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.auth-card {
    display: flex; flex-direction: column; gap: .4rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
    padding: clamp(1rem, 3vw, 1.8rem); box-shadow: var(--shadow-lg);
}
.auth-card .brand { margin-bottom: 1.2rem; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card form { margin-top: .6rem; }
.auth-foot { text-align: center; margin-top: 1rem; font-size: .9rem; }

@media (max-width: 520px) {
    .pub-header { padding: max(.5rem, env(safe-area-inset-top)) .7rem .5rem; }
    .pub-header .brand-logo { width: 2.2rem; height: 2.2rem; }
    .pub-header .brand-text strong { font-size: .85rem; }
    .pub-header .brand-text small { font-size: .6rem; }
    .pub-header-inner { gap: .4rem; }
    .pub-header .theme-toggle { min-height: 2.2rem; padding-inline: .5rem; font-size: .75rem; }
    .pub-header .theme-toggle [data-theme-target="label"] { display: none; }
    .pub-header .btn-icon { min-width: 2.2rem; min-height: 2.2rem; font-size: 1rem; }
    .pub-main { padding: .25rem .75rem 1.25rem; }
    .pub-footer { padding: 1rem .9rem calc(1rem + env(safe-area-inset-bottom)); }
    .pub-footer p:first-child { max-width: 34rem; margin-inline: auto; }
    .hero { padding: .9rem .15rem 1.1rem; }
    .hero h1 { font-size: 1.55rem; }
    .hero p { font-size: .98rem; }
    .panel { padding: 1rem; border-radius: 12px; }
    .auth-shell { min-width: 0; }
    .auth-card { padding: 1rem; }
    .auth-card .row-between { align-items: flex-start; }
    .auth-card .row-between .link-small { max-width: 50%; text-align: right; }
    .stack-lg { gap: 1.2rem; }
    .field > label, .field > legend { font-size: 1rem; line-height: 1.4; }
    .field input[type='text'], .field input[type='email'], .field input[type='password'],
    .field input[type='number'], .field input[type='date'], .field input[type='tel'], .field input[type='search'],
    .field select, .field textarea, .q textarea {
        min-height: 3rem;
        font-size: 16px;
    }
    .parcours-grid { grid-template-columns: 1fr; gap: .65rem; }
    .parcours-card-body {
        min-height: 5.25rem;
        display: grid;
        grid-template-columns: 3rem minmax(0, 1fr) 1.5rem;
        grid-template-rows: auto auto;
        align-content: center;
        justify-items: start;
        column-gap: .8rem;
        padding: .8rem;
        text-align: left;
    }
    .parcours-card-body .parcours-icon { grid-column: 1; grid-row: 1 / span 2; width: 3rem; height: 3rem; font-size: 1.6rem; }
    .parcours-card-body strong { grid-column: 2; grid-row: 1; align-self: end; font-size: 1rem; }
    .parcours-card-body small { grid-column: 2; grid-row: 2; align-self: start; }
    .parcours-check { top: 50%; right: .75rem; transform: translateY(-50%) scale(.5); }
    .parcours-card input:checked + .parcours-card-body .parcours-check { transform: translateY(-50%) scale(1); }
    .parcours-card:hover .parcours-card-body { transform: none; }
    .stepper-head { position: sticky; top: .35rem; z-index: 3; padding: .7rem .8rem; margin: 0 0 .8rem; background: rgb(245 249 248 / 94%); border: 1px solid var(--line); border-radius: var(--radius-sm); backdrop-filter: blur(8px); }
    .step-head { align-items: flex-start; gap: .7rem; margin-bottom: .7rem; padding-bottom: .75rem; }
    .step-head .parcours-icon { width: 2.8rem; height: 2.8rem; flex: 0 0 2.8rem; font-size: 1.5rem; }
    .step-head h2 { font-size: 1.15rem; }
    .q { padding: .9rem 0; scroll-margin-top: 1rem; }
    .q-title { line-height: 1.45; }
    .choices { display: grid; grid-template-columns: 1fr; gap: .5rem; }
    .choice { display: block; min-width: 0; }
    .choice span { display: flex; width: 100%; min-height: 3rem; padding: .65rem .9rem; border-radius: var(--radius-sm); line-height: 1.35; }
    .choice input[type='radio']:checked + span::before { content: '✓'; flex: 0 0 auto; margin-right: .55rem; font-weight: 700; }
    .survey-actions {
        position: sticky;
        bottom: max(.5rem, env(safe-area-inset-bottom));
        z-index: 4;
        margin: .8rem 0 1rem;
        padding: .55rem;
        background: rgb(255 255 255 / 96%);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(8px);
    }
    .survey-actions .btn { min-height: 3rem; }
    .survey-actions .btn-lg { flex: 1; }
    .survey-actions { align-items: stretch; }
    .survey-actions .btn { min-width: 0; white-space: normal; }
    .thanks { padding-block: 1.6rem; }
    .thanks .btn { width: 100%; min-height: 3rem; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
