/* ============================================
   BASE RESET & FOUNDATION
   Metamorfosis — Jimmy Frech
   ============================================ */

*, *::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-16);
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body, sans-serif);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

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; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }

::selection {
  background: oklch(from var(--color-primary) l c h / 0.2);
  color: var(--color-text);
}

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

@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;
  }
}

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

.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;
}

/* ============================================
   DESIGN TOKENS
   ============================================ */

:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.8125rem);
  --text-sm:   clamp(0.875rem, 0.83rem + 0.25vw, 0.9375rem);
  --text-base: clamp(1rem,     0.95rem + 0.3vw,  1.0625rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.65vw, 1.375rem);
  --text-xl:   clamp(1.375rem, 1rem    + 1.2vw,  2rem);
  --text-2xl:  clamp(1.75rem,  1.2rem  + 2vw,    2.75rem);
  --text-3xl:  clamp(2.25rem,  1rem    + 3.5vw,  4rem);
  --text-hero: clamp(3rem,     1rem    + 5.5vw,  6rem);

  /* 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-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Font Families */
  --font-display: 'Inter', 'Helvetica Neue', sans-serif;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 800px;
  --content-wide: 1080px;
  --content-full: 100%;
}

/* ============================================
   LIGHT MODE — White/Clean
   ============================================ */
:root, [data-theme="light"] {
  --color-bg:             #ffffff;
  --color-surface:        #f9fafb;
  --color-surface-2:      #f3f4f6;
  --color-surface-offset: #f5f5f5;
  --color-surface-offset-2: #eeeeee;
  --color-surface-dynamic: #e5e7eb;
  --color-divider:        #e5e7eb;
  --color-border:         #d1d5db;

  --color-text:           #111827;
  --color-text-muted:     #6b7280;
  --color-text-faint:     #9ca3af;
  --color-text-inverse:   #ffffff;

  /* Accent — olive green */
  --color-primary:        #7a9e1e;
  --color-primary-hover:  #6a8a19;
  --color-primary-active: #587413;
  --color-primary-highlight: #e8f0d2;

  --color-error:          #dc2626;
  --color-error-hover:    #b91c1c;
  --color-error-active:   #991b1b;
  --color-error-highlight: #fde8e8;

  --color-success:        #16a34a;
  --color-success-hover:  #15803d;
  --color-success-active: #166534;
  --color-success-highlight: #dcfce7;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
  --shadow-book: 0 20px 50px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.06);
}

/* ============================================
   DARK MODE — Dark navy
   ============================================ */
[data-theme="dark"] {
  --color-bg:             #0f172a;
  --color-surface:        #1e293b;
  --color-surface-2:      #283548;
  --color-surface-offset: #162032;
  --color-surface-offset-2: #1a2740;
  --color-surface-dynamic: #334155;
  --color-divider:        #1e293b;
  --color-border:         #334155;

  --color-text:           #f1f5f9;
  --color-text-muted:     #94a3b8;
  --color-text-faint:     #64748b;
  --color-text-inverse:   #0f172a;

  --color-primary:        #a3c43a;
  --color-primary-hover:  #b8d64f;
  --color-primary-active: #8fb030;
  --color-primary-highlight: #1a2a12;

  --color-error:          #f87171;
  --color-error-hover:    #fca5a5;
  --color-error-active:   #ef4444;
  --color-error-highlight: #2d1515;

  --color-success:        #4ade80;
  --color-success-hover:  #22c55e;
  --color-success-active: #16a34a;
  --color-success-highlight: #14261a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-book: 0 20px 50px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* System preference is handled via JS + data-theme attribute */
