/* ==========================================================================
   global.css — design tokens, reset, shared styles
   Palette: OKLCH for perceptually uniform tinted neutrals (impeccable).
   ========================================================================== */

/* --- Motion tokens -------------------------------------------------------- */
:root {
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:    cubic-bezier(0.65, 0, 0.35, 1);

  --dur-fast:   150ms;
  --dur-base:   250ms;
  --dur-slow:   400ms;
  --dur-enter:  600ms;
}

/* --- Design tokens: light mode -------------------------------------------- */
:root {
  /* Backgrounds — warm cream, not pure white, not beige */
  --bg-primary:    oklch(96%  0.012 75);
  --bg-secondary:  oklch(93%  0.014 75);
  --bg-tertiary:   oklch(90%  0.016 75);

  /* Text — warm near-black */
  --text-primary:   oklch(20%  0.010 60);
  --text-secondary: oklch(48%  0.016 60);
  --text-tertiary:  oklch(67%  0.010 60);

  /* Accent — deep terracotta; warm, refined, not orange */
  --accent:         oklch(50%  0.130 30);
  --accent-hover:   oklch(42%  0.130 30);
  --accent-subtle:  oklch(92%  0.030 30);

  /* Structure */
  --divider:        oklch(85%  0.014 75);
  --divider-light:  oklch(91%  0.012 75);
  --surface:        oklch(94%  0.013 75);
  --shadow-subtle:  oklch(40%  0.020 60 / 0.06);
  --shadow-medium:  oklch(40%  0.020 60 / 0.12);

  --nav-bg: oklch(96%  0.012 75 / 0.85);

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'Monaco', 'Menlo', 'Courier New', monospace;

  /* Type scale — modular, major-third (×1.25) */
  --text-xs:    0.75rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-lg:    1.25rem;
  --text-xl:    1.5rem;
  --text-2xl:   2rem;
  --text-3xl:   clamp(2rem, 4vw, 3rem);
  --text-4xl:   clamp(2.5rem, 5vw, 4rem);

  /* Legacy aliases (for compatibility) */
  --text-display:   clamp(2.5rem, 5vw, 4rem);
  --weight-display: 600;
  --line-display:   1.06;
  --letter-display: -0.02em;
  --text-title:     clamp(1.75rem, 3vw, 2.5rem);
  --weight-title:   600;
  --line-title:     1.12;
  --letter-title:   -0.015em;
  --text-headline:  1.25rem;
  --weight-headline: 600;
  --line-headline:  1.35;
  --text-body:      1rem;
  --weight-body:    400;
  --line-body:      1.7;
  --text-caption:   0.8125rem;
  --weight-caption: 400;
  --line-caption:   1.5;

  /* Spacing — 4pt base, named semantically */
  --space-1:   0.25rem;   /*  4px */
  --space-2:   0.5rem;    /*  8px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-6:   1.5rem;    /* 24px */
  --space-8:   2rem;      /* 32px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-24:  6rem;      /* 96px */
  --space-32:  8rem;      /* 128px */

  /* Legacy spacing aliases */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  2rem;
  --space-lg:  4rem;
  --space-xl:  6rem;
  --space-2xl: 8rem;
  --space-3xl: 12rem;

  --section-gap:   clamp(4rem, 8vw, 8rem);
  --header-height: 52px;
  --page-max:      1200px;
  --content-max:   720px;
}

/* --- Design tokens: dark mode -------------------------------------------- */
[data-theme="dark"] {
  /* Not pure black — medium charcoal with subtle cool tint */
  --bg-primary:    oklch(22%  0.010 255);
  --bg-secondary:  oklch(26%  0.010 255);
  --bg-tertiary:   oklch(30%  0.010 255);

  --text-primary:   oklch(88%  0.008 255);
  --text-secondary: oklch(63%  0.010 255);
  --text-tertiary:  oklch(47%  0.008 255);

  /* Accent — muted periwinkle; low saturation as requested */
  --accent:         oklch(70%  0.080 270);
  --accent-hover:   oklch(78%  0.080 270);
  --accent-subtle:  oklch(30%  0.040 270);

  --divider:        oklch(30%  0.010 255);
  --divider-light:  oklch(26%  0.010 255);
  --surface:        oklch(25%  0.010 255);
  --shadow-subtle:  oklch(0%   0     0   / 0.30);
  --shadow-medium:  oklch(0%   0     0   / 0.50);

  --nav-bg: oklch(22%  0.010 255 / 0.90);
}

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

html {
  scroll-behavior: smooth;
  transition: background-color 0.3s var(--ease-in-out),
              color           0.3s var(--ease-in-out);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: var(--line-body);
  overflow-x: hidden;
  transition: background-color 0.3s var(--ease-in-out),
              color           0.3s var(--ease-in-out);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
}

/* Subtle film-grain overlay — adds texture without visual noise */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
}

[data-theme="dark"] body::after { opacity: 0.035; }

img, video { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* --- Navigation ----------------------------------------------------------- */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 max(1.5rem, 4vw);
  height: var(--header-height);
  border-bottom: 1px solid var(--divider-light);
  position: sticky;
  top: 0;
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  z-index: 100;
  transition: background-color 0.3s var(--ease-in-out);
}

.brand {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--text-primary);
  text-transform: uppercase;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-links {
  display: flex;
  gap: 1.75rem;
}

.nav-link {
  text-decoration: none;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: color var(--dur-fast) var(--ease-out-quart);
}

.nav-link:hover,
.nav-link.active { color: var(--text-primary); }

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.9375rem;
  cursor: pointer;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dur-fast) var(--ease-out-quart);
  line-height: 1;
}

.theme-toggle:hover { color: var(--text-primary); }

/* --- Footer --------------------------------------------------------------- */
footer {
  padding: var(--space-12) max(1.5rem, 4vw);
  border-top: 1px solid var(--divider-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

/* --- Shared utilities ----------------------------------------------------- */
.tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border-radius: 2px;
  border: 1px solid var(--divider);
  letter-spacing: 0.05em;
}

/* --- Animations ----------------------------------------------------------- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.anim-fade-up {
  animation: fade-up 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.anim-delay-1 { animation-delay: 60ms; }
.anim-delay-2 { animation-delay: 130ms; }
.anim-delay-3 { animation-delay: 200ms; }
.anim-delay-4 { animation-delay: 270ms; }
.anim-delay-5 { animation-delay: 340ms; }

@media (prefers-reduced-motion: reduce) {
  .anim-fade-up { animation: none; }
  .status-dot   { animation: none; }
}

/* --- Shiki code blocks ---------------------------------------------------- */
.astro-code {
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--bg-secondary) !important;
}

.astro-code span {
  color: var(--shiki-light);
  font-style: var(--shiki-light-font-style);
  font-weight: var(--shiki-light-font-weight);
  text-decoration: var(--shiki-light-text-decoration);
}

[data-theme="dark"] .astro-code { background: var(--shiki-dark-bg) !important; }

[data-theme="dark"] .astro-code span {
  color: var(--shiki-dark);
  font-style: var(--shiki-dark-font-style);
  font-weight: var(--shiki-dark-font-weight);
  text-decoration: var(--shiki-dark-text-decoration);
}

/* --- Responsive nav ------------------------------------------------------- */
@media (max-width: 768px) {
  nav { padding: 0 1.25rem; }
  .nav-links { gap: 1.25rem; }
  .nav-right  { gap: 1.25rem; }
}

@media (max-width: 480px) {
  nav { padding: 0 1rem; }
  .nav-links { gap: 0.875rem; font-size: 0.75rem; }

  footer {
    flex-direction: column;
    gap: 0.25rem;
    text-align: center;
    padding: var(--space-8) 1rem;
  }
}
