/* Site-wide v1 styles. Moved out of base.html (inline) on 2026-11-30 so browsers cache them across pages.
   Served versioned (static_url, web/static_assets.py): edit freely, the URL changes with the content. */
/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --green: #2D6A2E;
    --green-light: #3A8C3B;
    --green-dark: #1E4D1F;
    --white: #ffffff;
    --cream: #E8F0E0;
    --bg: #f8faf8;
    --text: #1a1a1a;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --blue: #2563eb;
    --red: #dc2626;
    --positive: #16a34a;
    --negative: #dc2626;
    --radius: 6px;
}

body {
    font-family: 'Space Grotesk', 'Space Grotesk Fallback', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Nav ── */
nav {
    background: var(--green-dark);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    /* Safe area for iOS status bar in standalone PWA mode */
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: content-box;
}

nav .logo {
    text-decoration: none;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
nav .logo img {
    height: 36px;
    width: auto;
}

/* ── Nav right group ── */
/* One right-aligned container for {auth links + mobile search trigger}
   in BOTH auth states — the container owns the alignment so neither
   child needs an auth-conditional margin. */
nav .nav-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Nav link groups ── */
nav .nav-links {
    display: flex;
    gap: 4px;
    list-style: none;
}

nav .nav-links a {
    color: var(--white);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 7px 12px;
    border-radius: var(--radius);
    opacity: 0.85;
    transition: opacity 0.2s, background 0.2s;
    white-space: nowrap;
}

nav .nav-links a:hover,
nav .nav-links a.nav-active {
    opacity: 1;
    background: rgba(255,255,255,0.12);
}

nav .nav-links .logout {
    opacity: 0.5;
    font-size: 10px;
}

/* ── "How this works" — standalone nav button, desktop only ── */
nav .nav-help-link {
    color: var(--white);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 7px 12px;
    border-radius: var(--radius);
    opacity: 0.85;
    transition: opacity 0.2s, background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
nav .nav-help-link:hover,
nav .nav-help-link.nav-active {
    opacity: 1;
    background: rgba(255,255,255,0.12);
}

/* Mobile-only "how rankings work" icon; desktop has the text link above */
nav .nav-help-icon { display: none; }

/* ── Account menu (signed-in, all widths) ── */
nav .nav-account-wrap {
    position: relative;
    flex-shrink: 0;
}
nav .nav-account-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Undo the generic button rule */
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    width: 44px;
    min-height: 44px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
nav .nav-account-btn:hover { background: none; transform: none; }
nav .nav-account-btn svg { opacity: 0.8; transition: opacity 0.15s; }
nav .nav-account-btn:hover svg,
nav .nav-account-btn[aria-expanded="true"] svg { opacity: 1; }
.nav-account-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 170px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    overflow: hidden;
}
.nav-account-menu.open { display: block; }
.nav-account-menu a {
    display: block;
    padding: 0.7rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
}
.nav-account-menu a:last-child { border-bottom: none; }
.nav-account-menu a:hover { background: #f0fdf4; }

/* ── Following menu (star, both auth states) ──
   Desktop: anchored dropdown. Phones: bottom sheet over a scrim. */
nav .nav-follow-wrap { position: relative; flex-shrink: 0; }
nav .nav-follow-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    /* Undo the generic button rule */
    background: none; border: none; border-radius: 0; padding: 0 8px;
    min-height: 44px; min-width: 44px; cursor: pointer; color: var(--white);
    font: inherit; font-size: 0.8rem; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}
nav .nav-follow-btn:hover { background: none; transform: none; }
nav .nav-follow-btn svg { opacity: 0.8; transition: opacity 0.15s; }
nav .nav-follow-btn:hover svg,
nav .nav-follow-btn[aria-expanded="true"] svg { opacity: 1; }
/* Text via ::after (aria-label names the button) so "Following" isn't
   a literal span that reads as a team page's follow state. */
nav .nav-follow-btn::after { content: "Following"; opacity: 0.85; }
.nav-follow-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    width: 330px; max-width: calc(100vw - 16px);
    background: var(--white); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999; overflow: hidden; color: var(--text);
}
.nav-follow-menu.open { display: block; }
.nav-follow-scrim { display: none; }
.nfm-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0.7rem 0.9rem 0.4rem; font-size: 0.85rem; font-weight: 700; }
.nfm-head span { font-size: 0.75rem; font-weight: 500; color: var(--text-light); }
.nfm-list { list-style: none; margin: 0; padding: 0; max-height: min(60vh, 360px); overflow-y: auto; }
.nfm-row { display: flex; align-items: center; gap: 10px; padding: 0.55rem 0.9rem; border-top: 1px solid #f0f0f0; text-decoration: none; color: var(--text); min-height: 52px; }
a.nfm-row:hover { background: #f0fdf4; }
.nfm-who { min-width: 0; flex: 1; }
.nfm-name { display: block; font-size: 0.85rem; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nfm-sub { display: block; font-size: 0.72rem; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nfm-star { color: #c98a10; margin-left: 4px; }
.nfm-rk { text-align: right; flex: none; line-height: 1.2; }
.nfm-rk b { display: block; font-size: 0.95rem; }
.nfm-mv { font-size: 0.72rem; font-weight: 600; }
.nfm-mv.up { color: var(--green); }
.nfm-mv.dn { color: var(--negative); }
.nfm-note { padding: 0.8rem 0.9rem; font-size: 0.85rem; color: var(--text-light); border-top: 1px solid #f0f0f0; }
.nfm-foot { display: flex; justify-content: space-between; gap: 12px; padding: 0.65rem 0.9rem; border-top: 1px solid #f0f0f0; font-size: 0.8rem; font-weight: 600; }
.nfm-foot a, .nfm-note a { color: var(--green); text-decoration: none; }
.nfm-foot a:hover, .nfm-note a:hover { text-decoration: underline; }
.nfm-upgrade { padding: 0.55rem 0.9rem; border-top: 1px solid #f0f0f0; font-size: 0.78rem; background: #f0fdf4; }
.nfm-upgrade a { color: var(--green-dark); font-weight: 700; text-decoration: none; }

/* ── Team search ── */
.nav-search-wrap {
    position: relative;
    flex-shrink: 0;
}
/* Desktop: search sits dead-center in the bar regardless of what's
   on either side (logo left, account links right). */
@media (min-width: 769px) {
    .nav-search-wrap {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
}
.nav-search-input {
    background: #2a4a2b !important;
    border: 1.5px solid rgba(255,255,255,0.5) !important;
    border-radius: var(--radius);
    color: #fff !important;
    font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif;
    font-size: 13px;
    padding: 7px 10px 7px 30px;
    width: 210px;
    outline: none;
    transition: background 0.2s, width 0.2s, border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}
.nav-search-input::placeholder { color: rgba(255,255,255,0.7) !important; }
.nav-search-input:focus {
    background: #345c35 !important;
    width: 250px;
    border-color: rgba(255,255,255,0.85) !important;
}
/* Prevent browsers from overriding the autofill background to white */
.nav-search-input:-webkit-autofill,
.nav-search-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #2a4a2b inset !important;
    -webkit-text-fill-color: #fff !important;
}
.nav-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.5;
}
.nav-search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 260px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    overflow: hidden;
}
.nav-search-dropdown.open { display: block; }
.nav-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
}
.nav-search-item:last-child { border-bottom: none; }
.nav-search-item:hover, .nav-search-item.focused { background: #f0fdf4; }
.nav-search-item-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.nav-search-item-div  { font-size: 0.72rem; color: var(--text-light); }
/* Season chip: only rendered when a row needs explaining (a team from a
   season that hasn't started). Deliberately quiet — it is a caption, not
   a warning. The row is still a real team and still clickable; it just
   has no record yet, and saying so beats letting it read as a dead end. */
.nav-search-item-season {
  display: inline-block; margin-left: 0.4rem; padding: 0 0.32rem;
  border-radius: 3px; background: #eef0ee; color: #6b7280;
  font-size: 0.68rem; line-height: 1.5; vertical-align: baseline;
}
.nav-search-item.is-upcoming .nav-search-item-name { color: var(--text-light); font-weight: 500; }
.nav-search-empty { padding: 0.75rem 0.9rem; font-size: 0.85rem; color: var(--text-light); }

/* ── Mobile search overlay ── */
.mobile-search {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: var(--white);
    flex-direction: column;
}
.mobile-search.open { display: flex; }
.mobile-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--green-dark);
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
}
.mobile-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: var(--radius);
    padding: 11px 14px;
    /* 16px minimum so iOS doesn't zoom the focused field */
    font-size: 16px;
    font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif;
    background: var(--white);
    color: var(--text);
    outline: none;
}
.mobile-search-cancel {
    background: none;
    border: none;
    color: var(--white);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none;
    padding: 10px 8px;
    width: auto;
    min-height: 44px;
}
.mobile-search-cancel:hover { background: none; transform: none; }
.mobile-search-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.mobile-search-results .nav-search-item { padding: 14px 16px; }
.mobile-search-results .nav-search-item-name { font-size: 1rem; }
.mobile-search-results .nav-search-item-div { font-size: 0.8rem; }
.mobile-search-hint {
    padding: 1.25rem 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
}

/* Top-bar search trigger (both auth states) — mobile only; desktop shows the inline box */
.nav-search-open { display: none; }

/* ── Main ── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Typography ── */
h1, h2, h3, h4 {
    font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif;
    font-weight: 600;
    color: var(--text);
}

h2 { font-size: 1.6rem; margin-bottom: 1.25rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h4 { font-size: 1rem; margin-bottom: 0.5rem; }

small { color: var(--text-light); font-size: 0.85rem; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── Forms ── */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.3rem;
}

select, input[type="text"]:not(.nav-search-input):not(.mobile-search-input), input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif;
    font-size: 14px;
    background: var(--white);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

select:focus, input:focus {
    border-color: var(--green);
}

button, .cta-btn {
    display: inline-block;
    padding: 12px 28px;
    background: var(--green);
    color: var(--white);
    font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    width: 100%;
    text-align: center;
}

button:hover, .cta-btn:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
}

/* ── Grid ── */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Flash ──
   One shape, three tones. flash() must pass a category ("success",
   "info", "error"); anything else falls back to the neutral info tone
   rather than shouting red at what may be good news. */
.flash {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash-success {
    background: #f0fdf4;
    color: #15803d;
    border-color: #86efac;
}
.flash-info {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}
.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--white);
}

.stat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.stat-table th {
    background: var(--green-dark);
    color: var(--white);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.6rem 0.7rem;
    text-align: right;
    white-space: nowrap;
    position: sticky;
    top: 0;
    transition: background 0.15s;
}
.stat-table th:hover {
    background: var(--green-light);
}

.stat-table th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
}

.stat-table td {
    padding: 0.5rem 0.7rem;
    text-align: right;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.stat-table td:first-child {
    text-align: left;
    font-weight: 500;
    position: sticky;
    left: 0;
    background: var(--white);
    z-index: 1;
}

.stat-table tbody tr:hover {
    background: #f0faf0;
}

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

/* ── Win Bar ── */
.win-bar {
    display: flex;
    height: 2.2rem;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 0.5rem 0;
}

.win-bar-a {
    background: var(--blue);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.win-bar-b {
    background: var(--red);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ── Badges ── */
.seed-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green);
    color: var(--white);
    border-radius: 50%;
    width: 1.6rem;
    height: 1.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 0.3rem;
}

.advantage {
    display: inline-block;
    background: var(--cream);
    color: var(--green-dark);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    margin: 0.1rem;
}

.div-badge {
    display: inline-block;
    background: var(--cream);
    color: var(--green-dark);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
}

/* ── Bracket ── */
.round-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.matchup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.champion-box {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

/* ── Utility ── */
.positive { color: var(--positive); font-weight: 600; }
.negative { color: var(--negative); font-weight: 600; }

details summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ── Hide on mobile ── */
@media (max-width: 768px) {
    .col-hide-mobile { display: none !important; }
    /* Footer links are ~20px tall inline text; give thumbs a 44px target */
    footer a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.25rem; }
}

/* ── Narrow desktop / small laptop (tightens nav so Logout doesn't clip) ── */
@media (min-width: 769px) and (max-width: 1280px) {
    nav { padding: 0 1rem; gap: 0.7rem; }
    .nav-search-input { width: 160px; }
    .nav-search-input:focus { width: 200px; }
    nav .nav-links { gap: 2px; }
    nav .nav-links a { padding: 7px 9px; }
}

/* ── Mobile ── */
@media (max-width: 768px) {
    nav {
        /* Scrolls away with content — no fixed chrome on mobile;
           the header search trigger is the way back to search. */
        position: static;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
        padding-bottom: 0;
        /* padding-top inherits env(safe-area-inset-top) from base nav rule */
        height: 52px;
        flex-wrap: nowrap;
        gap: 0.5rem;
        align-items: center;
    }

    nav .logo { font-size: 18px; flex-shrink: 0; }

    /* Hide desktop nav elements on mobile */
    nav .nav-links { display: none; }
    nav .nav-help-link { display: none; }
    nav .nav-help-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        min-height: 44px;
        flex-shrink: 0;
    }
    .nav-search-wrap { display: none; }

    /* Following: icon only, menu becomes a bottom sheet */
    nav .nav-follow-btn::after { content: none; }
    nav .nav-follow-btn { width: 44px; padding: 0; }
    .nav-follow-menu {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto;
        width: auto; max-width: none; border-radius: 16px 16px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .nav-follow-menu.open ~ .nav-follow-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 9998; }

    /* Anonymous visitors keep their auth links visible */
    nav .nav-links.anon-links { display: flex; gap: 4px; }
    nav .nav-links.anon-links a { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
    /* Sign Up is desktop-only (founder call 2026-10-04): the sign-in
       page offers "Create an account", and dropping it is what lets
       the full wordmark fit beside search + Sign In on a phone. */
    nav .nav-links.anon-links .nav-signup { display: none; }

    /* Search trigger, both states (undo the generic button rule) */
    .nav-search-open {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: 0;
        padding: 0;
        width: 44px;
        min-height: 44px;
        flex-shrink: 0;
    }
    .nav-search-open:hover { background: none; transform: none; }

    main {
        padding: 1rem 0.85rem;
    }

    h2 { font-size: 1.2rem; }

    .grid { grid-template-columns: 1fr !important; }

    /* Larger, easier-to-read table cells outdoors */
    .stat-table th {
        padding: 0.6rem 0.65rem;
        font-size: 0.8rem;
    }
    .stat-table td {
        padding: 0.75rem 0.65rem;
        font-size: 0.95rem;
        min-height: 48px;
    }
    /* Sticky first column gets stronger background so it doesn't bleed */
    .stat-table td:first-child {
        background: #fff;
        box-shadow: 2px 0 4px rgba(0,0,0,0.06);
    }

    .matchup-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .champion-box { padding: 1rem; }
    .champion-box h2 { font-size: 1.3rem; }
    .champion-box p { font-size: 0.85rem; }
}
