/*
 * Oliver Dougherty - Unified Design System
 * A bespoke, elegant design language with contextual variations
 */

/* ========================================
   CSS Custom Properties - Core Design Tokens
   ======================================== */

:root {
  /* === Color Palette === */

  /* Primary - Deep forest backgrounds (Home page default) */
  --color-bg-primary: #0a0c0a;
  --color-bg-secondary: #10130f;
  --color-bg-tertiary: #161a14;
  --color-bg-elevated: #1c2118;

  /* Surface colors (Home page default - green undertone) */
  --color-surface: #141812;
  --color-surface-hover: #1a1f17;
  --color-surface-active: #20261c;

  /* Text hierarchy - warm parchment tones */
  --color-text-primary: #f5f0e8;
  --color-text-secondary: #a8a090;
  --color-text-tertiary: #78725e;
  --color-text-muted: #5a5545;

  /* Accent - Forest green */
  --color-accent: #173B34;
  --color-accent-hover: #2A6356;
  --color-accent-muted: #0F2A24;
  --color-accent-subtle: rgba(23, 59, 52, 0.2);

  /* Secondary accents */
  --color-accent-warm: #2A6356;
  --color-accent-cool: #173B34;
  --color-accent-neutral: #1E4F44;

  /* Borders and dividers - warm tinted */
  --color-border: rgba(245, 240, 232, 0.06);
  --color-border-subtle: rgba(245, 240, 232, 0.03);
  --color-border-emphasis: rgba(245, 240, 232, 0.12);

  /* Gradients - forest green transitions */
  --gradient-subtle: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-primary) 100%);
  --gradient-accent: linear-gradient(135deg, #2A6356 0%, #173B34 50%, #1E4F44 100%);
  --gradient-warm: linear-gradient(135deg, #2A6356 0%, #173B34 100%);
  --gradient-mesh: radial-gradient(at 40% 20%, rgba(23, 59, 52, 0.15) 0px, transparent 50%),
                   radial-gradient(at 80% 0%, rgba(42, 99, 86, 0.1) 0px, transparent 50%),
                   radial-gradient(at 0% 50%, rgba(30, 79, 68, 0.08) 0px, transparent 50%);

  /* === Typography === */

  /* Font families */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Font sizes - Fluid typography */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.75rem + 0.3vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.875rem + 0.3vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  --text-xl: clamp(1.1875rem, 1.1rem + 0.4vw, 1.25rem);
  --text-2xl: clamp(1.375rem, 1.25rem + 0.6vw, 1.5rem);
  --text-3xl: clamp(1.75rem, 1.5rem + 1.2vw, 2rem);
  --text-4xl: clamp(2.25rem, 1.8rem + 2vw, 2.75rem);
  --text-5xl: clamp(2.75rem, 2rem + 3.5vw, 3.75rem);
  --text-6xl: clamp(3.5rem, 2.5rem + 5vw, 5rem);

  /* Line heights */
  --leading-none: 1;
  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* Letter spacing */
  --tracking-tighter: -0.04em;
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.02em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* Font weights */
  --weight-light: 300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* === Spacing === */
  --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;

  /* === Border Radius === */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;
  --radius-nav: 0.5rem;

  /* === Shadows === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(23, 59, 52, 0.25);
  --shadow-glow-lg: 0 0 40px rgba(23, 59, 52, 0.3);

  /* === Transitions === */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;
  --duration-slower: 600ms;

  /* === Z-Index Scale === */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ========================================
   Theme Variations
   ======================================== */

/* Gallery Theme - Moody, dramatic, curved (#9693CC lavender) */
[data-theme="gallery"] {
  --color-bg-primary: #08080c;
  --color-bg-secondary: #0e0e14;
  --color-bg-tertiary: #15151e;
  --color-bg-elevated: #1c1c26;
  --color-surface: #121218;
  --color-surface-hover: #18181f;
  --color-surface-active: #1e1e26;
  --color-accent: #9693CC;
  --color-accent-hover: #B0ADDA;
  --color-accent-muted: #7A77AE;
  --color-accent-subtle: rgba(150, 147, 204, 0.1);
  --shadow-glow: 0 0 20px rgba(150, 147, 204, 0.15);
  --shadow-glow-lg: 0 0 40px rgba(150, 147, 204, 0.2);
  --gradient-accent: linear-gradient(135deg, #B0ADDA 0%, #9693CC 50%, #7A77AE 100%);
  --gradient-subtle: linear-gradient(135deg, #0e0e14 0%, #08080c 100%);
  --radius-lg: 1.25rem;
  --radius-xl: 1.75rem;
  --radius-2xl: 2.5rem;
}

/* Archive Theme - Rigid, academic, structured (#CDDBCD sage) */
[data-theme="archive"] {
  --color-bg-primary: #0a0c0a;
  --color-bg-secondary: #0f120f;
  --color-bg-tertiary: #151a15;
  --color-bg-elevated: #1b211b;
  --color-surface: #121612;
  --color-surface-hover: #181e18;
  --color-surface-active: #1e241e;
  --color-accent: #CDDBCD;
  --color-accent-hover: #DDE8DD;
  --color-accent-muted: #A8BCA8;
  --color-accent-subtle: rgba(205, 219, 205, 0.08);
  --shadow-glow: 0 0 20px rgba(205, 219, 205, 0.12);
  --shadow-glow-lg: 0 0 40px rgba(205, 219, 205, 0.15);
  --gradient-accent: linear-gradient(135deg, #DDE8DD 0%, #CDDBCD 50%, #A8BCA8 100%);
  --gradient-subtle: linear-gradient(135deg, #0f120f 0%, #0a0c0a 100%);
  --radius-sm: 0.125rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.375rem;
  --radius-xl: 0.5rem;
}

/* Resume Theme - Professional, clean (#6C8FD5 blue) */
[data-theme="resume"] {
  --color-bg-primary: #0a0a0e;
  --color-bg-secondary: #0f0f16;
  --color-bg-tertiary: #14141e;
  --color-bg-elevated: #1a1a26;
  --color-surface: #121218;
  --color-surface-hover: #181820;
  --color-surface-active: #1e1e28;
  --color-accent: #6C8FD5;
  --color-accent-hover: #8AABE0;
  --color-accent-muted: #5472B0;
  --color-accent-subtle: rgba(108, 143, 213, 0.1);
  --color-accent-warm: #6C8FD5;
  --shadow-glow: 0 0 20px rgba(108, 143, 213, 0.15);
  --shadow-glow-lg: 0 0 40px rgba(108, 143, 213, 0.2);
  --gradient-accent: linear-gradient(135deg, #8AABE0 0%, #6C8FD5 50%, #5472B0 100%);
  --gradient-subtle: linear-gradient(135deg, #0f0f16 0%, #0a0a0e 100%);
}

/* Dashboard Theme - Functional, grid-based (#EBE4B3 cream) */
[data-theme="dashboard"] {
  --color-bg-primary: #0c0c0a;
  --color-bg-secondary: #121210;
  --color-bg-tertiary: #1a1916;
  --color-bg-elevated: #201f1a;
  --color-surface: #161614;
  --color-surface-hover: #1c1c18;
  --color-surface-active: #22221e;
  --color-border: rgba(245, 240, 232, 0.08);
  --color-accent: #EBE4B3;
  --color-accent-hover: #F2ECC8;
  --color-accent-muted: #C8C28E;
  --color-accent-subtle: rgba(235, 228, 179, 0.08);
  --shadow-glow: 0 0 20px rgba(235, 228, 179, 0.12);
  --shadow-glow-lg: 0 0 40px rgba(235, 228, 179, 0.15);
  --gradient-accent: linear-gradient(135deg, #F2ECC8 0%, #EBE4B3 50%, #C8C28E 100%);
  --gradient-subtle: linear-gradient(135deg, #121210 0%, #0c0c0a 100%);
}

/* ========================================
   Base Reset & Defaults
   ======================================== */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Selection styling */
::selection {
  background-color: var(--color-accent);
  color: white;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-emphasis);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ========================================
   Typography Classes
   ======================================== */

.text-display {
  font-family: var(--font-display);
  font-weight: var(--weight-normal);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.text-heading {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
}

.text-body {
  font-family: var(--font-body);
  font-weight: var(--weight-normal);
  line-height: var(--leading-relaxed);
}

.text-mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.text-gradient {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========================================
   Layout Utilities
   ======================================== */

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: 900px;
}

.container-wide {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section {
  padding: var(--space-24) 0;
}

.section-lg {
  padding: var(--space-32) 0;
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Grid utilities */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ========================================
   Component Base Styles
   ======================================== */

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--duration-base) var(--ease-smooth);
}

.card:hover {
  border-color: var(--color-border-emphasis);
  background: var(--color-surface-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-elevated {
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-decoration: none;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-smooth);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border-emphasis);
}

.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  color: var(--color-text-primary);
  background: var(--color-surface);
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-smooth);
}

a:hover {
  color: var(--color-accent-hover);
}

/* Dividers */
.divider {
  height: 1px;
  background: var(--color-border);
  border: none;
  margin: var(--space-8) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--color-border);
}

/* Tags / Pills */
.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-radius: var(--radius-full);
}

/* ========================================
   Animation Utilities
   ======================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.animate-fade-in { animation: fadeIn var(--duration-slow) var(--ease-smooth) forwards; }
.animate-fade-in-up { animation: fadeInUp var(--duration-slow) var(--ease-out-expo) forwards; }
.animate-fade-in-down { animation: fadeInDown var(--duration-slow) var(--ease-out-expo) forwards; }
.animate-scale-in { animation: scaleIn var(--duration-slow) var(--ease-bounce) forwards; }
.animate-slide-in-right { animation: slideInRight var(--duration-slow) var(--ease-out-expo) forwards; }

/* Staggered animations */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* Scroll-triggered animations */
[data-animate] {
  opacity: 0;
}

[data-animate].visible {
  opacity: 1;
}

[data-animate="fade-up"] {
  transform: translateY(30px);
  transition: opacity var(--duration-slower) var(--ease-out-expo),
              transform var(--duration-slower) var(--ease-out-expo);
}

[data-animate="fade-up"].visible {
  transform: translateY(0);
}

/* ========================================
   Shared Navigation
   ======================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  padding: var(--space-4) 0;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  text-decoration: none;
}

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text-primary);
}

.logo-text .logo-d {
  color: var(--color-accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-nav);
  transition: all var(--duration-fast) var(--ease-smooth);
}

.nav-link:hover {
  color: var(--color-text-primary);
  background: var(--color-surface);
}

.nav-link.active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* Brighter active nav text for dark accent colors */
html:not([data-theme]) .nav-link.active {
  color: #3DAA7E;
  background: rgba(23, 59, 52, 0.2);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text-primary);
  transition: all var(--duration-base) var(--ease-smooth);
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ========================================
   Shared Footer
   ======================================== */

.footer {
  padding: var(--space-6) 0;
  border-top: 1px solid var(--color-border);
  position: relative;
}

.footer-inner {
  display: flex;
  align-items: center;
  position: relative;
  min-height: 40px;
}

.footer-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ========================================
   Responsive Breakpoints
   ======================================== */

@media (max-width: 1200px) {
  .container { padding: 0 var(--space-5); }
  .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .section { padding: var(--space-16) 0; }
}

@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--space-4);
    background: var(--color-bg-primary);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-base) var(--ease-smooth);
  }

  .nav-links.active {
    opacity: 1;
    visibility: visible;
  }

  .nav-toggle {
    display: flex;
    z-index: 10;
  }

  .nav-link {
    font-size: var(--text-xl);
    min-height: 44px;
  }

  .footer-inner {
    justify-content: center;
  }

  .footer-text {
    text-align: center;
  }
}

@media (max-width: 600px) {
  .container { padding: 0 var(--space-4); }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
  .section { padding: var(--space-12) 0; }

  /* Touch-friendly buttons */
  .btn {
    min-height: 44px;
    padding: var(--space-3) var(--space-5);
  }
}

@media (max-width: 480px) {
  .container { padding: 0 var(--space-3); }
  .section { padding: var(--space-10) 0; }

  /* Smaller cards on tiny screens */
  .card {
    padding: var(--space-4);
  }

  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ========================================
   Accessibility
   ======================================== */

/* Focus-visible styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Remove outline for mouse clicks, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}

/* Reduced 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;
  }
}

/* ========================================
   Custom cursor (optional enhancement)
   ======================================== */

.cursor-glow {
  position: fixed;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(23, 59, 52, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s;
}

/* ========================================
   Noise texture overlay
   ======================================== */

.noise-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}
