/**
 * Onboarding flows.
 *
 * Tokens are declared on .qb-root in light, then redefined for dark. Every
 * colour used anywhere below resolves through one of them — nothing is hard-coded
 * at the point of use, so the dark block is the only place a second palette
 * lives. Brand accent is navy #053C6D, #5b9bd5 on dark, matching the profile
 * panels.
 */

.qb-root {
    --qb-ink: #1a2230;
    --qb-ink-2: #5a6879;
    --qb-line: #dfe4ea;
    --qb-line-strong: #c4ccd6;
    --qb-surface: #fff;
    --qb-field: #fff;
    --qb-ground: #f4f6f9;
    --qb-accent: #053c6d;
    --qb-accent-ink: #fff;
    --qb-accent-soft: rgba(5, 60, 109, .08);
    --qb-error: #b3261e;
    --qb-error-soft: rgba(179, 38, 30, .08);
    --qb-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .18);
}

@media (prefers-color-scheme: dark) {
    .qb-root {
        --qb-ink: #e8ecf2;
        --qb-ink-2: #a8b3c2;
        --qb-line: #2b3442;
        --qb-line-strong: #3c4759;
        --qb-surface: #161c25;
        --qb-field: #1b2330;
        --qb-ground: #0f141b;
        --qb-accent: #5b9bd5;
        --qb-accent-ink: #0e1218;
        --qb-accent-soft: rgba(91, 155, 213, .14);
        --qb-error: #e87c6e;
        --qb-error-soft: rgba(232, 124, 110, .12);
        --qb-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    }
}

.qb-root {
    color: var(--qb-ink);
    max-width: 30rem;
    margin: 0 auto;
    box-sizing: border-box;
}

/* The taste deck needs more room than a two-field login card. */
.qb-root[data-qb-flow="questionnaire"] {
    max-width: 44rem;
}

.qb-root *,
.qb-root *::before,
.qb-root *::after {
    box-sizing: inherit;
}

/*
 * The engine hides the Back button and the live notice with the hidden
 * attribute. An author-origin display rule — .qb-btn sets inline-block — beats
 * the user agent's [hidden] rule, so without this the Back button shows on the
 * first chapter and the error box shows empty.
 */
.qb-root [hidden] {
    display: none !important;
}

/* Progress rail --------------------------------------------------------- */

.qb-rail {
    position: relative;
    height: .75rem;
    margin: 0 .25rem 1.25rem;
}

.qb-rail__track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--qb-line);
    transform: translateY(-50%);
    overflow: hidden;
}

.qb-rail__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: var(--qb-accent);
    transition: width .4s ease;
}

.qb-rail__dots {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qb-rail__dot {
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--qb-ground);
    border: 2px solid var(--qb-line-strong);
    transition: background .3s ease, border-color .3s ease;
}

.qb-rail__dot.is-done,
.qb-rail__dot.is-active {
    background: var(--qb-accent);
    border-color: var(--qb-accent);
}

/* Page card ------------------------------------------------------------- */

.qb-page {
    background: var(--qb-surface);
    border: 1px solid var(--qb-line);
    border-radius: .6rem;
    box-shadow: var(--qb-shadow);
    padding: 1.9rem 1.75rem 1.6rem;
}

.qb-eyebrow {
    margin: 0 0 .35rem;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--qb-accent);
}

.qb-title {
    margin: 0 0 .4rem;
    font-size: 1.4rem;
    line-height: 1.2;
    color: var(--qb-ink);
}

.qb-sub {
    margin: 0 0 1.4rem;
    color: var(--qb-ink-2);
    line-height: 1.5;
}

/* Chapters -------------------------------------------------------------- */

/*
 * Without the engine every chapter shows, which is the whole no-JavaScript
 * fallback. The engine sets .qb-root.is-enhanced on itself, and only then does
 * hiding begin — so a script that fails to load can never leave a blank card.
 */
.qb-root.is-enhanced .qb-chapter {
    display: none;
}

.qb-root.is-enhanced .qb-chapter.is-active {
    display: block;
    animation: qb-in .35s ease;
}

@keyframes qb-in {
    from { opacity: 0; transform: translateX(.75rem); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .qb-root.is-enhanced .qb-chapter.is-active { animation: none; }
    .qb-rail__fill { transition: none; }
}

/* Fields ---------------------------------------------------------------- */

.qb-field {
    margin: 0 0 1.1rem;
}

.qb-field label {
    display: block;
    margin: 0 0 .35rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--qb-ink-2);
}

.qb-field input[type="text"],
.qb-field input[type="email"],
.qb-field input[type="password"] {
    display: block;
    width: 100%;
    padding: .65rem .75rem;
    font: inherit;
    color: var(--qb-ink);
    background: var(--qb-field);
    border: 1px solid var(--qb-line-strong);
    border-radius: .35rem;
    transition: border-color .15s, box-shadow .15s;
}

.qb-field input:focus {
    outline: none;
    border-color: var(--qb-accent);
    box-shadow: 0 0 0 3px var(--qb-accent-soft);
}

.qb-field.is-invalid input {
    border-color: var(--qb-error);
    box-shadow: 0 0 0 3px var(--qb-error-soft);
}

.qb-error {
    display: none;
    margin: .4rem 0 0;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--qb-error);
}

.qb-field.is-invalid .qb-error {
    display: block;
}

.qb-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
    font-weight: 500;
    color: var(--qb-ink-2);
    cursor: pointer;
}

.qb-check input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--qb-accent);
    cursor: pointer;
}

/* Navigation ------------------------------------------------------------ */

.qb-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-top: 1.4rem;
}

/* On the first chapter there is no Back button, so the action sits on the right. */
.qb-nav.is-single {
    justify-content: flex-end;
}

.qb-btn {
    display: inline-block;
    padding: .6rem 1.2rem;
    font: inherit;
    font-weight: 600;
    color: var(--qb-accent-ink);
    background: var(--qb-accent);
    border: 0;
    border-radius: .35rem;
    cursor: pointer;
    transition: opacity .15s;
}

.qb-btn:hover {
    opacity: .92;
    color: var(--qb-accent-ink);
}

.qb-btn:focus-visible {
    outline: 2px solid var(--qb-accent);
    outline-offset: 2px;
}

.qb-btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
}

.qb-btn--ghost {
    background: transparent;
    color: var(--qb-ink-2);
    padding-left: .25rem;
    padding-right: .25rem;
}

.qb-btn--ghost:hover {
    color: var(--qb-ink);
}

/* Notices and links ----------------------------------------------------- */

.qb-notice {
    margin: 0 0 1.1rem;
    padding: .7rem .85rem;
    border: 1px solid var(--qb-error);
    border-left-width: 3px;
    border-radius: .35rem;
    background: var(--qb-error-soft);
    color: var(--qb-ink);
    font-size: .9rem;
}

.qb-footer {
    margin: 1.2rem 0 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--qb-line);
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1rem;
    font-size: .9rem;
}

.qb-link {
    color: var(--qb-accent);
    font-weight: 600;
    text-decoration: none;
}

.qb-link:hover {
    text-decoration: underline;
    color: var(--qb-accent);
}

.qb-root--plain .qb-title {
    font-size: 1.2rem;
    margin-bottom: .6rem;
}

@media (max-width: 30rem) {
    .qb-page {
        padding: 1.5rem 1.15rem 1.3rem;
    }

    .qb-title {
        font-size: 1.25rem;
    }
}

/* Textarea, selects ----------------------------------------------------- */

.qb-field textarea,
.qb-field select {
    display: block;
    width: 100%;
    padding: .65rem .75rem;
    font: inherit;
    color: var(--qb-ink);
    background: var(--qb-field);
    border: 1px solid var(--qb-line-strong);
    border-radius: .35rem;
}

.qb-field textarea {
    resize: vertical;
    min-height: 6rem;
    line-height: 1.5;
}

.qb-field textarea:focus,
.qb-field select:focus {
    outline: none;
    border-color: var(--qb-accent);
    box-shadow: 0 0 0 3px var(--qb-accent-soft);
}

/* Repeater rows --------------------------------------------------------- */

.qb-rows {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.qb-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: .5rem;
    align-items: center;
}

.qb-row select,
.qb-row input {
    margin: 0;
}

.qb-row__remove {
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--qb-ink-2);
    background: transparent;
    border: 1px solid var(--qb-line);
    border-radius: .35rem;
    cursor: pointer;
}

.qb-row__remove:hover {
    color: var(--qb-error);
    border-color: var(--qb-error);
}

.qb-add {
    margin-top: .6rem;
    padding-left: 0;
    font-size: .9rem;
}

/* Taste deck ------------------------------------------------------------ */

.qb-taste {
    margin: 0 0 1.5rem;
}

.qb-taste__heading {
    margin: 0 0 .6rem;
    padding-bottom: .4rem;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--qb-ink-2);
    border-bottom: 1px solid var(--qb-line);
}

.qb-taste__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(9rem, 14rem);
    gap: .5rem 1.25rem;
    align-items: center;
    padding: .45rem 0;
}

.qb-taste__row + .qb-taste__row {
    border-top: 1px solid var(--qb-line);
}

.qb-taste__label label {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--qb-ink);
}

.qb-taste__blurb {
    margin: .15rem 0 0;
    font-size: .8125rem;
    line-height: 1.4;
    color: var(--qb-ink-2);
}

.qb-taste__control {
    display: flex;
    align-items: center;
    gap: .6rem;
}

/*
 * The track and thumb are drawn explicitly rather than left to accent-color.
 * The active theme resets input elements globally — borders, heights, padding —
 * and a range input is an input, so the native control came through with an
 * invisible track and a stray dot for a thumb. These rules reset it back and
 * repaint it, with !important only where the theme's own input rules would
 * otherwise win on specificity.
 */
.qb-taste__control input[type="range"] {
    flex: 1;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 1.25rem;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
}

.qb-taste__control input[type="range"]:focus {
    outline: none;
}

.qb-taste__control input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--qb-accent-soft);
}

.qb-taste__control input[type="range"]:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--qb-accent-soft);
}

/* WebKit / Blink */
.qb-taste__control input[type="range"]::-webkit-slider-runnable-track {
    height: .35rem;
    border-radius: 999px;
    background: var(--qb-line-strong);
}

.qb-taste__control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    /* (track height - thumb height) / 2, to sit centred on the track. */
    margin-top: -.375rem;
    border: 2px solid var(--qb-surface);
    border-radius: 50%;
    background: var(--qb-accent);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .3);
}

/* Firefox */
.qb-taste__control input[type="range"]::-moz-range-track {
    height: .35rem;
    border: 0;
    border-radius: 999px;
    background: var(--qb-line-strong);
}

.qb-taste__control input[type="range"]::-moz-range-progress {
    height: .35rem;
    border-radius: 999px;
    background: var(--qb-accent);
}

.qb-taste__control input[type="range"]::-moz-range-thumb {
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--qb-surface);
    border-radius: 50%;
    background: var(--qb-accent);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .3);
}

.qb-taste__value {
    flex: 0 0 1.75rem;
    height: 1.75rem;
    display: grid;
    place-items: center;
    font-size: .8125rem;
    font-weight: 700;
    color: var(--qb-accent);
    background: var(--qb-accent-soft);
    border-radius: 50%;
}

/* Review summary -------------------------------------------------------- */

.qb-summary {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .5rem 1rem;
}

.qb-summary dt {
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--qb-ink-2);
}

.qb-summary dd {
    margin: 0;
    color: var(--qb-ink);
}

.qb-summary:empty::before {
    content: attr(data-empty);
    color: var(--qb-ink-2);
}

@media (max-width: 34rem) {
    .qb-taste__row {
        grid-template-columns: 1fr;
    }

    .qb-row {
        grid-template-columns: 1fr auto;
    }

    .qb-summary {
        grid-template-columns: 1fr;
        gap: .15rem;
    }

    .qb-summary dd {
        margin-bottom: .6rem;
    }
}
