/* Base styles: a small reset, the page text, and the helpers every page shares.
   Needs tokens.css loaded first. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote {
  margin: 0;
}

img,
svg,
video {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--link);
}

/* Figures that line up in columns. */
.num {
  font-variant-numeric: tabular-nums;
}

/* Keyboard focus. The ring is the accent, so it shows on every surface in both themes. A stage screen, where the accent
   is a fill and not a line, sets --focus-ring instead. */
:focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent));
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* The two logos swap with the theme. Put both in the page; one shows. */
.logo-on-light {
  display: var(--show-on-light);
}

.logo-on-dark {
  display: var(--show-on-dark);
}

/* A segmented control (the .seg of widgets.css and the theme control from theme.js): a soft track with a few buttons
   in it that act as one choice. The track has no overflow: hidden, so nothing it holds is clipped; each button has
   its own rounded corners (the track's radius less its padding) and the chosen one draws its ring inside them.
   The chosen button is raised (surface, shadow) as well as ringed, so the choice does not rest on color alone. */
.theme-control,
.seg {
  --seg-pad: 3px;
  display: inline-flex;
  gap: 2px;
  padding: var(--seg-pad);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

:is(.theme-control, .seg) > button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: calc(var(--radius-md) - var(--seg-pad));
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

:is(.theme-control, .seg) > button:hover:not([aria-pressed="true"]):not(:disabled) {
  background: var(--line);
  color: var(--text);
}

:is(.theme-control, .seg) > button[aria-pressed="true"] {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: inset 0 0 0 2px var(--accent-line), var(--shadow-sm);
}

/* The foundation's focus ring, drawn outside the button's own rounded shape and inside the track's padding, so it
   is not the same thing as the ring of the chosen button. */
:is(.theme-control, .seg) > button:focus-visible {
  z-index: 1;
  outline-offset: 1px;
}

.theme-control > button {
  width: 36px;
  height: 36px;
}

@media (pointer: coarse) {
  .theme-control > button {
    width: var(--touch);
    height: var(--touch);
  }
}

.theme-control > button svg {
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
