/* ═══════════════════════════════════════════════════════════════
   main.css — Design tokens, typography, theme, global layout
   Style: editorial / print magazine (Vogue/People aesthetic)
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts are loaded in HTML ── */

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
  /* Typography */
  --font-display: 'Playfair Display', 'PT Serif', Georgia, serif;
  --font-body: 'PT Serif', Georgia, serif;
  --font-ui: 'PT Sans', system-ui, sans-serif;
  --font-caption: 'Cormorant Garamond', Georgia, serif;

  /* Spacing */
  --gap-xs: 0.25rem;
  --gap-sm: 0.5rem;
  --gap-md: 1rem;
  --gap-lg: 2rem;
  --gap-xl: 4rem;
  --gap-2xl: 8rem;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-mid: 300ms;
  --dur-slow: 600ms;

  /* Z-indices */
  --z-bg: -1;
  --z-base: 1;
  --z-catalog: 10;
  --z-viewer: 100;
  --z-ui: 200;
}

/* ── Light theme (default) ─────────────────────────────────────── */
:root, [data-theme="light"] {
  --color-bg: #f7f5f0;
  --color-bg-secondary: #eeebe4;
  --color-surface: #ffffff;
  --color-border: #d8d3c8;
  --color-text: #1a1814;
  --color-text-secondary: #5a5650;
  --color-text-muted: #9a9590;
  --color-accent: #c8102e;         /* magazine red */
  --color-accent-light: #fce4e9;
  --color-overlay: rgba(247, 245, 240, 0.88);
  --color-overlay-dark: rgba(26, 24, 20, 0.6);
  --color-year-inactive: rgba(26, 24, 20, 0.25);
  --shadow-card: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-elevated: 0 8px 40px rgba(0,0,0,0.14);
}

/* ── Dark theme ────────────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg: #111009;
  --color-bg-secondary: #1c1a15;
  --color-surface: #232018;
  --color-border: #3a3830;
  --color-text: #f0ede6;
  --color-text-secondary: #a8a49c;
  --color-text-muted: #66635c;
  --color-accent: #e8304c;
  --color-accent-light: #3d0f18;
  --color-overlay: rgba(17, 16, 9, 0.88);
  --color-overlay-dark: rgba(0, 0, 0, 0.7);
  --color-year-inactive: rgba(240, 237, 230, 0.2);
  --shadow-card: 0 2px 16px rgba(0,0,0,0.4);
  --shadow-elevated: 0 8px 40px rgba(0,0,0,0.6);
}

/* ── System preference auto-detect ─────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #111009;
    --color-bg-secondary: #1c1a15;
    --color-surface: #232018;
    --color-border: #3a3830;
    --color-text: #f0ede6;
    --color-text-secondary: #a8a49c;
    --color-text-muted: #66635c;
    --color-accent: #e8304c;
    --color-accent-light: #3d0f18;
    --color-overlay: rgba(17, 16, 9, 0.88);
    --color-overlay-dark: rgba(0, 0, 0, 0.7);
    --color-year-inactive: rgba(240, 237, 230, 0.2);
    --shadow-card: 0 2px 16px rgba(0,0,0,0.4);
    --shadow-elevated: 0 8px 40px rgba(0,0,0,0.6);
  }
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background var(--dur-mid) var(--ease), color var(--dur-mid) var(--ease);
}

img, video {
  display: block;
  max-width: 100%;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── Theme toggle ──────────────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: var(--gap-md);
  right: var(--gap-md);
  z-index: var(--z-ui);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  font-size: 1.1rem;
  transition: box-shadow var(--dur-fast), transform var(--dur-fast);
  mix-blend-mode: normal;
}

.theme-toggle:hover {
  box-shadow: var(--shadow-elevated);
  transform: scale(1.05);
}

/* ── 404 page ──────────────────────────────────────────────────── */
.page-404 {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  z-index: var(--z-viewer);
}

.page-404__inner {
  text-align: center;
}

.page-404__num {
  font-family: var(--font-display);
  font-size: clamp(6rem, 20vw, 14rem);
  font-weight: 900;
  line-height: 1;
  color: var(--color-accent);
  letter-spacing: -0.04em;
}

.page-404__text {
  font-family: var(--font-caption);
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: var(--color-text-secondary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: var(--gap-sm);
}

/* ── Utility ───────────────────────────────────────────────────── */
.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;
}

.hidden { display: none !important; }

/* ── Scroll lock (when viewer open) ───────────────────────────── */
body.scroll-lock {
  overflow: hidden;
}

/* ── Cover screen ──────────────────────────────────────────────── */
gallery-cover {
  display: block;
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
}

.cover {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

/* Background layer */
.cover__bg {
  position: absolute;
  inset: 0;
  z-index: var(--z-bg);
  overflow: hidden;
}

.cover__bg img,
.cover__bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Overlay tint (theme color × bgOpacity) */
.cover__overlay {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--color-bg);
  /* opacity set inline from settings.bgOpacity */
}

/* Content layer */
.cover__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 6vw, 6rem) clamp(1.5rem, 8vw, 10rem);
  min-height: 100dvh;
}

/* Magazine-style meta line */
.cover__meta {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--gap-lg);
  margin-bottom: clamp(1rem, 3vh, 2.5rem);
}

.cover__meta-divider {
  width: 2rem;
  height: 1px;
  background: var(--color-accent);
  flex-shrink: 0;
}

.cover__meta-item strong {
  color: var(--color-accent);
}

/* Site title — huge display type */
.cover__title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 9rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--color-text);
  max-width: 16ch;
  margin-bottom: clamp(1.5rem, 4vh, 3rem);
}

.cover__title em {
  font-style: italic;
  color: var(--color-accent);
}

/* About / quote text */
.cover__about {
  font-family: var(--font-caption);
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 300;
  line-height: 1.65;
  color: var(--color-text-secondary);
  max-width: 55ch;
  margin-bottom: clamp(2rem, 5vh, 4rem);
}

.cover__about p + p {
  margin-top: 0.75em;
}

/* Scroll hint */
.cover__scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  animation: scrollHintBounce 2s ease-in-out infinite;
  cursor: pointer;
}

.cover__scroll-hint::after {
  content: '↓';
  font-size: 1.2rem;
  animation: none;
}

@keyframes scrollHintBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}

/* ── Markdown-rendered text ────────────────────────────────────── */
.markdown-content h1, .markdown-content h2, .markdown-content h3 {
  font-family: var(--font-display);
  margin: 1em 0 0.4em;
}
.markdown-content p { margin-bottom: 0.75em; }
.markdown-content pre {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  padding: var(--gap-md);
  overflow-x: auto;
  font-size: 0.85em;
  white-space: pre-wrap;
}
.markdown-content code { font-size: 0.85em; background: var(--color-bg-secondary); padding: 0.1em 0.3em; }
.markdown-content pre code { background: none; padding: 0; }
.markdown-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--gap-md);
  font-style: italic;
  color: var(--color-text-secondary);
}
.markdown-content ul, .markdown-content ol { padding-left: 1.5em; margin-bottom: 0.75em; }
.markdown-content a { color: var(--color-accent); text-decoration: underline; }

/* ── Loading spinner ───────────────────────────────────────────── */
.spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Copyright footer ──────────────────────────────────────────── */
.site-footer {
  padding: var(--gap-xl) clamp(1.5rem, 8vw, 10rem);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cover__content {
    padding: 4rem 1.5rem 6rem;
    justify-content: flex-end;
  }
  .cover__title {
    font-size: clamp(2.5rem, 13vw, 5rem);
  }
}
