/* ===================================
   GLOBAL STYLES
   Shared variables, resets, and base styles
   =================================== */

/* CSS Variables */
:root {
  --ink: #2C2C2C;
  --muted: #545454;
  --paper: #F0E5D1;
  --gold: #B8860B;
  --nav-bg: #EBD9B8;
  --nav-border: rgba(44, 44, 44, 0.12);
  --card-bg: #FAF6EC;
  --card-border: rgba(44, 44, 44, 0.08);
  --footer-bg: #E8D5B7;
  --link-color: rgba(26, 26, 26, 0.75);
  --link-hover: #000000;
  --text-primary: #1A1A1A;
  --text-secondary: #2C2C2C;
  --service-bg: #FAF6EC;
  --approach-bg: #F0E5D1;
}

[data-theme="dark"] {
  --ink: #e9e9e9;
  --muted: #b3b3b3;
  --paper: #1A1A1A;
  --gold: #C8A64A;
  --nav-bg: #1a1a1aef;
  --nav-border: rgba(35, 33, 33, 0.707);
  --card-bg: transparent;
  --card-border: transparent;
  --footer-bg: #1A1A1A;
  --link-color: rgba(255, 255, 255, 0.7);
  --link-hover: #FFFFFF;
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.95);
  --service-bg: #1A1A1A;
  --approach-bg: #1A1A1A;
}

/* Base Styles */
html, body {
  overflow-x: clip;
  height: 100%;
}

html {
  background: var(--paper);
  color: var(--ink);
  transition: background-color 0.3s ease;
}

body {
  font-family: 'Outfit', ui-sans-serif, system-ui, -apple-system, sans-serif;
  margin: 0;
  background: var(--paper);
  transition: background-color 0.3s ease;
  position: relative;
  min-height: 100%;
}

/* Subtle paper texture */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(44, 44, 44, 0.03) 2px, rgba(44, 44, 44, 0.03) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(44, 44, 44, 0.03) 2px, rgba(44, 44, 44, 0.03) 4px);
}

[data-theme="dark"] body::before {
  display: none;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .branch {
    transition: none !important;
    stroke-dashoffset: 0 !important;
  }
  
  .hero-art {
    transform: translate(-50%, -50%) !important;
  }
}

/* ===================================
GLOBAL NAVIGATION (Incorporating fixes)
=================================== 
*/

/* Keep the bar from creating horizontal scroll & make it sticky */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  overflow-x: clip;             /* ← clamps any accidental width bleed */
}

/* Flex container for brand + links */
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;   
  overflow: hidden;              
}

/* Brand block (your logo + fractal) */
.brand {
  position: relative;
  display: flex; 
  align-items: center;
  flex: 0 1 auto;
  min-width: 0; /* Ensures the logo/brand can shrink */
  /* overflow: hidden; Removed: Using position: fixed on the fractal instead */
  
  /* Control size via CSS vars with safe fallbacks (from original) */
  --logo-w: clamp(320px, 34vw, 780px);
  --fx-size: calc(var(--logo-w) * 0.55);
  --fx-shift: 24px;
  --fx-rise: 52%;
}

/* Fractal is decorative; use fixed positioning to ignore brand bounds */
#svg-fractal {
  /* New Positioning */
  position: fixed;              /* ← Takes it out of the layout flow entirely */
  top: 12px;                    /* Aligns with the top padding of .nav-inner */
  left: 20px;                   /* Aligns with the left padding of .nav-inner */
  
  /* New Containment */
  contain: layout paint;        /* ← isolate so it can't affect siblings/performance */
  
  /* Sizing and visual (from original) */
  z-index: 0;
  pointer-events: none;
  width: var(--fx-size);
  height: var(--fx-size);
  transform: translateY(calc(-1 * var(--fx-rise))); /* Only Y translation needed now */
  opacity: 0.42;
  backface-visibility: hidden;
}

.logo-mark {
  position: relative;
  z-index: 2;
  display: block;
  width: var(--logo-w);
  height: auto;
}

/* Dark mode adjusts only via CSS, keyed off your existing data-theme */
[data-theme="dark"] #svg-fractal {
  opacity: 0.32;
  mix-blend-mode: screen;
}

/* Optional: mobile tightening */
@media (max-width: 780px) {
  .brand { --fx-size: calc(var(--logo-w) * 0.48); --fx-shift: 12px; --fx-rise: 50%; }
}

/* Link list */
nav ul {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;                 /* ← critical for flex overflow */
}

nav li { min-width: 0; }
nav a { white-space: nowrap; color: var(--link-color); text-decoration: none; }
nav a:hover { color: var(--link-hover); }

/* Theme toggle shouldn’t force overflow */
.theme-toggle { flex: 0 0 auto; }

/* Small screens: allow wrap to avoid horizontal scroll entirely */
@media (max-width: 640px) {
  nav ul {
    flex-wrap: wrap;
    row-gap: 8px;
    justify-content: flex-start;
  }
}