/* BrightHeart design feedback — light, mobile-first, native CSS nesting. */

:root {
    color-scheme: light;

    --bg: #f7f5f2;
    --surface: #ffffff;
    --ink: #1f1d22;
    --muted: #6d6872;
    --line: #e4dfda;
    --accent: #e0475b;
    --accent-ink: #ffffff;
    --accent-soft: #fdebee;
    --danger: #b42318;
    --danger-soft: #fef3f2;

    --radius: 14px;
    --gap: 16px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 var(--font);
}

h1 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

/* ---------- Page shell ---------- */

.app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 560px;
    margin: 0 auto;

    &.is-welcome,
    &.is-intro,
    &.is-thanks {
        .content {
            display: grid;
            place-items: center;
        }
    }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    padding: calc(env(safe-area-inset-top) + 12px) 20px 12px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    .brand {
        font-weight: 700;
        letter-spacing: 0.01em;

        .heart {
            color: var(--accent);
        }
    }

    .step {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--muted);
        font-variant-numeric: tabular-nums;
    }

    .progress {
        position: absolute;
        inset: auto 0 0 0;
        height: 3px;
        background: var(--line);

        span {
            display: block;
            width: var(--p);
            height: 100%;
            background: var(--accent);
            border-radius: 0 3px 3px 0;
            transition: width 0.3s ease;
        }
    }
}

.content {
    flex: 1;
    padding: 20px 20px 28px;
}

/* ---------- Welcome / intro / thanks ---------- */

.hero {
    text-align: center;
    padding-block: 24px;

    .badge {
        display: grid;
        place-items: center;
        width: 72px;
        height: 72px;
        margin: 0 auto 24px;
        border-radius: 50%;
        background: var(--accent-soft);
        color: var(--accent);
        font-size: 2rem;
        font-weight: 700;
    }

    h1 {
        font-size: 1.75rem;
        margin-bottom: 16px;
    }

    p {
        margin: 0 auto 12px;
        max-width: 34ch;
        color: var(--muted);
        font-size: 1.05rem;
    }

    .hint {
        font-size: 0.9rem;
    }
}

/* ---------- Design page ---------- */

.design-title {
    font-size: 1.6rem;
    margin-bottom: var(--gap);
}

.design-image {
    display: block;
    margin-bottom: 24px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);

    img {
        display: block;
        width: 100%;
        height: auto;
    }
}

.error {
    margin: 0 0 var(--gap);
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
    font-size: 0.95rem;
}

.question {
    margin: 0 0 24px;
    padding: 0;
    border: 0;
    min-width: 0;

    legend {
        padding: 0;
        margin-bottom: 10px;
        font-weight: 650;
        font-size: 1.02rem;

        small {
            display: block;
            font-weight: 400;
            font-size: 0.85rem;
            color: var(--muted);
        }
    }

    &.is-missing legend {
        color: var(--danger);
    }
}

.options {
    display: grid;
    gap: 8px;

    /* Short answers (Yes/No, numbers, zones) sit side by side. */
    &.compact {
        grid-template-columns: repeat(var(--cols), minmax(0, 1fr));

        .option {
            justify-content: center;
            padding-inline: 4px;
            text-align: center;
        }

        .option:has(input[type="radio"]) .mark {
            display: none;
        }

        /* Checkbox tiles: tick above the label so long words fit narrow screens. */
        .option:has(input[type="checkbox"]) {
            flex-direction: column;
            gap: 6px;
            padding-block: 10px;
        }

        /* Keep the weight constant so labels never reflow when selected. */
        .option .text,
        .option:has(:checked) .text {
            font-weight: 500;
            font-size: 0.95rem;
            overflow-wrap: anywhere;
        }

        .option:has(:checked) .text {
            color: color-mix(in srgb, var(--accent) 75%, black);
        }
    }
}

.option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background-color 0.15s, transform 0.1s;

    input {
        position: absolute;
        opacity: 0;
        width: 1px;
        height: 1px;
        pointer-events: none;
    }

    .mark {
        flex: none;
        width: 20px;
        height: 20px;
        border: 2px solid var(--line);
        border-radius: 50%;
        background: var(--surface);
        transition: inherit;
    }

    &:has(input[type="checkbox"]) .mark {
        width: 18px;
        height: 18px;
        border-radius: 5px;
    }

    .text {
        font-weight: 500;
    }

    &:active {
        transform: scale(0.98);
    }

    &:has(:checked) {
        border-color: var(--accent);
        background: var(--accent-soft);

        .text {
            font-weight: 650;
        }

        .mark {
            border-color: var(--accent);
            background: var(--accent);
            box-shadow: inset 0 0 0 3px var(--accent-soft);
        }

        &:has(input[type="checkbox"]) .mark {
            box-shadow: none;
            background:
                url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
                center / 14px no-repeat var(--accent);
        }
    }

    &:has(:focus-visible) {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
}

/* ---------- Bottom actions ---------- */

.actions {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-direction: row-reverse; /* "Next" is first in the DOM (default button) but shown on the right */
    gap: 10px;
    padding: 12px 20px calc(env(safe-area-inset-bottom) + 12px);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
}

.btn {
    appearance: none;
    min-height: 52px;
    padding: 0 22px;
    border-radius: 12px;
    border: 1.5px solid transparent;
    font: inherit;
    font-weight: 650;
    font-size: 1.05rem;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.15s;

    &:active {
        transform: scale(0.98);
    }

    &.primary {
        flex: 1;
        background: var(--accent);
        color: var(--accent-ink);

        &:active {
            background: color-mix(in srgb, var(--accent) 88%, black);
        }
    }

    &.ghost {
        background: var(--surface);
        color: var(--ink);
        border-color: var(--line);
    }
}
