/* Pine Tar Press — Router, Home, Site-Wide Chat, Mobile Polish
   Loaded after style.css and trade_builder.css so it can override where needed. */

/* =====================================================
   HOME PAGE
   ===================================================== */
.home-section {
    padding: 20px 0 60px;
    background: var(--color-bg, #0a1a2f);
}
.home-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    align-items: start;
}
.home-main { min-width: 0; }

/* HERO */
.home-hero {
    background: linear-gradient(135deg, #0d2340 0%, #123a68 100%);
    border-radius: 14px;
    padding: 28px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.home-hero__inner { position: relative; z-index: 2; }
.home-hero__label {
    display: inline-block;
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 2px;
    font-size: 13px;
    color: #ffc32b;
    background: rgba(255,195,43,0.12);
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 18px;
}
.home-hero__scoreboard {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
}
.home-hero__team { text-align: center; }
.home-hero__abbr {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 42px;
    line-height: 1;
    color: #fff;
    letter-spacing: 1px;
}
.home-hero__team-name {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    margin-top: 4px;
    letter-spacing: 0.5px;
}
.home-hero__score {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 52px;
    line-height: 1;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}
.home-hero__num { color: #fff; }
.home-hero__dash { color: rgba(255,255,255,0.35); }
.home-hero__vs {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 26px;
    color: rgba(255,255,255,0.5);
}
.home-hero__inning {
    text-align: center;
    font-size: 13px;
    color: #86e6ff;
    letter-spacing: 1px;
    margin-bottom: 14px;
    text-transform: uppercase;
    font-weight: 600;
}
.home-hero__cta {
    display: inline-block;
    background: #ffc32b;
    color: #0a1a2f;
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    letter-spacing: 0.5px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.home-hero__cta:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255,195,43,0.35); }
.home-hero__empty, .home-hero__loading {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255,255,255,0.7);
}
.home-hero__empty a { color: #ffc32b; }

/* HEADLINES */
.home-headlines {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 22px;
}
.home-headlines__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.home-headlines__title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 2px;
    color: #fff;
    margin: 0;
}
.home-headlines__more {
    font-size: 12px;
    color: #ffc32b;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.home-headlines__list { display: flex; flex-direction: column; }
.home-headline {
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-decoration: none;
    display: block;
    transition: background 0.15s ease;
}
.home-headline:last-child { border-bottom: none; }
.home-headline:hover { background: rgba(255,255,255,0.02); }
.home-headline__source {
    font-size: 11px;
    color: #86e6ff;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
}
.home-headline__title {
    color: #fff;
    font-size: 15px;
    line-height: 1.4;
    font-weight: 500;
}

/* BEAT FEED RAIL */
.home-rail {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 18px;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}
.home-rail__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.home-rail__title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    letter-spacing: 2px;
    color: #fff;
    margin: 0;
}
.home-rail__live {
    font-size: 10px;
    color: #4ade80;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}
.home-rail__dot {
    width: 6px; height: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: rail-pulse 2s ease-in-out infinite;
}
@keyframes rail-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.home-rail__list { display: flex; flex-direction: column; gap: 12px; }
.home-rail__item {
    padding: 12px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.05);
    transition: border-color 0.15s ease;
}
.home-rail__item:hover { border-color: rgba(255,195,43,0.4); }
.home-rail__meta {
    display: flex;
    gap: 6px;
    font-size: 11px;
    margin-bottom: 6px;
    align-items: baseline;
    flex-wrap: wrap;
}
.home-rail__author { color: #fff; font-weight: 600; }
.home-rail__handle { color: rgba(255,255,255,0.5); }
.home-rail__time { color: rgba(255,255,255,0.45); margin-left: auto; font-size: 10px; }
.home-rail__text {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.home-rail__loading, .home-headlines__loading, .home-empty {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

/* =====================================================
   SITE-WIDE CHAT OVERLAY
   ===================================================== */
.site-chat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ffc32b;
    color: #0a1a2f;
    border-radius: 999px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    font-weight: 700;
    font-size: 14px;
    z-index: 1001; /* Above sticky nav */
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: none;
}
.site-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.site-chat-fab__label { letter-spacing: 0.5px; }

.site-chat-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 40px);
    background: #0d1e38;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    z-index: 10050; /* Above sticky nav (1000) and modal (10000) */
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
}
.site-chat-overlay__header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 14px 14px 18px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.site-chat-overlay__grabber {
    display: none; /* Only visible on mobile as swipe hint */
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.25);
}
.site-chat-overlay__title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
}
.site-chat-overlay__dot {
    width: 8px; height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 8px #4ade80;
}
.site-chat-overlay__close {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    line-height: 1;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    min-height: 36px;
    transition: background 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: rgba(255,255,255,0.15);
}
.site-chat-overlay__close:hover {
    background: rgba(255,107,107,0.20);
    border-color: rgba(255,107,107,0.5);
    color: #fff;
}
.site-chat-overlay__close:active { transform: scale(0.96); }
.site-chat-overlay__close-label { display: inline; }
.site-chat-overlay__body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.site-chat-overlay__body #chat-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
}
.site-chat-overlay__body .chat-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.site-chat-overlay__body .chat-room__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}
.site-chat-overlay__body .chat-gate { padding: 24px 20px; text-align: center; }
.site-chat-overlay__loading { color: rgba(255,255,255,0.6); padding: 30px; text-align: center; font-size: 14px; }

/* =====================================================
   NAV ADJUSTMENTS FOR ROUTER
   ===================================================== */
.nav-link.active {
    color: #ffc32b !important;
    position: relative;
}
.nav-link.active::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -6px;
    width: 22px;
    height: 2px;
    background: #ffc32b;
    border-radius: 2px;
}

/* =====================================================
   MOBILE (≤ 768px) — priority polish
   ===================================================== */
@media (max-width: 900px) {
    .home-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .home-rail {
        position: static;
        max-height: none;
        order: 3;
    }
}
@media (max-width: 640px) {
    .home-section { padding: 12px 0 40px; }
    .home-hero { padding: 18px 16px; border-radius: 12px; margin-bottom: 14px; }
    .home-hero__label { font-size: 11px; margin-bottom: 12px; }
    .home-hero__abbr { font-size: 30px; }
    .home-hero__team-name { display: none; } /* keep hero compact on mobile */
    .home-hero__score { font-size: 38px; }
    .home-hero__cta { display: block; text-align: center; padding: 12px; font-size: 14px; }
    .home-headlines { padding: 16px; border-radius: 12px; }
    .home-headlines__title { font-size: 18px; }
    .home-headline { padding: 12px 0; }
    .home-headline__title { font-size: 14px; }
    .home-rail { padding: 14px; border-radius: 12px; }
    .home-rail__title { font-size: 16px; }
    .home-rail__text { font-size: 12px; -webkit-line-clamp: 3; }

    /* Chat overlay becomes full-screen on mobile */
    .site-chat-overlay {
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
    /* Show grabber as swipe-down affordance */
    .site-chat-overlay__grabber { display: block; }
    .site-chat-overlay__header {
        padding: 20px 14px 12px 18px;
        min-height: 60px;
    }
    /* Big, obvious close button on mobile */
    .site-chat-overlay__close {
        padding: 10px 14px;
        min-height: 44px;
        font-size: 14px;
        background: rgba(255,107,107,0.18);
        border-color: rgba(255,107,107,0.4);
    }
    /* Lock body scroll behind full-screen chat */
    body.site-chat-open { overflow: hidden; }
    .site-chat-fab {
        bottom: 14px;
        right: 14px;
        padding: 12px 16px;
    }
    .site-chat-fab__label { display: none; } /* icon-only pill on mobile */
    .site-chat-fab {
        width: 52px;
        height: 52px;
        padding: 0;
        justify-content: center;
    }
}

/* =====================================================
   TRADE BUILDER — Mobile screenshot-friendly grade panel
   Goal: entire per-team grade card (name, composite, letter, verdict, blurb)
   fits into ~380px of vertical space so both teams' cards + title fit on one
   mobile screen for a screenshot.
   ===================================================== */
@media (max-width: 700px) {
    .tb-section { padding: 16px 0 40px !important; }
    .tb-page { padding: 0 12px !important; }

    /* TRADE GRADE panel container */
    .tb-grade {
        padding: 12px !important;
        margin-top: 12px !important;
        border-radius: 12px !important;
    }
    .tb-grade__title {
        font-size: 18px !important;
        margin-bottom: 4px !important;
        letter-spacing: 0.06em !important;
    }
    .tb-grade__note {
        font-size: 12px !important;
        margin-bottom: 10px !important;
        line-height: 1.35 !important;
    }

    /* Stack team cards vertically — easier to read on phone, still fits screenshot */
    .tb-grade__teams {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .tb-grade__team {
        padding: 10px 12px !important;
        border-radius: 10px !important;
    }

    /* Team header row: compact team name + verdict pill inline */
    .tb-grade__team-head {
        margin-bottom: 6px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }
    .tb-grade__team-title,
    .tb-grade__team-name {
        font-size: 15px !important;
        letter-spacing: 0.04em !important;
        margin: 0 !important;
    }
    .tb-grade__mode-chip {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
    .tb-grade__tier-badge {
        font-size: 10px !important;
        padding: 3px 8px !important;
    }

    /* Composite + letter side by side, compact */
    .tb-grade__score-row {
        gap: 12px !important;
        margin: 6px 0 4px !important;
        padding: 8px 10px !important;
    }
    .tb-grade__composite-num {
        font-size: 26px !important;
        line-height: 1 !important;
    }
    .tb-grade__composite-lbl {
        font-size: 9px !important;
        letter-spacing: 0.08em !important;
    }
    .tb-grade__score-row .tb-grade__grade,
    .tb-grade__letter {
        font-size: 34px !important;
        line-height: 1 !important;
    }

    /* The 5 metric factor bars — hide by default; keep collapsible via details tag if present */
    .tb-grade__factors {
        display: none !important;
    }
    /* If user wants details, they can tap a "details" toggle */
    details.tb-grade__factors-details .tb-grade__factors {
        display: flex !important;
        gap: 3px !important;
        margin-top: 6px !important;
    }
    .tb-grade__factor-head { font-size: 10px !important; }
    .tb-grade__factor-label { font-size: 10px !important; }
    .tb-grade__factor-val { font-size: 10px !important; }
    .tb-grade__factor-bar { height: 4px !important; }

    /* Verdict blurb — full text, compact type */
    .tb-grade__verdict {
        font-size: 12px !important;
        line-height: 1.4 !important;
        margin-top: 6px !important;
        padding: 8px 10px !important;
    }

    .tb-grade__context {
        font-size: 10px !important;
        margin-top: 4px !important;
        gap: 6px !important;
    }

    .tb-grade__notes,
    .tb-grade__note-item {
        font-size: 10px !important;
        padding: 5px 8px !important;
        margin-top: 4px !important;
        line-height: 1.3 !important;
    }

    .tb-grade__footer {
        margin-top: 10px !important;
        padding-top: 8px !important;
        font-size: 10px !important;
    }

    /* Player pill compaction — keep contract row visible but compact */
    .tb-pill { padding: 10px !important; border-radius: 8px !important; }
    .tb-pill__name { font-size: 13px !important; }
    .tb-pill__meta { font-size: 11px !important; }
    .tb-pill__row { gap: 3px 8px !important; font-size: 11px !important; }
}

/* Slightly reduced compaction for tablet */
@media (min-width: 701px) and (max-width: 900px) {
    .tb-grade__letter,
    .tb-grade__score-row .tb-grade__grade { font-size: 46px !important; }
    .tb-grade__composite-num { font-size: 32px !important; }
}

/* =====================================================
   GENERAL MOBILE POLISH — nav & sections
   ===================================================== */
@media (max-width: 640px) {
    .nav-inner { padding: 10px 14px; }
    .nav-logo { font-size: 15px; letter-spacing: 1px; }
    .section { padding: 24px 0; }
    .section-title { font-size: 24px; letter-spacing: 1px; }
    .section-subtitle { font-size: 12px; }
    .container { padding: 0 14px; }
    /* Give section headers breathing room below the scoreboard ticker */
    .section-header { padding-top: 8px; }
    /* Push content below scoreboard ticker so headings don't collide */
    .scoreboard-ticker-bar, .ticker, [class*="ticker"] { z-index: 40; }
    .tb-grade__title { padding-top: 4px; }
}

/* ============================================================
   FEATURED WHEELHOUSE CARD — pinned to top of headlines
   ============================================================ */
.home-headline-hero {
    display: block;
    text-decoration: none;
    color: inherit;
    background: linear-gradient(180deg, rgba(0, 184, 189, 0.10), rgba(12, 35, 64, 0.15));
    border: 1px solid rgba(0, 184, 189, 0.35);
    border-radius: 12px;
    overflow: hidden;
    margin: -4px -4px 16px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.home-headline-hero:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(0, 184, 189, 0.15);
    border-color: rgba(0, 184, 189, 0.6);
}
.home-headline-hero__img {
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    background-color: rgba(0, 0, 0, 0.35);
}
.home-headline-hero__body {
    padding: 14px 16px 16px;
}
.home-headline-hero__source {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.home-headline-hero__badge {
    background: #ffc32b;
    color: #0a1a2f;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 800;
    letter-spacing: 0.12em;
}
.home-headline-hero__source-name {
    color: #4dd9de;
    font-weight: 700;
}
.home-headline-hero__title {
    font-family: var(--font-display, 'Bebas Neue', sans-serif);
    color: #fff;
    font-size: 20px;
    line-height: 1.15;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}
.home-headline-hero__excerpt {
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 640px) {
    .home-headline-hero { margin: -2px -2px 12px; border-radius: 10px; }
    .home-headline-hero__body { padding: 12px 14px 14px; }
    .home-headline-hero__title { font-size: 18px; }
    .home-headline-hero__excerpt { font-size: 12.5px; -webkit-line-clamp: 2; }
    .home-headline-hero__badge { font-size: 10px; padding: 2px 7px; }
}
