/* Base: reset, layout and accessibility helpers. Colors and sizes come from themes.css. */

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

html {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

main:focus {
  outline: none;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 var(--space-md);
}

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

h1 {
  font-size: var(--font-size-h1);
  color: var(--color-heading);
}

h1:focus {
  outline: none;
}

p {
  margin: 0 0 var(--space-md);
  max-width: 65ch;
}

/* Links stand alone in this app (no links inside paragraphs): no underline, except on hover. */
a {
  color: var(--color-link);
}

/* Zero specificity, so links styled as buttons or tiles keep their own look. */
:where(a) {
  text-decoration: none;
}

:where(a:hover) {
  text-decoration: underline;
}

/* The hidden attribute always wins, even over components that set their own display. */
[hidden] {
  display: none !important;
}

/* Visible focus for every interactive element, keyboard-only. */
:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: 3px;
}

.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.6em 1.2em;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-on-accent);
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--color-accent-hover);
}

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

.button--secondary {
  background: transparent;
  color: var(--color-link);
  border-color: currentColor;
}

.button--secondary:hover {
  background: var(--color-surface);
}

/* Forms */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0; /* a fieldset is as wide as its content by default: it would overflow a phone */
  margin: 0;
  padding: 0;
  border: 0;
}

.field > label,
.field > legend {
  font-weight: 600;
  padding: 0;
}

select {
  max-width: 100%;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.35em 0.6em;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding-top: var(--space-sm);
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  cursor: pointer;
}

.choice input {
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--color-accent);
}

/* Alerts */
.alert {
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.alert > :last-child {
  margin-bottom: 0;
}

.alert--warning {
  background: var(--color-warning-bg);
  border: 2px solid var(--color-warning-border);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
}

.card > :last-child {
  margin-bottom: 0;
}

.lead {
  font-size: 1.2em;
}

.muted {
  color: var(--color-text-muted);
}

.skip-link {
  position: absolute;
  left: var(--space-md);
  top: -100px;
  z-index: 10;
  padding: 0.5em 1em;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: var(--space-md);
}

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

.noscript {
  max-width: 40rem;
  margin: 2rem auto;
  padding: 1rem;
}

@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;
  }
}
