/*
 * Trux Design System — ptools
 * Copyright Alpinereplay Inc., 2026. All rights reserved.
 * Author: Dean Srebnik
 *
 * Uses CSS light-dark() for automatic theme switching based on
 * the browser's prefers-color-scheme media query.
 */

@font-face {
    font-family: "Atak";
    font-weight: 200;
    src: url("https://api.go.traceup.com/atak/AtakLight-Web.woff2")
        format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "Atak";
    font-weight: 400;
    src: url("https://api.go.traceup.com/atak/AtakRegular-Web.woff2")
        format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "Atak";
    font-weight: 600;
    src: url("https://api.go.traceup.com/atak/AtakMedium-Web.woff2")
        format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "Atak";
    font-weight: 700;
    src: url("https://api.go.traceup.com/atak/AtakSemibold-Web.woff2")
        format("woff2");
    font-display: swap;
}

:root {
    color-scheme: light dark;

    /* --- Teal (interactive) --- */
    --teal-40: light-dark(#18929a, #5fc9c0);
    --teal-40-hover: light-dark(#157e84, #7cdcd1);
    --teal-40-pressed: light-dark(#11696e, #9ae5dd);
    --teal-30: light-dark(#7cdcd1, #18929a);
    --teal-10: light-dark(#e7f8f5, #112e2d);

    /* --- Charcoal (text, borders, surfaces) --- */
    --charcoal-50: light-dark(#393c3c, #e6e7e7);
    --charcoal-40: light-dark(#5a5c5c, #c0c1c1);
    --charcoal-30: light-dark(#7b7d7d, #9e9f9f);
    --charcoal-20: light-dark(#bdbebe, #6a6c6c);
    --charcoal-10: light-dark(#d7d8d8, #3a3b3b);
    --charcoal-1: light-dark(#e5e5e3, #262727);

    /* --- Surfaces --- */
    --surface: light-dark(#f7f7f5, #1a1b1b);
    --surface-raised: light-dark(#efefed, #222323);
    --bg: light-dark(#e8e8e5, #111212);

    /* --- Status --- */
    --error: light-dark(#ec5366, #ff6b7a);
    --confirmed: light-dark(#7ed321, #8ee638);
    --warning: light-dark(#fbc224, #ffd34e);

    /* --- Shadows --- */
    --shadow-xs: light-dark(
        0px 2px 2px rgba(50, 51, 51, 0.12),
        0px 2px 4px rgba(0, 0, 0, 0.4)
    );
    --shadow-sm: light-dark(
        0px 4px 4px rgba(50, 51, 51, 0.12),
        0px 4px 8px rgba(0, 0, 0, 0.4)
    );
    --shadow-md: light-dark(
        0px 8px 16px rgba(50, 51, 51, 0.12),
        0px 8px 16px rgba(0, 0, 0, 0.5)
    );
    --shadow-lg: light-dark(
        0px 16px 32px rgba(50, 51, 51, 0.12),
        0px 16px 32px rgba(0, 0, 0, 0.5)
    );

    /* --- Spacing (4px base) --- */
    --spacing: 4px;
    --spacing-2x: 8px;
    --spacing-3x: 12px;
    --spacing-4x: 16px;
    --spacing-5x: 20px;
    --spacing-6x: 24px;
    --spacing-8x: 32px;
    --spacing-10x: 40px;

    /* --- Annotation tool surfaces --- */
    --tool-header-bg: light-dark(#efefed, #161818);
    --tool-header-text: light-dark(#393c3c, #e6e7e7);
    --tool-body-bg: light-dark(#e4e4e1, #0e0f0f);
    --tool-sidebar-bg: light-dark(#f7f7f5, #222323);
    --tool-border: light-dark(#d0d0ce, rgba(255, 255, 255, 0.08));
    --gallery-bg: #606361;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Atak", sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: var(--charcoal-50);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--teal-40);
    transition: color 150ms ease;
}

a:hover {
    color: var(--teal-40-hover);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
}

img,
video {
    max-width: 100%;
    display: block;
}

h1,
.h1 {
    font-size: 50px;
    line-height: 52px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--charcoal-50);
}

h2,
.h2 {
    font-size: 38px;
    line-height: 40px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--charcoal-50);
}

h3,
.h3 {
    font-size: 28px;
    line-height: 30px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--charcoal-50);
}

h4,
.h4 {
    font-size: 21px;
    line-height: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--charcoal-50);
}

h5,
.h5 {
    font-size: 12px;
    line-height: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--charcoal-30);
}

p,
.body-text {
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    color: var(--charcoal-50);
}

.text-chip {
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
}

.text-small {
    font-size: 12px;
    line-height: 16px;
    font-weight: 400;
    color: var(--charcoal-30);
}

.text-muted {
    color: var(--charcoal-30);
}

.text-secondary {
    color: var(--charcoal-40);
}

.text-error {
    color: var(--error);
}

.text-center {
    text-align: center;
}

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-4x) var(--spacing-6x);
    background: var(--surface);
    border-bottom: 2px solid var(--charcoal-1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--teal-40);
    letter-spacing: -0.02em;
}

.top-bar-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-4x);
}

.top-bar-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--charcoal-40);
    transition: color 150ms ease;
}

.top-bar-link:hover {
    color: var(--teal-40);
}

.page-content {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-8x) var(--spacing-6x);
}

.page-content.narrow {
    max-width: 800px;
}

.page-content.full {
    max-width: none;
}

.card {
    background: var(--surface);
    border: 2px solid var(--charcoal-1);
    border-radius: 16px;
    padding: var(--spacing-6x);
}

.card-header {
    padding-bottom: var(--spacing-4x);
    margin-bottom: var(--spacing-4x);
    border-bottom: 2px solid var(--charcoal-1);
}

.btn {
    font-family: "Atak", sans-serif;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 32px;
    border: none;
    min-height: 48px;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background-color 100ms ease,
        box-shadow 100ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2x);
    text-decoration: none;
    color: var(--teal-40);
    background: var(--teal-10);
}

.btn:hover {
    background: light-dark(#d4f2ed, #1a4240);
}

.btn-primary {
    background: var(--teal-40);
    color: light-dark(#ffffff, #111212);
}

.btn-primary:hover {
    background: var(--teal-40-hover);
}

.btn-danger {
    background: light-dark(#fef2f2, #3d1519);
    color: var(--error);
}

.btn-danger:hover {
    background: light-dark(#fee2e2, #4d1a1f);
}

.btn-ghost {
    background: transparent;
    color: var(--charcoal-40);
}

.btn-ghost:hover {
    background: var(--charcoal-1);
    color: var(--charcoal-50);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    min-height: 36px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--charcoal-10);
    border-radius: 8px;
    font-family: "Atak", sans-serif;
    font-size: 16px;
    color: var(--charcoal-50);
    background: var(--surface);
    outline: none;
    transition: border-color 150ms ease;
}

.input-field:focus {
    border-color: var(--teal-40);
}

.input-field::placeholder {
    color: var(--charcoal-20);
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237b7d7d' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2x);
}

.form-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--charcoal-30);
}

.form-row {
    display: flex;
    gap: var(--spacing-4x);
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: var(--spacing-3x);
    flex-wrap: wrap;
}

/* ----------------------------------------------------------------
   9. TABLES
   ---------------------------------------------------------------- */
.trux-table {
    width: 100%;
    border-collapse: collapse;
}

.trux-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--charcoal-30);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    padding: var(--spacing-3x) var(--spacing-4x);
    border-bottom: 2px solid var(--charcoal-1);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.trux-table td {
    padding: var(--spacing-3x) var(--spacing-4x);
    border-bottom: 1px solid var(--charcoal-1);
    white-space: nowrap;
}

.trux-table tr:hover td {
    background: var(--charcoal-1);
}

.trux-table tr:last-child td {
    border-bottom: none;
}

.trux-table .col-num {
    text-align: right;
    width: 80px;
}

.table-scroll {
    overflow-y: auto;
    border: 2px solid var(--charcoal-1);
    border-radius: 16px;
    background: var(--surface);
}

.chip {
    height: 32px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    background: var(--charcoal-1);
    color: var(--charcoal-50);
}

.chip-selected {
    background: var(--charcoal-50);
    color: var(--surface);
}

.chip-success {
    background: light-dark(#e8f5e9, #1a3d1a);
    color: var(--confirmed);
}

.chip-error {
    background: light-dark(#fef2f2, #3d1519);
    color: var(--error);
}

.chip-warning {
    background: light-dark(#fff8e1, #3d3219);
    color: var(--warning);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.in-progress {
    background: light-dark(#fff8e1, #3d3219);
    color: var(--warning);
}
.status-badge.in-progress::before {
    background: var(--warning);
}

.status-badge.complete {
    background: light-dark(#e8f5e9, #1a3d1a);
    color: var(--confirmed);
}
.status-badge.complete::before {
    background: var(--confirmed);
}

.status-badge.not-started {
    background: light-dark(#fef2f2, #3d1519);
    color: var(--error);
}
.status-badge.not-started::before {
    background: var(--error);
}

.stat-card {
    background: var(--surface);
    border: 2px solid var(--charcoal-1);
    border-radius: 16px;
    padding: var(--spacing-6x);
}

.stat-value {
    font-size: 38px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--charcoal-50);
}

.stat-label {
    font-size: 16px;
    color: var(--charcoal-30);
    white-space: nowrap;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-window {
    background: var(--surface);
    border-radius: 24px;
    min-width: 500px;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-title-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    min-height: 56px;
    border-bottom: 2px solid var(--charcoal-1);
    position: relative;
}

.modal-title {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--charcoal-20);
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 16px;
    transition: background 150ms;
}

.modal-close:hover {
    background: var(--charcoal-1);
}

.modal-body {
    padding: var(--spacing-6x);
}

.loader {
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader::after {
    content: "";
    width: 48px;
    height: 48px;
    border: 4px solid var(--charcoal-1);
    border-top-color: var(--teal-40);
    border-radius: 50%;
    animation: trux-spin 0.75s ease infinite;
}

.loader-lg::after {
    width: 75px;
    height: 75px;
    border-width: 6px;
}

@keyframes trux-spin {
    from {
        transform: rotate(0turn);
    }
    to {
        transform: rotate(1turn);
    }
}

.alert {
    padding: var(--spacing-4x) var(--spacing-6x);
    border-radius: 12px;
    font-weight: 600;
    border: 2px solid;
}

.alert-info {
    background: var(--teal-10);
    border-color: var(--teal-30);
    color: var(--teal-40);
}

.alert-error {
    background: light-dark(#fef2f2, #3d1519);
    border-color: var(--error);
    color: var(--error);
}

.alert-success {
    background: light-dark(#e8f5e9, #1a3d1a);
    border-color: var(--confirmed);
    color: light-dark(#2e7d32, #8ee638);
}

.alert-warning {
    background: light-dark(#fff8e1, #3d3219);
    border-color: var(--warning);
    color: light-dark(#f57f17, #ffd34e);
}

.tool-shell {
    background: var(--tool-body-bg);
    color: var(--tool-header-text);
    min-height: 100vh;
}

.tool-shell a {
    color: var(--teal-40);
}

.tool-header {
    background: var(--tool-header-bg);
    color: var(--tool-header-text);
    padding: var(--spacing-3x) var(--spacing-4x);
    border-bottom: 2px solid var(--tool-border);
}

.tool-header h1,
.tool-header h2,
.tool-header h3,
.tool-header h4,
.tool-header p,
.tool-header span,
.tool-header label {
    color: var(--tool-header-text);
}

.tool-sidebar {
    background: var(--tool-sidebar-bg);
    color: var(--charcoal-50);
    padding: var(--spacing-3x);
}

.tool-btn {
    font-family: "Atak", sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid var(--charcoal-10);
    cursor: pointer;
    white-space: nowrap;
    transition: all 100ms ease;
    background: var(--charcoal-1);
    color: var(--charcoal-50);
}

.tool-btn:hover {
    background: var(--charcoal-10);
    border-color: var(--charcoal-20);
}

.tool-btn-primary {
    background: var(--teal-40);
    border-color: var(--teal-40);
    color: light-dark(#ffffff, #111212);
}

.tool-btn-primary:hover {
    background: var(--teal-40-hover);
    border-color: var(--teal-40-hover);
}

.tool-btn-success {
    background: light-dark(#2d7a3a, #3a8a4a);
    border-color: light-dark(#2d7a3a, #3a8a4a);
    color: #ffffff;
}

.tool-btn-success:hover {
    background: light-dark(#35913f, #4a9a5a);
}

.tool-btn-danger {
    background: light-dark(#a13030, #b33535);
    border-color: light-dark(#a13030, #b33535);
    color: #ffffff;
}

.tool-btn-danger:hover {
    background: light-dark(#b93a3a, #c44040);
}

.tool-btn-selected {
    background: var(--teal-40);
    border-color: var(--teal-40);
    color: light-dark(#ffffff, #111212);
}

.tool-btn-unselected {
    background: light-dark(#3630a3, #4a44c0);
    border-color: light-dark(#3630a3, #4a44c0);
    color: #ffffff;
}

.tool-btn-unselected:hover {
    background: light-dark(#4540b3, #5a54d0);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--charcoal-50);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-initials {
    color: var(--surface);
    font-weight: 600;
    font-size: 15px;
    text-transform: uppercase;
}

.flex {
    display: flex;
}
.flex-col {
    flex-direction: column;
}
.flex-wrap {
    flex-wrap: wrap;
}
.items-center {
    align-items: center;
}
.items-start {
    align-items: flex-start;
}
.items-stretch {
    align-items: stretch;
}
.justify-center {
    justify-content: center;
}
.justify-between {
    justify-content: space-between;
}
.justify-end {
    justify-content: flex-end;
}
.gap-1 {
    gap: var(--spacing);
}
.gap-2 {
    gap: var(--spacing-2x);
}
.gap-3 {
    gap: var(--spacing-3x);
}
.gap-4 {
    gap: var(--spacing-4x);
}
.gap-6 {
    gap: var(--spacing-6x);
}
.gap-8 {
    gap: var(--spacing-8x);
}

.w-full {
    width: 100%;
}
.mx-auto {
    margin-left: auto;
    margin-right: auto;
}
.mt-2 {
    margin-top: var(--spacing-2x);
}
.mt-4 {
    margin-top: var(--spacing-4x);
}
.mt-6 {
    margin-top: var(--spacing-6x);
}
.mt-8 {
    margin-top: var(--spacing-8x);
}
.mb-2 {
    margin-bottom: var(--spacing-2x);
}
.mb-4 {
    margin-bottom: var(--spacing-4x);
}
.mb-6 {
    margin-bottom: var(--spacing-6x);
}
.mb-8 {
    margin-bottom: var(--spacing-8x);
}
.p-4 {
    padding: var(--spacing-4x);
}
.p-6 {
    padding: var(--spacing-6x);
}

.hidden {
    display: none !important;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 768px) {
    h1,
    .h1 {
        font-size: 32px;
        line-height: 36px;
    }
    h2,
    .h2 {
        font-size: 28px;
        line-height: 32px;
    }
    h3,
    .h3 {
        font-size: 22px;
        line-height: 26px;
    }

    .page-content {
        padding: var(--spacing-4x) var(--spacing-4x);
    }

    .top-bar {
        padding: var(--spacing-3x) var(--spacing-4x);
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 44px;
    }

    .form-row {
        flex-direction: column;
    }

    .modal-window {
        min-width: auto;
        margin: var(--spacing-4x);
        max-width: calc(100vw - 32px);
    }

    .card {
        padding: var(--spacing-4x);
    }
}

@media (max-width: 480px) {
    .top-bar {
        flex-wrap: wrap;
        gap: var(--spacing-2x);
    }

    .top-bar-nav {
        gap: var(--spacing-3x);
    }
}

.annotation-unannotated {
    background-color: light-dark(#f0f0f0, #2a2b2b);
}
.annotation-same {
    background-color: light-dark(#90ee90, #1a3d1a);
}
.annotation-different {
    background-color: light-dark(#ffb6c1, #3d1a1e);
}
.annotation-unsure {
    background-color: light-dark(#add8e6, #1a2d3d);
}
.annotation-bad-track {
    background-color: light-dark(#a9a9a9, #3a3a3a);
}
.annotation-split-track {
    background-color: light-dark(#ffd580, #3d3219);
}

kbd {
    display: inline-block;
    background: var(--charcoal-1);
    border: 2px solid var(--charcoal-10);
    border-radius: 6px;
    padding: 2px 8px;
    font-family: "Atak", monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--charcoal-40);
    line-height: 1.4;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--charcoal-10);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--charcoal-20);
}

/* ----------------------------------------------------------------
   23. RECENT GAMES COMPONENT
   ---------------------------------------------------------------- */
.select-game-page {
    text-align: center;
    padding-top: var(--spacing-10x);
}
.game-form-card {
    max-width: 500px;
    margin: var(--spacing-8x) auto 0;
}
.recent-games-section {
    max-width: 700px;
    margin: var(--spacing-8x) auto 0;
}
.recent-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--spacing-3x);
    margin-top: var(--spacing-4x);
}
.recent-game-card {
    background: var(--surface);
    border: 2px solid var(--charcoal-1);
    border-radius: 12px;
    padding: var(--spacing-4x) var(--spacing-3x);
    text-align: center;
    cursor: pointer;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
    text-decoration: none;
    color: var(--charcoal-50);
}
.recent-game-card:hover {
    border-color: var(--teal-40);
    box-shadow: var(--shadow-sm);
    color: var(--charcoal-50);
}
.recent-game-id {
    font-size: 21px;
    font-weight: 700;
    color: var(--teal-40);
}
.recent-game-time {
    font-size: 12px;
    color: var(--charcoal-30);
    margin-top: var(--spacing);
}
.recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.clear-btn {
    font-size: 12px;
    color: var(--charcoal-30);
    cursor: pointer;
    background: none;
    border: none;
    transition: color 150ms ease;
}
.clear-btn:hover {
    color: var(--error);
}
