/*
 * ==========================================================================
 * CSS Custom Properties
 * ==========================================================================
 * Adjust these variables to modify spacing, typography, and colors globally.
 */

:root {
  /* Colors - Monochrome palette (Light mode defaults) */
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #6b6b6b;
  --color-background: #f8f8f8;
  --color-accent: #1a1a1a;
  --color-border: #e0e0e0;
  --color-muted: #999999;

  /* Typography - System sans-serif stack */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /*
   * Font sizes - Using clamp() for fluid typography
   * Adjust min/preferred/max values to scale text
   */
  --font-size-title: clamp(1.5rem, 4vw, 2.25rem);
  --font-size-subtitle: clamp(1rem, 2.5vw, 1.375rem);
  --font-size-nav: clamp(0.75rem, 1.5vw, 0.875rem);

  /* Spacing */
  --spacing-xs: clamp(0.5rem, 1vw, 0.75rem);
  --spacing-sm: clamp(1rem, 2vw, 1.5rem);
  --spacing-md: clamp(1.5rem, 3vw, 2.5rem);
  --spacing-lg: clamp(2rem, 5vw, 4rem);
  --spacing-xl: clamp(3rem, 8vw, 6rem);

  /* Logo size */
  --logo-size: clamp(100px, 20vw, 180px);

  /* Animation durations */
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Animation timing */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Dark mode - Terminal-adjacent aesthetic */
:root[data-theme="dark"] {
  --color-text-primary: #e8e8e8;
  --color-text-secondary: #a0a0a0;
  --color-background: #1a1a1a;
  --color-accent: #e8e8e8;
  --color-border: #333333;
  --color-muted: #666666;
}

/*
 * ==========================================================================
 * Reset & Base Styles
 * ==========================================================================
 */

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

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

body {
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background-color: var(--color-background);
  line-height: 1.5;
  transition: background-color var(--duration-normal) ease, color var(--duration-normal) ease;
  /* Sticky footer setup */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

ul {
  list-style: none;
}

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

/*
 * ==========================================================================
 * Page Layout
 * ==========================================================================
 * Full viewport layout using CSS Grid with place-items: center
 * - Entire stack is centered as one cohesive unit
 * - No flex:1 pushing nav to bottom — nav is part of the composition
 */

.page {
  display: grid;
  place-items: center;
  flex: 1;
  padding: clamp(24px, 4vw, 56px);
}

/*
 * ==========================================================================
 * Stack
 * ==========================================================================
 * Single centered composition containing logo, text, and nav
 * - Everything flows as one unified vertical stack
 * - Nav is visually connected to the content, not a footer
 */

.stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/*
 * ==========================================================================
 * Logo
 * ==========================================================================
 * Inlined SVG from /public/logo.svg
 * Telemetry-style intro animation:
 * 1. Stroke-draw (~600ms)
 * 2. Fill fade-in (~200ms)
 * 3. Subtle lock-in settle (scale 1.01 → 1, ~120ms)
 * Optional scanline during stroke draw
 */

.logo {
  position: relative;
  width: var(--logo-size);
  height: auto;
  margin-bottom: var(--spacing-sm);
}

.logo__svg {
  width: 100%;
  height: auto;
  display: block;
  transform-origin: center;
}

.logo__path {
  fill: transparent;
  stroke: var(--color-text-primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* Path length set via JS for cross-browser compatibility */
}

/* Scanline pseudo-element - appears during stroke draw */
.logo__scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(26, 26, 26, 0.15) 20%,
    rgba(26, 26, 26, 0.3) 50%,
    rgba(26, 26, 26, 0.15) 80%,
    transparent 100%
  );
  opacity: 0;
  pointer-events: none;
}

/* Scanline animation - sweeps top to bottom during stroke draw */
.logo--scanning .logo__scanline {
  animation: logo-scanline 600ms linear forwards;
}

@keyframes logo-scanline {
  0% {
    opacity: 1;
    top: 0%;
  }
  90% {
    opacity: 1;
    top: 100%;
  }
  100% {
    opacity: 0;
    top: 100%;
  }
}

/* Animation states - controlled via JS */

/* Phase 1: Stroke draw */
.logo--stroke .logo__path {
  animation: logo-stroke-draw 600ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes logo-stroke-draw {
  from {
    stroke-dashoffset: var(--path-length);
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* Phase 2: Fill fade-in */
.logo--fill .logo__path {
  animation: logo-fill-in 200ms ease-out forwards;
}

@keyframes logo-fill-in {
  from {
    fill: transparent;
  }
  to {
    fill: var(--color-text-primary);
  }
}

/* Phase 3: Lock-in settle (subtle scale) */
.logo--settle .logo__svg {
  animation: logo-settle 120ms ease-out forwards;
}

@keyframes logo-settle {
  from {
    transform: scale(1.01);
  }
  to {
    transform: scale(1);
  }
}

/* Phase 4: Acknowledge pulse - subtle brightness pulse after nav trace completes (intro only) */
.logo--acknowledge .logo__svg {
  animation: logo-acknowledge 400ms ease-out;
}

@keyframes logo-acknowledge {
  0% {
    filter: brightness(1);
  }
  40% {
    filter: brightness(0.7);
  }
  100% {
    filter: brightness(1);
  }
}

/*
 * Logo Scan Pulse Animation (for periodic pulse loop)
 * Replays the scanline sweep effect - same visual language as intro
 * Scanline sweeps top to bottom, then logo does subtle settle
 */
.logo--scan-pulse .logo__scanline {
  animation: logo-scan-pulse 700ms linear forwards;
}

@keyframes logo-scan-pulse {
  0% {
    opacity: 0;
    top: 0%;
  }
  10% {
    opacity: 1;
    top: 0%;
  }
  85% {
    opacity: 1;
    top: 100%;
  }
  100% {
    opacity: 0;
    top: 100%;
  }
}

/* Subtle settle/bounce after scanline (runs slightly delayed) */
.logo--scan-pulse .logo__svg {
  animation: logo-scan-settle 400ms ease-out 300ms;
}

@keyframes logo-scan-settle {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  30% {
    transform: scale(1.015);
    filter: brightness(1.05);
  }
  60% {
    filter: brightness(0.95);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

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

.title {
  /* Weight controlled on child elements */
}

.title__site {
  display: block;
  font-size: var(--font-size-title);
  font-style: normal;
  font-weight: 600;
  letter-spacing: -0.01em;
  opacity: 0;
}

.title__name {
  font-size: var(--font-size-subtitle);
  font-weight: 400;
  color: var(--color-text-secondary);
  letter-spacing: 0.01em;
  opacity: 0;
}

/* Text animation states */
.title__site--visible,
.title__name--visible {
  animation: fade-up var(--duration-normal) var(--ease-out) forwards;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*
 * ==========================================================================
 * Navigation
 * ==========================================================================
 * Part of the centered stack — not a separate footer
 * - margin-top creates controlled gap from "Curtis Evans"
 * - Uses clamp() for responsive spacing on different screen heights
 * - Links expand from center using transform: scaleX()
 */

.nav {
  margin-top: clamp(32px, 6vh, 72px);
  opacity: 0;
}

.nav--visible {
  animation: fade-in var(--duration-normal) var(--ease-out) forwards;
}

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

.nav__list {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(2rem, 6vw, 4rem);
}

.nav__item {
  /* Ensure consistent spacing */
}

.nav__link {
  position: relative;
  display: inline-block;
  padding: var(--spacing-xs) 0;
  font-size: var(--font-size-nav);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  transition:
    color var(--duration-fast) var(--ease-out),
    transform 80ms ease-out,
    opacity 80ms ease-out;
  transform-origin: center;
}

/*
 * ==========================================================================
 * Nav Link "Telemetry Trace" Animation
 * ==========================================================================
 * Matches the logo intro animation language:
 * - ::after = underline trace (draws left→right)
 * - ::before = scan head (bright segment that sweeps along the trace)
 * - Used for: on-load intro sequence, hover, focus, and periodic scan
 * - Monochrome, no glow, GPU-accelerated
 */

/* ::after = Underline trace line (hidden by default, shown on hover/focus) */
.nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background-color: var(--color-text-primary);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}

/* ::before = Scan head (bright segment that sweeps) */
.nav__link::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 12px;
  height: 2px;
  background: var(--color-text-primary);
  opacity: 0;
  pointer-events: none;
}

/*
 * On-load intro trace animation
 * JS adds .is-tracing class - trace draws then fades out (no permanent underline)
 */
.nav__link.is-tracing::after {
  animation: nav-trace-intro 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.nav__link.is-tracing::before {
  animation: nav-trace-head 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes nav-trace-intro {
  0% {
    transform: scaleX(0);
    opacity: 0.6;
  }
  60% {
    transform: scaleX(1);
    opacity: 0.6;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

@keyframes nav-trace-head {
  0% {
    left: 0;
    opacity: 1;
  }
  85% {
    left: calc(100% - 12px);
    opacity: 1;
  }
  100% {
    left: calc(100% - 12px);
    opacity: 0;
  }
}

/*
 * Hover/Focus state - show trace animation
 * Underline appears and stays while hovered
 */
.nav__link:hover {
  color: var(--color-text-primary);
}

.nav__link:hover::after {
  animation: nav-trace-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.nav__link:hover::before {
  animation: nav-trace-head-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes nav-trace-hover {
  0% {
    transform: scaleX(0);
    opacity: 0.5;
  }
  100% {
    transform: scaleX(1);
    opacity: 0.5;
  }
}

@keyframes nav-trace-head-hover {
  0% {
    left: 0;
    opacity: 1;
  }
  90% {
    left: calc(100% - 12px);
    opacity: 1;
  }
  100% {
    left: calc(100% - 12px);
    opacity: 0;
  }
}

/* Focus-visible state - identical to hover */
.nav__link:focus {
  outline: none;
}

.nav__link:focus-visible {
  color: var(--color-text-primary);
}

.nav__link:focus-visible::after {
  animation: nav-trace-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.nav__link:focus-visible::before {
  animation: nav-trace-head-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Active/press state - lock-in feedback for mobile */
.nav__link:active {
  transform: scale(0.98);
  opacity: 0.85;
}

/*
 * Periodic scan animation (JS adds .scan class)
 * Trace draws and fades out (ephemeral, like a signal pulse)
 */
.nav__link.scan::after {
  animation: nav-scan-draw 500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.nav__link.scan::before {
  animation: nav-scan-head 500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes nav-scan-draw {
  0% {
    transform: scaleX(0);
    opacity: 0.6;
  }
  60% {
    transform: scaleX(1);
    opacity: 0.6;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

@keyframes nav-scan-head {
  0% {
    left: 0;
    opacity: 1;
    width: 14px;
    height: 2px;
  }
  60% {
    left: calc(100% - 14px);
    opacity: 1;
  }
  100% {
    left: calc(100% - 14px);
    opacity: 0;
  }
}

/*
 * ==========================================================================
 * Reduced Motion
 * ==========================================================================
 * Respects user preference for reduced motion
 * - Disables animations
 * - Shows content immediately
 */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .logo__path {
    fill: var(--color-text-primary);
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }

  .logo__scanline {
    display: none;
  }

  .logo__svg {
    transform: none !important;
  }

  .title__site,
  .title__name,
  .nav {
    opacity: 1;
  }

  /* Nav links: simple underline on hover only, no animations */
  .nav__link::after {
    background: var(--color-text-primary);
    animation: none !important;
  }

  .nav__link::before {
    display: none;
  }

  .nav__link.is-tracing::after {
    animation: none !important;
    opacity: 0;
  }

  .nav__link:hover::after,
  .nav__link:focus-visible::after {
    transform: scaleX(1);
    opacity: 0.5;
    animation: none !important;
  }

  .nav__link.scan::after {
    animation: none !important;
  }

  .nav__link:active {
    transform: none;
    opacity: 1;
  }
}

/*
 * ==========================================================================
 * Responsive Adjustments
 * ==========================================================================
 * Fine-tuning for specific breakpoints
 */

/* Small screens - ensure nav doesn't wrap awkwardly */
@media (max-width: 400px) {
  .nav__list {
    gap: 1.5rem;
  }

  .nav__link {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
  }
}

/* Ensure minimum touch target size on mobile */
@media (hover: none) and (pointer: coarse) {
  .nav__link {
    padding: 0.75rem 0.5rem;
  }
}

/*
 * ==========================================================================
 * Copyright Notice
 * ==========================================================================
 * Sticky footer using flexbox (body is flex container).
 * - Stays at bottom on short pages
 * - Flows below content on long pages
 * - Respects mobile safe areas
 */

.copyright {
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  font-family: var(--font-family);
  font-size: 0.75rem;
  text-align: center;
  color: var(--color-text-primary);
  opacity: 0.4;
  user-select: none;
}

/*
 * ==========================================================================
 * Coming Soon Pages
 * ==========================================================================
 * Minimal placeholder pages for /projects, /articles, /contact
 * - Reuses existing layout and typography system
 * - Simple fade-in on load
 */

.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: coming-soon-fade-in 600ms var(--ease-out) forwards;
}

.coming-soon__title {
  font-size: var(--font-size-title);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-xs);
}

.coming-soon__text {
  font-size: var(--font-size-nav);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--color-text-secondary);
  opacity: 0.7;
}

@keyframes coming-soon-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reduced motion: disable fade-in animation */
@media (prefers-reduced-motion: reduce) {
  .coming-soon {
    animation: none;
    opacity: 1;
  }
}

/*
 * ==========================================================================
 * Contact Page
 * ==========================================================================
 * Clean, minimalist contact form matching site aesthetic.
 * - Uses existing typography and spacing variables
 * - Telemetry-style submit button hover animation
 * - Success state for post-submission feedback
 */

.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 480px;
  animation: coming-soon-fade-in 600ms var(--ease-out) forwards;
}

.contact__title {
  font-size: var(--font-size-title);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-xs);
}

.contact__subtitle {
  font-size: var(--font-size-nav);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--color-text-secondary);
  opacity: 0.7;
  margin-bottom: var(--spacing-md);
}

.contact__form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Form field container */
.form-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
}

.form-field__label {
  font-size: var(--font-size-nav);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.form-field__input,
.form-field__textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text-primary);
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0;
  outline: none;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}

.form-field__input::placeholder,
.form-field__textarea::placeholder {
  color: var(--color-muted);
}

.form-field__input:hover,
.form-field__textarea:hover {
  border-color: var(--color-text-secondary);
}

.form-field__input:focus,
.form-field__textarea:focus {
  border-color: var(--color-text-primary);
}

.form-field__textarea {
  resize: vertical;
  min-height: 120px;
}

/* Submit button - telemetry trace styling */
.contact__submit {
  position: relative;
  align-self: flex-start;
  margin-top: var(--spacing-xs);
  padding: 0.75rem 2rem;
  font-family: var(--font-family);
  font-size: var(--font-size-nav);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  background-color: transparent;
  border: 1px solid var(--color-text-primary);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform 80ms ease-out,
    opacity 80ms ease-out;
}

.contact__submit:hover {
  background-color: var(--color-text-primary);
  color: var(--color-background);
}

.contact__submit:focus {
  outline: none;
}

.contact__submit:focus-visible {
  outline: 2px solid var(--color-text-primary);
  outline-offset: 2px;
}

.contact__submit:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.contact__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error message - hidden by default */
.contact__error {
  display: none;
  margin-top: var(--spacing-xs);
  font-size: var(--font-size-nav);
  color: #c44;
  text-align: left;
}

.contact__error--visible {
  display: block;
}

/* Success message - hidden by default */
.contact__success {
  display: none;
  text-align: center;
  padding: var(--spacing-md);
}

.contact__success--visible {
  display: block;
  animation: coming-soon-fade-in 600ms var(--ease-out) forwards;
}

.contact__success-text {
  font-size: var(--font-size-subtitle);
  font-weight: 400;
  color: var(--color-text-primary);
  letter-spacing: 0.01em;
}

/* Reduced motion for contact page */
@media (prefers-reduced-motion: reduce) {
  .contact,
  .contact__success--visible {
    animation: none;
    opacity: 1;
  }
}

/* Small screens - adjust form layout */
@media (max-width: 400px) {
  .contact {
    max-width: 100%;
  }

  .contact__submit {
    width: 100%;
    text-align: center;
  }
}

/* Touch devices - larger touch targets */
@media (hover: none) and (pointer: coarse) {
  .form-field__input,
  .form-field__textarea {
    padding: 1rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .contact__submit {
    padding: 1rem 2rem;
  }
}

/*
 * ==========================================================================
 * Site Header Navigation (Inner Pages)
 * ==========================================================================
 * Top navigation bar for Projects, Articles, Contact pages.
 * - Left: brand link back to home
 * - Right: nav links with current page highlight
 * - Uses same telemetry animation language as homepage
 */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) clamp(1rem, 4vw, 2rem);
  padding-top: calc(var(--spacing-sm) + env(safe-area-inset-top, 0px));
  font-family: var(--font-family);
  background-color: var(--color-background);
  z-index: 100;
}

/* Subtle fade effect below header */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 20px;
  background: linear-gradient(to bottom, var(--color-background), transparent);
  pointer-events: none;
}

/* Brand link - back to home */
.site-header__brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.site-header__brand:hover {
  opacity: 1;
}

/* Nav logo - responsive sizing with hover animation */
.nav-logo {
  width: clamp(28px, 4vw, 40px);
  height: auto;
  display: block;
  fill: var(--color-text-primary);
  opacity: 0.8;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    transform 80ms ease-out;
}

.site-header__brand:hover .nav-logo {
  opacity: 1;
}

.site-header__brand:focus {
  outline: none;
}

.site-header__brand:focus-visible .nav-logo {
  opacity: 1;
}

.site-header__brand:active .nav-logo {
  transform: scale(0.96);
  opacity: 0.85;
}

/* Navigation container */
.site-nav {
  /* Container for nav list */
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 4vw, 2.5rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav__item {
  /* Item wrapper */
}

/* Nav links - same style as homepage nav */
.site-nav__link {
  position: relative;
  display: inline-block;
  padding: 0.25rem 0;
  font-size: var(--font-size-nav);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

/* Current page indicator - subtle persistent underline */
.site-nav__link--current {
  color: var(--color-text-primary);
}

.site-nav__link--current::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background-color: var(--color-text-primary);
  opacity: 0.4;
}

/* Hover/focus - telemetry trace animation (same as homepage) */
.site-nav__link::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 12px;
  height: 2px;
  background: var(--color-text-primary);
  opacity: 0;
  pointer-events: none;
}

.site-nav__link:not(.site-nav__link--current)::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background-color: var(--color-text-primary);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}

.site-nav__link:hover {
  color: var(--color-text-primary);
}

.site-nav__link:not(.site-nav__link--current):hover::after {
  animation: nav-trace-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.site-nav__link:not(.site-nav__link--current):hover::before {
  animation: nav-trace-head-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Focus-visible states */
.site-nav__link:focus {
  outline: none;
}

.site-nav__link:focus-visible {
  color: var(--color-text-primary);
}

.site-nav__link:not(.site-nav__link--current):focus-visible::after {
  animation: nav-trace-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.site-nav__link:not(.site-nav__link--current):focus-visible::before {
  animation: nav-trace-head-hover 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Reduced motion for site nav */
@media (prefers-reduced-motion: reduce) {
  .site-nav__link::after,
  .site-nav__link::before {
    animation: none !important;
  }

  .site-nav__link:not(.site-nav__link--current):hover::after,
  .site-nav__link:not(.site-nav__link--current):focus-visible::after {
    transform: scaleX(1);
    opacity: 0.5;
  }
}

/* Small screens - tighter spacing */
@media (max-width: 400px) {
  .site-header {
    padding: 0.75rem 1rem;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  }

  .nav-logo {
    width: 24px;
  }

  .site-nav__list {
    gap: 1rem;
  }

  .site-nav__link {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
  }
}

/*
 * Inner page layout adjustment when site header is present.
 * Prevents content from being vertically centered under fixed header.
 */
body.has-site-header .page {
  place-items: start center;
  padding-top: calc(var(--spacing-xl) + 40px);
}

/*
 * ==========================================================================
 * Theme Toggle
 * ==========================================================================
 * Minimal icon toggle in the navigation area.
 * Uses sun/moon icons with subtle hover animation.
 */

.theme-toggle {
  position: fixed;
  bottom: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0.75rem;
  margin-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  margin-right: calc(0.75rem + env(safe-area-inset-right, 0px));
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  opacity: 0.6;
  transition: opacity var(--duration-fast) ease, color var(--duration-fast) ease;
  z-index: 50;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  opacity: 1;
  color: var(--color-text-primary);
}

.theme-toggle:focus {
  outline: none;
}

.theme-toggle:focus-visible {
  outline: 1px solid var(--color-text-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.theme-toggle:active {
  opacity: 0.8;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Theme transition for all elements */
*,
*::before,
*::after {
  transition-property: background-color, border-color, color, fill, stroke, opacity;
  transition-duration: var(--duration-normal);
  transition-timing-function: ease;
}

/* Exclude animation properties from theme transitions */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/*
 * ==========================================================================
 * Article Pages
 * ==========================================================================
 * Typography and layout for long-form article content.
 * - Readable line length (~65-75ch)
 * - Comfortable paragraph spacing
 * - Styled callout/aside elements
 */

.article {
  width: 100%;
  max-width: 70ch;
  animation: coming-soon-fade-in 600ms var(--ease-out) forwards;
}

.article__header {
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

.article__title {
  font-size: var(--font-size-title);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  line-height: 1.2;
  margin-bottom: var(--spacing-xs);
}

.article__subtitle {
  font-size: var(--font-size-nav);
  font-weight: 400;
  font-style: italic;
  color: var(--color-text-secondary);
  opacity: 0.8;
  margin-bottom: var(--spacing-xs);
}

.article__meta {
  font-size: var(--font-size-nav);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--color-muted);
}

.article__content {
  font-size: clamp(1rem, 2vw, 1.125rem);
  line-height: 1.7;
  color: var(--color-text-primary);
}

.article__content h2 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.article__content p {
  margin-bottom: var(--spacing-sm);
}

.article__content ol,
.article__content ul {
  margin-bottom: var(--spacing-sm);
  padding-left: 1.5em;
}

.article__content li {
  margin-bottom: 0.5em;
  list-style: decimal;
}

.article__content ul li {
  list-style: disc;
}

.article__content a {
  color: var(--color-text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity var(--duration-fast) ease;
}

.article__content a:hover {
  opacity: 0.7;
}

/* Callout/aside styling */
.article__callout {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--color-border);
  border-left: 3px solid var(--color-text-secondary);
  font-size: 0.95em;
}

.article__callout h3 {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-xs);
}

.article__callout p {
  margin-bottom: 0.75em;
  color: var(--color-text-secondary);
}

.article__callout p:last-child {
  margin-bottom: 0;
}

/* References list */
.article__references {
  font-size: 0.9em;
  color: var(--color-text-secondary);
}

.article__references li {
  margin-bottom: 0.75em;
}

.article__references em {
  font-style: italic;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .article {
    animation: none;
    opacity: 1;
  }
}

/* Small screens */
@media (max-width: 600px) {
  .article__callout {
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-left: calc(-1 * var(--spacing-xs));
    margin-right: calc(-1 * var(--spacing-xs));
  }
}

/*
 * ==========================================================================
 * Article Listing Page
 * ==========================================================================
 * Styles for the articles index page showing article previews.
 */

.articles-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  width: 100%;
  max-width: 600px;
  animation: coming-soon-fade-in 600ms var(--ease-out) forwards;
}

.articles-list__title {
  font-size: var(--font-size-title);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  text-align: center;
  margin-bottom: var(--spacing-sm);
}

.article-preview {
  display: block;
  padding: var(--spacing-sm);
  border: 1px solid var(--color-border);
  transition: border-color var(--duration-fast) ease;
}

.article-preview:hover {
  border-color: var(--color-text-secondary);
}

.article-preview__title {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.25em;
  line-height: 1.3;
}

.article-preview__subtitle {
  font-size: var(--font-size-nav);
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-bottom: 0.5em;
}

.article-preview__year {
  font-size: var(--font-size-nav);
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .articles-list {
    animation: none;
    opacity: 1;
  }
}
