/* Shared foundation for the hub, the drill player and the progress page:
   fonts, design tokens, and the small set of components they all use. */

@font-face {
    font-family: "Rajdhani";
    src: url("../assets/fonts/rajdhani-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Rajdhani";
    src: url("../assets/fonts/rajdhani-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Rajdhani";
    src: url("../assets/fonts/rajdhani-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;

    --bg: #060912;
    --bg-2: #0a101d;
    --surface: #101828;             /* cards and chart backgrounds */
    --surface-2: #17223a;
    --panel: rgba(10, 16, 30, 0.9); /* HUD panels over the game canvas */
    --line: rgba(148, 163, 184, 0.16);
    --line-2: rgba(148, 163, 184, 0.3);

    --ink: #f1f5f9;
    --ink-2: #b4c0d6;
    --ink-3: #8593ad;

    --accent: #22d3ee;
    --accent-ink: #04202a;
    --hot: #f97316;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;

    /* Chart colours. Checked against --surface for contrast and colour-blind
       separation; change them together, not one at a time. */
    --series-1: #0ea5c6;
    --series-2: #e8662a;
    --series-muted: #475873;
    --grid: #1c2740;
    --axis: #2f3d5a;

    --font: "Rajdhani", "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 14px;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

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

html {
    background: var(--bg);
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
    line-height: 1.1;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

button {
    font-family: inherit;
}

[hidden] {
    display: none !important;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.62rem 1.15rem;
    border: 1px solid var(--line-2);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font: 700 0.98rem var(--font);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.btn:hover {
    border-color: var(--accent);
    background: #1c2a47;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible,
.cmd:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    border-color: transparent;
    background: linear-gradient(135deg, #22d3ee, #38bdf8);
    color: var(--accent-ink);
}

.btn-primary:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #67e8f9, #7dd3fc);
}

.btn-hot {
    border-color: transparent;
    background: linear-gradient(135deg, #f97316, #fbbf24);
    color: #1f1203;
    box-shadow: 0 10px 28px rgba(249, 115, 22, 0.28);
}

.btn-hot:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #fb923c, #fcd34d);
}

.btn-ghost {
    background: transparent;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* A key cap, for hotkey hints */
.kbd {
    display: inline-block;
    min-width: 1.75em;
    padding: 0.05em 0.45em;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: #0b1220;
    color: var(--ink);
    font: 700 0.85em var(--font);
    line-height: 1.45;
    text-align: center;
    white-space: nowrap;
}

.btn .kbd {
    background: rgba(4, 12, 22, 0.28);
    border-color: rgba(4, 12, 22, 0.35);
    color: inherit;
}

.btn:not(.btn-primary):not(.btn-hot) .kbd {
    background: #0b1220;
    border-color: var(--line-2);
}

/* ===== Labels ===== */
.eyebrow {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.12rem 0.6rem;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ink-2);
    white-space: nowrap;
}

/* Rank badge: the tier colour on the gem, the name always spelled out beside it */
.rank {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    white-space: nowrap;
}

.rank-gem {
    width: 0.8em;
    height: 0.8em;
    flex: none;
    background: var(--rank, var(--ink-3));
    transform: rotate(45deg);
    border-radius: 2px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), 0 0 12px color-mix(in srgb, var(--rank, transparent) 55%, transparent);
}

.rank.is-unranked {
    color: var(--ink-3);
}

.rank.is-unranked .rank-gem {
    background: transparent;
    border: 1.5px solid var(--ink-3);
    box-shadow: none;
}

/* ===== Cards ===== */
.card-surface {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* ===== Stat tile: label, value, optional note ===== */
.tile-stat {
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    min-width: 0;
}

.tile-stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-3);
}

.tile-stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink);
}

.tile-stat-note {
    font-size: 0.8rem;
    color: var(--ink-3);
}

/* ===== Meter: a value against a limit ===== */
.meter {
    height: 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--meter, var(--series-1)) 22%, var(--surface));
    overflow: hidden;
}

.meter > i {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: var(--meter, var(--series-1));
}

/* ===== Charts ===== */
.chart {
    position: relative;
    margin: 0;
}

.chart-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.4rem;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
}

.chart-sub {
    font-size: 0.82rem;
    color: var(--ink-3);
}

.chart-toggle {
    border: 0;
    background: none;
    padding: 0;
    color: var(--ink-3);
    font: 600 0.78rem var(--font);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.chart-toggle:hover {
    color: var(--accent);
}

.chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart text {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    fill: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.chart .chart-value {
    fill: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 0.3rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-2);
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chart-legend i {
    width: 14px;
    height: 0;
    border-top: 2px solid var(--c);
    border-radius: 2px;
}

.chart-empty {
    display: grid;
    place-items: center;
    min-height: 120px;
    color: var(--ink-3);
    font-size: 0.9rem;
    text-align: center;
}

.chart-tip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    padding: 0.35rem 0.6rem;
    background: #050810;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    font-size: 0.82rem;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -100%);
}

.chart-tip-head {
    color: var(--ink-3);
    font-weight: 600;
}

.chart-tip-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chart-tip-row i {
    width: 12px;
    border-top: 2px solid var(--c);
}

.chart-tip-row b {
    color: var(--ink);
    font-weight: 700;
}

.chart-tip-row span {
    color: var(--ink-3);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
    padding: 0.3rem 0.6rem;
    text-align: right;
    border-bottom: 1px solid var(--line);
}

.data-table th:first-child,
.data-table td:first-child {
    text-align: left;
}

.data-table th {
    color: var(--ink-3);
    font-weight: 600;
}

.table-scroll {
    max-height: 220px;
    overflow: auto;
}

/* ===== Overlays ===== */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow: auto;
    background: rgba(4, 6, 12, 0.74);
    backdrop-filter: blur(5px);
}

.sheet {
    width: min(940px, 100%);
    padding: 28px 32px;
    background: linear-gradient(180deg, #121c31, #0c1322);
    border: 1px solid var(--line-2);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.sheet-narrow {
    width: min(460px, 100%);
}

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

/* ===== Settings dialog ===== */
.settings-overlay {
    z-index: 80;
}

.settings {
    position: relative;
    width: min(860px, 100%);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.settings-head h2 {
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}

.tab {
    padding: 0.45rem 1rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--ink-3);
    font: 700 0.95rem var(--font);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.tab:hover {
    color: var(--ink);
}

.tab.is-active {
    color: var(--ink);
    border-bottom-color: var(--accent);
}

.settings-body {
    overflow: auto;
    padding: 16px 2px 4px;
}

.presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.preset {
    display: grid;
    gap: 2px;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line-2);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink-2);
    font: 500 0.92rem var(--font);
    text-align: left;
    cursor: pointer;
}

.preset b {
    color: var(--ink);
    font-size: 1.1rem;
}

.preset.is-active {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.settings-note {
    margin: 10px 0 14px;
    color: var(--ink-3);
    font-size: 0.92rem;
}

.binds {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.bind-group {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.bind-group.is-wide {
    margin-top: 12px;
}

.bind-group h3 {
    margin-bottom: 0.4rem;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.bind {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0.18rem 0;
}

.bind-label {
    color: var(--ink-2);
}

.bind-key {
    min-width: 62px;
    padding: 0.12rem 0.6rem;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: 7px;
    background: #0b1220;
    color: var(--ink);
    font: 700 0.95rem var(--font);
    cursor: pointer;
}

.bind-key:hover {
    border-color: var(--accent);
}

.bind-key.is-custom {
    color: var(--accent);
}

.bind-key.is-capturing {
    border-color: var(--warn);
    color: var(--warn);
}

.bind-fixed {
    color: var(--ink);
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.options {
    display: grid;
    gap: 8px;
}

.option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.option-text {
    display: grid;
    gap: 1px;
    color: var(--ink-3);
    font-size: 0.92rem;
}

.option-text b {
    color: var(--ink);
    font-size: 1.05rem;
}

.option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.option input[type="range"] {
    width: 220px;
    accent-color: var(--accent);
}

.segmented {
    display: inline-flex;
    border: 1px solid var(--line-2);
    border-radius: 9px;
    overflow: hidden;
}

.segmented button {
    padding: 0.3rem 0.8rem;
    border: 0;
    background: transparent;
    color: var(--ink-3);
    font: 700 0.9rem var(--font);
    cursor: pointer;
}

.segmented button.is-active {
    background: var(--accent);
    color: var(--accent-ink);
}

.btn-danger:hover {
    border-color: var(--bad);
    color: var(--bad);
}

.settings-toast {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    padding: 0.3rem 0.9rem;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    background: #050810;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.settings-toast.is-on {
    opacity: 1;
}
