/*
 * keystro.ke
 * Copyright (C) 2026 Mike O'Riley
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 */

/**
 * ============================================================================
 * Records Room - level, streak, lifetime stats, and badges
 * ============================================================================
 *
 * Presentation for records-room.html. Same CRT-monitor bezel as
 * lesson-hall.html and the main menu, duplicated here rather than shared per
 * this project's established per-page convention (see lesson-hall.css's own
 * header comment). Uses the main menu's gold tile accent throughout, the
 * same way Lesson Hall uses its own cyan accent.
 *
 * Unlike Lesson Hall's single horizontal trace path, this page's content
 * (progress, stats, badges) is naturally vertical and can exceed one
 * viewport on small screens, so the one deliberately scrollable region here
 * (records-viewport/records-lane, matching the site-wide "the CRT screen
 * itself never scrolls, but one inner region may" rule) scrolls vertically
 * instead of horizontally.
 * ============================================================================
 */

:root {
    --ground: #070914;
    --ground-deep: #04050c;
    --bezel: #14131c;
    --bezel-hi: #24222e;

    --ink: #f3f7ff;
    --ink-dim: #8b93c2;

    --cyan: #7febff;
    --cyan-rgb: 127, 235, 255;
    --amber: #ffcb57;
    --amber-rgb: 255, 203, 87;
    --gold: #ffe778;
    --gold-rgb: 255, 231, 120;

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background: radial-gradient(circle at 50% 20%, #14131c, var(--ground-deep) 70%);
    color: var(--ink);
    font-family: var(--mono);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(6px, 2vmin, 24px);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    background: var(--ground);
    color: var(--ink);
    border: 2px solid var(--gold);
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: 700;
    text-decoration: none;
    transition: top 150ms ease;
}

.skip-link:focus {
    top: 1rem;
}

/* ================= CRT MONITOR BEZEL ================= */

.monitor {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 2400px;
    max-height: 1400px;
    background: linear-gradient(155deg, var(--bezel-hi), var(--bezel) 40%, #0c0b12);
    border-radius: clamp(10px, 2.4vmin, 28px);
    padding: clamp(8px, 1.6vmin, 22px);
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.6),
        inset 0 2px 0 rgba(255, 255, 255, 0.05),
        inset 0 -6px 14px rgba(0, 0, 0, 0.5);
}

.monitor::after {
    content: "keystro.ke 9000";
    position: absolute;
    left: 50%;
    bottom: clamp(2px, 0.8vmin, 8px);
    transform: translateX(-50%);
    font-size: clamp(0.45rem, 1.1vmin, 0.6rem);
    letter-spacing: 0.3em;
    color: rgba(243, 247, 255, 0.18);
}

.screen {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: clamp(6px, 1.4vmin, 10px);
    background: var(--ground);
    box-shadow:
        inset 0 0 0 2px rgba(0, 0, 0, 0.6),
        inset 0 0 60px rgba(0, 0, 0, 0.7),
        inset 0 0 120px rgba(var(--gold-rgb), 0.06);
}

.crt-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 0px,
            rgba(0, 0, 0, 0.16) 1px,
            rgba(0, 0, 0, 0) 2px
        ),
        radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
    mix-blend-mode: multiply;
    animation: crt-flicker 6.5s steps(60, end) infinite;
}

@keyframes crt-flicker {
    0%, 96%, 100% { opacity: 0.92; }
    97% { opacity: 0.98; }
    98% { opacity: 0.86; }
}

.screen-content {
    position: relative;
    z-index: 5;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: clamp(8px, 1.6vmin, 20px) clamp(10px, 2vmin, 26px);
}

@media (prefers-reduced-motion: reduce) {
    .crt-overlay { animation: none; }
}

/* ================= HUD STRIP ================= */

.hud {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2.4vmin, 30px);
    flex-wrap: wrap;
    padding-bottom: clamp(8px, 1.8vmin, 18px);
    border-bottom: 2px solid rgba(var(--gold-rgb), 0.22);
    font-size: clamp(0.7rem, 2vmin, 1.05rem);
}

.brand-mark {
    color: var(--ink);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.brand-mark:hover,
.brand-mark:focus-visible {
    color: var(--gold);
    text-decoration: underline;
}

.records-label {
    color: var(--ink-dim);
    letter-spacing: 0.12em;
}

.sound-toggle {
    appearance: none;
    min-height: 28px;
    margin-left: auto;
    background: rgba(var(--gold-rgb), 0.08);
    border: 1px solid rgba(var(--gold-rgb), 0.4);
    color: var(--gold);
    font-family: var(--mono);
    font-size: clamp(0.62rem, 1.4vmin, 0.9rem);
    letter-spacing: 0.05em;
    padding: clamp(4px, 0.9vmin, 8px) clamp(8px, 1.4vmin, 14px);
    cursor: pointer;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
    background: rgba(var(--gold-rgb), 0.18);
}

/* ================= BANNER ================= */

.records-banner {
    text-align: center;
    padding: clamp(10px, 3vmin, 24px) 0 clamp(4px, 1.2vmin, 10px);
}

.records-kicker {
    margin: 0 0 0.4em;
    font-size: clamp(0.62rem, 1.5vmin, 0.85rem);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.records-title {
    margin: 0;
    font-size: clamp(1.3rem, 4.4vmin, 2.6rem);
    font-weight: 800;
    color: var(--ink);
    text-shadow: 0 0 18px rgba(var(--gold-rgb), 0.35);
}

/* ================= SCROLLABLE CONTENT ================= */

.records-viewport {
    flex: 1;
    min-height: 0;
    display: flex;
}

.records-lane {
    width: 100%;
    max-width: 900px;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    gap: clamp(20px, 3.6vmin, 40px);
    padding: 0 clamp(4px, 1vmin, 12px) clamp(16px, 3vmin, 32px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--gold-rgb), 0.4) transparent;
}

.panel-heading {
    margin: 0 0 clamp(10px, 2vmin, 18px);
    font-size: clamp(0.95rem, 2.4vmin, 1.3rem);
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.03em;
}

/* ================= PROGRESS PANEL ================= */

.progress-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(16px, 4vmin, 40px);
    padding: clamp(14px, 2.6vmin, 22px) clamp(16px, 3vmin, 28px);
    border: 1px solid rgba(var(--gold-rgb), 0.28);
    border-radius: 14px;
    background: rgba(var(--gold-rgb), 0.05);
}

.progress-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.progress-stat-label {
    font-size: clamp(0.6rem, 1.3vmin, 0.75rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.progress-stat-value {
    font-size: clamp(1.4rem, 3.6vmin, 2.2rem);
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 14px rgba(var(--gold-rgb), 0.4);
    line-height: 1;
}

.progress-stat-sublabel {
    font-size: clamp(0.6rem, 1.2vmin, 0.72rem);
    color: var(--ink-dim);
}

.progress-xp {
    flex: 1 1 220px;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.xp-track {
    position: relative;
    flex: 1;
    height: 10px;
    border-radius: 5px;
    background: rgba(243, 247, 255, 0.08);
    border: 1px solid rgba(var(--gold-rgb), 0.3);
    overflow: hidden;
}

.xp-fill {
    position: absolute;
    inset: 1px;
    width: 0%;
    background: linear-gradient(90deg, rgba(var(--gold-rgb), 0.5), rgba(var(--gold-rgb), 0.95));
    box-shadow: 0 0 8px rgba(var(--gold-rgb), 0.6);
    transition: width 400ms ease;
}

.progress-xp-label {
    font-size: clamp(0.7rem, 1.5vmin, 0.9rem);
    color: var(--ink-dim);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ================= STATS PANEL ================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: clamp(10px, 1.6vmin, 16px);
    margin: 0;
}

.stat-item {
    min-width: 0;
    padding: clamp(10px, 1.8vmin, 16px);
    border: 1px solid rgba(243, 247, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.stat-item dt {
    margin: 0 0 0.4em;
    font-size: clamp(0.6rem, 1.2vmin, 0.72rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.stat-item dd {
    margin: 0;
    color: var(--ink);
    font-size: clamp(1.2rem, 2.8vmin, 1.7rem);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 12px rgba(var(--cyan-rgb), 0.25);
}

/* ================= BADGES PANEL ================= */

.badge-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: clamp(10px, 1.6vmin, 16px);
}

.badge-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: clamp(12px, 2vmin, 18px);
    border-radius: 14px;
}

.badge-card.is-locked {
    border: 1px dashed rgba(243, 247, 255, 0.18);
    background: rgba(255, 255, 255, 0.02);
}

.badge-card.is-earned {
    border: 1px solid rgba(var(--gold-rgb), 0.7);
    background: rgba(var(--gold-rgb), 0.08);
    box-shadow: 0 0 1.1rem rgba(var(--gold-rgb), 0.25);
}

.badge-card-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: clamp(30px, 4.4vmin, 40px);
    height: clamp(30px, 4.4vmin, 40px);
    border-radius: 50%;
    font-size: clamp(0.85rem, 1.8vmin, 1.1rem);
    font-weight: 700;
}

.badge-card.is-locked .badge-card-icon {
    border: 1px dashed rgba(243, 247, 255, 0.22);
    color: var(--ink-dim);
}

.badge-card.is-earned .badge-card-icon {
    border: 1px solid rgba(var(--gold-rgb), 0.85);
    background: rgba(var(--gold-rgb), 0.2);
    color: var(--gold);
}

.badge-card-copy {
    min-width: 0;
}

.badge-card-name {
    margin: 0 0 0.3em;
    font-size: clamp(0.82rem, 1.7vmin, 0.98rem);
    font-weight: 700;
    color: var(--ink);
}

.badge-card.is-locked .badge-card-name {
    color: var(--ink-dim);
}

.badge-card-description {
    margin: 0;
    font-size: clamp(0.68rem, 1.4vmin, 0.82rem);
    color: var(--ink-dim);
    line-height: 1.4;
}

/* ================= FOOTER ================= */

.screen-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: clamp(6px, 1.6vmin, 14px);
    padding-top: clamp(4px, 1.2vmin, 10px);
    font-size: clamp(0.6rem, 1.3vmin, 0.85rem);
    color: var(--ink-dim);
}

.screen-footer a {
    color: var(--ink-dim);
    text-decoration: none;
}

.screen-footer a:hover,
.screen-footer a:focus-visible {
    color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
    .xp-fill {
        transition: none;
    }
}

/* Manual override for the Options Terminal "Reduce motion" toggle
   (src/settings.js sets data-motion="reduce" on <html>) - a blanket
   animation/transition kill switch, unlike the hand-tuned
   prefers-reduced-motion blocks above which only target this page's own
   specific animated elements. Lets someone reduce motion on this site
   without changing their OS-wide setting. */
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}
