/**
 * Foundation CSS
 * Design tokens and base styles for the photography portfolio.
 * Based on design-guidelines.md specification.
 */

/* ============================================
   CSS Custom Properties
   ============================================ */

:root {
  /* Colors - Dark Gallery Mode (default) - warm undertone */
  --color-bg: #282520;
  --color-text-primary: #e8e6e0;
  --color-text-secondary: #a8a6a0;
  --color-text-tertiary: #787570;
  --color-border: #3a3832;
  --color-skeleton: #333028;
  --color-lightbox-bg: rgba(18, 16, 12, 0.97);

  /* Typography - Font Family */
  --font-family: 'Plus Jakarta Sans', sans-serif;

  /* Typography - Font Sizes */
  --font-size-display: 48px;
  --font-size-h1: 36px;
  --font-size-h2: 28px;
  --font-size-h3: 22px;
  --font-size-body: 18px;
  --font-size-small: 15px;
  --font-size-caption: 13px;

  /* Typography - Line Heights */
  --line-height-display: 1.1;
  --line-height-h1: 1.2;
  --line-height-h2: 1.3;
  --line-height-h3: 1.4;
  --line-height-body: 1.6;
  --line-height-small: 1.5;
  --line-height-caption: 1.4;

  /* Typography - Font Weights */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;

  /* Spacing Scale (base unit: 8px) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;
  --space-5xl: 128px;

  /* Layout - Max Widths */
  --max-width-text: 680px;
  --max-width-gallery: 1000px;
  --max-width-container: 1200px;

  /* Motion - Durations */
  --duration-fast: 100ms;
  --duration-normal: 150ms;
  --duration-slow: 200ms;
  --duration-slower: 250ms;
  --duration-expand: 300ms;

  /* Motion - Easing */
  --ease-out: ease-out;
  --ease-default: ease;
}

/* Light theme for content pages (blog, about, contact) */
.theme-light {
  --color-bg: #f0efe8;
  --color-text-primary: #333333;
  --color-text-secondary: #5a5a5a;
  --color-text-tertiary: #888888;
  --color-border: #d8d6d0;
  --color-skeleton: #e5e4de;
}

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

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

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

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
}

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--font-weight-light);
}

h1 {
  font-size: var(--font-size-h1);
  line-height: var(--line-height-h1);
}

h2 {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-h2);
}

h3 {
  font-size: var(--font-size-h3);
  line-height: var(--line-height-h3);
}

p {
  margin: 0 0 var(--space-md) 0;
}

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

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

a:hover {
  text-decoration: underline;
}

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

header {
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3xl);
  margin-bottom: var(--space-3xl);
}

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

.main-nav {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-nav .site-title {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-h2);
  color: var(--color-text-primary);
  text-decoration: none;
}

.main-nav .site-title:hover {
  text-decoration: none;
}

/* Desktop navigation links */
.nav-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li a {
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-default);
}

.nav-links li a:hover,
.nav-links li a.active {
  color: var(--color-text-primary);
  text-decoration: none;
}

/* Hamburger menu button - hidden on desktop */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-sm);
  cursor: pointer;
  z-index: 1001;
}

.hamburger-icon {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-text-primary);
  position: relative;
  transition: background-color var(--duration-normal) var(--ease-default);
}

.hamburger-icon::before,
.hamburger-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 24px;
  height: 2px;
  background-color: var(--color-text-primary);
  transition: transform var(--duration-normal) var(--ease-out);
}

.hamburger-icon::before {
  top: -7px;
}

.hamburger-icon::after {
  bottom: -7px;
}

/* Hamburger to X animation when menu is open */
.menu-toggle[aria-expanded="true"] .hamburger-icon {
  background-color: transparent;
}

.menu-toggle[aria-expanded="true"] .hamburger-icon::before {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .hamburger-icon::after {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile menu overlay - hidden by default */
.mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform var(--duration-slower) var(--ease-out);
}

.mobile-menu.open {
  transform: translateX(0);
}

.mobile-nav-links {
  list-style: none;
  margin: 0;
  padding: 120px var(--space-xl) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.mobile-nav-links li a {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-h2);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-default);
}

.mobile-nav-links li a:hover,
.mobile-nav-links li a.active {
  color: var(--color-text-primary);
}

main {
  max-width: var(--max-width-container);
  margin: 0 auto;
  padding: 0 var(--space-3xl);
}

footer {
  padding: var(--space-3xl);
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-small);
}

/* ============================================
   Sections
   ============================================ */

.hero {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.hero h1 {
  font-size: var(--font-size-display);
  line-height: var(--line-height-display);
  margin-bottom: var(--space-md);
}

.hero .tagline {
  font-size: var(--font-size-h3);
  line-height: var(--line-height-h3);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-light);
}

.about {
  max-width: var(--max-width-text);
  margin: 0 auto var(--space-3xl) auto;
  text-align: center;
}

/* ============================================
   Page Title
   ============================================ */

.page-title {
  font-size: var(--font-size-h1);
  line-height: var(--line-height-h1);
  margin-bottom: var(--space-2xl);
}

/* ============================================
   Hero Image (Homepage)
   ============================================ */

.hero-image-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-link {
  display: block;
  text-decoration: none;
}

.hero-image {
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Ultrawide hero: simple like feed - fill width, natural height */
.hero-image-container.hero-image--ultrawide {
  width: 100%;
  padding: 0 var(--space-3xl);
}

.hero-image--ultrawide {
  width: 100%;
  height: auto;
}

/* Mobile: match nav text margins */
@media (max-width: 640px) {
  .hero-image-container.hero-image--ultrawide {
    padding: 0 var(--space-md);
  }
}

/* Wide images (aspect 1.5-2.0): fill viewport width, natural height */
.hero-image--wide {
  width: 100%;
  max-height: none;
}

/* Tall images (aspect < 0.9): constrain to viewport height */
.hero-image--tall {
  max-height: 80vh;
}

/* Square-ish images (0.9 to 1.5): balanced constraint */
.hero-image--square {
  max-height: 85vh;
}

/* ============================================
   Project Grid (Work Page)
   ============================================ */

.project-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(3, 1fr);
}

.project-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  text-decoration: none;
}

.project-card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background-color: var(--color-skeleton);
}

.project-card-title {
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  margin-top: var(--space-sm);
  color: var(--color-text-primary);
}

/* ============================================
   About Page
   ============================================ */

.about-page {
  max-width: var(--max-width-text);
  margin: 0 auto;
}

.portrait-container {
  margin-bottom: var(--space-2xl);
}

.portrait-image {
  max-width: 300px;
  width: 100%;
  height: auto;
  display: block;
}

.bio-section {
  margin-bottom: var(--space-xl);
}

.bio-section p {
  color: var(--color-text-secondary);
}

.contact-section {
  margin-bottom: var(--space-lg);
}

.email-link {
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-default);
}

.email-link:hover {
  color: var(--color-text-secondary);
  text-decoration: underline;
}

.social-section {
  margin-top: var(--space-lg);
}

.social-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-lg);
}

.social-links a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-default);
}

.social-links a:hover {
  color: var(--color-text-primary);
}

/* ============================================
   Contact Page
   ============================================ */

.contact-page {
  max-width: var(--max-width-text);
  margin: 0 auto;
}

.location-section {
  margin-bottom: var(--space-lg);
}

.location {
  color: var(--color-text-secondary);
}

/* ============================================
   404 Page
   ============================================ */

.not-found-page {
  max-width: var(--max-width-text);
  margin: 0 auto;
  text-align: center;
  padding: var(--space-3xl) 0;
}

.not-found-page p {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

.not-found-page a {
  color: var(--color-text-primary);
}

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

/* Phone landscape and small tablet (md: 640-1024px) */
@media (max-width: 1024px) {
  header {
    padding: 0 var(--space-xl);
    margin-bottom: var(--space-2xl);
  }

  main {
    padding: 0 var(--space-xl);
  }

  /* Show hamburger, hide desktop nav on mobile */
  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none;
  }

  .mobile-menu {
    display: block;
  }

  /* Project grid: 2 columns on tablet */
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Phone portrait (sm: < 640px) */
@media (max-width: 640px) {
  header {
    padding: 0 var(--space-md);
    margin-bottom: var(--space-lg);
  }

  main {
    padding: 0 var(--space-md);
  }

  .hero h1 {
    font-size: var(--font-size-h1);
  }

  /* Project grid: 1 column on mobile */
  .project-grid {
    grid-template-columns: 1fr;
  }

  /* Page title smaller on mobile */
  .page-title {
    font-size: var(--font-size-h2);
  }

  /* Social links stack on mobile */
  .social-links {
    flex-direction: column;
    gap: var(--space-md);
  }
}

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

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

/* Remove focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Screen reader only utility class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
