/* ==========================================================================
   Meowsic Design Tokens — "Analog Press × Audio Lab"
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces (Warm Vinyl Carbon — default) */
  --bg: #0a0a09;
  --bg-2: #11110f;
  --bg-stage: #050505;
  --surface: #141412;
  --surface-2: #1c1c19;
  --surface-hover: rgba(244, 239, 230, 0.055);
  --surface-glass: rgba(10, 10, 9, 0.86);

  /* Ink */
  --ink: #f4efe6;
  --ink-2: #c9c3b8;
  --muted: #948d80;

  /* Architectural Rules */
  --rule: rgba(244, 239, 230, 0.12);
  --rule-strong: rgba(244, 239, 230, 0.26);

  /* Dynamic Song-Synced Accent (Studio Jade default) */
  --accent: #2ee585;
  --accent-rgb: 46, 229, 133;
  --accent-soft: rgba(var(--accent-rgb), 0.11);
  --accent-dim: rgba(var(--accent-rgb), 0.26);
  --accent-glow: rgba(var(--accent-rgb), 0.30);
  --accent-contrast: #06150c;

  /* Meowsic PRE (Warm Brushed Brass) */
  --brass: #dfb364;
  --brass-rgb: 223, 179, 100;
  --brass-soft: rgba(223, 179, 100, 0.10);
  --brass-rule: rgba(223, 179, 100, 0.32);
  --brass-contrast: #171104;

  /* Semantic Status */
  --danger: #e86b58;
  --danger-soft: rgba(232, 107, 88, 0.11);
  --warning: #e0a44c;
  --success: #2ee585;

  /* Semantic Token Aliases */
  --text: var(--ink);
  --text-secondary: var(--ink-2);
  --border: var(--rule);
  --border-strong: var(--rule-strong);
  --bg-elevated: var(--bg-2);
  --pre-gold: var(--brass);
  --pre-gold-rgb: var(--brass-rgb);
  --pre-soft: var(--brass-soft);
  --pre-border: var(--brass-rule);
  --pre-contrast: var(--brass-contrast);

  /* Typography */
  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Type Scale */
  --text-xs: 0.78rem;
  --text-sm: 0.88rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.38rem;
  --text-2xl: clamp(1.55rem, 1.2rem + 1.4vw, 2.1rem);
  --text-3xl: clamp(1.95rem, 1.4rem + 2.2vw, 2.85rem);
  --text-hero: clamp(2.45rem, 1.6rem + 3.4vw, 4.1rem);

  /* Spacing (4/8px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* Sharp Industrial Radii */
  --radius-none: 0px;
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-window: 12px;
  --radius-pill: 999px;

  /* Elevation Shadows */
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.48);
  --shadow-stage: 0 26px 68px rgba(0, 0, 0, 0.64), 0 0 0 1px rgba(244, 239, 230, 0.08);

  /* Motion */
  --dur-fast: 140ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Layout */
  --frame-max: 1320px;
  --container-max: 1320px;
  --header-h: 64px;
}

/* Light Mode — Archival Print Paper */
[data-theme="light"] {
  color-scheme: light;

  --bg: #f3efe6;
  --bg-2: #eae4d7;
  --bg-stage: #0e0e0c;
  --surface: #ebe5d8;
  --surface-2: #e0d9ca;
  --surface-hover: rgba(20, 19, 17, 0.05);
  --surface-glass: rgba(243, 239, 230, 0.90);

  --ink: #141311;
  --ink-2: #33302a;
  --muted: #59544b;

  --rule: rgba(20, 19, 17, 0.14);
  --rule-strong: rgba(20, 19, 17, 0.30);

  --accent: #0d7540;
  --accent-rgb: 13, 117, 64;
  --accent-contrast: #f7f4ee;

  --brass: #704906;
  --brass-rgb: 112, 73, 6;
  --brass-soft: rgba(112, 73, 6, 0.09);
  --brass-rule: rgba(112, 73, 6, 0.30);
  --brass-contrast: #ffffff;

  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --warning: #8a5200;
  --success: #0d7540;

  --shadow-sm: 0 2px 10px rgba(20, 19, 17, 0.06);
  --shadow-md: 0 12px 28px rgba(20, 19, 17, 0.10);
  --shadow-stage: 0 22px 52px rgba(20, 19, 17, 0.16), 0 0 0 1px rgba(20, 19, 17, 0.10);
}

/* ==========================================================================
   Base Reset, Analog Grain & Accessibility Primitives
   ========================================================================== */

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

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

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Subtle analog paper/vinyl grain overlay */
body::after {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  opacity: 0.026;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 240px 240px;
}

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

img {
  height: auto;
}

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

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

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

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
ul,
ol,
dl,
dd {
  margin: 0;
}

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

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
}

[hidden] {
  display: none !important;
}

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

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0.01ms;
    --dur-base: 0.01ms;
    --dur-slow: 0.01ms;
  }

  html {
    scroll-behavior: auto;
  }
}
