/*
 * SportiCals site styles: fonts, the colour, shape and motion tokens, and the
 * parts every page shares (the header bar, the phone menu, the footer,
 * buttons, competition bands and the subscribe popups).
 * Themes follow the device: light, dark (prefers-color-scheme) and high
 * contrast (prefers-contrast: more). There is no switch and nothing is stored.
 *
 * Big Shoulders Display and Atkinson Hyperlegible Next are both SIL OFL 1.1;
 * their licences sit beside the font files.
 */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("/fonts/big-shoulders-display/big-shoulders-display-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Big Shoulders Display";
  src: url("/fonts/big-shoulders-display/big-shoulders-display-latin-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next/atkinson-hyperlegible-next-latin-400-normal.woff2")
    format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next/atkinson-hyperlegible-next-latin-700-normal.woff2")
    format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Stand-ins sized to each font's width, so text barely moves when the real one arrives. */
@font-face {
  font-family: "Big Shoulders fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Roboto Bold");
  font-weight: 700 800;
  size-adjust: 98%;
}

@font-face {
  font-family: "Atkinson fallback";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Roboto");
  size-adjust: 92%;
}

:root {
  color-scheme: light dark;

  --font-display: "Big Shoulders Display", "Big Shoulders fallback", sans-serif;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson fallback", sans-serif;

  /* Colours: light theme. */
  --bg: #f3f4f1;
  --surface: #fff;
  --ink: #121417;
  --muted: #4f5560;
  --rule: #d9dcd6;
  --outline: #121417;
  --button: #121417;
  --button-ink: #fff;
  --success: #0b7a3b;
  --error: #b3261e;

  /* The header bar: dark in the light theme, the page's own colour in dark. */
  --bar: #121417;
  --bar-ink: #fff;
  --bar-rule: transparent;
  --bar-current: #ffffff1f;

  /* The page's own text colour, for fields and lists inside the header bar, which sets its own. */
  --page-ink: var(--ink);

  /* Shape, spacing and motion. */
  --radius-control: 6px;
  --radius-card: 10px;
  --radius-chip: 999px;
  --gutter: clamp(16px, 4vw, 48px);
  --page-max: 1440px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #171a1f;
    --ink: #eef1f5;
    --muted: #a3abb7;
    --rule: #2a2f37;
    --outline: #ffffff59;
    --button: #eef1f5;
    --button-ink: #0e1013;
    --success: #4ade80;
    --error: #ff8a80;
    --bar: #0e1013;
    --bar-ink: #eef1f5;
    --bar-rule: #2a2f37;
    --bar-current: transparent;
  }
}

@media (prefers-contrast: more) {
  :root {
    --bg: #fff;
    --surface: #fff;
    --ink: #000;
    --muted: #000;
    --rule: #000;
    --outline: #000;
    --button: #000;
    --button-ink: #fff;
    --bar: #fff;
    --bar-ink: #000;
    --bar-rule: #000;
    --bar-current: transparent;
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --surface: #000;
    --ink: #fff;
    --muted: #fff;
    --rule: #fff;
    --outline: #fff;
    --button: #fff;
    --button-ink: #000;
    --bar: #000;
    --bar-ink: #fff;
    --bar-rule: #fff;
  }
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

/* The page itself. */
html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--font-body);
  text-size-adjust: 100%;
}

:where(h1, h2, h3, p) {
  margin: 0;
}

/* Headings split evenly over their lines; paragraphs avoid a lone last word. */
:where(h1, h2, h3) {
  text-wrap: balance;
}

:where(p) {
  text-wrap: pretty;
}

/* Sizes include padding and borders. */
*,
::before,
::after {
  box-sizing: border-box;
}

/* Hidden means hidden, whatever display a class sets. */
[hidden] {
  display: none !important;
}

/* Read out, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The double ring: a gap in the page colour, then the text colour, so it shows on any band. */
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--bg);
}

/* The header bar. */
.site-bar {
  --ink: var(--bar-ink);
  --bg: var(--bar);

  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 0 var(--gutter);
  background: var(--bar);
  color: var(--bar-ink);
  border-bottom: 1px solid var(--bar-rule);
  font: 700 16px/1.2 var(--font-body);
}

/* 44 px tall to tap, like every other control. */
.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font: 800 28px/1 var(--font-display);
  letter-spacing: 0.04em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav {
  display: flex;
  gap: 2px;
}

.main-nav a,
.menu-panel a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  color: inherit;
  text-decoration: none;
}

.main-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.main-nav a[aria-current="page"] {
  background: var(--bar-current);
}

@media (prefers-color-scheme: dark), (prefers-contrast: more) {
  .main-nav a[aria-current="page"] {
    border-radius: 0;
    box-shadow: inset 0 -3px 0 var(--bar-ink);
  }
}

/* Search boxes: in the bar on wide screens, in the menu on phones, and on the search page. */
.search-form {
  position: relative;
  display: flex;
  gap: 10px;
}

.search-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--page-ink);
  font: 400 16px/1.2 var(--font-body);
}

.search-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.bar-search {
  width: min(300px, 32vw);
  margin-left: auto;
}

.search-link {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border-radius: var(--radius-control);
  color: inherit;
}

.search-link svg {
  width: 22px;
  height: 22px;
}

/* Suggestions as you type, under the box (added by the script). */
.suggestions {
  position: absolute;
  inset: calc(100% + 6px) 0 auto;
  z-index: 20;
  max-height: min(60vh, 420px);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 14px 32px -16px #0e101366;
  color: var(--page-ink);
  font: 400 16px/1.3 var(--font-body);
  list-style: none;
}

.suggestion {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.suggestion[aria-selected="true"] {
  background: color-mix(in srgb, var(--page-ink) 9%, transparent);
  outline: 2px solid var(--page-ink);
  outline-offset: -2px;
}

.suggestion-name {
  font-weight: 700;
}

.suggestion-kind {
  color: var(--muted);
  font-size: 14px;
}

@media (hover: hover) {
  .suggestion:hover {
    background: color-mix(in srgb, var(--page-ink) 9%, transparent);
  }
}

/* The phone menu: a drop-down that opens without scripts. */
.menu {
  display: none;
}

.menu summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  cursor: pointer;
  list-style: none;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu svg {
  display: block;
  width: 22px;
  height: 22px;
}

.menu-close,
.menu[open] .menu-open {
  display: none;
}

.menu[open] .menu-close {
  display: block;
}

.menu-panel {
  position: absolute;
  inset: 64px 0 auto;
  z-index: 10;
  display: grid;
  gap: 12px;
  padding: 8px var(--gutter) 20px;
  background: var(--bar);
  border-bottom: 1px solid var(--bar-rule);
  font-size: 20px;
}

.menu-panel nav {
  display: grid;
}

.menu:not([open]) .menu-panel {
  display: none;
}

.menu[open] .menu-panel {
  animation: menu-drop 180ms var(--ease-out);
}

@keyframes menu-drop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (width <= 860px) {
  .site-bar {
    position: relative;
  }

  .main-nav,
  .bar-search {
    display: none;
  }

  .search-link {
    display: grid;
  }

  .menu {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu[open] .menu-panel {
    animation: menu-fade 150ms linear;
  }

  @keyframes menu-fade {
    from {
      opacity: 0;
    }
  }
}

/* The footer: the not-affiliated notice and the credit. */
.site-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 48px;
  padding: 24px var(--gutter);
  border-top: 3px solid var(--ink);
  background: var(--bg);
  color: var(--muted);
  font: 400 14px/1.5 var(--font-body);
}

.site-foot p {
  margin: 0;
  max-width: 75ch;
}

.site-foot a:any-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Buttons: ink-filled primary, outline secondary. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 1.5px solid var(--button);
  border-radius: var(--radius-control);
  font: 700 16px/1.2 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 120ms var(--ease-out),
    background-color 160ms var(--ease-out),
    border-color 160ms var(--ease-out),
    color 160ms var(--ease-out);
}

.button:active {
  transform: scale(0.97);
}

/* The same small press on everything else you press: the popup's Close, the guide tabs and the Menu button. */
:is(.subscribe-close, .guide-tabs [role="tab"], .menu summary) {
  transition: transform 120ms var(--ease-out);
}

:is(.subscribe-close, .guide-tabs [role="tab"], .menu summary):active {
  transform: scale(0.97);
}

.button svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.button-primary {
  background: var(--button);
  color: var(--button-ink);
}

.button-outline {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

@media (hover: hover) {
  .button-primary:hover {
    background: color-mix(in srgb, var(--button) 86%, var(--bg));
  }

  .button-outline:hover {
    background: color-mix(in srgb, var(--ink) 8%, transparent);
  }
}

/*
 * A competition band: its colour with black or white text (--c and --c-ink,
 * set in the markup) and the logo on a near-black plate.
 */
.band {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 8px 8px 14px;
  background: var(--c);
  color: var(--c-ink);
  font: 800 18px/1.1 var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.logo-plate {
  display: grid;
  flex: none;
  place-items: center;
  height: 36px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #121417;
}

.logo-plate img {
  display: block;
  width: auto;
  max-width: 72px;
  height: 28px;
  object-fit: contain;
}

.band-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Dark: a wash of the colour into the card with a stripe of the full colour. */
@media (prefers-color-scheme: dark) {
  .band {
    padding-bottom: 12px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--c) 40%, var(--surface)), var(--surface) 85%);
    color: var(--ink);
    box-shadow: inset 0 -4px var(--c);
  }
}

/* High contrast: plain text colours with a thicker stripe. */
@media (prefers-contrast: more) {
  .band {
    padding-bottom: 16px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: inset 0 -8px var(--c);
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  .logo-plate {
    background: #fff;
  }
}

/*
 * The subscribe popup. Without scripts it opens as a popover; with them, as a
 * modal dialog. Both get the same look and motion: on desktop it fades and
 * grows from 0.96, on phones it is a sheet that slides up from the bottom.
 */
.subscribe {
  inset: 0;
  width: min(600px, 100% - 32px);
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/1.45 var(--font-body);
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 150ms var(--ease-out),
    transform 150ms var(--ease-out),
    overlay 150ms allow-discrete,
    display 150ms allow-discrete;
}

.subscribe:is([open], :popover-open) {
  opacity: 1;
  transform: none;
  transition-duration: 200ms;
}

@starting-style {
  .subscribe:is([open], :popover-open) {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* The backdrop fades by opacity, which the GPU handles, rather than by repainting its colour. */
.subscribe::backdrop {
  background: #0e1013b3;
  opacity: 0;
  transition:
    opacity 150ms var(--ease-out),
    overlay 150ms allow-discrete,
    display 150ms allow-discrete;
}

.subscribe:is([open], :popover-open)::backdrop {
  opacity: 1;
  transition-duration: 200ms;
}

@starting-style {
  .subscribe:is([open], :popover-open)::backdrop {
    opacity: 0;
  }
}

/*
 * Closing with scripts: the script marks the popup closing, waits for this
 * exit to finish, then closes it, so every browser plays it. (Without
 * scripts, browsers that can't animate the overlay property close at once.)
 */
.subscribe[data-closing] {
  opacity: 0;
  transform: scale(0.96);
  transition-duration: 150ms;
}

.subscribe[data-closing]::backdrop {
  opacity: 0;
  transition-duration: 150ms;
}

.subscribe-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.subscribe-close svg {
  width: 22px;
  height: 22px;
}

@media (hover: hover) {
  .subscribe-close:hover {
    background: color-mix(in srgb, currentcolor 14%, transparent);
  }
}

.subscribe-body {
  display: grid;
  gap: 14px;
  padding: 20px 22px 24px;
}

.subscribe-title {
  margin: 4px 0 2px;
  color: inherit;
  font: 800 36px/1 var(--font-display);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.subscribe-open {
  min-height: 52px;
  font-size: 18px;
}

.subscribe-link {
  display: flex;
  gap: 8px;
}

/* The link wraps rather than being cut off, and one tap selects all of it. */
.link-field {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-control);
  background: var(--bg);
  font: 400 16px/1.3 var(--font-body);
  overflow-wrap: anywhere;
  user-select: all;
  cursor: text;
}

.copy {
  flex: none;
  min-width: 118px;
  padding: 0 16px;
}

.copy[data-copied] {
  border-color: var(--success);
  background: var(--success);
  color: var(--surface);
}

.copied-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.copy:not([data-copied]) .copied-label,
.copy[data-copied] .copy-label {
  display: none;
}

/* Ticks in each time Copied shows. */
.copied-label svg {
  animation: tick 160ms var(--ease-out);
}

@keyframes tick {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
}

.copy-status {
  margin: -4px 0 0;
}

/* Takes no room until there is something to say. */
.copy-status:empty {
  position: absolute;
}

.copy-error {
  color: var(--error);
  font-weight: 700;
}

.guides-title {
  margin: 10px 0 0;
  color: inherit;
  font: 800 24px/1 var(--font-display);
  text-transform: uppercase;
}

.guide summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-weight: 700;
  cursor: pointer;
}

.guide summary svg,
.guide-tabs [role="tab"] svg {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0 8px 0 6px;
  vertical-align: -3px;
}

.guide-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 2px solid var(--ink);
}

.guide-tabs [role="tab"] {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  background: transparent;
  color: var(--ink);
  font: 700 15px/1.2 var(--font-body);
  cursor: pointer;
}

.guide-tabs [role="tab"] svg {
  margin-left: 0;
}

.guide-tabs [aria-selected="true"] {
  background: var(--ink);
  color: var(--surface);
}

.guide-steps ol {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.guide-steps li {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 32px;
  font-weight: 700;
  counter-increment: step;
}

.guide-steps li::before {
  content: counter(step);
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font: 800 20px/1 var(--font-display);
}

/* Phones: a sheet from the bottom edge. */
@media (width <= 640px) {
  .subscribe {
    width: 100%;
    max-height: calc(100dvh - 40px);
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    opacity: 1;
    transform: translateY(100%);
    transition:
      transform 220ms var(--ease-drawer),
      overlay 220ms allow-discrete,
      display 220ms allow-discrete;
  }

  .subscribe:is([open], :popover-open) {
    transform: none;
    transition-duration: 300ms;
  }

  @starting-style {
    .subscribe:is([open], :popover-open) {
      transform: translateY(100%);
    }
  }

  .subscribe[data-closing] {
    opacity: 1;
    transform: translateY(100%);
    transition-duration: 220ms;
  }

  .subscribe-body {
    padding: 18px 16px 24px;
  }

  .subscribe-title {
    font-size: 30px;
  }
}

/* Reduced motion: nothing moves; the popup and Copied fade instead. */
@media (prefers-reduced-motion: reduce) {
  .button:active,
  :is(.subscribe-close, .guide-tabs [role="tab"], .menu summary):active {
    transform: none;
  }

  .subscribe {
    opacity: 0;
    transform: none;
    transition:
      opacity 150ms linear,
      overlay 150ms allow-discrete,
      display 150ms allow-discrete;
  }

  .subscribe:is([open], :popover-open) {
    opacity: 1;
    transform: none;
    transition-duration: 150ms;
  }

  @starting-style {
    .subscribe:is([open], :popover-open) {
      opacity: 0;
      transform: none;
    }
  }

  .subscribe[data-closing] {
    opacity: 0;
    transform: none;
    transition-duration: 150ms;
  }

  .copied-label svg {
    animation: fade-in 150ms linear;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
  }
}

/* Page and section headings on the redesigned pages. */
.page-title {
  font: 800 clamp(56px, 7vw, 96px) / 0.9 var(--font-display);
  text-transform: uppercase;
}

.section-title {
  margin-bottom: 16px;
  font: 800 34px/1 var(--font-display);
  text-transform: uppercase;
}

/* Next up: what starts soonest, with a countdown to it. */
.next-up {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.next-body {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 18px 18px 20px;
}

.next-up-empty {
  display: grid;
  gap: 6px;
  padding: 24px 18px;
}

.next-when {
  color: var(--muted);
  font-weight: 700;
}

.next-title {
  font: 800 clamp(30px, 3vw, 40px) / 1 var(--font-display);
  overflow-wrap: anywhere;
}

.next-label {
  color: var(--muted);
}

.countdown {
  display: flex;
  gap: 22px;
  margin: 6px 0 12px;
}

.count {
  display: grid;
  gap: 4px;
}

.count-value {
  display: block;
  font: 800 60px/0.9 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.count-unit {
  color: var(--muted);
  font: 700 13px/1 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (width <= 640px) {
  .count-value {
    font-size: 52px;
  }
}

/* Fixture dates and times: the date muted, the time in the text colour. */
.when {
  color: var(--muted);
  font: 700 15px/1.2 var(--font-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.when-time,
.when-allday {
  color: var(--ink);
}

.when-allday {
  text-transform: none;
}

/* In the Next up line the date reads as part of the sentence. */
.next-when .when {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
}
