/**
 * @file
 * Base element styling. No classes here — only bare elements and the
 * handful of utilities every page needs.
 */

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Headings ---------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-brand-strong);
  text-wrap: balance;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5,
h6 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Text -------------------------------------------------------------- */

p,
ul,
ol,
dl,
blockquote,
figure,
table {
  margin: 0 0 var(--space-md);
}

p {
  text-wrap: pretty;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover,
a:focus {
  color: var(--color-link-hover);
}

strong,
b {
  font-weight: var(--fw-semibold);
}

small {
  font-size: var(--fs-xs);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  padding: var(--space-sm);
  overflow-x: auto;
  background: var(--c-ink-100);
  border-radius: var(--radius-md);
}

blockquote {
  padding-left: var(--space-md);
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-muted);
  font-size: var(--fs-md);
}

hr {
  height: 0;
  margin: var(--space-xl) 0;
  border: 0;
  border-top: var(--border-rule);
}

/* Lists ------------------------------------------------------------- */

ul,
ol {
  padding-left: var(--space-md);
}

li + li {
  margin-top: var(--space-3xs);
}

/* Media ------------------------------------------------------------- */

img,
picture,
svg,
video,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

figure figcaption {
  margin-top: var(--space-2xs);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

/* Tables — SWALIM publishes a lot of tabular station data ------------ */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

caption {
  margin-bottom: var(--space-2xs);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  text-align: left;
}

th,
td {
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: var(--border-hairline);
  text-align: left;
  vertical-align: top;
}

th {
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-brand);
  border-bottom: 2px solid var(--color-brand);
  white-space: nowrap;
}

/* Numeric cells read as data, not prose. */
td.numeric,
th.numeric {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

tbody tr:hover {
  background: var(--c-green-100);
}

/* Forms ------------------------------------------------------------- */

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

input[type='text'],
input[type='search'],
input[type='email'],
input[type='url'],
input[type='tel'],
input[type='password'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-brand);
}

label {
  display: block;
  margin-bottom: var(--space-3xs);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

/* Focus — visible and consistent, never removed ---------------------- */

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Utilities --------------------------------------------------------- */

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

.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
  position: static !important;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: inherit;
}

.skip-link {
  position: absolute;
  z-index: var(--z-modal);
  top: var(--space-2xs);
  left: var(--space-2xs);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-brand-strong);
  color: var(--c-white);
  border-radius: var(--radius-md);
  text-decoration: none;
}
