/* ==========================================================================
   MODERN CSS RESET
   Combines best of Josh Comeau, Andy Bell, and our own opinionated tweaks
   for political/static-site work.
   ========================================================================== */

/* Use border-box everywhere; predictable layout math */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margin/padding on common elements but keep semantic spacing
   we'll re-apply via typography.css */
html,
body,
h1, h2, h3, h4, h5, h6,
p, blockquote, figure, hr,
ul, ol, dl, dt, dd,
pre,
fieldset, legend,
table, th, td {
  margin: 0;
  padding: 0;
}

/* Allow percentage-based heights in the application */
html, body {
  block-size: 100%;
}

/* Smooth scrolling, but only when not reduced motion */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Native form control color */
  color-scheme: light dark;
  tab-size: 4;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

body {
  min-block-size: 100vh;
  min-block-size: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  background: var(--surface-bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: var(--weight-regular);
  overflow-x: clip;
}

/* Inheritable defaults */
input, button, textarea, select, optgroup {
  font: inherit;
  color: inherit;
}

/* Avoid font-size inflation on iOS landscape */
@supports (-webkit-touch-callout: none) {
  body {
    -webkit-text-size-adjust: none;
  }
}

/* Improve media defaults */
img, picture, video, canvas, svg, iframe, embed, object {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

img, video {
  font-style: italic;
  background-repeat: no-repeat;
  background-size: cover;
  shape-margin: 0.75rem;
}

/* Inherit fonts for inputs and buttons */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: transparent;
  border: 0;
  margin: 0;
}

button {
  cursor: pointer;
  background: none;
  padding: 0;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

/* Remove iOS rounded corners on inputs */
input,
textarea,
select,
button {
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--field-placeholder);
  opacity: 1;
}

/* Strip list defaults when ARIA role indicates non-list use */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* Anchor defaults */
a {
  color: var(--text-link);
  text-decoration-color: currentColor;
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.2em;
  transition: color var(--motion-fast) var(--ease-out),
              text-decoration-color var(--motion-fast) var(--ease-out);
}

a:hover {
  color: var(--text-link-hover);
  text-decoration-thickness: 0.125em;
}

a:focus-visible {
  outline: var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

a:not([class]) {
  text-decoration-skip-ink: auto;
}

/* Tables */
table {
  border-collapse: collapse;
  border-spacing: 0;
  inline-size: 100%;
}

/* HR */
hr {
  border: 0;
  block-size: 1px;
  background: var(--surface-border);
  margin-block: var(--space-6);
}

/* Address */
address {
  font-style: normal;
}

/* SVG icon defaults */
svg {
  fill: currentColor;
  flex-shrink: 0;
}

/* Forms */
fieldset {
  border: 0;
}

legend {
  padding: 0;
  display: table;
}

/* Make textareas easier to resize */
textarea {
  resize: vertical;
  min-block-size: 6rem;
}

/* Remove number-input spinners (we use proper validation instead) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Style focus rings consistently */
:focus {
  outline: none;
}
:focus-visible {
  outline: var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Selection */
::selection {
  background-color: var(--color-navy-700);
  color: var(--color-ink-0);
}

/* Improve disabled state visibility */
:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Prevent layout shift from sticky positioning behavior */
[hidden] {
  display: none !important;
}

/* Accessibility: hide visually but keep for assistive tech */
.sr-only,
.visually-hidden {
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  block-size: 1px;
  inline-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:focus-within {
  position: static !important;
  clip: auto;
  clip-path: none;
  block-size: auto;
  inline-size: auto;
  margin: 0;
  overflow: visible;
  white-space: normal;
}

/* Skip link visible on focus */
.skip-link {
  position: absolute;
  inset-block-start: -100px;
  inset-inline-start: 0;
  background: var(--color-navy-900);
  color: var(--color-ink-0);
  padding: var(--space-3) var(--space-5);
  text-decoration: none;
  font-weight: var(--weight-semibold);
  z-index: var(--z-max);
  border-end-end-radius: var(--radius-md);
  transition: inset-block-start var(--motion-fast) var(--ease-out);
}

.skip-link:focus,
.skip-link:focus-visible {
  inset-block-start: 0;
}

/* Avoid font swap layout shift */
.font-loaded body {
  font-display: swap;
}

/* Long-word breaking */
.break-words {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Smooth scroll-margin so anchors land below sticky header */
[id] {
  scroll-margin-block-start: calc(var(--header-height) + 1rem);
}

/* Make sure focus rings don't get clipped by overflow */
:focus-visible {
  position: relative;
  z-index: 1;
}
