/* ==========================================================================
   Base — reset, typography, global elements
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

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

img {
  height: auto;
}

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

button {
  cursor: pointer;
}

/* ---------- Typography ---------- */

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-heading);
  color: var(--color-text);
  text-wrap: balance;
  /* Long Bulgarian compounds must never overflow narrow screens.
     No hyphens:auto — browser hyphenation of Bulgarian headings is poor. */
  overflow-wrap: break-word;
}

h1 { font-size: var(--fs-2xl); font-weight: var(--fw-black); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg);  line-height: var(--lh-snug); }
h4 { font-size: var(--fs-md);  line-height: var(--lh-snug); }

p,
li,
dd {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}

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

a:hover {
  color: var(--color-link-hover);
  text-decoration-thickness: 2px;
}

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

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

/* :where() keeps specificity at 0 so component classes can set padding */
:where(ul[role="list"], ol[role="list"]) {
  list-style: none;
  padding: 0;
}

address {
  font-style: normal;
}

hr {
  border: 0;
  border-top: var(--border-w) solid var(--color-border);
}

::selection {
  background: var(--coris-sand);
  color: var(--color-text);
}

/* ---------- Focus ---------- */

:focus {
  outline: none;
}

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

/* Inside dark sections the ring switches to orange */
.u-inverse :focus-visible {
  outline-color: var(--color-focus-inverse);
}

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

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

.u-inverse {
  color: var(--color-inverse-text);
  background-color: var(--color-inverse-bg);
}

/* Dark areas: pale yellow highlight instead of orange */
.u-inverse,
.hero {
  --color-highlight: var(--color-highlight-inverse);
  --color-on-highlight: var(--coris-brown);
}

.u-inverse h1,
.u-inverse h2,
.u-inverse h3 {
  color: var(--color-inverse-text);
}

.u-inverse a:not([class]) {
  color: var(--color-inverse-text);
}

.u-nowrap {
  white-space: nowrap;
}

/* Placeholder content that must be replaced before launch */
.u-placeholder {
  outline: 2px dashed var(--color-warning);
  outline-offset: 2px;
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

/* Reduced motion: kill all transitions/animations globally */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
