/*
 * Home page: today's games as boxes (layout from the user's reference: dark header bar with a time pill,
 * light body with logos, names and records split by a divider, season stats underneath).
 * Unlike the board, this page scrolls and works at any width.
 */
:root {
    --page: #0b0e13;
    --page-ink: #f4f6f8;
    --page-muted: #8b95a1;
    --card: #eef1f5;
    --card-head: #262c3a;
    --ink: #1d2330;
    --muted: #5c6574;
    --rule: #c9d0d9;
    --live: #d61f2c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--page-ink);
    font-family: 'Inter', system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

.masthead {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 24px 8px;
}
/* The white hockeynerd logo, as on the board's top bar; links back to today */
.brand { justify-self: start; display: block; line-height: 0; border-radius: 6px; }
.brand img { display: block; height: 40px; width: auto; }
.brand:focus-visible { outline: 2px solid var(--page-ink); outline-offset: 4px; }

.day { text-align: center; }
/* ‹ date › 📅. The title keeps a fixed width so the buttons stay put as the date's length changes */
.day-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.day h1 {
    margin: 0;
    min-width: 13.4em; /* "Wednesday, September 30", the longest date */
    font-size: 26px;
    font-weight: 700;
    white-space: nowrap;
}
.day h1 .short { display: none; }
.nav-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--page-ink);
    background: #161c24;
    border: 1px solid #263040;
    border-radius: 8px;
    cursor: pointer;
}
.nav-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-button svg.filled { fill: currentColor; stroke: none; }
.nav-button:hover, .nav-button:focus-visible { border-color: var(--page-ink); outline: none; }
.nav-button:disabled { opacity: 0.35; cursor: default; border-color: #263040; }
/* The calendar button opens the browser's own date picker. Its input lies invisible over the button, so a tap on a
   phone lands on the input itself: iOS Safari won't open the picker for a script on a hidden input. */
.calendar { position: relative; display: inline-flex; margin-left: 4px; }
.calendar input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    font-size: 16px; /* under 16px, iOS zooms the page on focus */
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.calendar:hover .nav-button { border-color: var(--page-ink); }
.day-note {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--page-muted);
}
.day-note a, .empty a { color: var(--page-ink); font-weight: 600; text-underline-offset: 3px; }
.day-note a:hover, .empty a:hover { text-decoration-thickness: 2px; }
.my-team {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.my-team-button,
.my-board {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font: 600 14px 'Inter', sans-serif;
    color: var(--page-ink);
    text-decoration: none;
    background: #161c24;
    border: 1px solid #263040;
    border-radius: 8px;
    cursor: pointer;
}
.my-board[hidden] { display: none; }
.my-board img { width: 22px; height: 22px; object-fit: contain; }
.my-team-button:hover, .my-team-button:focus-visible,
.my-board:hover, .my-board:focus-visible { border-color: var(--page-ink); outline: none; }

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px 48px;
}
.games {
    transition: opacity 0.15s;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 410px), 1fr));
    gap: 18px;
}
.games.loading { opacity: 0.45; }
.empty {
    margin: 48px 0;
    text-align: center;
    font-size: 17px;
    color: var(--page-muted);
}

/* --- A game box --- */
.game {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ink);
    text-decoration: none;
    background: var(--card);
    border-radius: 12px;
    outline: 3px solid transparent;
    outline-offset: -1px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
/* My team's box: header bar in the team's colour */
.game.mine .game-head { background: var(--mine); }
.game:hover,
.game:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    outline-color: rgba(255, 255, 255, 0.65);
}

.game-head {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 10px 12px;
    background: var(--card-head);
}
.mine-tag {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    padding: 3px 7px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.4);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ffffff;
}
.pill {
    padding: 5px 14px;
    border-radius: 7px;
    background: #ffffff;
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}
.pill.live { color: var(--live); }
.pill.live::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--live);
    vertical-align: 2px;
    animation: pulse 1.4s infinite;
}
.pill.final { text-transform: uppercase; letter-spacing: 0.04em; }
.pill.muted { background: #9aa3ae; color: #fff; }
@keyframes pulse { 50% { opacity: 0.25; } }

.matchup {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 18px 14px 10px;
}
.divider {
    align-self: stretch;
    width: 1px;
    margin: 0 10px;
    background: var(--rule);
}
.team {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.team.home { flex-direction: row-reverse; text-align: right; }
.logo {
    flex: none;
    width: 54px;
    height: 54px;
    object-fit: contain;
}
.team-text { min-width: 0; flex: 1; }
/* Long names ("Blue Jackets", "Golden Knights") wrap to a second line rather than being cut off */
.team-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
}
.record {
    margin-top: 2px;
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
}
.score {
    flex: none;
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
}
.score.loser { color: #8a93a0; }

.season-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    column-gap: 10px;
    row-gap: 3px;
    padding: 6px 22px 16px;
    font-size: 14px;
}
.stat-value:nth-child(3n + 1) { text-align: left; padding-left: 12px; }
.stat-value:nth-child(3n) { text-align: right; padding-right: 12px; }
.stat-value { font-weight: 600; }
.stat-label { text-align: center; color: var(--muted); }

.team-name .abbrev { display: none; }

/* Narrow boxes (phones): smaller logos and type so names and scores still fit */
@container (max-width: 380px) {
    .logo { width: 40px; height: 40px; }
    .team-name { font-size: 14.5px; }
    .record { font-size: 13px; }
    .score { font-size: 24px; }
    .season-stats { font-size: 12.5px; padding: 6px 12px 14px; }
    .stat-value:nth-child(3n + 1) { padding-left: 4px; }
    .stat-value:nth-child(3n) { padding-right: 4px; }
}

@media (max-width: 720px) {
    .masthead { grid-template-columns: minmax(0, 1fr) auto; padding: 20px 16px 4px; }
    .day { grid-column: 1 / -1; grid-row: 2; text-align: left; }
    .day h1 { font-size: 22px; min-width: 0; flex: 1; }
    .day-nav { display: flex; gap: 6px; }
    .brand img { height: 32px; }
    main { padding: 12px 16px 40px; }
    .my-team { flex-wrap: nowrap; gap: 8px; }
    .my-team-button, .my-board { padding: 7px 10px; font-size: 13px; white-space: nowrap; }
    .board-team { display: none; } /* "Board" with the team logo is enough on a phone */
    .my-board { text-transform: capitalize; }
}

/* --- Team picker --- */
.picker {
    width: min(92vw, 900px);
    max-height: 90vh;
    border: 1px solid #1c232d;
    border-radius: 12px;
    background: #0d1117;
    color: var(--page-ink);
    padding: 24px;
}
.picker::backdrop { background: rgba(0, 0, 0, 0.75); }
.picker h2 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.picker-note { margin: 0 0 16px; font-size: 14px; color: var(--page-muted); text-align: center; }
.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.picker-grid button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 6px;
    font: 500 13px 'Inter', sans-serif;
    color: var(--page-ink);
    background: #161c24;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}
.picker-grid button:hover,
.picker-grid button:focus-visible { border-color: var(--team); outline: none; background: #1d252f; }
.picker-grid button.selected { border-color: var(--page-ink); }
.picker-grid img { width: 64px; height: 64px; object-fit: contain; }
.picker-close {
    display: block;
    margin: 18px auto 0;
    padding: 9px 18px;
    font: 600 14px 'Inter', sans-serif;
    color: var(--page-ink);
    background: #161c24;
    border: 1px solid #263040;
    border-radius: 8px;
    cursor: pointer;
}

/* Phones: "Sat, Oct 10", so the date and its three buttons share one line */
@media (max-width: 520px) {
    .day h1 .full { display: none; }
    .day h1 .short { display: inline; }
    .nav-button { width: 36px; height: 36px; }
}

/* Very narrow phones: the team buttons get their own row under the brand */
@media (max-width: 380px) {
    .masthead { grid-template-columns: minmax(0, 1fr); }
    .my-team { justify-content: flex-start; }
    .day { grid-row: 3; }
}

/* The narrowest boxes: team abbreviations instead of names */
@container (max-width: 320px) {
    .team-name .full { display: none; }
    .team-name .abbrev { display: inline; }
}
