/* CheapWrapped — the look of a projector bulb in a dark room.
   Three hues rather than one accent, and they carry meaning: amber is daytime, teal is the small
   hours, magenta is the evening. The same three colour the hour ring, the badge tiers and the rails,
   so the palette reads as a system instead of decoration. */

:root {
    --ink: #0B0E14;
    --ink-card: #131826;
    --ink-raised: #1C2233;
    --line: #2A3145;

    --bulb: #FFB25C;
    --phosphor: #5BD1C4;
    --flare: #F0568F;

    --paper: #F3EFE7;
    --paper-dim: #8C95AB;

    --display: 'Syne', system-ui, sans-serif;
    --body: 'Sora', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;

    --gutter: clamp(1.5rem, 6vw, 5rem);
}

html, body {
    margin: 0;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- the story ---------- */

.story {
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* Animated scrolling is motion too. Jumping straight to a card also makes per-card links land
   reliably instead of easing through every card on the way. */
@media (prefers-reduced-motion: reduce) {
    .story {
        scroll-behavior: auto;
    }
}

.card {
    position: relative;
    min-height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.75rem;
    padding: clamp(4rem, 12vh, 7rem) var(--gutter) clamp(4.5rem, 12vh, 7rem);
    box-sizing: border-box;
}

/* A single wash of colour per card, so scrolling feels like moving through rooms rather than
   flicking through identical slides. */
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(120% 80% at 50% 0%, var(--wash, transparent) 0%, transparent 62%);
    opacity: 0.5;
}

.card > * {
    position: relative;
    max-width: 100%;
}

.card--amber { --wash: rgba(255, 178, 92, 0.16); }
.card--teal { --wash: rgba(91, 209, 196, 0.16); }
.card--magenta { --wash: rgba(240, 86, 143, 0.14); }

/* ---------- card furniture ---------- */

.eyebrow {
    min-width: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--paper-dim);
}

.eyebrow__index {
    flex: none;
    font-variant-numeric: tabular-nums;
    color: var(--line);
}

.hero {
    overflow-wrap: anywhere;
    font-family: var(--display);
    font-weight: 800;
    line-height: 0.92;
    letter-spacing: -0.03em;
    margin: 0;
    text-wrap: balance;
}

.hero--stat {
    font-size: clamp(5rem, 26vw, 13rem);
    font-variant-numeric: tabular-nums;
    color: var(--bulb);
}

.hero--title {
    font-size: clamp(2.25rem, 9vw, 5.5rem);
}

.hero__unit {
    display: block;
    font-family: var(--mono);
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--paper-dim);
    margin-top: 0.9rem;
}

.copy {
    font-size: clamp(1.05rem, 4vw, 1.5rem);
    line-height: 1.55;
    max-width: 34ch;
    color: var(--paper);
    opacity: 0.86;
    margin: 0;
    text-wrap: pretty;
}

.copy--lead {
    max-width: 30ch;
    opacity: 1;
}

/* ---------- the hour ring: the signature ---------- */

.ring {
    width: min(74vw, 22rem);
    height: auto;
    align-self: center;
}

.ring__spoke {
    stroke-width: 5.5;
    stroke-linecap: round;
    transform-origin: 50% 50%;
}

.ring__spoke--night { stroke: var(--phosphor); }
.ring__spoke--day { stroke: var(--bulb); }
.ring__spoke--evening { stroke: var(--flare); }

.ring__dial {
    fill: none;
    stroke: var(--line);
    stroke-width: 1;
}

.ring__label {
    font-family: var(--mono);
    font-size: 7px;
    letter-spacing: 0.12em;
    fill: var(--paper-dim);
    text-anchor: middle;
}

.ring__legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1.25rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--paper-dim);
}

.ring__key {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.ring__swatch {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
}

/* ---------- badges ---------- */

.badges {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    width: 100%;
}

.badges__group-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--paper-dim);
    margin-bottom: 0.7rem;
}

.badges__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.6rem;
}

.badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: var(--ink-card);
    font-size: 0.82rem;
    line-height: 1.25;
}

.badge__icon {
    font-size: 1.15rem;
    line-height: 1;
}

.badge--legendary {
    border-color: color-mix(in srgb, var(--flare) 55%, transparent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--flare) 14%, var(--ink-card)), var(--ink-card));
}

.badge--rare { border-color: color-mix(in srgb, var(--bulb) 45%, transparent); }
.badge--uncommon { border-color: color-mix(in srgb, var(--phosphor) 40%, transparent); }

/* ---------- archetype ---------- */

.archetype__mark {
    font-size: clamp(3.5rem, 16vw, 6rem);
    line-height: 1;
}

/* ---------- tallies ---------- */

.tally {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: 100%;
    max-width: 32rem;
}

.tally__row {
    display: grid;
    /* minmax(0, 1fr) — a plain 1fr floors at min-content, so the nowrap title below
       widens the whole row past the card and the value falls off the screen. */
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
}

.tally__name {
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tally__rank {
    display: inline-block;
    min-width: 1.6rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--paper-dim);
    font-variant-numeric: tabular-nums;
}

/* Your own row, marked without a medal or a podium — the position is stated, not celebrated. */
.tally__row--you {
    border-bottom-color: var(--bulb);
}

.tally__row--you .tally__name,
.tally__row--you .tally__value,
.tally__row--you .tally__rank {
    color: var(--bulb);
}

.tally__value {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--paper-dim);
    font-variant-numeric: tabular-nums;
}

/* ---------- posters ---------- */

/* Backdrop art sits under the wash, faded hard so the type stays readable on any still. */
.card--art::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--art) center / cover no-repeat;
    opacity: 0.16;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 85%);
}

.poster {
    display: block;
    width: 5.5rem;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 0.6rem;
    background: var(--ink-raised);
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.45);
}

.poster--large {
    width: clamp(7.5rem, 28vw, 13rem);
    border-radius: 0.9rem;
}

.feature {
    display: flex;
    align-items: flex-end;
    gap: clamp(1rem, 4vw, 2rem);
    width: 100%;
}

.feature__text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.facts {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--paper-dim);
}

.tagline {
    margin: 0;
    font-style: italic;
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    color: var(--paper);
    opacity: 0.75;
    text-wrap: pretty;
}

.shelf {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 32rem;
}

.shelf__item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.shelf__item .poster {
    width: 100%;
}

.shelf__name {
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shelf__value {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--paper-dim);
    font-variant-numeric: tabular-nums;
}

/* ---------- version ---------- */

.version {
    position: fixed;
    left: 0.9rem;
    bottom: 0.7rem;
    z-index: 2;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--paper-dim);
    opacity: 0.35;
    pointer-events: none;
}

/* ---------- progress rail ---------- */

.rail {
    position: fixed;
    right: max(0.85rem, env(safe-area-inset-right));
    top: 50%;
    translate: 0 -50%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 5;
}

.rail__tick {
    width: 2px;
    height: 1.05rem;
    border-radius: 2px;
    background: var(--line);
}

/* ---------- viewer picker ---------- */

/* ---------- loading ---------- */

.loading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
}

.loading__ring {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--bulb);
    animation: loading-spin 0.9s linear infinite;
}

@keyframes loading-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    /* A still ring plus the sentence carries the same message without the motion. */
    .loading__ring { animation: none; }
}

.picker {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.5rem;
    padding: clamp(3rem, 10vh, 6rem) var(--gutter);
    box-sizing: border-box;
}

.picker__list {
    display: grid;
    gap: 0.5rem;
    width: 100%;
    max-width: 34rem;
}

.picker__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    background: var(--ink-card);
    color: var(--paper);
    text-decoration: none;
    transition: border-color 140ms ease, background 140ms ease;
}

.picker__row:hover,
.picker__row:focus-visible {
    border-color: var(--bulb);
    background: var(--ink-raised);
}

.picker__name {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.15rem;
}

.picker__meta {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--paper-dim);
    font-variant-numeric: tabular-nums;
}

/* ---------- accessibility floor ---------- */

:focus-visible {
    outline: 2px solid var(--bulb);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Cards ease in as they reach the viewport where the browser supports it, and simply sit still
   where it does not. No JavaScript either way. */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .card > .card__body {
            animation: rise linear both;
            animation-timeline: view();
            animation-range: entry 5% cover 28%;
        }
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(2.5rem);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.card__body {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    align-items: flex-start;
}

.card__body--centred {
    align-items: center;
    text-align: center;
}
