/* ==========================================================================
   Gator Gang Bowling League — retro lane house
   --------------------------------------------------------------------------
   Mid-century bowling alley: maple lane tones, scorecard paper, pin red and
   a deep bowling-ball teal. Built on top of Bootstrap 5.3 by retheming its
   own custom properties rather than fighting its grid.

   Light and dark are both first-class. The device setting wins by default;
   an explicit choice stored by theme.js overrides it.
   ========================================================================== */

/* ---------- 1. Tokens: light ---------- */
:root {
    color-scheme: light;

    /* Surfaces */
    --paper: #FAF3E6;           /* scorecard paper */
    --paper-raised: #FFFDF7;    /* cards sitting on the paper */
    --lane: #E3C89C;            /* maple lane */
    --lane-edge: #B8905C;

    /* Ink */
    --ink: #221A13;
    --ink-soft: #6F6155;
    --ink-faint: #9A8B7D;

    /* Accents */
    --ball: #0F3B4C;            /* deep teal, the house ball */
    --ball-bright: #176076;
    --pin-red: #C13B28;
    --mustard: #D9971B;
    --mint: #2E9B82;

    /* Semantics */
    --good: var(--mint);
    --bad: var(--pin-red);

    /* Lines and shadow */
    --line: rgba(34, 26, 19, 0.14);
    --line-strong: rgba(34, 26, 19, 0.28);
    --shadow-sm: 0 1px 2px rgba(34, 26, 19, .08);
    --shadow: 0 6px 18px rgba(34, 26, 19, .10);
    --shadow-lg: 0 14px 38px rgba(34, 26, 19, .16);

    /* Shape — retro means restrained rounding */
    --radius: 6px;
    --radius-lg: 10px;

    /* Type */
    --font-display: 'Alfa Slab One', Georgia, serif;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --ease: 220ms cubic-bezier(.2, .8, .25, 1);
}

/* ---------- 2. Tokens: dark ----------
   Applied when the device asks for dark, unless the viewer explicitly chose
   light; and always when they explicitly chose dark. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --paper: #15110D;
        --paper-raised: #1F1913;
        --lane: #3A2C1D;
        --lane-edge: #5B452C;

        --ink: #F5EADA;
        --ink-soft: #B6A491;
        --ink-faint: #8A7866;

        --ball: #4BB8D4;
        --ball-bright: #6FD3EC;
        --pin-red: #E8694F;
        --mustard: #F0B13C;
        --mint: #4FC4A8;

        --line: rgba(245, 234, 218, 0.16);
        --line-strong: rgba(245, 234, 218, 0.30);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 6px 18px rgba(0, 0, 0, .45);
        --shadow-lg: 0 14px 38px rgba(0, 0, 0, .55);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --paper: #15110D;
    --paper-raised: #1F1913;
    --lane: #3A2C1D;
    --lane-edge: #5B452C;

    --ink: #F5EADA;
    --ink-soft: #B6A491;
    --ink-faint: #8A7866;

    --ball: #4BB8D4;
    --ball-bright: #6FD3EC;
    --pin-red: #E8694F;
    --mustard: #F0B13C;
    --mint: #4FC4A8;

    --line: rgba(245, 234, 218, 0.16);
    --line-strong: rgba(245, 234, 218, 0.30);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 14px 38px rgba(0, 0, 0, .55);
}

/* ---------- 3. Hand the tokens to Bootstrap ---------- */
:root {
    --bs-body-bg: var(--paper);
    --bs-body-color: var(--ink);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--ink-soft);
    --bs-tertiary-color: var(--ink-faint);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-body-font-family: var(--font-body);
    --bs-link-color: var(--ball);
    --bs-link-hover-color: var(--ball-bright);
    --bs-primary: var(--ball);
    --bs-success-text-emphasis: var(--mint);
    --bs-danger-text-emphasis: var(--pin-red);
}

/* ---------- 4. Base ---------- */
* { box-sizing: border-box; }

html { font-size: 15px; }

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Faint lane boards running down the page. Subtle enough to read over. */
    background-image: repeating-linear-gradient(
        90deg,
        transparent 0 58px,
        color-mix(in srgb, var(--lane) 22%, transparent) 58px 59px
    );
}

main[role="main"] { flex: 1 0 auto; }

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -0.01em; }

/* Scores line up in columns only with tabular figures. */
.table, .stat-value, .score, td, th { font-variant-numeric: tabular-nums; }

a { text-decoration-thickness: 1px; text-underline-offset: 2px; }

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

/* ---------- 5. Masthead ---------- */
.lane-header {
    background: var(--lane);
    border-bottom: 3px solid var(--lane-edge);
    position: relative;
}

/* The red/mustard pinstripe that every alley sign seems to have. */
.lane-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -3px;
    height: 3px;
    background: linear-gradient(90deg,
        var(--pin-red) 0 22%,
        var(--mustard) 22% 44%,
        var(--ball) 44% 66%,
        var(--mustard) 66% 88%,
        var(--pin-red) 88% 100%);
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.35rem, 5.2vw, 2.9rem);
    line-height: 1.05;
    letter-spacing: 0.01em;
    text-align: center;
    margin: 0;
    color: var(--paper-raised);
    /* Layered sign-painter shadow */
    text-shadow:
        2px 2px 0 var(--ball),
        4px 4px 0 var(--pin-red),
        5px 5px 10px rgba(0, 0, 0, .25);
}

.wordmark .season-tag {
    display: block;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: clamp(.68rem, 2.1vw, .92rem);
    letter-spacing: .22em;
    text-transform: uppercase;
    margin-top: .5rem;
    color: var(--ink);
    text-shadow: none;
    opacity: .72;
}

/* ---------- 6. Lane navigation ---------- */
.lane-nav {
    display: flex;
    gap: .4rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: .7rem 0 .85rem;
}

.lane-nav a {
    --nav-ink: var(--ink);
    font-weight: 600;
    font-size: .92rem;
    letter-spacing: .02em;
    color: var(--nav-ink);
    text-decoration: none;
    padding: .4rem .85rem;
    border-radius: 999px;
    border: 2px solid transparent;
    white-space: nowrap;
    transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}

.lane-nav a:hover {
    background: color-mix(in srgb, var(--paper-raised) 55%, transparent);
    border-color: var(--line-strong);
}

.lane-nav a.active {
    background: var(--ball);
    border-color: var(--ball);
    color: var(--paper-raised);
}

/* ---------- 7. Scorecard panels ---------- */
.card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 2px solid var(--line);
    padding: .85rem 1.1rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
}

.card-header h1, .card-header h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.05rem;
    letter-spacing: .02em;
    margin: 0;
    color: var(--ink);
}

.card-body { padding: 1.1rem; }

/* ---------- 8. Tables ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--line);
    --bs-table-striped-bg: color-mix(in srgb, var(--lane) 14%, transparent);
    --bs-table-striped-color: var(--ink);
    --bs-table-hover-bg: color-mix(in srgb, var(--mustard) 14%, transparent);
    --bs-table-hover-color: var(--ink);
    margin-bottom: 0;
}

.table > thead th {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
    padding-top: .5rem;
    padding-bottom: .5rem;
}

.table > tbody td {
    border-bottom-color: var(--line);
    vertical-align: middle;
}

/* The leader gets a lane-arrow marker. */
.table tbody tr:first-child .rank::before {
    content: "▲";
    color: var(--mustard);
    font-size: .7em;
    margin-right: .3em;
}

.rank { color: var(--ink-faint); font-weight: 700; }

/* ---------- 9. Callout cards ---------- */
.callout {
    position: relative;
    height: 100%;
    border: 1px solid var(--line);
    border-left: 5px solid var(--kind, var(--ball));
    background: var(--paper-raised);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--ease), box-shadow var(--ease);
}

.callout:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.callout--high  { --kind: var(--mint); }
.callout--game  { --kind: var(--ball); }
.callout--low   { --kind: var(--mustard); }
.callout--up    { --kind: var(--mint); }
.callout--down  { --kind: var(--pin-red); }

.callout .kicker {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--kind, var(--ball));
}

.callout .who {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.15rem;
    line-height: 1.2;
    margin: .35rem 0 .1rem;
}

.callout .team { font-size: .82rem; color: var(--ink-faint); }

.callout .stat-value {
    font-family: var(--font-display);
    font-size: clamp(2rem, 7vw, 2.9rem);
    line-height: 1;
    color: var(--kind, var(--ball));
    margin: .45rem 0 .35rem;
}

.callout .quip {
    font-size: .92rem;
    color: var(--ink-soft);
    font-style: italic;
    margin: 0;
}

/* ---------- 10. Fixtures ---------- */
.fixture {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-raised);
}

.fixture + .fixture { margin-top: .5rem; }

.fixture .side { font-weight: 600; min-width: 0; }
.fixture .side.away { text-align: right; }

.fixture .vs {
    font-family: var(--font-display);
    font-size: .8rem;
    color: var(--ink-faint);
    padding: .15rem .5rem;
    border: 2px solid var(--line);
    border-radius: 999px;
}

.fixture .points {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--ball);
}

/* ---------- 11. Bits and pieces ---------- */
.pill {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: .18rem .5rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    color: var(--ink-soft);
}

.delta-up { color: var(--mint); font-weight: 600; }
.delta-down { color: var(--pin-red); font-weight: 600; }

.btn-primary {
    --bs-btn-bg: var(--ball);
    --bs-btn-border-color: var(--ball);
    --bs-btn-hover-bg: var(--ball-bright);
    --bs-btn-hover-border-color: var(--ball-bright);
    --bs-btn-color: var(--paper-raised);
    --bs-btn-hover-color: var(--paper-raised);
    font-weight: 600;
}

.btn-secondary {
    --bs-btn-bg: transparent;
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-bg: color-mix(in srgb, var(--lane) 30%, transparent);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-border-color: var(--line-strong);
    font-weight: 600;
}

.form-control, .form-select {
    background-color: var(--paper);
    border-color: var(--line-strong);
    color: var(--ink);
}

.form-control:focus, .form-select:focus {
    background-color: var(--paper);
    border-color: var(--ball);
    color: var(--ink);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--ball) 25%, transparent);
}

.alert {
    border: 1px solid var(--line-strong);
    border-left-width: 5px;
    background: var(--paper-raised);
    color: var(--ink);
    border-radius: var(--radius);
}

.alert-info { border-left-color: var(--ball); }
.alert-warning { border-left-color: var(--mustard); }

/* Empty states shouldn't look like errors. */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ink-soft);
}

.empty-state .pins { font-size: 2rem; opacity: .5; margin-bottom: .5rem; }

/* ---------- 12. Theme toggle ---------- */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--line-strong);
    color: var(--ink);
    border-radius: 999px;
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .95rem;
    line-height: 1;
    transition: background-color var(--ease), transform var(--ease);
}

.theme-toggle:hover { background: color-mix(in srgb, var(--paper-raised) 60%, transparent); }
.theme-toggle:active { transform: scale(.94); }

/* ---------- 13. Footer ---------- */
.lane-footer {
    margin-top: auto;
    border-top: 2px solid var(--line);
    background: color-mix(in srgb, var(--lane) 30%, var(--paper));
    color: var(--ink-soft);
    font-size: .85rem;
    padding: 1rem 0;
}

/* ---------- 14. Motion ----------
   Everything here is decoration, so it all collapses to nothing when the
   viewer has asked for reduced motion. */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.rise { animation: rise .5s var(--ease) both; }
.rise-1 { animation-delay: .05s; }
.rise-2 { animation-delay: .12s; }
.rise-3 { animation-delay: .19s; }
.rise-4 { animation-delay: .26s; }

/* Sparklines draw themselves in. */
.spark path, .spark polyline {
    stroke-dasharray: var(--len, 200);
    stroke-dashoffset: var(--len, 200);
    animation: draw 1.1s var(--ease) forwards;
}

@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    .spark path, .spark polyline { stroke-dashoffset: 0; }
}

/* ---------- 15. Small screens ---------- */
@media (max-width: 575.98px) {
    .card-body { padding: .85rem; }

    .table > thead th,
    .table > tbody td { padding-left: .45rem; padding-right: .45rem; font-size: .86rem; }

    .fixture { grid-template-columns: 1fr auto 1fr; gap: .4rem; padding: .65rem .7rem; }

    /* The lane boards get noisy on a phone. */
    body { background-image: none; }
}
