/* Schoenworks - Mobile-First Optimized Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;400;700&family=Playfair+Display:wght@400;700&display=swap');

/* CSS Custom Properties for Theming */
:root {
  --color-bg: #0a0a0a;
  --color-text: #f2f2f2;
  --color-text-muted: #aaa;
  --color-text-dim: #666;
  --color-accent: rgba(255, 255, 255, 0.1);
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.4s ease;
}

/* Reduced motion for accessibility */
@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;
  }
}

/* Base Reset - Mobile First */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* Prevent font size adjustments on orientation change */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  /* Smooth scrolling but respect reduced motion */
  scroll-behavior: smooth;
}

body {
  color: var(--color-text);
  background: var(--color-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  /* Better font rendering on mobile */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Safe area support for notched devices */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Canvas Background - Performance Optimized */
canvas#background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  /* Hardware acceleration hint */
  will-change: transform;
  /* Reduce quality on low-end devices */
  image-rendering: optimizeSpeed;
}

/* Mobile-First Header */
header {
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-sm) var(--spacing-md);
  padding-top: max(var(--spacing-lg), env(safe-area-inset-top, var(--spacing-lg)));
}

header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  letter-spacing: 0.1em;
  margin-bottom: var(--spacing-sm);
  /* Prevent text selection on double tap */
  -webkit-user-select: none;
  user-select: none;
}

/* Navigation - Touch Optimized */
nav {
  margin-top: var(--spacing-sm);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-xs);
}

nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--spacing-xs) var(--spacing-sm);
  transition: color var(--transition-fast);
  /* Minimum touch target size (WCAG) */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  /* Remove tap highlight on mobile */
  -webkit-tap-highlight-color: transparent;
}

nav a:active {
  transform: scale(0.95);
}

/* Quote Section - Mobile Optimized */
.subtitle-quote {
  margin: var(--spacing-md) auto 0;
  max-width: min(600px, 90vw);
  padding: var(--spacing-sm);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 60px;
  /* Prevent layout shift */
  contain: layout style;
}

.subtitle-quote .quote-text {
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  color: var(--color-text-muted);
  font-weight: 300;
  margin-bottom: var(--spacing-xs);
  line-height: 1.7;
  transition: opacity var(--transition-normal);
}

.subtitle-quote .quote-text:empty {
  opacity: 0;
  min-height: 1.5em;
}

.subtitle-quote .quote-author {
  font-size: clamp(0.65rem, 2vw, 0.7rem);
  color: var(--color-text-dim);
  font-weight: 300;
  letter-spacing: 0.05em;
}

/* Main Content */
main {
  width: min(900px, 95vw);
  margin: 0 auto;
  padding-bottom: var(--spacing-xl);
}

section {
  margin: var(--spacing-xl) 0;
}

section h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  margin-bottom: var(--spacing-sm);
}

/* Home Intro */
.home-intro {
  text-align: center;
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-xl) var(--spacing-sm);
}

.tagline {
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 200;
  letter-spacing: 0.05em;
  color: #ccc;
  line-height: 1.9;
  max-width: min(700px, 90vw);
  margin-bottom: var(--spacing-xl);
}

/* Tooltip - Mobile Friendly */
.term-tooltip {
  position: relative;
  display: inline-block;
}

.term {
  color: var(--color-text);
  border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
  cursor: help;
  transition: all var(--transition-normal);
  -webkit-tap-highlight-color: transparent;
}

.tooltip-content {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(30, 30, 30, 0.98);
  color: var(--color-text);
  padding: var(--spacing-sm);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: clamp(0.8rem, 2.5vw, 0.85rem);
  line-height: 1.6;
  width: min(280px, 80vw);
  text-align: left;
  z-index: 100;
  pointer-events: none;
  transition: all var(--transition-normal);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  /* Hardware acceleration */
  will-change: transform, opacity;
}

.tooltip-content strong {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: #fff;
  font-size: 0.9em;
}

.tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: rgba(30, 30, 30, 0.98);
}

/* Desktop hover, mobile tap */
@media (hover: hover) {
  nav a:hover {
    color: #fff;
  }
  
  .term:hover {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.8);
  }
  
  .term-tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  
  .subtitle-quote:hover {
    transform: scale(1.05);
  }
  
  .subtitle-quote:hover .quote-text {
    color: #ddd;
    font-size: 1rem;
  }
  
  .subtitle-quote:hover .quote-author {
    color: var(--color-text-muted);
    font-size: 0.75rem;
  }
}

/* Mobile-specific tooltip activation */
@media (hover: none) {
  .term-tooltip.active .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
  }
  
  .subtitle-quote:active {
    transform: scale(0.98);
  }
}

/* Footer */
footer {
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-sm);
  padding-bottom: max(var(--spacing-lg), env(safe-area-inset-bottom, var(--spacing-lg)));
  font-size: clamp(0.85rem, 2.5vw, 0.9rem);
  color: #777;
}

/* Tablet and up */
@media (min-width: 768px) {
  :root {
    --spacing-sm: 1.25rem;
    --spacing-md: 2rem;
    --spacing-lg: 2.5rem;
    --spacing-xl: 4rem;
  }
  
  header {
    padding: var(--spacing-xl) var(--spacing-sm) var(--spacing-lg);
  }
  
  nav {
    gap: var(--spacing-sm);
  }
  
  nav a {
    padding: var(--spacing-xs) var(--spacing-md);
  }
  
  section {
    margin: 6rem 0;
  }
}

/* Desktop */
@media (min-width: 1200px) {
  main {
    width: 90%;
  }
  
  .home-intro {
    min-height: 40vh;
    padding: 4rem 1rem;
  }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) and (max-height: 500px) {
  header {
    padding: var(--spacing-md) var(--spacing-sm) var(--spacing-sm);
  }
  
  header h1 {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-xs);
  }
  
  .home-intro {
    min-height: auto;
    padding: var(--spacing-lg) var(--spacing-sm);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Prevent iOS input zoom */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Utility classes */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
