/* Shared building blocks for the home page and every game: sky header,
   Nayla, buttons, choices, speech bubble, scores table.
   Colours come from theme.css; markup helpers live in ui.js. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-ui);
    background: var(--page);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Sky header ─────────────────────────────────────────────── */

.sky {
    position: relative;
    background: var(--sky);
    color: var(--sky-text);
    padding: 14px 16px 64px;
    overflow: hidden;
}

/* Oversized layers so the shifted tiles never leave a gap at the edges */
.sky::before, .sky::after {
    content: '';
    position: absolute;
    inset: -600px 0 -200px -200px;
    pointer-events: none;
    background-size: 200px 200px;
    animation-name: var(--motion);
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
.sky::before {
    background-image: var(--particles-far);
    opacity: .6;
    animation-duration: var(--speed-far);
}
.sky::after {
    background-image: var(--particles-near);
    opacity: .85;
    animation-duration: var(--speed-near);
}
@keyframes fall  { to { transform: translateY(200px); } }
@keyframes drift { to { transform: translate(200px, 600px); } }
@keyframes rise  { to { transform: translateY(-200px); } }
@media (prefers-reduced-motion: reduce) {
    .sky::before, .sky::after { animation: none; }
}

.sky > * { position: relative; z-index: 1; }

.drift {
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    width: 100%;
    height: 44px;
    z-index: 1;
    display: block;
    color: var(--page);
}

.sky-bar {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Translucent pill on the sky: back link, sound toggle, sign-in */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 6px 14px;
    border: none;
    border-radius: var(--r-pill);
    background: var(--chip-bg);
    color: inherit;
    font: 500 .9rem var(--font-ui);
    cursor: pointer;
    white-space: nowrap;
}
.chip:hover { background: var(--chip-hover); }
.chip--icon {
    width: 34px;
    padding: 0;
    justify-content: center;
    font-size: 1.05rem;
    line-height: 1;
}

.mascot {
    width: 116px;
    height: 116px;
    margin: 20px auto 0;
    border-radius: 50%;
    overflow: hidden;
    background: var(--page);
    border: 4px solid var(--wordmark);
    box-shadow: 0 4px 0 var(--wordmark-shadow);
    flex-shrink: 0;
}
.mascot svg { display: block; width: 100%; height: 100%; }
@media (min-width: 600px) {
    .mascot { width: 136px; height: 136px; }
}
.mascot--sm {
    width: 56px;
    height: 56px;
    margin: 0;
    border-width: 3px;
    box-shadow: 0 3px 0 var(--wordmark-shadow);
}

.wordmark {
    margin: 12px auto 6px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(3.2rem, 15vw, 6rem);
    line-height: 1;
    letter-spacing: .01em;
    /* The season's topping (snow, blossom, sunshine, toffee) settles on the top third of each letter */
    background: linear-gradient(180deg, var(--cap) 0 30%, var(--cap-edge) 30% 34%, var(--wordmark) 34% 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 0 var(--wordmark-shadow));
}
.wordmark--game {
    margin-top: 22px;
    font-size: clamp(2.4rem, 11vw, 4rem);
}

.tagline {
    text-align: center;
    font-size: 1rem;
    color: var(--sky-muted);
}

/* ── Page body ──────────────────────────────────────────────── */

.page {
    max-width: 760px;
    margin: 0 auto;
    padding: 8px 16px 40px;
}
.page--narrow { max-width: 520px; }

.stack > * + * { margin-top: 16px; }

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    margin-top: 32px;
    margin-bottom: 10px;
}

.panel {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-bottom: 5px solid var(--ledge);
    border-radius: var(--r-tile);
    padding: 16px 18px;
}

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
    display: block;
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: #fff;
    font: 600 1.15rem var(--font-ui);
    text-align: center;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--accent-ledge);
    transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-ledge); }
.btn:disabled { opacity: .5; cursor: default; }

.btn--deep { background: var(--deep); color: var(--on-deep); box-shadow: 0 5px 0 var(--ink); }
.btn--deep:active { box-shadow: 0 2px 0 var(--ink); }

.btn--ghost {
    background: var(--surface);
    color: var(--ink);
    border: 1.5px solid var(--line);
    box-shadow: 0 5px 0 var(--ledge);
}
.btn--ghost:active { box-shadow: 0 2px 0 var(--ledge); }

/* ── Choices (one option of a group is pressed) ─────────────── */

.choice {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    gap: 10px;
}

.choice-btn {
    padding: 14px 10px;
    background: var(--surface);
    border: 2px solid var(--line);
    border-bottom-width: 5px;
    border-radius: var(--r-tile);
    color: var(--ink);
    font: 600 1rem var(--font-ui);
    cursor: pointer;
    transition: transform .08s, border-color .15s, background .15s;
}
.choice-btn:active { transform: translateY(2px); }
.choice-btn[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-tint);
}

/* ── Nayla explains (rules, hints) ──────────────────────────── */

.nayla-says {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.bubble {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-bottom: 5px solid var(--ledge);
    border-radius: 6px var(--r-tile) var(--r-tile) var(--r-tile);
    padding: 12px 16px;
    line-height: 1.55;
}
.bubble > div + div { margin-top: 6px; }

/* ── Scores table ───────────────────────────────────────────── */

.scores-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    font-size: .88rem;
}
.scores-table th {
    background: var(--deep);
    color: #fff;
    font-weight: 600;
    padding: 9px 10px;
}
.scores-table td {
    padding: 8px 10px;
    text-align: center;
    border-top: 1px solid var(--line);
}

.empty-note { color: var(--muted); font-size: .9rem; }

/* ── Forms ──────────────────────────────────────────────────── */

.field { display: block; }
.field + .field { margin-top: 14px; }

.field-label {
    display: block;
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.field-hint { font-weight: 400; color: var(--muted); }

.input {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font: 500 1rem var(--font-ui);
    outline: none;
    transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 90px; }

.alert {
    background: var(--bad-tint);
    color: var(--bad);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: .9rem;
    font-weight: 500;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; width: auto; }

.btn--small {
    display: inline-block;
    width: auto;
    padding: 8px 16px;
    font-size: .9rem;
    box-shadow: 0 3px 0 var(--accent-ledge);
}
.btn--ghost.btn--small { box-shadow: 0 3px 0 var(--ledge); }

.btn--danger { background: var(--bad); box-shadow: 0 5px 0 #9E2536; }
.btn--danger:active { box-shadow: 0 2px 0 #9E2536; }

.hidden { display: none !important; }
