/* The Star Wheel — a brass-rimmed planisphere in a dark observatory.
   Identity: deep night navy, starlight ivory, brass fittings.
   Fonts: Cormorant Garamond (engraved display) + Archivo (instrument UI). */

:root {
    color-scheme: only dark;
    --night: #060b16;            /* the room */
    --night-soft: #0b1526;
    --field: #0d1b2e;            /* the chart itself */
    --grid: #24364f;
    --starlight: #e8ecf4;
    --ivory: #d9dfeb;
    --ink-soft: #8b98ad;
    --brass: #c09a55;
    --brass-bright: #d6b471;
    --brass-soft: rgba(192, 154, 85, 0.5);
    --figure: #5d7ea8;
    --figure-bright: #9fc2ef;
    --correct: #7ddfa3;
    --wrong: #e2705f;
    --hint: #ffd97a;
    --font-display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
    --font-ui: 'Archivo', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }

body {
    font-family: var(--font-ui);
    min-height: 100svh;
    color: var(--ivory);
    background-color: var(--night);
    background-image:
        radial-gradient(1px 1px at 12% 22%, rgba(233, 238, 248, 0.55), transparent 55%),
        radial-gradient(1px 1px at 78% 12%, rgba(233, 238, 248, 0.4), transparent 55%),
        radial-gradient(1.5px 1.5px at 62% 74%, rgba(233, 238, 248, 0.35), transparent 55%),
        radial-gradient(1px 1px at 30% 82%, rgba(233, 238, 248, 0.45), transparent 55%),
        radial-gradient(1px 1px at 90% 55%, rgba(233, 238, 248, 0.3), transparent 55%),
        radial-gradient(ellipse 120% 80% at 50% -20%, #12233c, transparent 60%),
        linear-gradient(var(--night), var(--night-soft) 55%, var(--night));
}

/* ---------------------------------------------------------- start screen */

#startScreen {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px 24px 40px;
    text-align: center;
}

.library-link {
    position: absolute;
    top: 26px;
    left: 32px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--brass);
    opacity: 0.85;
}
@media (hover: hover) {
    .library-link:hover { opacity: 1; text-decoration: underline; }
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--brass);
    margin-bottom: 20px;
}

h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(46px, 7vw, 76px);
    line-height: 1.02;
    color: var(--starlight);
    text-shadow: 0 0 26px rgba(159, 194, 239, 0.35);
}

.rule {
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(340px, 60vw);
    margin: 24px 0 16px;
    color: var(--brass);
    font-size: 11px;
}
.rule::before, .rule::after { content: ''; flex: 1; height: 1px; background: var(--brass-soft); }

.subtitle {
    color: var(--ink-soft);
    font-size: 16px;
    max-width: 480px;
    margin-bottom: 40px;
}

#startControls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: min(420px, 100%);
}

.select-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}
.select-group label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--brass);
}

select, #answerInput {
    font-family: var(--font-ui);
    font-size: 14.5px;
    color: var(--ivory);
    background: var(--night-soft);
    border: 1px solid rgba(139, 152, 173, 0.35);
    border-radius: 4px;
    padding: 10px 12px;
    width: 100%;
}
select:focus-visible, #answerInput:focus-visible, button:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 1px;
}

button {
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--brass-soft);
    background: transparent;
    color: var(--brass-bright);
}

#startBtn {
    margin-top: 14px;
    padding: 13px;
    font-size: 15.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: linear-gradient(180deg, rgba(192, 154, 85, 0.22), rgba(192, 154, 85, 0.08));
    border: 1px solid var(--brass);
    color: var(--brass-bright);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
@media (hover: hover) {
    #startBtn:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(192, 154, 85, 0.25); }
}

.how-note {
    margin-top: 34px;
    max-width: 470px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink-soft);
    border-top: 1px solid rgba(192, 154, 85, 0.25);
    padding-top: 16px;
}

.credits {
    margin-top: 22px;
    font-size: 11px;
    color: rgba(139, 152, 173, 0.65);
}
.credits a { color: rgba(192, 154, 85, 0.8); }

/* ------------------------------------------------------------ quiz screen */

#quizScreen {
    position: relative;
    height: 100svh;
    overflow: hidden;
}

.quiz-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    padding: 12px 18px 26px;
    background: linear-gradient(180deg, rgba(6, 11, 22, 0.92) 40%, rgba(6, 11, 22, 0));
    pointer-events: none;
}
.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar-row > * { pointer-events: auto; }

.round-controls { display: flex; gap: 6px; }
.round-controls button {
    padding: 7px 14px;
    font-size: 12.5px;
    background: rgba(11, 21, 38, 0.9);
}
@media (hover: hover) {
    .round-controls button:hover { border-color: var(--brass-bright); color: var(--brass-bright); }
}

.prompt-area { display: flex; align-items: baseline; gap: 12px; min-height: 40px; }
#promptLabel {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--brass);
}
#promptName {
    font-family: var(--font-display);
    font-size: clamp(24px, 3.4vw, 34px);
    font-weight: 700;
    color: var(--starlight);
    line-height: 1;
}

#answerArea { display: flex; gap: 8px; flex: 1; max-width: 380px; }
#answerInput { flex: 1; }
#answerBtn { padding: 0 16px; }

.stats-compact {
    display: flex;
    gap: 18px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: default;
}
.stats-compact b { color: var(--ivory); font-weight: 600; font-size: 12.5px; letter-spacing: 0; }

/* the wheel — full-bleed, sized to the viewport's short side */
#chartWrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#chartContainer {
    height: min(97svh, 97vw);
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;   /* zoomed sky stays inside the brass rim */
    box-shadow:
        0 0 0 3px rgba(192, 154, 85, 0.55),
        0 0 0 5px rgba(192, 154, 85, 0.18),
        0 0 70px rgba(20, 40, 75, 0.9),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
}
#chartContainer svg { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* chart theming — overrides the SVG's embedded defaults */
#chartContainer svg .sky-field { fill: var(--field); }
#chartContainer svg .ring, #chartContainer svg .spoke { stroke: var(--grid); stroke-width: 0.6; }
#chartContainer svg .equator { stroke: #31486a; stroke-width: 1; }
#chartContainer svg .cline { stroke: var(--figure); stroke-width: 1.1; transition: stroke 0.15s; }
#chartContainer svg .land { fill: #ffffff; fill-opacity: 0; stroke: rgba(60, 86, 122, 0.5); stroke-width: 0.5; }

#chartContainer svg .country { cursor: pointer; }
@media (hover: hover) {
    #chartContainer svg .country:hover { fill-opacity: 0.07; }
}
#chartContainer svg .cline.lit { stroke: var(--figure-bright); stroke-width: 1.7; }

#chartContainer svg .country.highlighted {
    fill: var(--figure-bright);
    fill-opacity: 0.14;
    stroke: var(--figure-bright);
    stroke-width: 1.2;
    animation: breathe 2.2s ease-in-out infinite;
}
#chartContainer svg .country.correct-flash {
    fill: var(--correct); fill-opacity: 0.3;
    stroke: var(--correct); stroke-width: 1.4;
}
#chartContainer svg .country.wrong-flash {
    fill: var(--wrong); fill-opacity: 0.3;
    stroke: var(--wrong); stroke-width: 1.4;
}
#chartContainer svg .country.hint-pulse {
    animation: hintPulse 0.9s ease-in-out 2;
}
@keyframes breathe { 0%, 100% { fill-opacity: 0.10; } 50% { fill-opacity: 0.22; } }
@keyframes hintPulse {
    0%, 100% { fill-opacity: 0; }
    50% { fill: var(--hint); fill-opacity: 0.35; }
}

.zoom-controls {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.zoom-controls button {
    width: 34px;
    height: 34px;
    font-size: 17px;
    background: rgba(11, 21, 38, 0.85);
}

/* shape mode */
#shapeArea {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#shapeCard {
    width: min(58vh, 86vw);
    aspect-ratio: 1;
    background:
        radial-gradient(ellipse at 50% 40%, #12233c 0%, var(--field) 70%);
    border: 1px solid var(--brass-soft);
    border-radius: 8px;
    box-shadow: 0 14px 50px rgba(0, 0, 0, 0.55), inset 0 0 50px rgba(0, 0, 0, 0.35);
    padding: 4%;
}
#shapeSvg { width: 100%; height: 100%; }
#shapeSvg path { fill: none; stroke: var(--figure-bright); stroke-width: 1.4; stroke-linecap: round; }
#shapeSvg circle { fill: var(--starlight); }

/* feedback: second line of the topbar, right where the eye already is */
#feedback {
    margin-top: 8px;
    text-align: center;
    font-size: 15px;
    min-height: 22px;
    color: var(--ink-soft);
    text-shadow: 0 1px 6px rgba(4, 8, 16, 0.95), 0 0 14px rgba(4, 8, 16, 0.9);
    pointer-events: none;
}
#feedback.good { color: var(--correct); }
#feedback.bad { color: var(--wrong); }
#feedback .gen { font-style: italic; color: var(--ink-soft); }

@media (hover: hover) {
    .zoom-controls button:hover, #answerBtn:hover {
        border-color: var(--brass-bright);
        color: var(--brass-bright);
    }
}

/* completion card */
#completionCard {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 8, 16, 0.8);
    z-index: 20;
}
.completion-inner {
    background: var(--night-soft);
    border: 1px solid var(--brass);
    border-radius: 8px;
    padding: 40px 48px;
    text-align: center;
    max-width: 460px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7);
}
.completion-inner h2 {
    font-family: var(--font-display);
    font-size: 34px;
    color: var(--brass-bright);
    margin-bottom: 10px;
}
.completion-inner p { color: var(--ink-soft); margin-bottom: 22px; }
.completion-inner button { padding: 11px 26px; font-size: 14px; margin: 0 5px; }

/* did-you-mean buttons live inside the feedback line */
#feedback.dym { pointer-events: auto; }
#feedback .dym-btn {
    margin-left: 8px;
    padding: 4px 12px;
    font-size: 13px;
}

/* observer's log: spelling practice */
#logModal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 8, 16, 0.8);
    z-index: 30;
}
.log-card {
    background: var(--night-soft);
    border: 1px solid var(--brass);
    border-radius: 8px;
    padding: 34px 44px 22px;
    text-align: center;
    width: min(400px, 92vw);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7);
}
.log-eyebrow {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--brass);
    margin-bottom: 8px;
}
.log-instruction { color: var(--ink-soft); font-size: 14px; }
#logTarget {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 700;
    color: var(--starlight);
    margin: 10px 0 4px;
    text-shadow: 0 0 18px rgba(159, 194, 239, 0.35);
}
#logDots { font-size: 18px; letter-spacing: 8px; color: var(--brass-bright); margin-bottom: 14px; }
#logInput {
    font-family: var(--font-ui);
    font-size: 15px;
    text-align: center;
    color: var(--ivory);
    background: var(--night);
    border: 1px solid rgba(139, 152, 173, 0.35);
    border-radius: 4px;
    padding: 10px;
    width: 100%;
}
#logInput.shake { animation: logShake 0.35s; }
@keyframes logShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px); }
    75% { transform: translateX(7px); }
}
.log-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
#logSubmit { padding: 8px 22px; font-size: 13px; }
.log-skip {
    border: none;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-soft);
    text-decoration: underline;
    text-underline-offset: 3px;
}
@media (hover: hover) {
    .log-skip:hover { color: var(--ivory); }
}
#logFeedback { min-height: 20px; margin-top: 10px; font-size: 13.5px; color: var(--ink-soft); }
#logFeedback.good { color: var(--correct); }
#logFeedback.bad { color: var(--wrong); }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
