/* ===================================================
   VENTURES IN WISDOM — Dark Cosmic Theme
   =================================================== */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

/* ── Design Tokens ── */
:root {
  /* Typography */
  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;

  /* Type Scale */
  --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);

  /* Spacing (4px system) */
  --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;

  /* Color Palette — Dark Cosmic */
  --color-bg:          #0a0a0f;
  --color-surface:     #12121a;
  --color-surface-2:   #1a1a25;
  --color-surface-3:   #222230;
  --color-border:      #2a2a3a;
  --color-border-light:#3a3a50;
  --color-text:        #e8e4df;
  --color-text-muted:  #9895a0;
  --color-text-faint:  #5a5868;
  --color-accent:      #8b5cf6;
  --color-accent-hover:#a78bfa;
  --color-accent-glow: rgba(139, 92, 246, 0.15);
  --color-gold:        #c9a84c;
  --color-gold-muted:  rgba(201, 168, 76, 0.6);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transitions */
  --transition-fast: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 400ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 700ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.08);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;

  /* Header */
  --header-height: 4rem;
}

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, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--color-accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-accent-hover); }

::selection {
  background: rgba(139, 92, 246, 0.3);
  color: var(--color-text);
}

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

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

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

/* ── Starfield Canvas ── */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ── Header / Navigation ── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(139, 92, 246, 0.1);
  transition: background var(--transition-smooth);
}

.site-header.scrolled {
  background: rgba(10, 10, 15, 0.95);
  border-bottom-color: rgba(139, 92, 246, 0.2);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.site-logo svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.site-logo-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--color-text);
  white-space: nowrap;
}

.nav-desktop {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-desktop a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.nav-desktop a:hover,
.nav-desktop a.active {
  color: var(--color-text);
  background: rgba(139, 92, 246, 0.08);
}

.nav-desktop a.active {
  color: var(--color-accent);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 24px;
  padding: var(--space-2);
  z-index: 110;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Nav Overlay */
.nav-mobile {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 105;
  background: rgba(10, 10, 15, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.nav-mobile.open {
  opacity: 1;
  pointer-events: auto;
}

.nav-mobile a {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-6);
  transition: color var(--transition-fast);
}

.nav-mobile a:hover,
.nav-mobile a.active {
  color: var(--color-accent);
}

@media (max-width: 900px) {
  .nav-desktop { display: none; }
  .hamburger { display: flex; }
  .nav-mobile { display: flex; }
}

/* ── Main Content ── */
main {
  position: relative;
  z-index: 1;
  padding-top: var(--header-height);
}

/* ── Page Sections ── */
.page-section {
  display: none;
  min-height: 100vh;
}

.page-section.active {
  display: block;
}

/* ── Hero Banners ── */
.hero {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.hero-home {
  height: clamp(70vh, 80vh, 90vh);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-page {
  height: clamp(30vh, 35vh, 40vh);
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 15, 0.3) 0%,
    rgba(10, 10, 15, 0.5) 50%,
    rgba(10, 10, 15, 0.9) 85%,
    rgba(10, 10, 15, 1) 100%
  );
}

.hero-page .hero-overlay {
  background: linear-gradient(
    180deg,
    rgba(10, 10, 15, 0.2) 0%,
    rgba(10, 10, 15, 0.6) 60%,
    rgba(10, 10, 15, 1) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: var(--space-8);
  max-width: var(--content-default);
}

.hero-quote {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-style: italic;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: var(--space-6);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

.hero-attribution {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero-page-title {
  position: absolute;
  bottom: var(--space-12);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 500;
  color: var(--color-text);
  text-align: center;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
}

/* ── Category Grid (Home) ── */
.categories-section {
  padding: var(--space-12) var(--space-6);
  max-width: var(--content-wide);
  margin: 0 auto;
}

.categories-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--color-text);
  text-align: center;
  margin-bottom: var(--space-10);
  letter-spacing: 0.04em;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.category-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16 / 10;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
  text-decoration: none;
  color: var(--color-text);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
}

.category-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.category-card:hover img {
  transform: scale(1.05);
}

.category-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 15, 0.1) 0%,
    rgba(10, 10, 15, 0.75) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-6);
}

.category-card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.category-card-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Content Page Layout ── */
.page-content {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-16);
}

.page-intro {
  text-align: center;
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-border);
}

.page-intro p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 48ch;
  margin: 0 auto;
  font-style: italic;
}

/* ── Post Cards ── */
.post-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.post-card:hover {
  border-color: var(--color-border-light);
  box-shadow: var(--shadow-glow);
}

.post-card-image {
  width: 100%;
  object-fit: cover;
}

.post-card-image.aspect-16-9 {
  aspect-ratio: 16 / 9;
}

.post-card-image.aspect-square {
  aspect-ratio: 1;
  max-height: 400px;
}

.post-card-body {
  padding: var(--space-6) var(--space-8);
}

.post-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.post-card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.post-card-title:hover {
  color: var(--color-accent);
}

.post-card-date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.post-card-content {
  overflow: hidden;
  transition: max-height var(--transition-slow), opacity var(--transition-smooth);
}

.post-card-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.post-card-content.expanded {
  max-height: none;
  opacity: 1;
}

.post-card-text {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.8;
  white-space: pre-line;
}

.post-card-text p {
  margin-bottom: var(--space-4);
}

.post-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-accent);
  padding: var(--space-2) 0;
  transition: color var(--transition-fast);
}

.post-toggle:hover {
  color: var(--color-accent-hover);
}

.post-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.post-card.is-expanded .post-toggle svg {
  transform: rotate(180deg);
}

/* ── Poetry Specific ── */
.poem-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.8;
  color: var(--color-text);
  white-space: pre-line;
  font-style: italic;
}

/* ── Quote Cards ── */
.quote-block {
  position: relative;
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-4);
  border-left: 3px solid var(--color-accent);
  background: rgba(139, 92, 246, 0.04);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.quote-block-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--color-text);
  white-space: pre-line;
  font-style: italic;
}

.quote-author {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-gold);
  margin-top: var(--space-4);
  font-style: normal;
}

.quote-interpretation {
  margin-top: var(--space-4);
}

.quote-interpretation-label {
  font-size: var(--text-xs);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: var(--space-2);
  font-weight: 500;
}

.quote-interpretation-text {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.8;
  white-space: pre-line;
}

/* ── Book Cards ── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-8);
}

.book-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition-smooth), border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  color: var(--color-text);
  display: block;
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  color: var(--color-text);
}

.book-card-image {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.book-card-body {
  padding: var(--space-6);
}

.book-card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.book-card-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.5;
}

.book-card-author {
  font-size: var(--text-sm);
  color: var(--color-gold);
}

.book-card-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-accent);
  font-weight: 500;
}

/* ── About Section ── */
.about-content {
  max-width: var(--content-narrow);
  margin: 0 auto;
}

.about-content h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  margin-bottom: var(--space-6);
  color: var(--color-text);
}

.about-content p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.8;
  margin-bottom: var(--space-4);
}

.about-content .contact-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-8);
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.about-content .contact-btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  color: #fff;
}

/* ── Footer ── */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: rgba(10, 10, 15, 0.8);
}

.site-footer p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: 0.04em;
  max-width: none;
}

.footer-divider {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
  margin: 0 auto var(--space-4);
}

/* ── Scroll Reveal Animation ── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0ms; }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 80ms; }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 160ms; }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 240ms; }
.reveal-stagger.visible > *:nth-child(5) { transition-delay: 320ms; }
.reveal-stagger.visible > *:nth-child(6) { transition-delay: 400ms; }

.reveal-stagger.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ── Author Sidebar (category pages) ── */
.author-sidebar {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  margin-top: var(--space-12);
  border-top: 1px solid var(--color-border);
}

.author-sidebar p {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  font-style: italic;
  max-width: 36ch;
  margin: 0 auto;
}

/* ── Decorative Elements ── */
.section-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin: var(--space-8) 0;
  color: var(--color-text-faint);
}

.section-ornament::before,
.section-ornament::after {
  content: '';
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border-light), transparent);
}

.section-ornament svg {
  width: 16px;
  height: 16px;
  opacity: 0.4;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero-home {
    height: 70vh;
  }
  
  .hero-page {
    height: 28vh;
  }
  
  .hero-content {
    padding: var(--space-6);
  }

  .hero-quote {
    font-size: var(--text-xl);
  }
  
  .hero-page-title {
    bottom: var(--space-8);
    font-size: var(--text-2xl);
  }
  
  .categories-grid {
    grid-template-columns: 1fr;
  }
  
  .post-card-body {
    padding: var(--space-4) var(--space-5);
  }
  
  .quote-block {
    padding: var(--space-4) var(--space-5);
  }
  
  .page-content {
    padding: var(--space-6) var(--space-4) var(--space-12);
  }
  
  .post-card-header {
    flex-direction: column;
    gap: var(--space-1);
  }

  .book-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .site-logo-text {
    font-size: var(--text-base);
  }
  
  .hero-home {
    height: 65vh;
  }
}

/* ── Loading State ── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16);
}

.loading-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  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); }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-faint);
}

.empty-state p {
  font-style: italic;
  max-width: none;
}
