/* ============================================
   Michael David — Author Bio Page
   Art direction: Deep cosmic dark, gold accent,
   silver text — derived from the book covers.
   ============================================ */

/* ─── Design Tokens ─────────────────────────── */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);
  --text-hero: clamp(3rem, 0.5rem + 7vw, 8rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;
}

/* ─── Dark Mode (default — cosmic theme) ────── */
:root,
[data-theme='dark'] {
  --color-bg: #0a0a0c;
  --color-surface: #121214;
  --color-surface-2: #1a1a1e;
  --color-surface-offset: #0f0f12;
  --color-border: #2a2a2e;
  --color-divider: #1e1e22;

  --color-text: #e8e8ea;
  --color-text-muted: #99999e;
  --color-text-faint: #7a7a7e;

  --color-primary: #e8af34;
  --color-primary-hover: #f5c051;
  --color-primary-dim: rgba(232, 175, 52, 0.12);
  --color-silver: #f5f4f0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(232, 175, 52, 0.08);

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Satoshi', 'Helvetica Neue', sans-serif;
}

/* ─── Light Mode ───────────────────────────── */
[data-theme='light'] {
  --color-bg: #f7f6f2;
  --color-surface: #ffffff;
  --color-surface-2: #f3f0ec;
  --color-surface-offset: #edeae5;
  --color-border: #d4d1ca;
  --color-divider: #dcd9d5;

  --color-text: #1a1a1e;
  --color-text-muted: #5a5a5e;
  --color-text-faint: #99999e;

  --color-primary: #b07a00;
  --color-primary-hover: #8a5b00;
  --color-primary-dim: rgba(176, 122, 0, 0.08);

  --color-silver: #2a2a2e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 40px rgba(176, 122, 0, 0.05);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

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

img, svg { display: block; max-width: 100%; height: auto; }

a, button {
  transition: color 180ms cubic-bezier(0.16, 1, 0.3, 1),
              background 180ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 180ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--color-primary-dim);
  color: var(--color-primary);
}

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

/* ─── Starfield Canvas ─────────────────────── */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

[data-theme='light'] #starfield {
  opacity: 0.15;
}

/* ─── Header ────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) clamp(var(--space-6), 5vw, var(--space-12));
  background: color-mix(in oklab, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
}

.nav {
  display: flex;
  gap: var(--space-8);
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--color-primary);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
}

.nav-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.nav-toggle.open svg {
  transform: rotate(90deg);
  transition: transform 200ms ease;
}

@media (max-width: 640px) {
  .nav {
    position: fixed;
    top: 57px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: color-mix(in oklab, var(--color-bg) 95%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-divider);
    padding: var(--space-2) var(--space-6) var(--space-4);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1),
                opacity 200ms ease;
    z-index: 49;
  }

  .nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav.open .nav-link {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-divider);
    font-size: var(--text-base);
  }

  .nav.open .nav-link:last-child {
    border-bottom: none;
  }

  .nav-toggle {
    display: flex;
  }
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ─── Hero ──────────────────────────────────── */
.hero {
  position: relative;
  z-index: 1;
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-32) var(--space-6);
}

.hero-content {
  max-width: 800px;
}

.hero-eyebrow {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-6);
}

.hero-name {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 400;
  line-height: 1.05;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  letter-spacing: -0.02em;
}

.hero-tagline {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 500px;
  margin-inline: auto;
  font-style: italic;
}

.hero-scroll {
  margin-top: var(--space-20);
  color: var(--color-text-faint);
  animation: gentle-bob 3s ease-in-out infinite;
}

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

/* ─── Sections ──────────────────────────────── */
.section {
  position: relative;
  z-index: 1;
  padding-block: clamp(var(--space-12), 6vw, var(--space-24));
}

.container {
  width: 100%;
  max-width: 1000px;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-8);
  letter-spacing: -0.01em;
}

.section-title--center {
  text-align: center;
}

.section-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto var(--space-12);
  text-align: center;
  line-height: 1.7;
}

/* ─── About Section ─────────────────────────── */
.about-section {
  border-top: 1px solid var(--color-divider);
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-16);
  align-items: start;
}

@media (max-width: 768px) {
  .about-grid {
    grid-template-columns: 1fr;
    gap: var(--space-12);
  }
}

.bio-content p {
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  max-width: 65ch;
}

.bio-content em {
  color: var(--color-primary);
  font-style: italic;
}

.about-aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.aside-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-5);
}

.aside-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}

.aside-value {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

/* ─── Trilogy Section ───────────────────────── */
.trilogy-section {
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface-offset);
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
  margin-bottom: var(--space-16);
}

@media (max-width: 768px) {
  .books-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
}

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

.book-cover {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 2 / 3;
  margin-bottom: var(--space-6);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card:hover .book-cover {
  transform: translateY(-8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.book-info {
  max-width: 240px;
}

.book-number {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.book-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.book-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.trilogy-quote {
  text-align: center;
  margin-top: var(--space-12);
}

.trilogy-quote blockquote {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-style: italic;
  color: var(--color-primary);
  max-width: 600px;
  margin-inline: auto;
  line-height: 1.4;
}

/* ─── Connect Section ───────────────────────── */
.connect-section {
  border-top: 1px solid var(--color-divider);
}

.connect-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.connect-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
}

.connect-link:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}

.connect-note {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ─── Newsletter / Email Capture ────────────── */
.newsletter-section {
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface-offset);
}

.newsletter-inner {
  max-width: 640px;
  margin-inline: auto;
  text-align: center;
}

.newsletter-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  line-height: 1.2;
}

.newsletter-desc {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-8);
  max-width: 52ch;
  margin-inline: auto;
}

.newsletter-desc em {
  color: var(--color-primary);
  font-style: italic;
}

.newsletter-form {
  max-width: 480px;
  margin-inline: auto;
}

.form-row {
  display: flex;
  gap: var(--space-3);
}

@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
  }
}

.form-input {
  flex: 1;
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  outline: none;
}

.form-input::placeholder {
  color: var(--color-text-faint);
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
}

.form-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-bg);
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.form-submit:hover {
  background: var(--color-primary-hover);
}

.form-submit:disabled {
  opacity: 0.5;
  cursor: wait;
}

.form-status {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  min-height: 1.2em;
}

.form-status.error {
  color: #e06c5c;
}

.newsletter-success {
  max-width: 480px;
  margin-inline: auto;
  padding: var(--space-8);
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  animation: fade-in-up 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.success-check {
  color: var(--color-primary);
  margin: 0 auto var(--space-4);
}

.success-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.success-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.success-download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-primary);
  background: var(--color-primary-dim);
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  text-decoration: none;
}

.success-download:hover {
  background: var(--color-primary);
  color: var(--color-bg);
}

/* ─── Footer ─────────────────────────────────── */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--color-divider);
  padding: var(--space-12) var(--space-6);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
}

.footer-logo svg {
  color: var(--color-primary);
}

.footer-logo span {
  font-family: var(--font-display);
  font-size: var(--text-lg);
}

.footer-copy {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
