/* ===== Chrome =====
 * App-shell elements shared across sports: base typography, sticky header,
 * pill nav, settings drawer, acrylic page-header, flash messages. Loaded
 * after tokens.css; before per-sport sheets so sport sheets can override
 * individual selectors if they need to.
 */

/* ---- View Transitions (Chrome 126+ / Safari 18+) ----
 * Cross-document opt-in: navigations between same-origin pages animate
 * automatically. Server-side rendering is unchanged — the browser
 * snapshots before and after, then morphs paired elements + cross-fades
 * the rest. Browsers without support just do a normal page load.
 *
 * Two named elements pair across navigations:
 *   top-nav      — the outer nav row stays visually still
 *   active-pill  — the highlighted pill morphs from old page's pill
 *                  to new page's pill (the "slide" effect)
 * Everything else cross-fades as part of the default root transition.
 */
@view-transition { navigation: auto; }

.content > header > nav { view-transition-name: top-nav; }
header nav .nav-pills a.active { view-transition-name: active-pill; }

/* Same morph trick for any in-page chip-switcher row — opt in by adding
 * a marker class alongside .centered-buttons (e.g. .prop-switcher). The
 * active .button.on element gets paired across navigations and slides
 * from one chip to the next. Use a different name per switcher class
 * so multiple switchers on the same page can coexist. */
.prop-switcher .button.on { view-transition-name: prop-pill; }

/* ---- Base elements ---- */
html {
    font-family: var(--font-sans);
    color: var(--color-text-primary);
    /* Crop horizontal overflow on both html and body so off-screen fixed
     * elements (the closed .menu-drawer in particular) can't extend the
     * document scroll width and break position:sticky on the nav header.
     * `overflow: clip` is the right tool here — it crops without
     * establishing a scroll container, which `hidden` would do (and
     * `hidden` ALSO breaks sticky on descendants). */
    overflow-x: clip;
}

body {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 var(--content-padding) 12px var(--content-padding);
    background: var(--color-bg-primary);
    overflow-x: clip;
}

a {
    color: var(--color-link);
    text-decoration: none;
}

hr {
    border: none;
    border-top: 1px solid var(--color-border-strong);
}

/* ---- Sticky header ----
 * Outer .content > header is sticky and TRANSPARENT so the .page-header
 * banner inside it can show blurred scrolling content beneath. The nav
 * row itself is OPAQUE — it sits at the very top and pinning it solid
 * keeps the pill bar legible while content scrolls under the page-header.
 */
.content > header {
    background-color: transparent;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 3;
}

.content > header > nav {
    padding: 16px var(--content-padding);
    margin: 0 calc(-1 * var(--content-padding));
    background: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border-acrylic);
}

/* ---- Page-header banner (acrylic) ----
 * Lives below the nav row, holds the page header (components/header.html,
 * styled in components.css "Page header"). Translucent + backdrop-blur so
 * scrolling content shows through with frosting.
 */
.page-header {
    display: flex;
    margin: 0 calc(-1 * var(--content-padding));
    padding: 6px var(--content-padding);
    background: var(--bg-acrylic);
    -webkit-backdrop-filter: var(--blur-acrylic);
    backdrop-filter: var(--blur-acrylic);
    border-bottom: 1px solid var(--color-border-acrylic);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .page-header { background: var(--color-bg-tertiary); }
}

/* ---- Nav layout (header > nav > div container) ----
 * Plain flex with space-between: sport icon at left edge, burger at
 * right edge, pill bar takes its natural width and sits in the middle.
 * Page-level padding handles the outer breathing room — no negative
 * margins needed.
 */
header nav > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: transparent;
    border: none;
    padding: 0;
}

/* ---- Sport indicator (bare emoji glyph at the left edge) ----
 * No chrome: no blur background, no bordered container. The emoji's
 * own color glyph carries enough visual weight on its own. */
.sport-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: var(--text-4xl);
    color: var(--color-text-primary);
}

/* ---- Pill nav (Jimmy's pill bar) ---- */
header nav .nav-pills {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px;
    background: var(--bg-acrylic-strong);
    -webkit-backdrop-filter: var(--blur-acrylic);
    backdrop-filter: var(--blur-acrylic);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

header nav .nav-pills a {
    padding: 8px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--text-3xl);
    line-height: 1;
    color: var(--color-accent);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    margin-right: 0;
}

header nav .nav-pills a:hover {
    background: var(--color-accent-bg-soft);
}

header nav .nav-pills a.active {
    background: var(--color-accent);
    color: var(--color-bg-primary);
}

/* ---- Hamburger menu button (round chrome button in nav row) ----
 * Sized just slightly under the .sport-pill / .nav-pills height — the
 * heavier 2px border on this one already adds visual weight, so trim
 * a couple pixels off the padding to prevent it dominating the nav. */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 2px solid var(--color-border-strong);
    border-radius: 50%;
    padding: 12px;
    line-height: 1;
    color: var(--color-text-secondary);
    font-size: var(--text-3xl);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.menu-toggle:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

/* ---- Settings drawer + backdrop ----
 * Drawer slides in from the right when .menu-toggle is clicked. Backdrop
 * dims the page behind it; clicking it closes the drawer (handled in
 * site.js). Both are fixed-position so they cover the sticky header.
 */
.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 40;
}

.menu-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.menu-drawer {
    /* Slide via `right` rather than `transform: translateX(100%)`. A
     * transformed fixed element's bounding box can extend the document's
     * scrollWidth in some browsers, which then breaks position:sticky on
     * the nav header. Animating `right` keeps the drawer wholly outside
     * the layout when closed. */
    --drawer-w: min(560px, 100vw);
    position: fixed;
    top: 0;
    right: calc(-1 * var(--drawer-w));
    height: 100vh;
    width: var(--drawer-w);
    background: var(--bg-acrylic-strong);
    -webkit-backdrop-filter: var(--blur-acrylic-strong);
    backdrop-filter: var(--blur-acrylic-strong);
    border-left: 1px solid var(--color-border-acrylic);
    transition: right 0.25s ease-out;
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .menu-drawer { background: var(--color-bg-secondary); }
}

.menu-drawer.open {
    right: 0;
}

.menu-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-acrylic);
}

.menu-drawer-header h2 {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-text-primary);
}

.menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    padding: 8px;
    line-height: 1;
    color: var(--color-text-secondary);
    font-size: var(--text-xl);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.menu-close:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.menu-drawer-body {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.menu-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: none;
    border: none;
    text-align: left;
    text-decoration: none;
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-2xl);
    cursor: pointer;
    transition: background 0.15s;
}

.menu-row:hover {
    background: var(--color-accent-bg-soft);
}

.menu-row .icon,
.menu-row-emoji {
    font-size: var(--text-3xl);
    color: var(--color-text-secondary);
    line-height: 1;
    text-align: center;
}

.menu-row-label {
    flex: 1;
}

/* ---- Site search (settings drawer + home page) ----
 * Typeahead over players/teams across sports (common/search.js +
 * /search/api). Results render inline below the input — no absolute
 * dropdown — so they behave in the scrollable drawer and on the home
 * page alike. */
.site-search {
    position: relative;
}

.menu-drawer .site-search {
    padding: 16px 24px 8px;
}

.site-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 16px 22px;
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    color: var(--color-text-primary);
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
}

.site-search input:focus {
    outline: 2px solid var(--color-accent);
    border-color: transparent;
}

.search-results {
    display: none;
}

.search-results.open {
    display: block;
    padding: 4px 0;
}

.menu-drawer .search-results.open {
    padding: 4px 24px 12px;
}

.search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.search-row:last-child {
    border-bottom: none;
}

.search-row-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none;
}

.search-row-emoji {
    font-size: var(--text-lg);
    line-height: 1;
}

.search-row-name {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-link);
}

.search-row-sub {
    font-size: var(--text-md);
    color: var(--color-text-tertiary);
    white-space: nowrap;
}

.search-row-chips {
    display: flex;
    gap: 8px;
}

.search-chip {
    font-size: var(--text-md);
    color: var(--color-link);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    padding: 4px 14px;
    text-decoration: none;
    white-space: nowrap;
}

.search-chip:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-bg-primary);
}

.search-empty {
    color: var(--color-text-tertiary);
    font-size: var(--text-sm);
    padding: 10px 0;
}

/* ---- Flash messages ---- */
.flash {
    margin: 1em 0;
    padding: 1em;
    background: var(--color-flash-bg);
    border: 1px solid var(--color-flash-border);
}

/* ---- Font utilities ---- */
.icon {
    font-family: var(--font-icon);
}

.mono {
    font-family: var(--font-mono);
}

/* ---- Acrylic utility (opt-in for sticky/overlay surfaces) ---- */

/* ---- Responsive ---- */
@media (max-width: 767px) {
    body {
        padding: 0 12px 12px 12px;
    }

    .content > header > nav {
        padding: 12px 12px;
        margin: 0 -12px;
    }

    /* Hide the sport icon on narrow screens so the pill bar + burger
     * always fit. The drawer's "Switch to {sport}" row preserves the
     * affordance for sport-aware users on phones. */
    header nav > div > .sport-pill { display: none; }

    header nav .nav-pills a {
        font-size: var(--text-sm);
        padding: 8px 14px;
    }
}

/* Standalone cross-sport pages (home.html, login.html, xsport/ledger.html): the shell they share. */
.home-wrapper { margin: 0 auto; max-width: 1200px; padding: 0.75rem 1rem 2rem; }
.home-title { font-size: var(--text-3xl); margin: 0.25rem 0 0; text-align: center; }
.home-quote { color: var(--color-text-tertiary); font-size: var(--text-md); font-style: italic; margin: 0.5rem 0 1.5rem; text-align: center; }
.home-search { margin: 0 auto 1.5rem; max-width: 640px; }
/* Single column on phones (no viewport meta site-wide -> ~980px virtual
 * width); side-by-side cards only on genuinely wide screens. */
.home-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .home-grid { grid-template-columns: repeat(3, 1fr); } }
.sport-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.sport-card-title {
    align-items: center;
    color: var(--color-text-primary);
    display: flex;
    font-size: var(--text-xl);
    font-weight: 600;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}
.sport-links { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
.sport-links a.button { margin: 0; padding: 24px 8px; }
.sport-links a.button.primary { grid-column: 1 / -1; }

/* Login page (/login) */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}
.login-box {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-md);
}
.login-box h1 {
    font-size: var(--text-lg);
    margin: 0 0 1.5rem 0;
    text-align: center;
    color: var(--color-text-primary);
}
.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    box-sizing: border-box;
}
.login-box input[type="text"] {
    margin-bottom: 0.6rem;
}
.login-box input[type="text"]:focus,
.login-box input[type="password"]:focus {
    outline: 2px solid var(--color-accent);
    border-color: transparent;
}
.login-box button {
    width: 100%;
    padding: 0.6rem;
    margin-top: 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-accent);
    color: var(--color-on-strong);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
}
.login-box button:hover {
    opacity: 0.9;
}
.login-error {
    color: var(--color-lose-strong);
    font-size: var(--text-xs);
    margin-top: 0.75rem;
    text-align: center;
}
