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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Stop iOS flashing a grey box on every tap; focus styles below do the job instead. */
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
  /* A long unbroken word (e.g. a URL in a place's text) wraps rather than widening the page. */
  overflow-wrap: break-word;
}

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

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

/* Typography */
h1,
h2,
h3 {
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-bold);
  /* Headings often sit in grid or flex layouts, which only wrap a long word with "anywhere". */
  overflow-wrap: anywhere;
}

/* Titles get the display serif: a nod to old signage and print, and a clear step up from body text. */
h1,
h2 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-display);
}

h1 {
  font-size: var(--font-size-xl);
}

h2 {
  font-size: var(--font-size-lg);
}

h3 {
  font-size: var(--font-size-md);
}

p {
  max-width: 65ch;
}

a {
  color: var(--color-accent);
  text-underline-offset: 0.15em;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-target);
  min-width: var(--tap-target);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-button-bg);
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-standard),
    transform var(--duration-fast) var(--easing-standard), filter var(--duration-fast) var(--easing-standard);
  touch-action: manipulation;
}

.button:active {
  background-color: var(--color-button-bg-active);
  transform: scale(0.96);
}

/* Only where there's a real pointer: iOS keeps :hover on whatever was last tapped. */
@media (hover: hover) {
  .button:hover {
    background-color: var(--color-button-bg-active);
  }

  .button--primary:hover {
    filter: brightness(1.05);
  }
}

.button--primary,
.button--primary:hover,
.button--primary:active {
  background: var(--color-accent-gradient);
  color: var(--color-text-on-accent);
  box-shadow: var(--shadow-accent);
}

.button--primary:active {
  filter: brightness(0.94);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Focus: only show the ring for keyboard users, but make it unmissable when shown. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* App shell. Safe-area padding keeps content clear of the notch and home indicator. */
.app {
  min-height: 100%;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + var(--space-4)) calc(var(--safe-right) + var(--space-4))
    calc(var(--safe-bottom) + var(--space-4)) calc(var(--safe-left) + var(--space-4));
}

.app:focus {
  outline: none;
}

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