/* ═══════════════════════════════════════════════════
   THE WEAVER OF WOE — SHARED STYLES
   ═══════════════════════════════════════════════════ */

/* ─── ROOT & RESET ─── */
:root {
  --void: #050505;
  --abyss: #0a0908;
  --obsidian: #1a1816;
  --smoke: #2a2724;
  --ash: #5a5550;
  --bone: #c8bfb0;
  --parchment: #e0d8cc;
  --gold: #c4a265;
  --gold-dim: #8a7245;
  --gold-glow: rgba(196, 162, 101, 0.15);
  --ember: #7a2e2e;
  --purple: #b044d4;
  --purple-glow: rgba(176, 68, 212, 0.4);
  --purple-deep: #8a2eb8;
  --cyan: #00e5ff;
  --cyan-glow: rgba(0, 229, 255, 0.3);
  --blood: #BE1E2D;
  --blood-glow: rgba(190, 30, 45, 0.4);
}

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

::selection { background: var(--purple); color: var(--void); }

html { background-color: #050505; scroll-behavior: smooth; overflow-x: hidden; overscroll-behavior-x: none; scrollbar-width: thin; scrollbar-color: #6b2d8e #0a0908; }
html::-webkit-scrollbar { width: 6px; }
html::-webkit-scrollbar-track { background: #0a0908; }
html::-webkit-scrollbar-thumb { background: #6b2d8e; border-radius: 3px; }
html::-webkit-scrollbar-thumb:hover { background: #8a3db0; }

body {
  background: transparent; /* html carries the base color; an opaque body paints over z-index:-2 page backgrounds */
  color: var(--parchment);
  font-family: 'Cinzel', serif;
  font-weight: 400;
  line-height: 1.75;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  width: 100%;
  max-width: 100vw;
}

/* ─── GRAIN OVERLAY ─── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 10000;
}

/* ─── BACKGROUND SYSTEM ─── */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.page-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
}

/* Darkened variant for placeholder pages */
.page-bg-overlay.darkened {
  background: rgba(0, 0, 0, 0.70);
}

/* ─── TYPOGRAPHY ───
   Fonts load via <link> tags in each page head.
   (An @import here is invalid after other rules and is ignored by browsers.) */

a {
  color: var(--gold);
  text-decoration: none;
  transition: all 0.4s ease;
}
a:hover { color: var(--parchment); }

/* ─── PURPLE STITCHED TITLE ─── */
.page-title {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.5rem);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--purple);
  text-shadow:
    0 0 10px var(--purple-glow),
    0 0 30px var(--purple-glow),
    0 0 60px rgba(176, 68, 212, 0.15);
  text-align: center;
  position: relative;
}

/* Stitch texture overlay on title */
.page-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: transparent;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.3) 2px,
    rgba(0,0,0,0.3) 4px
  );
  -webkit-background-clip: text;
  background-clip: text;
  pointer-events: none;
}

/* ─── FIXED NAV BAR (mirrors loom.html) ─── */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9000;
  padding: 1.8rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-bar-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5,5,5,0.9) 0%, transparent 100%);
  pointer-events: none;
}

.nav-brand {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: #BE1E2D;
  text-shadow: 0 0 15px rgba(190, 30, 45, 0.4);
  position: relative;
  z-index: 1;
}

.nav-icons {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  position: relative;
  z-index: 9600;
}

.nav-icon-btn {
  width: 69px;
  height: 69px;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.4s ease;
  background: none;
  border: none;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon-btn:hover { opacity: 1; }

.nav-icon-btn .icon-glow {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--purple-glow) 0%, transparent 70%);
  filter: blur(9px);
  opacity: 0.6;
  transition: opacity 0.4s ease;
}
.nav-icon-btn:hover .icon-glow { opacity: 1; }

.nav-icon-btn img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

/* Music mute overlay */
.music-mute-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}
.music-mute-overlay.active { display: flex; }
.music-mute-overlay img {
  width: 62px;
  height: 62px;
  object-fit: contain;
}

/* ─── FULL-SCREEN NAV OVERLAY ─── */
.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(5, 5, 5, 0.96);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.nav-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.nav-overlay a {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ash);
  text-decoration: none;
  transition: all 0.4s ease;
  position: relative;
  padding: 0.3rem 0;
}

.nav-overlay a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 1px;
  background: var(--purple);
  transition: all 0.4s ease;
  transform: translateX(-50%);
}

.nav-overlay a:hover {
  color: var(--purple);
  text-shadow: 0 0 20px var(--purple-glow);
}

.nav-overlay a:hover::after {
  width: 100%;
}

.nav-overlay a.current {
  color: var(--purple);
}

/* Nav divider line */
.nav-divider {
  width: 40px;
  height: 1px;
  background: var(--smoke);
  margin: 0.2rem 0;
}

/* ─── FOOTER ─── */
.site-footer {
  text-align: center;
  padding: 3rem 1rem 2rem;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--ash);
  text-transform: uppercase;
}

.site-footer span {
  color: var(--ash);
}

/* ─── PLACEHOLDER PAGE CONTENT ─── */
.placeholder-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  gap: 2rem;
}

.placeholder-message {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  color: var(--ash);
  max-width: 500px;
  line-height: 1.8;
  opacity: 0;
  animation: fadeInUp 1.5s ease-out 0.8s forwards;
}

.placeholder-return {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--purple);
  text-decoration: none;
  transition: all 0.4s ease;
  opacity: 0;
  animation: fadeInUp 1.5s ease-out 1.4s forwards;
  position: relative;
  padding-bottom: 4px;
}

.placeholder-return::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--purple);
  transform: scaleX(0);
  transition: transform 0.4s ease;
}

.placeholder-return:hover {
  color: var(--parchment);
  text-shadow: 0 0 15px var(--purple-glow);
}

.placeholder-return:hover::after {
  transform: scaleX(1);
}

/* ─── ANIMATIONS ─── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes titleReveal {
  from {
    opacity: 0;
    letter-spacing: 0.4em;
    filter: blur(4px);
  }
  to {
    opacity: 1;
    letter-spacing: 0.15em;
    filter: blur(0);
  }
}

@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(176, 68, 212, 0.3)); opacity: 0.6; }
  50% { filter: drop-shadow(0 0 14px rgba(176, 68, 212, 0.5)); opacity: 0.8; }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .nav-bar {
    padding: 1.2rem 1.5rem;
  }

  .nav-icon-btn {
    width: 55px;
    height: 55px;
  }

  .nav-icon-btn img {
    width: 50px;
    height: 50px;
  }

  .nav-icon-btn .icon-glow {
    inset: -10px;
    filter: blur(7px);
  }

  .music-mute-overlay img {
    width: 48px;
    height: 48px;
  }

  .nav-overlay a {
    font-size: 1rem;
    letter-spacing: 0.15em;
  }
}

/* ─── NAV BRAND AS LINK ─── */
a.nav-brand { color: #BE1E2D; text-decoration: none; }
a.nav-brand:hover { color: #BE1E2D; text-shadow: 0 0 22px rgba(190, 30, 45, 0.7); }

/* ─── KEYBOARD FOCUS ─── */
:focus-visible {
  outline: 1px solid var(--purple);
  outline-offset: 4px;
  border-radius: 2px;
}
.nav-icon-btn:focus-visible { opacity: 1; }

/* ─── REDUCED MOTION ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  /* Elements that rely on animation to become visible must not stay hidden */
  .placeholder-message, .placeholder-return { opacity: 1; }
}

/* ─── ARTICLE END-CAP ─── */
.article-endcap {
  margin: 4.5rem auto 1rem;
  text-align: center;
}
.article-endcap .endcap-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2.2rem;
}
.article-endcap .endcap-divider .line {
  width: 60px;
  height: 1px;
  background: var(--ash);
}
.article-endcap .endcap-divider .symbol {
  color: var(--gold-dim, #8a7a4a);
  font-size: 0.7rem;
}
.article-endcap .endcap-label {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 0.6rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #BE1E2D;
  margin-bottom: 0.8rem;
}
.article-endcap .endcap-next {
  display: inline-block;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  color: #FFFFFF;
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.4s ease, text-shadow 0.4s ease;
}
.article-endcap .endcap-next:hover {
  color: #BE1E2D;
  text-shadow: 0 0 18px rgba(190, 30, 45, 0.5);
}
.article-endcap .endcap-book {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.95rem, 1.8vw, 1.05rem);
  color: var(--ash);
  margin-top: 2.4rem;
  line-height: 1.9;
}
.article-endcap .endcap-book a {
  color: #BE1E2D;
  text-decoration: none;
  font-style: normal;
  transition: text-shadow 0.4s ease;
}
.article-endcap .endcap-book a:hover {
  text-shadow: 0 0 15px rgba(190, 30, 45, 0.6);
}



/* ─── MOBILE BACKGROUND LIFT ───
   Small screens crop the rug art to its darkest central region and OLED
   dimming compounds it; ease the veil so the weave reads. All lift is done
   via overlay opacity: a CSS filter on a position:fixed layer is unreliable
   in iOS WebKit compositing and can silently stop rendering. */
@media (max-width: 700px) {
  .page-bg-overlay.darkened {
    background: rgba(0, 0, 0, 0.55);
  }
}
