/* ==========================================================================
   Vibeberg — base.css
   Design tokens, resets, and typography.
   Structural/design changes only — do not add component or layout rules here.
   ========================================================================== */

/* ---- Design tokens -------------------------------------------------- */

:root {
  /* Light mode (default) */
  --color-bg: #FAF7F2;
  --color-bg-elevated: #FFFFFF;
  --color-text-primary: #2B2622;
  --color-text-secondary: #6B6058;
  --color-accent-primary: #E0785A;    /* decorative only in light mode — see accent-primary-text */
  --color-accent-secondary: #D9A24B;  /* decorative only, sparing use — fails AA as text/UI (2.13:1) */
  --color-border: #E8E1D8;
  --color-focus-ring: #B8542F;

  /*
   * accent-primary measures 2.81:1 on --color-bg and 3.00:1 on --color-bg-elevated —
   * short of the 4.5:1 AA text minimum (and only just grazing the 3:1 large-text/UI
   * floor). Any button, link, or label that needs to read as accessible text uses
   * this darker derived token instead (4.5–4.8:1). Purely decorative uses (card
   * borders, icon fills, hover glows, gradient stops) can keep using accent-primary.
   */
  --color-accent-primary-text: #B8542F;

  --color-success: #4B7A5A;
  --color-overlay: rgba(43, 38, 34, 0.55);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 3px rgba(43, 38, 34, 0.08);
  --shadow-md: 0 8px 24px rgba(43, 38, 34, 0.10);
  --shadow-lg: 0 20px 48px rgba(43, 38, 34, 0.14);

  --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: 4.5rem;
  --space-9: 6rem;

  --container-max: 1180px;

  color-scheme: light;
}

[data-theme="dark"] {
  --color-bg: #1C1917;
  --color-bg-elevated: #262220;
  --color-text-primary: #F2EDE6;
  --color-text-secondary: #B0A69B;
  --color-accent-primary: #EC916F;    /* accessible as text/UI on dark surfaces (7.37:1) */
  --color-accent-secondary: #E0B563;
  --color-border: #3A342F;
  --color-focus-ring: #EC916F;

  /* Already accessible in dark mode — no darker variant needed. */
  --color-accent-primary-text: #EC916F;

  --color-success: #7FB08C;
  --color-overlay: rgba(0, 0, 0, 0.6);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);

  color-scheme: dark;
}

/* Auto dark-mode detection: applied only when the visitor has never chosen a
   theme explicitly. theme-toggle.js sets data-theme as soon as it runs, and
   a stored choice takes precedence — this media query is just the day-one
   default for visitors who haven't toggled anything yet. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg: #1C1917;
    --color-bg-elevated: #262220;
    --color-text-primary: #F2EDE6;
    --color-text-secondary: #B0A69B;
    --color-accent-primary: #EC916F;
    --color-accent-secondary: #E0B563;
    --color-border: #3A342F;
    --color-focus-ring: #EC916F;
    --color-accent-primary-text: #EC916F;
    --color-success: #7FB08C;
    --color-overlay: rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ---- Reset ------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote {
  margin: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text-primary);
}

h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text-primary);
}

h1 { font-size: clamp(2.25rem, 4vw + 1rem, 3.75rem); }
h2 { font-size: clamp(1.75rem, 2.5vw + 1rem, 2.5rem); }
h3 { font-size: clamp(1.375rem, 1.5vw + 1rem, 1.75rem); }
h4 { font-size: 1.125rem; }

p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-primary);
}

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

.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-primary-text);
}

.serif {
  font-family: var(--font-serif);
}

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

::selection {
  background-color: var(--color-accent-primary);
  color: var(--color-bg-elevated);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  background: var(--color-accent-primary-text);
  color: #FFFFFF;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  z-index: 200;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: var(--space-4);
}
