/* Book of Worlds — warm museum-library atmosphere */
@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap");

:root {
  --bg-deep: #1a1510;
  --bg-mid: #2a2219;
  --bg-card: rgba(42, 36, 30, 0.72);
  --text: #f0e8dc;
  --text-muted: #b8a99a;
  --accent: #c9a227;
  --accent-soft: rgba(201, 162, 39, 0.25);
  --shadow: rgba(0, 0, 0, 0.45);
  --page-paper: #faf6ef;
  --page-ink: #2c241c;
  --radius: 14px;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-deep);
  min-height: 100dvh;
  line-height: 1.55;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ——— Header ——— */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(26, 21, 16, 0.95) 0%, rgba(26, 21, 16, 0.65) 70%, transparent 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header .inner {
  width: min(1200px, 94vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-pill {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.nav-pill:hover,
.nav-pill[aria-current="true"] {
  color: var(--text);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

.sound-toggle {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--bg-deep);
  background: var(--accent);
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s var(--ease), filter 0.2s;
}

.sound-toggle:hover {
  filter: brightness(1.08);
}

.sound-toggle:active {
  transform: scale(0.97);
}

.sound-toggle.muted {
  background: var(--text-muted);
  color: var(--bg-deep);
}

/* ——— Views ——— */
.view {
  display: none;
  min-height: 100dvh;
  padding-top: 72px;
}

.view.is-active {
  display: block;
}

/* ——— Grand Hall ——— */
#view-hall {
  position: relative;
  overflow: hidden;
}

.hall-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 80% at 50% 100%, #3d3228 0%, var(--bg-deep) 55%);
  pointer-events: none;
}

.hall-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, transparent 30%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.hall-content {
  position: relative;
  z-index: 2;
  width: min(900px, 92vw);
  margin: 0 auto;
  text-align: center;
  padding: 8vh 16px 12vh;
}

.hall-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.hall-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  line-height: 1.12;
  margin-bottom: 16px;
  text-shadow: 0 4px 40px var(--shadow);
}

.hall-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  color: var(--text-muted);
  margin-bottom: 40px;
}

.hall-cta {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.btn-primary {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--bg-deep);
  background: linear-gradient(135deg, #e8d5a8, var(--accent));
  border: none;
  padding: 14px 32px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(201, 162, 39, 0.25);
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(201, 162, 39, 0.35);
}

.btn-ghost {
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
}

/* Floating exhibition */
.floating-shelf {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  perspective: 1200px;
}

.float-book {
  position: absolute;
  width: clamp(48px, 8vw, 88px);
  height: clamp(64px, 11vw, 120px);
  border-radius: 4px 10px 10px 4px;
  background: linear-gradient(90deg, #2a1810 0%, #4a3224 40%, #3d2618 100%);
  box-shadow: inset -3px 0 8px rgba(0, 0, 0, 0.4), 4px 12px 24px var(--shadow);
  transform-style: preserve-3d;
  animation: drift-glow 10s ease-in-out infinite;
  opacity: 0.55;
}

.float-book::after {
  content: "";
  position: absolute;
  inset: 8% 12% 8% 18%;
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.15), transparent);
  border-radius: 2px;
}

.float-book:nth-child(1) {
  left: 8%;
  top: 22%;
  animation-delay: 0s;
  transform: rotateY(-18deg) rotateZ(-6deg);
}
.float-book:nth-child(2) {
  right: 10%;
  top: 18%;
  animation-delay: -2s;
  height: clamp(72px, 13vw, 140px);
  background: linear-gradient(90deg, #1e2a32 0%, #2d4550 50%, #243540 100%);
  transform: rotateY(22deg) rotateZ(4deg);
}
.float-book:nth-child(3) {
  left: 18%;
  bottom: 12%;
  animation-delay: -4s;
  width: clamp(56px, 9vw, 96px);
  transform: rotateY(12deg) rotateZ(-8deg);
}
.float-book:nth-child(4) {
  right: 20%;
  bottom: 18%;
  animation-delay: -1.5s;
  background: linear-gradient(90deg, #2a1e28 0%, #4a3048 50%, #352030 100%);
  transform: rotateY(-25deg) rotateZ(5deg);
}
.float-book:nth-child(5) {
  left: 42%;
  top: 12%;
  animation-delay: -3s;
  opacity: 0.35;
  transform: rotateY(5deg) scale(0.85);
}

@keyframes drift-glow {
  0%,
  100% {
    opacity: 0.45;
    filter: brightness(1);
  }
  50% {
    opacity: 0.62;
    filter: brightness(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .float-book {
    animation: none;
  }
  .btn-primary:hover {
    transform: none;
  }
}

/* ——— Library ——— */
#view-library {
  padding-bottom: 80px;
}

.library-intro {
  width: min(720px, 92vw);
  margin: 0 auto 36px;
  text-align: center;
}

.library-intro h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  margin-bottom: 12px;
}

.library-intro p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.world-grid {
  width: min(1100px, 94vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.world-card {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 28px 22px 24px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.45s var(--ease), border-color 0.35s, box-shadow 0.45s var(--ease);
  overflow: hidden;
}

.world-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.35s;
}

.world-card:hover,
.world-card:focus-visible {
  transform: translateY(-6px) scale(1.01);
  border-color: rgba(201, 162, 39, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  outline: none;
}

.world-card:hover::before,
.world-card:focus-visible::before {
  opacity: 1;
}

.world-card .book-label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.world-card h3 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.2;
}

.world-card .logline {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

.world-card .enter-hint {
  margin-top: 18px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ——— Transition overlay ——— */
.portal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-deep);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s var(--ease);
}

.portal-overlay.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* ——— Storybook ——— */
#view-storybook {
  padding-bottom: 100px;
}

.story-toolbar {
  width: min(960px, 94vw);
  margin: 0 auto 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-toolbar .back-lib {
  font-size: 0.88rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.story-toolbar .back-lib:hover {
  border-color: var(--accent);
}

.world-jump {
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--page-paper);
  color: var(--page-ink);
  border: 1px solid rgba(44, 36, 28, 0.15);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  max-width: min(280px, 100%);
}

.book-stage {
  width: min(880px, 94vw);
  margin: 0 auto;
  perspective: 2000px;
}

.book-spread {
  position: relative;
  background: var(--page-paper);
  color: var(--page-ink);
  border-radius: 4px 16px 16px 4px;
  min-height: min(72vh, 640px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  overflow: hidden;
  transform-origin: left center;
  animation: page-in 0.7s var(--ease) both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: rotateY(-8deg) translateX(12px);
  }
  to {
    opacity: 1;
    transform: rotateY(0) translateX(0);
  }
}

.book-inner {
  padding: clamp(24px, 4vw, 48px);
  max-height: min(72vh, 640px);
  overflow-y: auto;
}

.book-inner h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--page-ink);
}

.book-inner h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin: 24px 0 10px;
}

.book-inner p {
  margin-bottom: 14px;
  font-size: 0.95rem;
  line-height: 1.65;
}

.book-inner .lead {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: #5c4d42;
}

.page-hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 280px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #e8dfd0, #c4b5a0);
}

.page-hero.placeholder {
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-style: italic;
  color: #7a6b5c;
  font-size: 1.1rem;
}

.pillars {
  display: grid;
  gap: 14px;
}

@media (min-width: 640px) {
  .pillars {
    grid-template-columns: repeat(2, 1fr);
  }
}

.pillar {
  border: 1px solid rgba(44, 36, 28, 0.12);
  border-radius: 10px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.5);
}

.pillar strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin-bottom: 6px;
  color: var(--page-ink);
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.artifact-tile {
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(145deg, #ebe4d8, #d4c9b8);
  border: 1px dashed rgba(44, 36, 28, 0.2);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  text-align: center;
  padding: 8px;
  color: #6a5c50;
}

.score-block audio {
  width: 100%;
  margin-top: 12px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.book-nav {
  width: min(880px, 94vw);
  margin: 20px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.book-nav button {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}

.book-nav button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.book-nav button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.page-dots button {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s, background 0.2s;
}

.page-dots button[aria-current="true"] {
  background: var(--accent);
  transform: scale(1.25);
}

.threads {
  width: min(880px, 94vw);
  margin: 16px auto 0;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.threads strong {
  color: var(--text);
  font-weight: 600;
}

.threads a {
  margin-right: 10px;
  white-space: nowrap;
}

/* ——— Manifesto ——— */
#view-manifesto {
  padding-bottom: 80px;
}

.manifesto-wrap {
  width: min(720px, 92vw);
  margin: 0 auto;
}

.manifesto-wrap h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 2.75rem);
  text-align: center;
  margin-bottom: 10px;
}

.manifesto-wrap .sub {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 40px;
}

.manifesto-pillar {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.manifesto-pillar:last-child {
  border-bottom: none;
}

.manifesto-pillar h3 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.manifesto-pillar p {
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ——— Footer note ——— */
.hall-footnote {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.65;
  z-index: 3;
  text-align: center;
  width: 90%;
}

@media (max-width: 520px) {
  .book-nav {
    flex-direction: column;
  }
  .page-dots {
    order: -1;
  }
}
