/* TV grid — broadcast-board styling.
 *
 * Networks down the left, half-hour kickoff windows across the top, each game a
 * two-band block in the two teams' own colours.
 *
 * The board keeps its own dark palette regardless of the site theme. It is a
 * listings board, the same object as the printed grid in a TV guide, and the
 * team-colour bands only read correctly against a dark surround — on a light
 * background every block becomes a bright rectangle and the grid loses its rows.
 */

.gridwrap {
  padding-top: 22px;
  padding-bottom: 52px;
}

/* ---- board palette. Self-contained: nothing here reads a site token, so a
 * theme change cannot wash out the team colours. ---- */
.board {
  --bd-bg: #0b1b33;
  --bd-bg-2: #102544;
  --bd-line: #1d3a63;
  --bd-line-soft: #16304f;
  --bd-ink: #eaf1fb;
  --bd-ink-2: #9db4d4;
  --bd-ink-3: #6f8bb0;
  --bd-live: #ff4438;
  --bd-rail: #f4f7fc;
  --bd-slot: 66px;
  --bd-netw: 118px;
  margin-top: 14px;
  border: 1px solid var(--bd-line);
  border-radius: 14px;
  background: var(--bd-bg);
  overflow: hidden;
}

.gridhead {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.gridhead h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.gridnote {
  margin: 0;
  color: var(--ink-3);
  font-size: var(--text-sm);
}

.boardscroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--bd-line) transparent;
}

.tvgrid {
  display: grid;
  grid-template-columns: var(--bd-netw) repeat(var(--cols, 24), minmax(var(--bd-slot), 1fr));
  min-width: max-content;
  background: var(--bd-bg);
}

/* ---- time axis ---- */
.tvtime {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 8px 4px 7px;
  border-bottom: 1px solid var(--bd-line);
  border-left: 1px solid var(--bd-line-soft);
  background: var(--bd-bg-2);
  color: var(--bd-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tvtime .mer {
  display: block;
  margin-top: 1px;
  color: var(--bd-ink-3);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Corner cell, sticky in both axes. Carries the day and the live zone label —
 * the reference graphic's fixed "ALL TIMES EST" line, made truthful. */
.tvcorner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 6;
  padding: 7px 10px;
  border-right: 1px solid var(--bd-line);
  border-bottom: 1px solid var(--bd-line);
  background: var(--bd-bg-2);
  color: var(--bd-ink);
  font-family: var(--display);
  font-size: 13px;
  line-height: 1.15;
  text-transform: uppercase;
}

.tvcorner span {
  display: block;
  margin-top: 2px;
  color: var(--bd-ink-2);
  font-family: var(--body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ---- network rail ---- */
.tvnet {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 5px 7px;
  border-right: 1px solid var(--bd-line);
  border-top: 1px solid var(--bd-line-soft);
  background: var(--bd-bg);
}

/* The tile. A light plate so a network mark reads the way it does in a TV guide,
 * against the dark board. */
.nettile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 5px 6px;
  border-radius: 7px;
  background: var(--bd-rail);
  overflow: hidden;
}

.nettile img {
  display: block;
  max-width: 100%;
  max-height: 26px;
  object-fit: contain;
}

/* Typographic fallback: a wordmark, not a reproduction of a broadcaster's logo.
 * See the note in grid.js — real marks are licensed artwork and the ESPN feed
 * supplies none, so networks are set in type and tinted per network instead. */
.netword {
  color: var(--nc, #0b1b33);
  font-family: var(--display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.netword.sm {
  font-size: 12px;
  letter-spacing: -0.01em;
}

.netword.xs {
  font-size: 10px;
  letter-spacing: 0;
}

.netword b {
  font-weight: 800;
}

.netword i {
  font-style: normal;
  opacity: 0.62;
}

/* Continuation row for a network with concurrent games: no tile, just a tick so
 * the eye knows the row still belongs to the network above. */
.tvnet.cont .nettile {
  min-height: 0;
  background: none;
}

.tvnet.cont::after {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--bd-line);
}

/* ---- empty slot ---- */
.tvcell {
  border-top: 1px solid var(--bd-line-soft);
  border-left: 1px solid var(--bd-line-soft);
  min-height: 52px;
}

/* ---- a game block ---- */
.tvg {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: stretch;
  margin: 4px 3px;
  border-radius: 6px;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.tvg:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.tvg:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Logo plates at each end, as in the reference: away left, home right. */
.tvg .lg {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  background: rgba(255, 255, 255, 0.1);
}

.tvg .lg img {
  width: 21px;
  height: 21px;
  object-fit: contain;
}

.tvg .mid {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* One band per team, in that team's colour. */
.tvg .bd {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 3px 7px;
  background: var(--c, #24405f);
  color: var(--t, #fff);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.tvg .bd.away {
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.28);
}

.tvg .nm {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-transform: uppercase;
  /* Uppercase at 12px needs the tracking BACK, not tightened. With the block's
   * -0.01em inherited, "NEW ENGLAND PATRIOTS" read as one word. */
  letter-spacing: 0.015em;
  word-spacing: 0.12em;
}

.tvg .rk {
  flex: 0 0 auto;
  opacity: 0.75;
  font-size: 10px;
  font-weight: 800;
}

/* The "@" sits on the home band, small, the way a printed grid marks the host. */
.tvg .at {
  flex: 0 0 auto;
  opacity: 0.7;
  font-size: 9px;
  font-weight: 800;
}

.tvg .sc {
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: 5px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Kickoff strip, only when the block is wide enough to carry it. */
.tvg .kick {
  position: absolute;
  right: 33px;
  bottom: 2px;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.tvg.is-live {
  outline: 2px solid var(--bd-live);
  outline-offset: -2px;
}

.tvg.is-live .kick {
  background: var(--bd-live);
}

.tvg.is-done {
  opacity: 0.55;
}

/* Narrow blocks drop the logo plates and the kickoff strip before they drop the
 * team names — the names are the payload. */
.tvg.tight .lg {
  display: none;
}

.tvg.tight .kick {
  display: none;
}

.tvg.tight .bd {
  padding: 3px 5px;
  font-size: 11px;
}

/* ---- morning shows band ---- */
.tvband {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 12px;
  border-top: 1px solid var(--bd-line);
  background: #0d2138;
  color: var(--bd-ink);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tvband span {
  font-family: var(--body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--bd-ink-3);
}

.tvband.games {
  border-top-width: 2px;
}

/* A studio show, deliberately NOT team-coloured. It is not a game, and colouring
 * it like one would make the grid claim a matchup that does not exist. */
.tvshow {
  align-items: center;
  border: 1px dashed #3d5f8a;
  background: repeating-linear-gradient(
    135deg,
    #16304f,
    #16304f 6px,
    #132a45 6px,
    #132a45 12px
  );
  cursor: default;
}

.tvshow:hover {
  transform: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.shw {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 4px 9px;
}

.shw b {
  overflow: hidden;
  color: var(--bd-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.shw i {
  color: #7fa8d8;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tvnet.ismorning {
  background: #0d2138;
}

/* ---- rotate-to-see-grid cue ---- */
.rotate {
  display: none;
}

/* ---- streaming list ---- */
.streamsec {
  padding: 16px 16px 18px;
  border-top: 1px solid var(--bd-line);
  background: var(--bd-bg-2);
}

.streamsec h3 {
  margin: 0 0 3px;
  color: var(--bd-ink);
  font-size: var(--text-base);
}

.streamsec p {
  margin: 0 0 11px;
  color: var(--bd-ink-2);
  font-size: var(--text-sm);
}

.streamgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 7px;
}

.streamrow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--bd-line);
  border-radius: 8px;
  background: var(--bd-bg);
  color: var(--bd-ink);
  font-size: var(--text-sm);
  text-decoration: none;
}

.streamrow:hover {
  border-color: var(--bd-ink-3);
}

.streamrow .st-k {
  flex: 0 0 auto;
  color: var(--bd-ink-2);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.streamrow .st-t {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  /* WRAPS, does not ellipsise. With nowrap, 66 of the 81 streaming rows truncated
   * mid-matchup - "Eastern Michigan @ ..." tells a reader nothing, and the opponent
   * is the whole point of the row. Two lines is worth the vertical space. */
  overflow-wrap: break-word;
  line-height: 1.25;
}

.streamrow .st-n {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bd-line);
  color: var(--bd-ink);
  font-size: 10px;
  font-weight: 800;
}

/* ---- states ---- */
.gridempty {
  padding: 34px 18px;
  color: var(--bd-ink-2);
  text-align: center;
}

.gridempty button {
  border: 0;
  background: none;
  color: var(--bd-ink);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.gridskel {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.gridskel i {
  display: block;
  height: 48px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--bd-bg-2) 25%, var(--bd-line) 37%, var(--bd-bg-2) 63%);
  background-size: 400% 100%;
  animation: gridsheen 1.25s ease-in-out infinite;
}

@keyframes gridsheen {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gridskel i {
    animation: none;
  }
  .tvg:hover {
    transform: none;
  }
}

/* Slightly tighter columns on mid-size screens before the stack kicks in. */
@media (max-width: 1100px) {
  .board {
    --bd-slot: 60px;
    --bd-netw: 104px;
  }
}

/* Rotate hint. Shown ONLY on a narrow PORTRAIT screen, which is exactly the case
 * where the stacked list is being served instead of the grid. Keyed on orientation
 * as well as width so it never appears on a small desktop window, where turning the
 * device is not a thing the reader can do. It disappears the moment the phone is
 * rotated, because at that point the grid itself is on screen. */
@media (max-width: 720px) and (orientation: portrait) {
  .rotate {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--text-sm);
    line-height: 1.35;
  }

  .rotate svg {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    color: var(--accent);
    animation: tilt 2.6s ease-in-out infinite;
  }

  .rotate b {
    color: var(--ink);
  }
}

@keyframes tilt {
  0%, 55%, 100% { transform: rotate(0deg); }
  70%, 85% { transform: rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate svg {
    animation: none;
  }
}

/* Phone: a grid at 60px columns is unreadable, so the same data becomes a
 * per-network stack. The columns are hidden, never squeezed. */
@media (max-width: 720px) {
  .board.is-stacked {
    border: 0;
    border-radius: 0;
    background: none;
  }
  .is-stacked .boardscroll {
    overflow-x: visible;
  }
  .is-stacked .tvgrid {
    display: block;
    min-width: 0;
    background: none;
  }
  .is-stacked .tvtime,
  .is-stacked .tvcorner,
  .is-stacked .tvcell {
    display: none;
  }
  .is-stacked .tvnet {
    position: static;
    justify-content: flex-start;
    min-height: 0;
    margin: 16px 0 7px;
    padding: 0;
    border: 0;
    background: none;
  }
  .is-stacked .tvnet.cont {
    display: none;
  }
  .is-stacked .nettile {
    width: auto;
    min-width: 92px;
    max-width: 128px;
  }
  .is-stacked .tvg {
    margin: 0 0 6px;
  }
  .is-stacked .tvg.tight .lg {
    display: flex;
  }
  .is-stacked .tvg.tight .kick {
    display: block;
  }
  .is-stacked .tvg .bd {
    padding: 5px 8px;
    font-size: 13px;
  }
  .is-stacked .streamsec {
    margin-top: 18px;
    border-radius: 12px;
  }
}

/* ---- print button ---- */
.printbtn {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}

.printbtn:hover {
  border-color: var(--accent);
}

/* ================================================================= PRINT
 * One board per page, landscape, at full width — the shape of the reference
 * graphic rather than a screenshot of a scrolling page.
 *
 * The board keeps its dark palette on paper. That is a deliberate choice: the
 * blocks ARE the team colours, and forcing a light background would either wash
 * them out or leave dark text on dark fills. `print-color-adjust: exact` stops
 * browsers "helpfully" dropping the backgrounds, which is what turns a colour
 * grid into an unreadable set of empty boxes.
 */
@media print {
  @page {
    size: letter landscape;
    margin: 0.4in;
  }

  /* Chrome scales to fit the page only if the element is not inside a horizontal
   * scroller, so the scroller is unwound and the grid allowed to size naturally. */
  .boardscroll {
    overflow: visible !important;
  }

  .tvgrid {
    min-width: 0 !important;
    width: 100% !important;
  }

  .board {
    --bd-slot: 42px;
    break-inside: avoid;
    border-color: #1d3a63 !important;
  }

  /* Each board starts a fresh sheet. */
  .board + .gridhead {
    break-before: page;
  }

  .masthead,
  .hero-sub,
  .printbtn,
  footer,
  .skip,
  [data-nav],
  .tz,
  #themeBtn {
    display: none !important;
  }

  .hero {
    padding: 0 0 6px !important;
    background: none !important;
  }

  .hero-h1 {
    margin: 0;
    font-size: 20pt;
  }

  .gridwrap {
    padding: 0 !important;
  }

  .gridhead {
    margin: 0 0 4px !important;
  }

  .gridhead h2 {
    font-size: 13pt;
  }

  .gridnote {
    font-size: 8pt;
  }

  /* Sticky is meaningless on paper and can float a cell over the grid. */
  .tvtime,
  .tvcorner,
  .tvnet {
    position: static !important;
  }

  .tvg,
  .tvcell,
  .tvnet,
  .tvtime,
  .tvcorner,
  .board,
  .tvgrid,
  .streamsec {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .tvg {
    box-shadow: none !important;
  }

  .tvg .bd {
    font-size: 7.5pt;
    padding: 2px 5px;
  }

  .tvtime {
    font-size: 7pt;
  }

  .tvg .lg {
    width: 22px;
  }

  .tvg .lg img {
    width: 16px;
    height: 16px;
  }

  /* The streaming list is long and is the least useful part on paper. */
  .streamsec {
    break-inside: avoid;
  }

  .streamgrid {
    grid-template-columns: repeat(3, 1fr);
  }

  .streamrow {
    font-size: 7.5pt;
  }
}
