@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@500;600;700&display=swap");

:root {
    --color-bg: #f4f1ec;
    --color-surface: #ffffff;
    --color-text: #2b2622;
    --color-text-muted: #6b625a;
    --color-primary: #8a5a3b;
    --color-primary-dark: #6d4529;
    --color-accent: #c98f4a;
    --color-locked: #cfc8bf;
    --color-success: #4f7a5c;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 6px 20px rgba(109, 69, 41, 0.16);
    --shadow-lifted: 0 10px 28px rgba(109, 69, 41, 0.22);
    --focus-ring: 3px solid #2f6fb0;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Quicksand", "Segoe UI", "Tahoma", system-ui, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

#app {
    min-height: 100vh;
    position: relative;
}

/* Every screen fades/slides in on mount — navigation.js just swaps DOM,
   this is what makes screen changes feel like transitions instead of a
   hard cut. Pure CSS: plays automatically whenever the element is inserted. */
#app > * {
    animation: screen-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes screen-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Generic staggered-entrance helper for grids of repeated items (level
   nodes, menu cards, test choices) — set --i to the item's index. */
.stagger-in {
    opacity: 0;
    animation: item-in 0.4s ease-out forwards;
    animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes item-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    #app > * {
        animation: none;
    }
    .stagger-in {
        opacity: 1;
        animation: none;
    }
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

button:disabled {
    cursor: default;
}

button:active:not(:disabled) {
    transform: scale(0.96);
}

button:focus-visible,
a:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }
    button:active:not(:disabled) {
        transform: none;
    }
}

/* Persistent replay guide control */
.guide-btn {
    position: fixed;
    bottom: 24px;
    inset-inline-end: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 28px;
    box-shadow: var(--shadow);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-btn:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-lifted);
}

.guide-btn--pulse {
    animation: guide-pulse 0.5s ease-out;
}

@keyframes guide-pulse {
    from { box-shadow: 0 0 0 0 rgba(138, 90, 59, 0.5); }
    to { box-shadow: 0 0 0 18px rgba(138, 90, 59, 0); }
}

/* Onboarding */
.onboarding {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.onboarding__card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 48px 40px;
    text-align: center;
    max-width: 420px;
    width: 100%;
}

@media (max-width: 400px) {
    .onboarding__card {
        padding: 32px 24px;
    }

    .onboarding__title {
        font-size: 26px;
    }
}

.onboarding__icon {
    font-size: 56px;
}

.onboarding__title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-primary-dark);
    margin: 12px 0 32px;
}

.onboarding__start {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 32px;
    box-shadow: var(--shadow);
}

.onboarding__start:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-lifted);
    transform: scale(1.04);
}

/* Completion overlay */
.completion {
    position: absolute;
    inset: 0;
    background: rgba(43, 38, 34, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.completion__card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    text-align: center;
    min-width: 240px;
    animation: completion-in 0.3s ease-out;
}

.completion__badge {
    font-size: 48px;
    color: var(--color-success);
}

.completion__stars {
    font-size: 28px;
    margin: 12px 0 24px;
}

.completion__return {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 26px;
}

.completion__return:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-lifted);
}

@keyframes completion-in {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
