/* Cricket Scores — base layer.
 *
 * Document defaults, typography, links and focus, the application shell, the
 * top bar, the mobile bottom navigation, notices and the footer.
 *
 * Rules here describe *structure that every page shares*. Component rules live in
 * components.css. Nothing in this file may hardcode a colour: consume the
 * semantic tokens from tokens.css.
 */

/* -------------------------------------------------------------- 1. reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-3);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--hit) + var(--sp-7) + env(safe-area-inset-bottom));
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* --------------------------------------------------------- 2. typography */

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-2);
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  font-weight: var(--fw-bold);
}

h1 {
  font-size: var(--fs-7);
}

h2 {
  font-size: var(--fs-5);
}

h3 {
  font-size: var(--fs-4);
  letter-spacing: -0.01em;
}

h4 {
  font-size: var(--fs-3);
}

p {
  margin: 0 0 var(--sp-3);
}

ul,
ol {
  margin: 0 0 var(--sp-3);
  padding-left: 1.15rem;
}

li + li {
  margin-top: var(--sp-1);
}

strong {
  font-weight: var(--fw-bold);
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: var(--fs-1);
}

/* Scores, overs, counts and times all align in a column. */
.tabular,
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.num {
  text-align: right;
}

.tag {
  display: inline-block;
  margin-left: var(--sp-2);
  padding: 1px var(--sp-2);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-xs);
  font-size: var(--fs-1);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-text);
  vertical-align: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------ 3. links & focus */

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 32%, transparent);
  text-underline-offset: 0.18em;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

/* One ring for the whole product, drawn outside the element so it is never
   hidden by an overflow clip and never mistaken for the emerald accent. */
/* The ring is offset by 2px, so it sits against the page surface rather than the
   control's own fill; `inherit` keeps it in the control's shape (a pill stays a
   pill). Measured 6.99:1 on paper and 9.64:1 on navy. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: inherit;
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -4rem;
  z-index: 40;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-2);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: top var(--dur) var(--ease);
}

.skip-link:focus {
  top: var(--sp-3);
}

/* ------------------------------------------------------------ 4. the shell */

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.shell__main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-8);
}

.shell__main:focus {
  outline: none;
}

.page__head {
  margin: 0 0 var(--sp-6);
}

.page__head h1 {
  max-width: 22ch;
}

.page__lede {
  margin: 0;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: var(--fs-4);
  line-height: var(--lh-snug);
}

.page__back {
  display: inline-block;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-1);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--text-muted);
}

.page__back:hover {
  color: var(--text);
}

.section {
  margin: 0 0 var(--sp-7);
}

.section:last-child {
  margin-bottom: 0;
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.section__head h2 {
  margin: 0;
}

.section__head span,
.section__head .muted {
  font-size: var(--fs-1);
}

.prose {
  max-width: 68ch;
}

.prose li {
  margin-bottom: var(--sp-2);
}

.cols {
  display: grid;
  gap: var(--sp-5);
}

.grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: 1fr;
}

/* --------------------------------------------------------------- 5. top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: var(--maxw);
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
  text-decoration: none;
  color: var(--text);
}

/* Sized in components.css, after the shared `.icon` rule that would otherwise win. */
.brand__mark {
  flex: none;
  color: var(--accent);
}

.brand__text {
  font-size: var(--fs-4);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topbar__nav {
  display: none;
  gap: var(--sp-1);
  margin-left: auto;
}

.topbar__nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--control-h-sm);
  padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  font-size: var(--fs-2);
  font-weight: var(--fw-medium);
  text-decoration: none;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.topbar__nav a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Current section: filled pill with full-strength text. The accent carries a
   separate dot, so the state is never signalled by colour alone and the label
   keeps a 7:1+ ratio instead of the 4.06:1 the old tinted green managed. */
.topbar__nav a[aria-current="page"] {
  background: var(--surface-active);
  color: var(--text);
  font-weight: var(--fw-bold);
}

.topbar__nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: 0.3rem;
  height: 2px;
  border-radius: var(--r-full);
  background: var(--accent);
}

.theme-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.theme-toggle[aria-pressed="true"] {
  color: var(--accent-text);
  border-color: var(--accent-border);
}

@media (min-width: 48rem) {
  .topbar__nav {
    display: flex;
  }

  .theme-toggle {
    margin-left: 0;
  }
}

/* ------------------------------------------------------ 6. bottom navigation */

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: var(--hit);
  padding: var(--sp-2) var(--sp-1) calc(var(--sp-2) + env(safe-area-inset-bottom));
  font-size: var(--fs-1);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item svg {
  color: currentColor;
}

.bottom-nav__item .icon {
  width: 22px;
  height: 22px;
}

.bottom-nav__item[aria-current="page"] {
  color: var(--accent-text);
}

.bottom-nav__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 30%;
  right: 30%;
  height: 2px;
  border-radius: var(--r-full);
  background: var(--accent);
}

.bottom-nav__item[aria-current="page"] .bottom-nav__label {
  font-weight: var(--fw-bold);
}

/* --------------------------------------------------------------- 7. notices */

.notices {
  max-width: var(--maxw);
  margin: var(--sp-4) auto 0;
  padding: 0 var(--sp-4);
  display: grid;
  gap: var(--sp-2);
}

.notice {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--sp-3);
  margin: 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-2);
  line-height: var(--lh-snug);
}

/* The icon repeats the notice's own state colour, so the kind of notice is legible
 * before the sentence is read. Both tones are already-measured text tokens on the
 * soft background the notice uses. */
.notice__icon {
  display: inline-flex;
  color: var(--text-subtle);
}

.notice__body {
  min-width: 0;
}

.notice--sample .notice__icon,
.notice--warn .notice__icon {
  color: var(--warn-text);
}

.notice--error .notice__icon {
  color: var(--danger-text);
}

.notice--ok .notice__icon {
  color: var(--accent-text);
}

.notice::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: var(--border-strong);
}

.notice strong {
  font-weight: var(--fw-bold);
}

.notice--sample,
.notice--warn {
  border-color: var(--warn-border);
  background: var(--warn-soft);
  color: var(--text);
}

.notice--sample::before,
.notice--warn::before {
  background: var(--warn);
}

.notice--sample strong,
.notice--warn strong {
  color: var(--warn-text);
}

.notice--error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.notice--error::before {
  background: var(--danger);
}

.notice--error strong {
  color: var(--danger-text);
}

.notice--ok {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.notice--ok::before {
  background: var(--accent);
}

.notice--ok strong {
  color: var(--accent-text);
}

/* ---------------------------------------------------------------- 8. footer */

.footer {
  margin-top: var(--sp-8);
  padding: var(--sp-7) var(--sp-4) var(--sp-8);
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
}

.footer__cols {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  gap: var(--sp-6);
}

.footer h2 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-1);
  font-weight: var(--fw-bold);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-subtle);
}

.footer p {
  font-size: var(--fs-2);
  line-height: var(--lh-snug);
}

.footer__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
  font-size: var(--fs-2);
}

.footer__meta {
  max-width: min(var(--maxw), 80ch);
  margin: var(--sp-6) auto 0;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-1);
}

@media (min-width: 40rem) {
  .cols {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  }

  .footer__cols {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 60rem) {
  .bottom-nav {
    display: none;
  }

  body {
    padding-bottom: 0;
  }

  .shell__main {
    padding: var(--sp-7) var(--sp-5) var(--sp-8);
  }
}

/* ---------------------------------------------------------- 9. motion & a11y */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .card,
  .notice,
  .topbar,
  .bottom-nav,
  .footer {
    border-color: CanvasText;
  }

  .topbar__nav a[aria-current="page"]::after,
  .bottom-nav__item[aria-current="page"]::before,
  .notice::before {
    background: Highlight;
  }
}

@media print {
  .topbar,
  .bottom-nav,
  .theme-toggle,
  .footer {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .shell__main {
    max-width: none;
    padding: 0;
  }
}
