/* App shell and shared components. View-specific styles live in app/views/<view>/view.css.

   Colors are theme tokens. The <head> script in index.php sets data-theme on <html> before first
   paint (the viewer's saved choice, else light) and app/theme.js handles the toggle. Without JS
   the site uses the light theme. */

:root {
    --radius: 14px;
    --appbar-h: 64px;
    --tabbar-h: 64px;
}

:root[data-theme="dark"] {
    --bg: #0a0d0c;
    --page-overlay: linear-gradient(rgba(6, 8, 7, 0.88), rgba(6, 8, 7, 0.95));
    --logo-opacity: 0.025;
    --appbar-bg: rgba(8, 11, 10, 0.75);
    --tabbar-bg: rgba(8, 11, 10, 0.94);
    --surface: rgba(20, 25, 23, 0.78);
    --surface-solid: #141917;
    --raised: rgba(255, 255, 255, 0.06);
    --raised-hover: rgba(255, 255, 255, 0.10);
    --row-hover: rgba(255, 255, 255, 0.03);
    --track: rgba(255, 255, 255, 0.18);
    --border: rgba(255, 255, 255, 0.09);
    --text: #eef2f0;
    --muted: #9ba7a1;
    --accent: #1266f1;
    --accent-hover: #0f57d0;
    --accent-soft: rgba(18, 102, 241, 0.18);
    --accent-text: #7eaaff;
    --live: #3ccf7a;
    --live-soft: rgba(60, 207, 122, 0.15);
    --live-ink: #06210f;
    --warn: #f0b429;
    --warn-soft: rgba(240, 180, 41, 0.18);
    --danger-text: #ff8a80;
    --gold: #f5c542;
    --gold-soft: rgba(245, 197, 66, 0.2);
    --silver: #d5dbe1;
    --silver-soft: rgba(213, 219, 225, 0.16);
    --bronze: #e09a5a;
    --bronze-soft: rgba(224, 154, 90, 0.2);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

:root,
:root[data-theme="light"] {
    --bg: #f3f5f4;
    --page-overlay: linear-gradient(rgba(243, 245, 244, 0.93), rgba(243, 245, 244, 0.97));
    --logo-opacity: 0.025;
    --appbar-bg: rgba(255, 255, 255, 0.8);
    --tabbar-bg: rgba(255, 255, 255, 0.95);
    --surface: rgba(255, 255, 255, 0.9);
    --surface-solid: #ffffff;
    --raised: rgba(16, 24, 20, 0.05);
    --raised-hover: rgba(16, 24, 20, 0.09);
    --row-hover: rgba(16, 24, 20, 0.03);
    --track: rgba(16, 24, 20, 0.15);
    --border: rgba(16, 24, 20, 0.11);
    --text: #15201b;
    --muted: #5b6963;
    --accent: #1266f1;
    --accent-hover: #0f57d0;
    --accent-soft: rgba(18, 102, 241, 0.11);
    --accent-text: #0b5bd8;
    --live: #17924c;
    --live-soft: rgba(23, 146, 76, 0.12);
    --live-ink: #ffffff;
    --warn: #a86a00;
    --warn-soft: rgba(240, 180, 41, 0.2);
    --danger-text: #c62828;
    --gold: #8a6400;
    --gold-soft: rgba(245, 197, 66, 0.35);
    --silver: #4a5560;
    --silver-soft: rgba(140, 152, 164, 0.22);
    --bronze: #8a4a14;
    --bronze-soft: rgba(224, 154, 90, 0.3);
    --shadow: 0 8px 24px rgba(16, 24, 20, 0.08);
    color-scheme: light;
}

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

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font: 16px/1.55 Roboto, system-ui, sans-serif;
    background-color: var(--bg);
    background-image: var(--page-overlay), url('/assets/sg/turf.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* The big SG badge as a faint watermark behind everything; its strength is set per theme
   (--logo-opacity) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: url('/assets/sg/silver_500_500.png') center / min(80vh, 90vw) no-repeat;
    opacity: var(--logo-opacity);
    pointer-events: none;
}

h1, h2, h3 {
    font-family: Nunito, Roboto, sans-serif;
    font-weight: 800;
    line-height: 1.15;
}

a {
    color: var(--accent-text);
}

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

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.page {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 16px;
}


/* ---------- App bar ---------- */

.appbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--appbar-bg);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.appbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: var(--appbar-h);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font: 800 20px Nunito, sans-serif;
    letter-spacing: 0.02em;
}

.brand img {
    width: 32px;
    height: 32px;
}

.tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.tabs a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s, background-color 0.15s;
}

.tabs a:hover {
    color: var(--text);
    background: var(--raised);
}

.tabs a.active {
    color: var(--text);
    background: var(--accent-soft);
}

.tabs a.active i {
    color: var(--accent-text);
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.theme-toggle:hover {
    background: var(--raised);
    color: var(--text);
}

/* Thin bar under the app bar while a slow navigation loads */
#route-progress {
    position: absolute;
    left: 0;
    bottom: -1px;
    height: 2px;
    width: 0;
    background: var(--accent-text);
    opacity: 0;
}

.route-loading #route-progress {
    opacity: 1;
    width: 85%;
    transition: width 6s cubic-bezier(0.1, 0.7, 0.2, 1);
}

#app {
    padding-top: 40px;
    padding-bottom: 72px;
}

#app:focus {
    outline: none;
}

#app.enter {
    animation: view-in 0.22s ease-out;
}

@keyframes view-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* Phones: the tabs become a bottom tab bar */
@media (max-width: 767px) {
    /* No blur on the top bar here: backdrop-filter makes it the containing block for fixed
       children, which would pin the tab bar to the top bar instead of the bottom of the screen */
    .appbar {
        background: var(--tabbar-bg);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .tabs {
        z-index: 50;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        justify-content: space-around;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: var(--tabbar-bg);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--border);
    }

    .tabs a {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        padding: 6px;
        font-size: 12px;
    }

    .tabs a i {
        font-size: 18px;
    }

    .tabs a.active {
        background: none;
    }

    .appbar .theme-toggle {
        margin-left: auto;
    }

    #app {
        padding-top: 28px;
        padding-bottom: calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom));
    }
}


/* ---------- Components ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--raised);
    color: var(--text);
    font: 500 15px/1.2 Roboto, sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--raised-hover);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

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

.btn-ghost:hover {
    background: var(--raised);
}

.btn-lg {
    padding: 14px 22px;
    font-size: 16px;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head h2 {
    margin: 0;
    font-size: 20px;
}

.link-more {
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}

.link-more:hover {
    text-decoration: underline;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.page-head {
    margin-bottom: 28px;
}

.page-head h1 {
    margin: 0 0 8px;
    font-size: clamp(30px, 4vw, 40px);
}

.page-head p:not(.eyebrow) {
    max-width: 680px;
    margin: 0;
    color: var(--muted);
}

.page-head p:empty {
    display: none;
}

/* Event pages (leagues): title block with an optional event logo, and the sponsor on the right.
   Views fill these from the route: {{logo}}, data-sponsor="{{sponsor}}". */
.event-head {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.event-head > div {
    flex: 1 1 260px;
}

.event-logo {
    width: 96px;
    height: auto;
    flex-shrink: 0;
}

.event-logo[src=""],
.event-head:not([data-sponsor="1"]) .sponsor {
    display: none;
}

.sponsor {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 16px;
    border-radius: var(--radius);
    background: #fff;
    color: #3a4a5c;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
    transition: transform 0.15s;
}

.sponsor:hover {
    transform: translateY(-1px);
}

.sponsor img {
    width: auto;
    height: 52px;
}

@media (max-width: 767px) {
    .event-head {
        flex-wrap: wrap;
    }

    .event-logo {
        width: 72px;
    }

    .sponsor {
        order: 3;
    }

    .sponsor img {
        height: 40px;
    }
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--raised);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.chip.live {
    background: var(--live-soft);
    color: var(--live);
}

.chip.live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.chip.upcoming {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--raised);
}

.segmented button,
.segmented a {
    padding: 6px 14px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font: 500 14px Roboto, sans-serif;
    text-decoration: none;
    cursor: pointer;
}

.segmented button:hover,
.segmented a:hover {
    color: var(--text);
}

.segmented button.active,
.segmented a.active {
    background: var(--accent);
    color: #fff;
}

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

.input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--raised);
    color: var(--text);
    font: 15px Roboto, sans-serif;
}

.input::placeholder {
    color: var(--muted);
}

.empty {
    margin: 0;
    padding: 28px 12px;
    color: var(--muted);
    text-align: center;
}

.skeleton {
    border-radius: 10px;
    background: linear-gradient(90deg, var(--raised), var(--raised-hover), var(--raised));
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
}

.skeleton + .skeleton {
    margin-top: 10px;
}

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}


/* ---------- Match agenda (home and calendar) ---------- */

.agenda,
.agenda-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.agenda-day {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.agenda-day:first-child {
    padding-top: 0;
    border-top: 0;
}

.agenda-date {
    text-align: center;
    line-height: 1.1;
}

.agenda-date .dow,
.agenda-date .mon {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.agenda-date .dom {
    display: block;
    font: 800 26px Nunito, sans-serif;
}

.agenda-day.today .dom {
    color: var(--accent-text);
}

.agenda-items {
    display: grid;
    gap: 8px;
}

.agenda-item {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 12px;
    align-items: baseline;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--raised);
}

.agenda-item time {
    color: var(--muted);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.agenda-item .title {
    overflow-wrap: anywhere;
}


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