/* ==========================================================================
   Custom Door & Mirror — main.css
   Fonts · design tokens · reset · base typography · layout primitives
   Reference: docs/DESIGN-SYSTEM.md
   ========================================================================== */

/* ---------- Fonts (local, latin subset) ---------- */
@font-face {
  font-family: "Instrument Serif";
  src: url("../assets/fonts/instrument-serif-italic-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../assets/fonts/plus-jakarta-sans-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Design tokens ---------- */
:root {
  /* Palette */
  --color-ivory: #ffffff;        /* page background */
  --color-linen: #f6f1eb;        /* warm soft surface, cards */
  --color-sand: #ebe2d6;
  --color-stone: #8a94a0;
  --color-graphite: #55606b;
  --color-charcoal: #142230;     /* midnight navy */
  --color-ink: #0d1822;
  --color-bronze: #a85a30;       /* copper (5.0:1 on white) */
  --color-bronze-light: #e0a27a; /* light copper for dark surfaces */
  --color-white: #ffffff;
  --color-error: #9b3b2e;
  --color-success: #4f6b4a;

  /* Semantic roles (re-mapped inside .section--dark) */
  --bg: var(--color-ivory);
  --surface: var(--color-linen);
  --text: var(--color-charcoal);
  --text-muted: var(--color-graphite);
  --accent: var(--color-bronze);
  --line: rgba(20, 34, 48, 0.12);
  --line-strong: rgba(20, 34, 48, 0.28);

  /* Typography */
  --font-display: "Plus Jakarta Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-sans: "Plus Jakarta Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-accent: "Instrument Serif", Georgia, "Times New Roman", serif; /* italic accent words only */

  --fs-display: clamp(2.5rem, 1.5rem + 3.4vw, 4.5rem);
  --fs-h1: clamp(2.25rem, 1.5rem + 2.6vw, 3.75rem);
  --fs-h2: clamp(1.875rem, 1.35rem + 1.8vw, 3rem);
  --fs-h3: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
  --fs-h4: 1.25rem;
  --fs-lead: clamp(1.125rem, 1.03rem + 0.4vw, 1.375rem);
  --fs-body: 1rem;
  --fs-small: 0.875rem;
  --fs-eyebrow: 0.75rem;

  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-display: 650;

  --lh-tight: 1.06;
  --lh-heading: 1.12;
  --lh-body: 1.7;
  --tracking-display: -0.03em;
  --tracking-eyebrow: 0.14em;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;
  --section-y: clamp(4.5rem, 2.8rem + 7vw, 10rem);
  --section-y-sm: clamp(3rem, 2rem + 4vw, 6rem);
  --gutter: clamp(1.25rem, 0.6rem + 3vw, 3.5rem);
  --grid-gap: clamp(1rem, 0.5rem + 2vw, 2.5rem);

  /* Layout */
  --container: 1320px;
  --container-narrow: 760px;
  --container-wide: 1600px;
  --header-h: 76px;

  /* Shape & elevation */
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 10px rgba(20, 34, 48, 0.06);
  --shadow-md: 0 24px 48px -24px rgba(20, 34, 48, 0.32);

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 180ms;
  --dur-base: 320ms;
  --dur-slow: 700ms;
  --dur-reveal: 900ms;

  /* Layers */
  --z-header: 100;
  --z-menu: 90;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.is-menu-open {
  overflow: hidden;
}

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

img {
  height: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
  font-synthesis: none;
}

p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

p {
  text-wrap: pretty;
}

/* :where() keeps specificity at zero so utilities like .u-mt-* still apply */
:where(ul[class], ol[class]) {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

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

button {
  cursor: pointer;
}

address {
  font-style: normal;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

/* ---------- Accessibility helpers ---------- */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: calc(var(--z-header) + 1);
  padding: var(--space-3) var(--space-4);
  background: var(--color-charcoal);
  color: var(--color-ivory);
  font-size: var(--fs-small);
  transform: translateY(-200%);
}

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

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

/* ---------- Typography ---------- */
.display,
.h1,
.h2,
.h3 {
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  letter-spacing: var(--tracking-display);
}

.display {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
}

.h1 {
  font-size: var(--fs-h1);
  line-height: 1.05;
}

.h2 {
  font-size: var(--fs-h2);
}

.h3 {
  font-size: var(--fs-h3);
}

.h4 {
  font-family: var(--font-sans);
  font-size: var(--fs-h4);
  font-weight: var(--fw-medium);
  letter-spacing: -0.005em;
  line-height: 1.35;
}

/* Accent words: serif italic inside sans headlines */
.display em,
.h1 em,
.h2 em,
.h3 em {
  font-family: var(--font-accent);
  font-size: 1.08em;
  font-style: italic;
  font-weight: var(--fw-regular);
  letter-spacing: -0.01em;
  color: var(--accent);
}

.lead {
  font-size: var(--fs-lead);
  font-weight: var(--fw-regular);
  line-height: 1.6;
  color: var(--text-muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-eyebrow);
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow--rule::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.label {
  font-family: var(--font-sans);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-eyebrow);
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.muted {
  color: var(--text-muted);
}

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

.prose p {
  max-width: 64ch;
  color: var(--text-muted);
}

.prose a {
  color: var(--text);
}

.prose ul {
  padding-left: 1.1em;
  color: var(--text-muted);
}

.prose li + li {
  margin-top: var(--space-2);
}

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: calc(var(--container-narrow) + var(--gutter) * 2);
}

.container--wide {
  max-width: calc(var(--container-wide) + var(--gutter) * 2);
}

.section {
  padding-block: var(--section-y);
}

.section--tight {
  padding-block: var(--section-y-sm);
}

.section--flush-top {
  padding-top: 0;
}

.section--surface {
  background: var(--surface);
}

.section--dark {
  --bg: var(--color-charcoal);
  --surface: #1c2d3d;
  --text: var(--color-ivory);
  --text-muted: rgba(255, 255, 255, 0.72);
  --accent: var(--color-bronze-light);
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.36);
  background: var(--bg);
  color: var(--text);
}

.section--bordered {
  border-top: 1px solid var(--line);
}

.stack > * + * {
  margin-top: var(--stack-gap, var(--space-5));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-5));
}

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--grid-gap);
  row-gap: var(--space-7);
}

.grid-12 > * {
  grid-column: 1 / -1;
}

.rule {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--line);
}

/* ---------- Spacing utilities (use sparingly; prefer component spacing) ---------- */
.u-mt-5 { margin-top: var(--space-5); }
.u-mt-6 { margin-top: var(--space-6); }
.u-mt-7 { margin-top: var(--space-7); }
.u-mt-8 { margin-top: var(--space-8); }
.u-mb-5 { margin-bottom: var(--space-5); }

/* Inline icon sprite (see tools/sync-icons.js): present in the DOM, never rendered */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
