/* ==========================================================================
   FRAME & FORM — MASTER STYLESHEET (MAIN.CSS)
   Visual Architecture & Multidisciplinary Creative Direction
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;1,300&family=Space+Grotesk:wght@300;400;500;600;700&family=Syne:wght@400;500;600;700;800&display=swap');

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Color Palette — Stark Editorial & Material Palette */
  --bg-primary: #09090b;
  --bg-secondary: #121215;
  --bg-tertiary: #1a1a1f;
  --bg-elevated: #22222a;
  --bg-glass: rgba(14, 14, 18, 0.78);
  --bg-glass-heavy: rgba(9, 9, 11, 0.92);

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #61616c;
  --text-dim: #3f3f46;

  --border-hairline: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.28);
  --border-active: #ffffff;

  --accent-gold: #d4af37;
  --accent-rust: #e05a47;
  --accent-sage: #3b7a57;
  --accent-blue: #4e82a0;
  --accent-sand: #c2b280;

  /* Typography Stacks */
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-display: 'Syne', sans-serif;
  --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spatial Rhythm */
  --site-gutter: clamp(1.25rem, 4vw, 4rem);
  --section-gap: clamp(5rem, 12vw, 14rem);
  --header-height: 84px;

  /* Transitions & Easings (Architectural / Fluid Curves) */
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-fluid: cubic-bezier(0.25, 1, 0.5, 1);
  --duration-fast: 200ms;
  --duration-normal: 400ms;
  --duration-slow: 750ms;
  --duration-cinematic: 1200ms;

  /* Z-Index Hierarchy */
  --z-grain: 999;
  --z-cursor: 9999;
  --z-modal: 900;
  --z-nav: 500;
  --z-palette: 950;
  --z-toast: 990;
  --z-transition: 980;
}

/* Light Theme Variables (Toggleable if desired) */
[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ebebee;
  --bg-tertiary: #dfdfe4;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(245, 245, 247, 0.82);
  --bg-glass-heavy: rgba(245, 245, 247, 0.95);

  --text-primary: #0f0f11;
  --text-secondary: #4b4b54;
  --text-muted: #888892;
  --text-dim: #c5c5cb;

  --border-hairline: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.16);
  --border-strong: rgba(0, 0, 0, 0.32);
  --border-active: #000000;
}

/* --- Global Reset & Box-Sizing --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  letter-spacing: -0.01em;
  position: relative;
  overflow-x: hidden;
}

/* --- Film Grain Texture Overlay --- */
.grain-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: var(--z-grain);
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Selection */
::selection {
  background-color: var(--text-primary);
  color: var(--bg-primary);
}

/* Links & Buttons Reset */
a {
  color: inherit;
  text-decoration: none;
  cursor: none; /* Relies on custom cursor */
}

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

/* Keyboard Focus States (WCAG AA Compliance) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

img, video {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
}

ul, ol {
  list-style: none;
}

/* Typography Utility Classes */
.font-serif { font-family: var(--font-serif); }
.font-display { font-family: var(--font-display); }
.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }

.italic { font-style: italic; }
.uppercase { text-transform: uppercase; }
.tracking-tight { letter-spacing: -0.03em; }
.tracking-wide { letter-spacing: 0.08em; }
.tracking-widest { letter-spacing: 0.16em; }

.hover-underline {
  position: relative;
  display: inline-block;
}
.hover-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0%;
  height: 1px;
  background-color: currentColor;
  transition: width var(--duration-normal) var(--ease-expo);
}
.hover-underline:hover::after {
  width: 100%;
}

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

/* Structural Containers */
.site-container {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 var(--site-gutter);
}

.site-container-full {
  width: 100%;
  padding: 0 var(--site-gutter);
}

.section-padding {
  padding-top: clamp(4rem, 8vw, 9rem);
  padding-bottom: clamp(4rem, 8vw, 9rem);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Accessibility & Motion preference */
@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;
  }
}
