/* ---------- easing ---------- */
:root {
    --spring-bounce:   cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out-expo:   cubic-bezier(0.16, 1, 0.3, 1);
    --ease-snappy:     cubic-bezier(0.4, 0, 0.2, 1);
    --ease-polish:     cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- tokens ----------
   one accent triple drives everything. the inline head script
   swaps --accent-rgb; pink is the no-js fallback. */
:root {
    --accent-rgb: 255, 192, 203;

    --background: #000000;
    --text:                 rgba(var(--accent-rgb), 0.85);
    --text-muted:           rgba(var(--accent-rgb), 0.5);
    --text-bright:          rgba(var(--accent-rgb), 0.95);
    --card-bg:              rgba(var(--accent-rgb), 0.1);
    --card-hover:           rgba(var(--accent-rgb), 0.15);
    --border:               rgba(var(--accent-rgb), 0.2);
    --hover-border:         rgba(var(--accent-rgb), 0.4);
    --button-bg:            rgba(var(--accent-rgb), 0.15);
    --button-hover:         rgba(var(--accent-rgb), 0.25);
    --button-shadow-soft:   rgba(var(--accent-rgb), 0.12);
    --button-shadow-strong: rgba(var(--accent-rgb), 0.2);
    --link-color:           rgb(var(--accent-rgb));
    --link-hover:           rgba(var(--accent-rgb), 0.8);
}

/* ---------- base ---------- */
html {
    color-scheme: dark;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.06);
}

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

::selection { background-color: var(--link-hover); color: var(--background); }
::-moz-selection { background-color: var(--link-hover); color: var(--background); }

[hidden] { display: none !important; }

body {
    background-color: var(--background);
    color: var(--text);
    font-family: 'Sora', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh; /* mobile browser chrome */
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    touch-action: manipulation;
}

/* room for the sticky bar, dropped once the result is up */
body.js-enabled.has-bar { padding-bottom: 96px; }
body.js-enabled.done { padding-bottom: 0; }

a { color: var(--link-color); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* ---------- grain ---------- */
.noise-bg {
    position: fixed;
    top: -50%; left: -50%; right: -50%; bottom: -50%;
    width: 200%;
    height: 200vh;
    background: transparent url('noise.png') repeat 0 0;
    opacity: 0.9;
    pointer-events: none;
    z-index: 1;
    animation: noise-animation 0.2s infinite;
}

@keyframes noise-animation {
    0%   { transform: translate(0, 0) }
    10%  { transform: translate(-5%, -5%) }
    20%  { transform: translate(-10%, 5%) }
    30%  { transform: translate(5%, -10%) }
    40%  { transform: translate(-5%, 15%) }
    50%  { transform: translate(-10%, 5%) }
    60%  { transform: translate(15%, 0) }
    70%  { transform: translate(0, 10%) }
    80%  { transform: translate(-15%, 0) }
    90%  { transform: translate(10%, 5%) }
    100% { transform: translate(5%, 0) }
}

/* ---------- layout ---------- */
.container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex-grow: 1;
    position: relative;
    z-index: 2;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
    animation: headerEntrance 0.6s var(--ease-out-expo) both;
}

header h1 {
    font-family: 'Rubik 80s Fade', sans-serif;
    font-weight: 400;
    font-size: 3rem;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
    line-height: 1.15;
}

header p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 46ch;
    margin: 0 auto;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
}

footer {
    max-width: 1060px;
    width: 100%;
    margin: 3rem auto 0;
    padding: 1.5rem 2rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

footer p { color: var(--text-muted); font-size: 0.9rem; }

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-muted);
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    font-size: 0.9rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition:
        color 0.18s var(--ease-snappy),
        background-color 0.18s var(--ease-snappy),
        border-color 0.18s var(--ease-snappy);
}

.footer-link:hover {
    color: var(--text-bright);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    border-color: var(--hover-border);
}

.footer-link:active { opacity: 0.72; transition-duration: 0.06s; }

/* ---------- question list ---------- */
.qlist {
    counter-reset: q;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.q {
    counter-increment: q;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 6px;
    transition:
        background-color 0.2s var(--ease-snappy),
        border-color 0.2s var(--ease-snappy);
}

.q:hover { background: var(--card-bg); border-color: var(--border); }

.q:has(input:checked) {
    background: var(--card-hover);
    border-color: var(--hover-border);
}

.q-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.q-num {
    font-family: 'Geist Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 2.6ch;
    flex-shrink: 0;
    text-align: right;
    padding-top: 0.2rem;
    font-variant-numeric: tabular-nums;
}

.q-num::before { content: counter(q); }

.q-text { flex: 1; min-width: 0; }

.q:has(input:checked) .q-text { color: var(--text-bright); }
.q:has(input:checked) .q-num { color: var(--text); }

/* custom checkbox */
.q input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 0.25rem;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 4px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
        var(--button-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    cursor: pointer;
    transition:
        background-color 0.15s var(--ease-snappy),
        border-color 0.15s var(--ease-snappy);
}

.q input[type="checkbox"]::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 7px;
    height: 12px;
    border: 2px solid var(--text-bright);
    border-top: 0;
    border-left: 0;
    transform: rotate(40deg) scale(0);
    transition: transform 0.24s var(--spring-bounce);
}

.q input[type="checkbox"]:hover { border-color: var(--hover-border); }

.q input[type="checkbox"]:checked {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
        var(--button-hover);
    border-color: var(--hover-border);
}

.q input[type="checkbox"]:checked::after { transform: rotate(40deg) scale(1); }

/* the subtle ? affordance */
.q-help {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Geist Mono', monospace;
    font-size: 0.7rem;
    line-height: 1;
    cursor: help;
    opacity: 0.45;
    transition:
        opacity 0.2s var(--ease-snappy),
        background-color 0.2s var(--ease-snappy),
        border-color 0.2s var(--ease-snappy),
        color 0.2s var(--ease-snappy);
}

.q:hover .q-help { opacity: 0.7; }

.q-help:hover,
.q-help[aria-expanded="true"] {
    opacity: 1;
    background: var(--button-bg);
    border-color: var(--hover-border);
    color: var(--text-bright);
}

/* ---------- tooltip ---------- */
#tip {
    position: fixed;
    z-index: 40;
    max-width: min(320px, calc(100vw - 24px));
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--hover-border);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)),
        rgba(0, 0, 0, 0.86);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 12px 30px rgba(0, 0, 0, 0.45);
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition:
        opacity 0.18s var(--ease-snappy),
        transform 0.18s var(--ease-polish);
}

#tip.show { opacity: 1; transform: translateY(0); }

/* ---------- sticky bar ---------- */
.bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    border-top: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
        rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.3);
    padding-bottom: max(0px, env(safe-area-inset-bottom));
}

/* driven by transform so it tracks the scroll frame-for-frame */
.bar-progress {
    height: 1px;
    width: 100%;
    background: var(--hover-border);
    transform: scaleX(0);
    transform-origin: 0 50%;
    will-change: transform;
}

.bar-inner {
    max-width: 1060px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bar-score {
    font-family: 'Geist Mono', monospace;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.bar-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: auto;
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
        var(--button-bg);
    border: 1px solid var(--border);
    color: var(--text-bright);
    padding: 0.7rem 1.4rem;
    border-radius: 7px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    transition:
        background-color 0.18s var(--ease-snappy),
        border-color 0.18s var(--ease-snappy),
        color 0.18s var(--ease-snappy);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn:hover {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.03)),
        var(--button-hover);
    border-color: var(--hover-border);
    color: var(--text-bright);
}

.btn:active { opacity: 0.72; transition-duration: 0.06s; }

.btn-quiet {
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.55rem 1rem;
    color: var(--text-muted);
    background: transparent;
    box-shadow: none;
}

.btn-quiet:hover { color: var(--text); }

/* ---------- result ---------- */
.result {
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    text-align: center;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.025) 34%, rgba(0, 0, 0, 0.08) 100%),
        var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -1px 0 rgba(0, 0, 0, 0.24),
        0 10px 28px rgba(0, 0, 0, 0.16);
    animation: cardEntrance 0.55s var(--ease-out-expo) both;
}

.result-label {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.result-score {
    font-family: 'Rubik 80s Fade', sans-serif;
    font-weight: 400;
    font-size: clamp(4rem, 18vw, 7rem);
    line-height: 1;
    color: var(--text-bright);
}

.result-band {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-top: 0.5rem;
}

.result-blurb {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.result-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.75rem;
}

/* category bars */
.cats {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    text-align: left;
}

.cat { display: flex; align-items: center; gap: 0.75rem; }

/* fixed gutter so the bars line up whatever categories exist */
.cat-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 11ch;
    flex-shrink: 0;
    overflow-wrap: anywhere;
}

.cat-track {
    flex: 1;
    height: 8px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    overflow: hidden;
}

.cat-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--hover-border);
    transition: width 0.8s var(--ease-out-expo);
}

.cat-val {
    font-family: 'Geist Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-bright);
    width: 3.5ch;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* ---------- cross-link block ---------- */
.cta {
    margin-top: 3rem;
    padding: 1.75rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(0, 0, 0, 0.06) 100%),
        var(--card-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.cta h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 0.35rem;
}

.cta p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.1rem;
    max-width: 52ch;
    margin-left: auto;
    margin-right: auto;
}

/* scoring explainer */
.scoring {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.scoring summary { cursor: pointer; color: var(--text); }
.scoring p { margin-top: 0.6rem; }
.scoring code { font-family: 'Geist Mono', monospace; color: var(--text-bright); }

/* ---------- 404 ---------- */
.center-page {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.25rem;
    padding: 2rem;
    position: relative;
    z-index: 2;
}

.center-page h1 {
    font-family: 'Rubik 80s Fade', sans-serif;
    font-weight: 400;
    font-size: clamp(5rem, 22vw, 9rem);
    line-height: 1;
    color: var(--text-bright);
}

/* ---------- entrance ---------- */
@keyframes cardEntrance {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* ---------- focus ---------- */
.q input[type="checkbox"]:focus-visible,
.q-help:focus-visible,
.btn:focus-visible,
.footer-link:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--hover-border);
    outline-offset: 3px;
}

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--background); }
::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
    border: 2px solid var(--background);
}
::-webkit-scrollbar-thumb:hover { background-color: var(--hover-border); }

/* ---------- mobile ---------- */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    header { margin-bottom: 1.75rem; }
    header h1 { font-size: 2.1rem; }
    header p { font-size: 1rem; }

    .q { padding: 0.7rem 0.5rem; gap: 0.35rem; }
    .q-label { gap: 0.6rem; }
    .q-num { width: 2.4ch; font-size: 0.75rem; }

    .bar-inner { padding: 0.7rem 1rem; gap: 0.75rem; }
    .bar-score { font-size: 1.25rem; }
    .bar-meta { font-size: 0.75rem; }
    .bar .btn { padding: 0.6rem 1rem; font-size: 0.9rem; }

    .result { padding: 2rem 1.25rem; }
    .result-actions .btn { width: 100%; }

    .cat-name { width: 9ch; font-size: 0.75rem; }

    footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.5rem 1rem 2rem;
    }
}

/* ---------- narrow phones ---------- */
@media (max-width: 400px) {
    header h1 { font-size: 1.8rem; }
    .q { padding: 0.6rem 0.35rem; }
    .q input[type="checkbox"] { width: 20px; height: 20px; }
    .q-num { width: 2.2ch; }

    /* the bar runs out of room before the buttons do */
    .bar-meta { display: none; }
    .bar-score { margin-right: auto; }
    .bar-inner { gap: 0.5rem; }
    .bar .btn { padding: 0.55rem 0.75rem; font-size: 0.85rem; }

    .cat { gap: 0.5rem; }
    .cat-name { width: 8ch; font-size: 0.7rem; }
    .scoring { font-size: 0.8rem; }
}

/* ---------- short viewports: phones on their side, split windows ---------- */
@media (max-height: 560px) and (orientation: landscape) {
    header { margin-bottom: 1.25rem; }
    header h1 { font-size: 1.9rem; }
    header p { font-size: 0.9rem; }

    .bar-inner { padding: 0.45rem 1rem; }
    .bar-score { font-size: 1.1rem; }
    .bar .btn { padding: 0.45rem 0.9rem; font-size: 0.85rem; }
    body.js-enabled.has-bar { padding-bottom: 68px; }

    .result { padding: 1.5rem 1.25rem; }
    .result-score { font-size: clamp(2.75rem, 11vh, 4.5rem); }
    .cats { margin-top: 1.25rem; padding-top: 1rem; }
    .result-actions { margin-top: 1.25rem; }

    /* a fixed tooltip has nowhere to go in 400px of height */
    #tip { max-height: 40vh; overflow: hidden; }
}

/* ---------- wide viewports ---------- */
@media (min-width: 1400px) {
    header h1 { font-size: 3.5rem; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .noise-bg { animation: none; }
}
