/* Hallmark · pre-emit critique: P5 H5 E4 S5 R5 V4 */
/* Hallmark · component: page layout · genre: editorial (the CHAG data-led system) · theme: tokens.css (locked)
 *
 * The site-wide column layout (owner decisions 2026-11-30 and 2026-12-01, modelled on the owner's samples):
 *
 *   >= 1280 px, sports pages:  [ left column 300 px | content up to 790 px | right column 320 px ], one centred group
 *   >= 1280 px, other pages:   [ content up to 790 px, centred | right column ]
 *   1024-1279 px:              [ content up to 790 px | right column ] (no left column)
 *   < 1024 px:                 one column, at most 632 px wide and centred; the slip keeps its bottom sheet
 *
 * The left column (sports pages) holds the Top leagues list and, below it, the News panel. The right column holds the
 * Prediction Slip and, on the homepage, the Featured pick under it. Both start below the page's top band (the
 * homepage hero, `.site-layout__top`) and then stay in view while the page scrolls (sticky), scrolling away with the
 * end of the page. The side columns keep their widths; the centre column is 25% wider than the first 632 px sample
 * (owner decision 2026-12-01) and gives way on narrower desktops, never the side columns.
 *
 * Every value is a token or derived from tokens; the percentages resolve against the body (.site-main), so the
 * group is always centred with at least 24 px either side.
 */

:root {
  --layout-content: 39.5rem; /* 632 px - the content column below 1024 px (the owner's first sample) */
  --layout-content-wide: 49.375rem; /* 790 px - the desktop centre column: 632 px + 25% (owner, 2026-12-01) */
  --layout-rail: 18.75rem; /* 300 px - the left column */
  --layout-gap: var(--space-24);
  /* Where the side columns stop while the page scrolls: the slip's former fixed top. */
  --layout-sticky-top: calc(var(--touch-target-min) + var(--space-48));
}

/* ---- every size: the content column and the top band ---- */

/* The content column - and the top band - are the size container the page stylesheets ask
   (`@container page-content (...)`), so a page's own two- or three-column arrangements follow the column's width,
   not the screen's. Below 632 px both are the screen, so phones are as before. Header, footer and slip rules stay
   screen-based (@media). */
.site-layout__content,
.site-layout__top {
  container: page-content / inline-size;
  width: 100%;
  max-width: var(--layout-content);
  min-width: 0;
  margin-inline: auto;
}

/* The page's own .container-page keeps its mobile gutters; inside the column it never re-widens the content. */
.site-layout__content .container-page,
.site-layout__top .container-page {
  max-width: none;
}

.site-layout__rail,
.site-layout__aside-extra {
  display: none;
}

/* ---- 1024 px+: content beside the right column, centred as one group ---- */
@media (min-width: 1024px) {
  :root {
    --layout-group: calc(var(--layout-content-wide) + var(--layout-gap) + var(--slip-width));
    --layout-side: max(var(--space-24), calc((100% - var(--layout-group)) / 2));

    /* Headings keep the tablet scale instead of growing for a wide page (this file loads after responsive.css,
       whose 1280/1440 px steps it therefore overrides). */
    --font-size-display: 3rem; /* 48px */
    --font-size-h1: 2.5rem; /* 40px */
    --font-size-h2: 2rem; /* 32px */
    --font-size-h3: 1.5rem; /* 24px */
  }

  /* The slip is a column now, not a box fixed over the page, so neither main nor the footer reserves room for it. */
  .site-main {
    padding-inline: var(--layout-side);
  }

  .site-footer {
    padding-right: 0;
  }

  .site-layout__content {
    max-width: var(--layout-content-wide);
  }

  .site-layout__top {
    max-width: none;
  }

  .site-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--slip-width);
    column-gap: var(--layout-gap);
    align-items: start;
  }

  .site-layout__content {
    grid-column: 1;
    grid-row: 1;
  }

  .site-layout__content .container-page,
  .site-layout__top .container-page {
    padding-inline: 0;
  }

  /* The right column is itself the sticky grid item, exactly like the left column: WebKit (Safari) did not keep a
     sticky element nested inside a stretched grid item stuck once its height became automatic. */
  .site-layout__aside {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: var(--layout-sticky-top);
    margin-top: var(--space-24);
  }

  /* The slip on top at its own height (scrolling inside itself when taller than the room left), the homepage's
     Featured pick under it. */
  .site-layout__aside-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-16);
    max-height: calc(100vh - var(--layout-sticky-top) - var(--space-24));
  }

  .site-layout__aside .prediction-slip--desktop {
    position: static;
    flex: 0 1 auto;
    box-sizing: border-box;
    min-height: 0;
    width: var(--slip-width);
  }

  .site-layout__aside-extra {
    display: block;
    flex: none;
  }

  .site-layout__aside-extra .match-card-list {
    margin-block: 0;
  }
}

/* ---- 1280 px+: the left column (Top leagues, then News) on sports pages ---- */
@media (min-width: 1280px) {
  :root {
    --layout-group: calc(var(--layout-rail) + var(--layout-gap) + var(--layout-content-wide) + var(--layout-gap)
      + var(--slip-width));
  }

  /* The left column follows the content in the document (the page's own heading comes first for screen readers and
     the skip link) and is placed on the left here. Both side columns keep their widths; the centre takes the rest,
     up to 790 px. */
  .site-layout:has(> .site-layout__rail) {
    grid-template-columns: var(--layout-rail) minmax(0, var(--layout-content-wide)) var(--slip-width);
  }

  .site-layout:has(> .site-layout__rail) > .site-layout__content {
    grid-column: 2;
    max-width: none;
    margin-inline: 0;
  }

  .site-layout:has(> .site-layout__rail) > .site-layout__aside {
    grid-column: 3;
  }

  /* Top leagues at its own height, up to half the column (its list scrolls inside it), News below in the rest. */
  .site-layout__rail {
    display: flex;
    flex-direction: column;
    gap: var(--space-16);
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: var(--layout-sticky-top);
    height: calc(100vh - var(--layout-sticky-top) - var(--space-24));
    margin-top: var(--space-24);
  }

  .league-rail {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    max-height: calc((100% - var(--space-16)) / 2);
    min-height: 0;
  }

  .league-rail__panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .league-rail__list {
    min-height: 0;
    overflow-y: auto;
  }

  .site-layout__rail .news-panel {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
  }
}

/* ---- the Top leagues rail (components/sports/league_rail.html) ----
 * states (each link): default · hover · focus-visible · active page (aria-current, a weight and a left bar - never
 *   colour alone) · loading/error/disabled n/a (plain links)
 * contrast: --color-text-primary / --color-text-secondary on --color-rail-bg (grey in the light theme), both themes,
 *   >= 4.5:1 */
.league-rail__panel {
  padding: var(--space-16) var(--space-8) var(--space-12);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-rail-bg);
}

.league-rail__title {
  margin: 0 var(--space-8) var(--space-8);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.league-rail__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.league-rail__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-12);
  min-height: var(--touch-target-min);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transition: background-color var(--transition-fast);
}

.league-rail__link:hover {
  background: var(--color-rail-hover);
  color: var(--color-text-primary);
  text-decoration: none;
}

.league-rail__link:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 0;
}

.league-rail__link.is-active {
  background: var(--color-rail-hover);
  font-weight: var(--font-weight-black);
}

.league-rail__link.is-active::before {
  content: "";
  position: absolute;
  top: var(--space-8);
  bottom: var(--space-8);
  left: 0;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
}

.league-rail__name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.league-rail__more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--touch-target-min);
  margin: var(--space-4) var(--space-8) 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

.league-rail__more:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .league-rail__link {
    transition: none;
  }
}

/* ---- the News panel (components/content/news_panel.html) ----
 * Laid out like the owner's reference panel (2026-12-01), in Chag Sports colours: a "News" heading; the newest
 * article first, its image full width and its headline below; the others with a small square image beside the
 * headline; full-width dividers between articles; "<source> · <age>" in secondary text; "See more" closes the panel.
 * The list scrolls inside the panel when its articles are taller than the half column.
 * states (each link): default · hover (a fill, never an underline) · focus-visible (inset ring) · loading/error/
 * disabled n/a
 * contrast: --color-text-primary / --color-text-secondary on --color-surface, both themes, >= 4.5:1 */
.news-panel {
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.news-panel__title {
  flex: none;
  margin: 0;
  padding: var(--space-16) var(--space-16) var(--space-12);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-bold);
  line-height: 1.25;
  color: var(--color-text-primary);
}

.news-panel__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.news-panel__item + .news-panel__item {
  border-top: 1px solid var(--color-line);
}

.news-panel__link {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
  padding: var(--space-12) var(--space-16);
  color: var(--color-text-primary);
  text-decoration: none;
  transition: background-color var(--transition-fast);
}

/* The newest article: image on top, the headline under it. */
.news-panel__item--lead .news-panel__link {
  flex-direction: column;
  gap: var(--space-8);
  padding-top: 0;
  padding-bottom: var(--space-16);
}

.news-panel__link:hover,
.news-panel__more:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  text-decoration: none;
}

.news-panel__link:focus-visible,
.news-panel__more:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

.news-panel__image {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-card);
  object-fit: cover;
  background: var(--color-bg-secondary);
}

.news-panel__item--lead .news-panel__image {
  width: 100%;
  height: auto;
  aspect-ratio: 19 / 10;
  border-radius: var(--radius-slip);
}

.news-panel__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.news-panel__headline {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-bold);
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.news-panel__meta {
  color: var(--color-text-secondary);
  font-size: var(--font-size-control);
}

.news-panel__empty {
  margin: 0;
  padding: 0 var(--space-16) var(--space-16);
  color: var(--color-text-secondary);
  font-size: var(--font-size-control);
}

/* "See more": a full-width row closing the panel, at least 44 px tall. */
.news-panel__more {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--touch-target-min);
  padding: 0 var(--space-16);
  border-top: 1px solid var(--color-line);
  color: var(--color-text-primary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--transition-fast);
}

@media (prefers-reduced-motion: reduce) {
  .news-panel__link,
  .news-panel__more {
    transition: none;
  }
}

/* ---- Scroll hints (static/js/scroll-hints.js; owner decision 2026-12-01) ----
 * The slip, the News panel, the Top leagues rail, the date strip and the market buttons scroll without a visible
 * scroll bar; a tiny arrow on a short fade (in the container's own colour) marks each edge with more content. The
 * arrows are pointer conveniences (a click scrolls most of one view), aria-hidden and outside the tab order.
 * states: shown / hidden by edge · hover (the arrow brightens) · no focus state (not focusable) */
[data-scroll-hints] {
  scrollbar-width: none;
}

[data-scroll-hints]::-webkit-scrollbar {
  display: none;
}

.scroll-hints-host {
  position: relative;
}

.scroll-hint {
  --scroll-hint-bg: var(--color-bg);
  --scroll-hint-color: var(--color-text-secondary);
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--scroll-hint-color);
  cursor: pointer;
}

.scroll-hint[hidden] {
  display: none;
}

.scroll-hint:hover {
  color: var(--color-text-primary);
}

/* The arrow itself: a 6 px chevron drawn from two borders, pointing the way to scroll. */
.scroll-hint::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.scroll-hint--y {
  height: 1.25rem;
}

.scroll-hint--y.scroll-hint--after {
  background: linear-gradient(to top, var(--scroll-hint-bg) 45%, transparent);
}

.scroll-hint--y.scroll-hint--after::before {
  transform: translateY(-1px) rotate(45deg);
}

.scroll-hint--y.scroll-hint--before {
  background: linear-gradient(to bottom, var(--scroll-hint-bg) 45%, transparent);
}

.scroll-hint--y.scroll-hint--before::before {
  transform: translateY(2px) rotate(-135deg);
}

.scroll-hint--x {
  width: 1.25rem;
}

.scroll-hint--x.scroll-hint--after {
  justify-content: flex-end;
  background: linear-gradient(to left, var(--scroll-hint-bg) 45%, transparent);
}

.scroll-hint--x.scroll-hint--after::before {
  transform: translateX(-2px) rotate(-45deg);
}

.scroll-hint--x.scroll-hint--before {
  justify-content: flex-start;
  background: linear-gradient(to right, var(--scroll-hint-bg) 45%, transparent);
}

.scroll-hint--x.scroll-hint--before::before {
  transform: translateX(2px) rotate(135deg);
}

/* Each host's own colour under the fade. */
.site-layout__aside-inner > .scroll-hint {
  --scroll-hint-bg: var(--color-surface-analytical);
  --scroll-hint-color: var(--color-intelligence);
}

.site-layout__aside-inner > .scroll-hint:hover {
  color: #ffffff;
}

.news-panel > .scroll-hint {
  --scroll-hint-bg: var(--color-surface);
}

.league-rail__panel > .scroll-hint {
  --scroll-hint-bg: var(--color-rail-bg);
}

/* The league badges keep a fill that differs from the rail's own shade, so their circles stay visible. */
.league-rail .crest-badge {
  background: var(--color-rail-badge-bg);
}
