/* ==========================================================================
   base.css — Quiet Days Press
   Design tokens (type scale, spacing, palette, radii) + element reset.
   Loaded BEFORE style.css. Do not add component styles here.
   ========================================================================== */

:root {
  /* Type scale — fluid, 12px floor */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 0.9375rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.1vw, 2.125rem);
  --text-2xl: clamp(2rem, 1.35rem + 2.1vw, 3.25rem);

  /* 4px spacing system */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Content widths */
  --content-narrow: 42rem;
  --content-default: 60rem;
  --content-wide: 76rem;

  /* Radii — deliberately near-square. This is a print imprint, not a SaaS app. */
  --radius-sm: 1px;
  --radius-md: 2px;
  --radius-full: 9999px;

  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Type DNA (locked by QDP_Design_Aesthetic_Specs.md) */
  --font-display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --font-body: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;

  /* ---- Catalog-level imprint palette (light / "paper") ----
     Imprint constants: ink, paper, brass.
     Per-title accents are overridden on a scoped element — see
     [data-product="mind-field"] in style.css. */
  --color-bg: #f2efe7;
  --color-surface: #f7f4ed;
  --color-surface-2: #ece8dd;
  --color-surface-offset: #e5e0d3;
  --color-divider: #d8d2c3;
  --color-border: #c4bda9;

  --color-text: #17150f;
  --color-text-muted: #5c574a;
  --color-text-faint: #8c8778;
  --color-text-inverse: #f2efe7;

  /* Brass: dim brass carries light mode for contrast (AA on paper) */
  --color-primary: #6f5d38;
  --color-primary-hover: #514328;
  --color-primary-active: #382f1c;
  --color-primary-quiet: #cfc6ac;

  --color-ink-field: #0a0a0a; /* the constant black field of the imprint */
  --color-error: #8a3521;
  --color-success: #405c31;

  --shadow-sm: 0 1px 2px rgb(23 21 15 / 0.06);
  --shadow-md: 0 6px 18px rgb(23 21 15 / 0.09);
  --shadow-lg: 0 22px 48px -12px rgb(23 21 15 / 0.22);
}

/* ---- Dark ("field") ---- */
[data-theme='dark'] {
  --color-bg: #0a0a0a;
  --color-surface: #101010;
  --color-surface-2: #151412;
  --color-surface-offset: #1a1917;
  --color-divider: #262421;
  --color-border: #333333;

  --color-text: #e8e2d4;
  --color-text-muted: #98928a;
  --color-text-faint: #6b665e;
  --color-text-inverse: #0a0a0a;

  --color-primary: #b8985b;
  --color-primary-hover: #cdae72;
  --color-primary-active: #e0c793;
  --color-primary-quiet: #453a24;

  --color-ink-field: #0a0a0a;
  --color-error: #d08a6f;
  --color-success: #8fae77;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.5);
  --shadow-md: 0 6px 18px rgb(0 0 0 / 0.55);
  --shadow-lg: 0 22px 48px -12px rgb(0 0 0 / 0.7);
}

/* System preference for visitors who have not used the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0a0a0a;
    --color-surface: #101010;
    --color-surface-2: #151412;
    --color-surface-offset: #1a1917;
    --color-divider: #262421;
    --color-border: #333333;
    --color-text: #e8e2d4;
    --color-text-muted: #98928a;
    --color-text-faint: #6b665e;
    --color-text-inverse: #0a0a0a;
    --color-primary: #b8985b;
    --color-primary-hover: #cdae72;
    --color-primary-active: #e0c793;
    --color-primary-quiet: #453a24;
    --color-error: #d08a6f;
    --color-success: #8fae77;
  }
}

/* ---------------------------- reset ---------------------------- */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: var(--space-20);
}

body {
  min-height: 100dvh;
  line-height: 1.65;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color 320ms ease, color 320ms ease;
}

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

ul[role='list'],
ol[role='list'] {
  list-style: none;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
  line-height: 1.15;
  font-weight: 400;
}

p,
li,
figcaption {
  text-wrap: pretty;
  max-width: 68ch;
}

::selection {
  background: var(--color-primary-quiet);
  color: var(--color-text);
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

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

a,
button,
[role='button'],
input,
textarea,
select {
  transition: color var(--transition-interactive), background var(--transition-interactive),
    border-color var(--transition-interactive), box-shadow var(--transition-interactive),
    opacity var(--transition-interactive);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
