@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Lato:wght@400;500&display=swap');

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

/* Ensure the HTML hidden attribute always hides elements, even when author CSS
   sets a display value (e.g. display:flex or display:grid), because the UA
   stylesheet's [hidden]{display:none} has no !important and gets overridden. */
[hidden] {
  display: none !important;
}

:root {
  --bg: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --text: #e0e0e0;
  --text-muted: #a8a8a8;
  --accent: #d4a574;
  --overlay-bg: rgba(0, 0, 0, 0.95);

  /* Typography scales */
  --font-heading: 'Cormorant Garamond', serif;
  --font-body: 'Lato', -apple-system, system-ui, sans-serif;

  /* Type sizes (fixed scale with 1.25 ratio) */
  --text-xs: 0.75rem;       /* 12px */
  --text-sm: 0.875rem;      /* 14px */
  --text-base: 1rem;        /* 16px */
  --text-lg: 1.125rem;      /* 18px */
  --text-xl: 1.375rem;      /* 22px */
  --text-2xl: 1.75rem;      /* 28px */
  --text-3xl: 2.25rem;      /* 36px */

  /* Line heights */
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* Animation timing */
  --duration-instant: 100ms;
  --duration-quick: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Easing curves (natural deceleration) */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* Header */
.site-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.site-header h1 {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
  line-height: var(--leading-tight);
}

.site-header .tagline {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  margin-top: 0.75rem;
  letter-spacing: 0.08em;
  font-weight: 500;
  text-transform: uppercase;
}

/* Section Nav / Tabs */
.section-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

.tab {
  background: transparent;
  border: 1px solid #333;
  color: var(--text-muted);
  padding: 0.625rem 1.25rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all var(--duration-quick) var(--ease-out-quart);
}

.tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212, 165, 116, 0.1);
}

/* Loading */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 1rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error */
.error-message {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-base);
}

.error-message button {
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Start Slideshow Buttons */
.slideshow-start-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 1rem 1rem;
}

.start-slideshow-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 0.75rem 2.5rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--duration-quick) var(--ease-out-quart), 
              transform var(--duration-quick) var(--ease-out-quart);
}

.start-slideshow-btn:hover {
  background: #e0b88a;
  transform: scale(1.03);
}

.start-slideshow-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.start-zen-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid #444;
  padding: 0.75rem 2.5rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color var(--duration-quick) var(--ease-out-quart), 
              color var(--duration-quick) var(--ease-out-quart), 
              transform var(--duration-quick) var(--ease-out-quart);
}

.start-zen-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: scale(1.03);
}

.start-zen-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Photo Grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  padding: 0.5rem 1rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

.photo-card {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  transition: transform var(--duration-quick) var(--ease-out-quart), 
              box-shadow var(--duration-quick) var(--ease-out-quart);
  animation: cardFadeIn var(--duration-slow) var(--ease-out-quart) backwards;
}

.photo-card:nth-child(1) { animation-delay: 0ms; }
.photo-card:nth-child(2) { animation-delay: 50ms; }
.photo-card:nth-child(3) { animation-delay: 100ms; }
.photo-card:nth-child(n+4) { animation-delay: 150ms; }

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

.photo-card:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(212, 165, 116, 0.15);
}

.photo-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  background: #111;
}

.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5rem 0.75rem 0.6rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  opacity: 0;
  transition: opacity var(--duration-quick) var(--ease-out-quart);
}

.photo-card:hover .card-overlay {
  opacity: 1;
}

.card-overlay .card-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 500;
  color: #fff;
  line-height: var(--leading-tight);
}

.card-overlay .card-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Skeleton Loading */
.photo-card.skeleton {
  cursor: default;
  pointer-events: none;
}

.photo-card.skeleton img {
  background: linear-gradient(90deg, #1a1a1a 25%, #252525 50%, #1a1a1a 75%);
  background-size: 200% 100%;
  animation: skeletonPulse var(--duration-slow) ease-in-out infinite;
}

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Slideshow Image Loading */
#slideshow-img.loading {
  opacity: 0.5;
}

.slideshow-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 2px solid rgba(212, 165, 116, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin var(--duration-normal) linear infinite;
  opacity: 0;
  transition: opacity var(--duration-quick) var(--ease-out-quart);
  pointer-events: none;
}

.slideshow-loading.active {
  opacity: 1;
}

/* Slideshow Overlay */
.slideshow-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none; /* don't intercept clicks while invisible */
  transition: opacity var(--duration-slow) var(--ease-out-quart);
}

.slideshow-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.slideshow-overlay.visible .slideshow-backdrop {
  animation: backdropFadeIn var(--duration-slow) var(--ease-out-quart);
}

.slideshow-overlay.visible #slideshow-img {
  animation: imageFadeScale var(--duration-normal) var(--ease-out-quint) 100ms both;
}

.slideshow-overlay.visible .slideshow-content {
  animation: contentFadeIn var(--duration-normal) var(--ease-out-quint) 150ms both;
}

.slideshow-overlay.visible .slideshow-controls {
  animation: controlsFadeIn var(--duration-normal) var(--ease-out-quint) 200ms both;
}

@keyframes backdropFadeIn {
  from { opacity: 0; }
  to { opacity: 0.5; }
}

@keyframes imageFadeScale {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

/* Blurred ambient backdrop — same image scaled to cover + heavy blur fills
   the letterbox bars left by portrait or narrow photos. z-index 0 keeps it
   behind all controls and the main image. */
.slideshow-backdrop {
  position: absolute;
  top: -5%;
  left: -5%;
  width: 110%;
  height: 110%;
  object-fit: cover;
  filter: blur(35px);
  opacity: 0;
  z-index: 0;
}

.slideshow-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
  padding: 0.25rem;
  transition: color var(--duration-quick) var(--ease-out-quart);
  border-radius: 4px;
}

.slideshow-close:hover {
  color: #fff;
}

.slideshow-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.slideshow-prev,
.slideshow-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  font-size: 2.5rem;
  width: 50px;
  height: 70px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-quick) var(--ease-out-quart), 
              color var(--duration-quick) var(--ease-out-quart);
  z-index: 10;
}

.slideshow-prev:hover,
.slideshow-next:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.slideshow-prev:focus-visible,
.slideshow-next:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.slideshow-prev { left: 1rem; }
.slideshow-next { right: 1rem; }

.slideshow-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 85vh;
  position: relative; /* establish stacking context above the backdrop */
  z-index: 1;
}

#slideshow-img {
  max-width: 90vw;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 4px;
  transition: opacity 0.3s;
}

#slideshow-img.fading {
  opacity: 0.3;
}

.slideshow-info {
  text-align: center;
  padding: 1.25rem 0 0;
  max-width: 90vw;
}

.slideshow-info h2 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 500;
  color: #fff;
  line-height: var(--leading-tight);
}

.slideshow-info p {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 0.5rem;
  letter-spacing: 0.03em;
}

.slideshow-controls {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-muted);
  z-index: 2;
}

#autoplay-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #444;
  color: var(--text-muted);
  padding: 0.375rem 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--duration-quick) var(--ease-out-quart);
}

#autoplay-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
  color: var(--text);
}

#autoplay-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#autoplay-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212, 165, 116, 0.1);
}

#fullscreen-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #444;
  color: var(--text-muted);
  padding: 0.375rem 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--duration-quick) var(--ease-out-quart);
}

#fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
  color: var(--text);
}

#fullscreen-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#fullscreen-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212, 165, 116, 0.1);
}

#slideshow-link {
  font-family: var(--font-body);
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#slideshow-link:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  border-top: 1px solid #1a1a1a;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
  :root {
    --text-3xl: 1.75rem;
    --text-xl: 1.25rem;
  }

  .site-header {
    padding: 2rem 1rem 1rem;
  }

  .site-header h1 {
    font-size: var(--text-2xl);
  }

  .site-header .tagline {
    font-size: var(--text-xs);
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    padding: 0.5rem 0.5rem 2rem;
  }

  .card-overlay {
    opacity: 1;
  }

  .slideshow-prev,
  .slideshow-next {
    width: 40px;
    height: 55px;
    font-size: 1.8rem;
  }

  .slideshow-prev { left: 0.5rem; }
  .slideshow-next { right: 0.5rem; }
}

/* Hide scrollbar when slideshow open */
body.slideshow-open {
  overflow: hidden;
}

/* ── Zen fullscreen view ────────────────────────────────────────────────── */

.zen-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #000;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.zen-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Blurred ambient backdrop for zen */
.zen-backdrop {
  position: absolute;
  top: -5%;
  left: -5%;
  width: 110%;
  height: 110%;
  object-fit: cover;
  filter: blur(40px);
  opacity: 0.45;
  z-index: 0;
}

/* Two absolutely-stacked images for smooth cross-fading */
.zen-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out-quart);
  z-index: 1; /* above backdrop */
}

.zen-img--active {
  opacity: 1;
}

.zen-hint {
  position: absolute;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out-quart);
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(212, 165, 116, 0.3);
  backdrop-filter: blur(8px);
}

.zen-overlay.visible .zen-hint {
  animation: zenHintFadeIn var(--duration-slow) var(--ease-out-quart) forwards;
}

@keyframes zenHintFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.zen-hint kbd {
  font-family: var(--font-body);
  background: rgba(212, 165, 116, 0.15);
  border: 1px solid rgba(212, 165, 116, 0.4);
  border-radius: 4px;
  padding: 0.25em 0.5em;
  font-weight: 600;
  color: var(--accent);
}

.zen-hint.fade-out {
  opacity: 0.25;
}

.zen-fullscreen-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(212, 165, 116, 0.4);
  color: rgba(212, 165, 116, 0.8);
  border-radius: 4px;
  padding: 0.5em 0.8em;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out-quart),
              color var(--duration-quick) var(--ease-out-quart), 
              border-color var(--duration-quick) var(--ease-out-quart),
              background var(--duration-quick) var(--ease-out-quart);
}

.zen-overlay.visible .zen-fullscreen-btn {
  animation: zenHintFadeIn var(--duration-slow) var(--ease-out-quart) forwards;
}

.zen-fullscreen-btn:hover {
  color: #fff;
  border-color: rgba(212, 165, 116, 0.8);
  background: rgba(0, 0, 0, 0.8);
}

.zen-fullscreen-btn:focus-visible {
  outline: 2px solid rgba(212, 165, 116, 0.8);
  outline-offset: 2px;
}

.zen-fullscreen-btn.hidden {
  animation: zenButtonHide var(--duration-slow) var(--ease-out-quart) forwards;
  pointer-events: none;
}

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

/* ──────────────────────────────────────────────────────────────────────────
   Accessibility: Respect user's motion preferences
   ────────────────────────────────────────────────────────────────────────── */

@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;
  }

  /* Ensure key focus states still work without animation */
  *:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}
