/* ==========================================================================
   base.css — Reset, typography baseline, focus, accessibility utilities,
   font-face declarations, and user-preference overrides.
   Source of truth: design/DESIGN.md §3.2, §3.4, §3.4.1, §4.11.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Modern reset (compact)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  line-height: var(--lh-body);
  font-family: var(--ff-sans);
  font-size: var(--fs-body);
  color: var(--c-ink-2);
  background-color: var(--c-paper);
  text-rendering: optimizeLegibility;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   @font-face — self-hosted WOFF2, sourced from Google Fonts (SIL OFL).
   Both families ship as variable fonts; the same file serves every weight
   we use via the wght axis. The browser only downloads the latin-ext subset
   when a glyph in that range is actually rendered (Romanian: ă â î ș ț).
   `font-display: swap` keeps LCP cheap; the system-fallback metric overrides
   below minimise CLS during the swap.
   -------------------------------------------------------------------------- */

/* Playfair Display — used at 400 and 600/700 for serif display + headings */
@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/playfair-display-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/playfair-display-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Inter — used at 400, 500, 600 for body, eyebrow, nav, buttons */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* System-font fallback metric overrides (reduces CLS during swap).
   Applied automatically while WOFF2 is loading. */
@font-face {
  font-family: "Playfair Display Fallback";
  src: local("Georgia");
  size-adjust: 102%;
  ascent-override: 95%;
  descent-override: 25%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 100%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* --------------------------------------------------------------------------
   Typography defaults
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--ff-serif);
  color: var(--c-ink);
  letter-spacing: var(--tk-display);
  line-height: var(--lh-h2);
  font-weight: 600;
}

h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); line-height: 1.25; }

p {
  max-width: 70ch;
}

a {
  color: var(--c-ink);
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--c-gold);
}

::selection {
  background-color: var(--c-gold);
  color: var(--c-ink);
}

/* --------------------------------------------------------------------------
   :focus-visible — per-surface contrast (DESIGN §4.11)
   Default: gold ring on light surfaces. Overridden inside .surface-ink for dark.
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 3px;
  border-radius: 2px;
}

.surface-ink :focus-visible,
.surface-ink:focus-visible {
  outline-color: var(--c-on-ink);
}

/* --------------------------------------------------------------------------
   Skip link — first focusable element on every page
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: var(--z-skip-link);
  padding: var(--sp-3) var(--sp-4);
  background-color: var(--c-ink);
  color: var(--c-on-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--c-on-ink);
}

/* --------------------------------------------------------------------------
   .sr-only — visually hidden, available to assistive tech
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Eyebrow label utility (DESIGN §3.2)
   -------------------------------------------------------------------------- */
.eyebrow {
  font-size: var(--fs-eyebrow);
  letter-spacing: var(--tk-eyebrow);
  text-transform: uppercase;
  color: var(--c-gold);
  font-weight: 500;
}

/* Decorative gold rule under headlines (DESIGN §3.4) */
.rule-gold {
  display: block;
  width: var(--rule-w-eyebrow);
  height: 1px;
  background-color: var(--c-gold);
  border: 0;
  margin-block: var(--sp-4);
}

/* --------------------------------------------------------------------------
   User preferences — DESIGN §3.4.1
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :focus-visible {
    outline-width: 3px;
  }

  .rule-gold {
    background-color: var(--c-ink);
  }
}

/* Windows High Contrast / forced-colors mode */
@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid CanvasText;
  }

  .rule-gold {
    background-color: CanvasText;
    forced-color-adjust: none;
  }
}
