/* Reset, app shell (sidebar, topbar, footer) and global search. */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    background-image: radial-gradient(900px 420px at 12% -8%, var(--glow), transparent 70%), radial-gradient(700px 360px at 100% 0%, var(--glow-2), transparent 70%);
    background-attachment: fixed;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
code { font-size: 0.92em; color: var(--accent); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: rgba(157, 27, 29, 0.25); }

/* Slim scrollbars that match the dark theme. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: var(--border-strong) padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3) padding-box; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: absolute; left: 12px; top: -40px; z-index: 100; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.skip-link:focus { top: 12px; }

/* ---- shell ---------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: var(--sidebar-w);
    height: 100vh;
    flex: none;
    padding: 18px 14px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--sidebar-bg);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; color: var(--text); font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-gradient); color: var(--accent-ink); font-size: 14px; font-weight: 900; box-shadow: 0 6px 16px rgba(157, 27, 29, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25); transition: transform var(--ease); }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.05); }

.sport-switch { display: grid; grid-auto-flow: column; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sport-switch a { padding: 7px 0; border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--fs-sm); font-weight: 800; letter-spacing: 0.06em; text-align: center; transition: background var(--ease), color var(--ease); }
.sport-switch a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.sport-switch a.active { background: var(--brand-gradient); color: var(--accent-ink); box-shadow: var(--shadow-sm); }

.side-nav { display: grid; gap: 2px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--fs-md); font-weight: 600; transition: background var(--ease), color var(--ease); }
.nav-link .icon { color: var(--text-3); transition: color var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link:hover .icon { color: var(--text-2); }
.nav-link.active { background: var(--accent-soft); color: var(--text); }
.nav-link.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-gradient); }
.nav-link.active .icon { color: var(--accent); }

.side-section { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.side-label { padding: 0 10px; color: var(--text-3); font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.side-watchlist { display: grid; gap: 1px; }
.side-watchlist a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--fs-sm); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-watchlist a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-watchlist img, .side-watchlist .dot { width: 18px; height: 18px; flex: none; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.side-empty { padding: 0 10px; color: var(--text-3); font-size: var(--fs-sm); }
.side-soon { display: grid; gap: 2px; margin-top: auto; }
.side-soon a, .side-soon span.soon-item { display: flex; justify-content: space-between; padding: 6px 10px; color: var(--text-3); font-size: var(--fs-sm); }
.side-soon small { color: var(--text-3); font-size: var(--fs-xs); opacity: 0.8; }

.main-col { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--topbar-bg);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
}

.nav-toggle { display: none; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; flex: 1; color: var(--text-3); font-size: var(--fs-sm); }
.crumbs a { color: var(--text-2); font-weight: 600; }
.crumbs a:hover { color: var(--text); }
.crumbs .crumb-sep { color: var(--border-strong); }
.crumbs [aria-current] { overflow: hidden; color: var(--text); font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }

.main-content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 24px 32px 48px; flex: 1; }

.app-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; padding: 14px 32px; border-top: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-sm); }
.app-footer kbd, .kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--text-2); font: 600 11px/16px var(--font); text-align: center; }

/* ---- global search -------------------------------------------------- */
.global-search { position: relative; width: min(440px, 42vw); }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--input-bg); box-shadow: var(--shadow-sm); transition: border-color var(--ease), box-shadow var(--ease); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .icon { color: var(--text-3); }
.search-box input { width: 100%; min-height: 38px; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: var(--fs-md); }
.search-box input::-webkit-search-cancel-button { filter: sepia(1) opacity(0.6); }
.search-box .kbd { flex: none; }

.search-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 40;
    width: min(520px, 92vw);
    max-height: min(70vh, 560px);
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--popover);
    box-shadow: var(--shadow);
}
.search-group-label { position: sticky; top: 0; padding: 8px 12px 4px; background: var(--popover); color: var(--text-3); font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.search-option { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 12px; color: var(--text); cursor: pointer; }
.search-option:hover, .search-option.active { background: var(--surface-3); text-decoration: none; color: var(--text); }
.search-option.active { box-shadow: inset 3px 0 0 var(--accent); }
.search-option img, .search-option .ph { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.search-option .ph { display: grid; place-items: center; color: var(--text-3); font-size: var(--fs-xs); font-weight: 800; }
.search-option .ph .icon { width: 16px; height: 16px; }
.search-option strong { display: block; overflow: hidden; font-size: var(--fs-md); white-space: nowrap; text-overflow: ellipsis; }
.search-option small { display: block; overflow: hidden; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; text-overflow: ellipsis; }
.search-option .stat-line { color: var(--text-2); font-size: var(--fs-sm); text-align: right; white-space: nowrap; }
.search-option .sport-badge { margin-left: 6px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font-size: 10px; font-weight: 800; vertical-align: 1px; }
.search-status { padding: 14px 12px; color: var(--text-3); font-size: var(--fs-sm); }
.search-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-xs); }
.search-foot a { font-weight: 700; }

/* ---- hover cards ---------------------------------------------------- */
.hovercard {
    position: absolute;
    z-index: 60;
    width: 300px;
    padding: 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--popover);
    box-shadow: var(--shadow);
    pointer-events: auto;
}
.hovercard-head { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 10px; }
.hovercard-head img, .hovercard-head .ph { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.hovercard-head strong { display: block; font-size: var(--fs-lg); }
.hovercard-head small { color: var(--text-3); font-size: var(--fs-sm); }
.hovercard dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; margin: 12px 0 0; }
.hovercard dt { color: var(--text-3); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; }
.hovercard dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.hovercard .note { margin-top: 10px; }

/* ---- responsive shell ----------------------------------------------- */
@media (max-width: 960px) {
    .sidebar { position: fixed; left: 0; z-index: 50; transform: translateX(-100%); transition: transform 180ms ease; box-shadow: var(--shadow); }
    body.nav-open .sidebar { transform: none; }
    .nav-scrim { position: fixed; inset: 0; z-index: 45; display: none; background: rgba(42, 28, 18, 0.45); }
    body.nav-open .nav-scrim { display: block; }
    .nav-toggle { display: inline-flex; }
    .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
    .crumbs { order: 1; }
    .global-search { order: 2; width: 100%; }
    .search-box .kbd { display: none; }
    .search-panel { left: 0; right: 0; width: auto; }
    .main-content { padding: 18px 16px 40px; }
    .app-footer { padding: 14px 16px; }
}

/* `hidden` must win over component display rules. */
[hidden] { display: none !important; }
