/* ==========================================================================
   base.css — design tokens, fonts, typography, base elements
   --------------------------------------------------------------------------
   1. Fonts (@font-face, local files only)
   2. Design tokens (:root) — colours, type scale, spacing, layout
   3. Base elements
   4. Typography helpers
   5. Accessibility helpers (focus, skip link, visually hidden)
   6. Reduced motion
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/playfair-display-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/playfair-display-latin-wght-italic.woff2") format("woff2");
}

/* 2. Design tokens -------------------------------------------------------- */
:root {
  /* Colours — change these to re-theme the whole template */
  --ink: #0E0E0E;          /* body text, headlines */
  --paper: #F7F5F0;        /* page background */
  --surface: #FFFFFF;      /* cards, form fields */
  --accent: #1F3FBF;       /* links on hover, focus, small highlights */
  --muted: #8A8A85;        /* large meta text, icons, decorative marks */
  --muted-text: #6B6B66;   /* small captions (meets 4.5:1 on paper) */
  --rule: #E2DFD8;         /* hairline dividers */
  --accent-soft: #D5DCF5;  /* pale cobalt — image backgrounds only, never text */

  /* Typefaces */
  --font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Type scale — six fixed steps. Every font-size in the template uses one of these. */
  --fs-display: clamp(3.5rem, 2.2rem + 5.2vw, 5rem);
  --fs-h1: clamp(2.5rem, 2.1rem + 1.6vw, 3.25rem);
  --fs-h2: clamp(1.75rem, 1.55rem + 0.8vw, 2.25rem);
  --fs-h3: clamp(1.25rem, 1.15rem + 0.4vw, 1.5rem);
  --fs-body: 1rem;
  --fs-small: 0.875rem;

  --lh-heading: 1.15;
  --lh-body: 1.65;

  /* Spacing — one 8px-based scale. Use only these values. */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 40px;
  --s5: 64px;
  --s6: 96px;
  --s7: 144px;

  /* Layout */
  --max-width: 1320px;
  --page-pad: var(--s3);           /* side padding; doubled on desktop (layout.css) */
  --gutter: var(--s3);
  --measure: 68ch;                 /* comfortable reading width */
  --section-pad: var(--s5);        /* vertical section padding; --s6 from 768px */
  --rule-thin: 1px;
  --rule-heavy: 3px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 600ms;
}

/* 3. Base elements -------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

/* Keep the hidden attribute working even on elements that set their own display. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-feature-settings: "kern", "liga";
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: var(--lh-heading);
  overflow-wrap: break-word;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-body); font-family: var(--font-sans); font-weight: 600; }

p,
ul,
ol,
dl,
blockquote,
figure,
pre,
table { margin: 0; }

ul,
ol { padding: 0; }

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

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: var(--rule-thin);
  text-underline-offset: 0.2em;
  transition: color 200ms var(--ease);
}

a:hover { color: var(--accent); }

hr {
  height: 0;
  margin: 0;
  border: 0;
  border-top: var(--rule-thin) solid var(--rule);
}

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

code,
pre,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--fs-small);
}

::selection {
  background: var(--accent);
  color: var(--surface);
}

/* 4. Typography helpers --------------------------------------------------- */
.display {
  font-family: var(--font-serif);
  font-size: var(--fs-display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.lead {
  font-size: var(--fs-h3);
  font-family: var(--font-serif);
  line-height: 1.45;
}

.meta {
  color: var(--muted-text);
  font-size: var(--fs-small);
}

.prose > * + * { margin-top: var(--s2); }

.prose { max-width: var(--measure); }

.prose ul,
.prose ol { padding-left: var(--s3); }

/* 5. Accessibility helpers ------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: var(--s1);
  left: var(--s1);
  z-index: 100;
  padding: var(--s1) var(--s2);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--fs-small);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

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

/* 6. Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
