:root {
  --ground: #151C2E;
  --surface: #1C2436;
  --line: #26304A;
  --line-strong: #3E4A68;
  --text: #F4EDE0;
  --muted: #CFC5B3;
  --accent: #F2A341;
  --gold: #F2C14E;
  --gold-soft: #E8C877;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--text);
  font-family: Mukta, "Noto Sans", system-ui, sans-serif;
  /* book size scales with screen height so everything fits */
  --bw: clamp(60px, 10vh, 104px);
}

a { color: var(--gold); }
a:hover { color: #FFE09A; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

/* Header & footer */
.site-header {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: clamp(8px, 1.4vh, 14px) clamp(20px, 5vw, 72px);
}
.logo {
  font-family: Marcellus, Georgia, serif; font-size: 22px;
  color: var(--text); text-decoration: none; letter-spacing: 0.02em;
}
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 26px; font-size: 16px; }
.site-header nav a { color: #E6DDCC; text-decoration: none; padding: 8px 0; }
.site-header nav a:hover { color: var(--gold); }

.site-footer {
  flex: 0 0 auto;
  padding: 8px clamp(20px, 5vw, 72px); border-top: 1px solid var(--line);
  font-size: 13px; color: #B8AE9C;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px;
}

/* One-screen hero: title, Maharaj, books */
main {
  flex: 1 1 auto; min-height: 0; width: 100%;
  padding: clamp(8px, 1.6vh, 20px) clamp(16px, 4vw, 48px) 0;
  display: flex; flex-direction: column; align-items: center;
}
.hero-title { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
h1 {
  margin: 0; font-family: Marcellus, Georgia, serif; font-weight: 400;
  font-size: clamp(28px, 5.2vh, 52px); line-height: 1.05;
}
.intro { margin: 0; font-size: clamp(14px, 1.9vh, 17px); line-height: 1.4; color: var(--muted); }

/* Stage: video on top, books in their own row beneath his hands */
.stage {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(ellipse 30% 44% at 50% 36%, #262C41 0%, #1E2539 45%, #181F31 75%, var(--ground) 100%);
}
.vid-wrap { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; justify-content: center; }
.stage video {
  display: block; height: 100%; width: auto; max-width: 100%; aspect-ratio: 880 / 720; object-fit: cover;
  -webkit-mask-image:
    linear-gradient(to right, transparent 0%, #000 20%, #000 80%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, #000 10%, #000 82%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent 0%, #000 20%, #000 80%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, #000 10%, #000 82%, transparent 100%);
  mask-composite: intersect;
}

/* Books: reserved space so they never cover his hands; they overlap only the faded cushion */
.books-area {
  flex: 0 0 auto; width: 100%;
  margin-top: calc(var(--bw) * -0.18);
  min-height: calc(var(--bw) * 1.62 + 56px);
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: clamp(6px, 1.2vh, 12px);
}
.books-area[hidden] { display: flex; visibility: hidden; }
.shelf-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; padding: 10px 4px 6px; }
.books {
  list-style: none; margin: 0 auto; padding: 0 8px;
  display: flex; align-items: flex-start; gap: clamp(10px, 1.4vw, 20px); justify-content: safe center;
  width: max-content; min-width: 100%;
}
.book {
  width: var(--bw); height: calc(var(--bw) * 1.44); padding: calc(var(--bw) * 0.07); border: 0; cursor: pointer;
  border-radius: 5px 9px 9px 5px; color: #FFF8EA; font-family: inherit;
  box-shadow: inset 5px 0 0 rgba(0,0,0,0.25), 0 10px 24px rgba(0,0,0,0.5);
  animation: bookIn .8s cubic-bezier(.2,.8,.2,1) backwards;
  transition: transform .25s ease;
}
.book:hover, .book:focus-visible { transform: translateY(-8px); }
.book[aria-pressed="true"] {
  box-shadow: inset 5px 0 0 rgba(0,0,0,0.25), 0 10px 24px rgba(0,0,0,0.5), 0 0 0 3px var(--ground), 0 0 0 6px var(--accent);
}
.cover-frame {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  width: 100%; height: 100%; border: 1.5px solid var(--gold-soft); border-radius: 4px;
  padding: 6px 4px; text-align: center;
}
.cover-sanskrit { font-size: calc(var(--bw) * 0.125); line-height: 1.2; color: #F6DC97; }
.cover-rule { width: 24px; height: 1px; background: var(--gold-soft); }
.cover-title { font-family: Marcellus, Georgia, serif; font-size: max(12px, calc(var(--bw) * 0.125)); line-height: 1.15; }
.hint-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 16px; animation: rise .6s ease 2.4s both; }
.hint { margin: 0; font-size: 15px; color: var(--muted); }
.replay {
  min-height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
  font-family: inherit; font-size: 14px; cursor: pointer;
}
.replay:hover { color: var(--text); border-color: var(--muted); }

/* Details overlay (opens over the page, no scrolling) */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(10, 14, 24, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade .25s ease both;
}
.overlay[hidden] { display: none; }

/* Details panel */
.panel {
  width: 100%; max-width: 920px; max-height: calc(100svh - 32px); overflow-y: auto;
  padding: clamp(20px, 3vw, 40px); background: var(--surface);
  border: 1px solid #303A55; border-radius: 16px;
  display: flex; flex-wrap: wrap; gap: 32px;
  animation: rise .45s ease both;
}
.panel-cover {
  flex: 0 0 160px; height: 230px; padding: 12px; border-radius: 6px 12px 12px 6px; color: #FFF8EA;
  box-shadow: inset 8px 0 0 rgba(0,0,0,0.25), 0 14px 30px rgba(0,0,0,0.45);
}
.panel-cover .cover-sanskrit { font-size: 20px; }
.panel-cover .cover-title { font-size: 19px; }
.panel-body { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel-meaning { margin: 0; font-size: 14px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.panel h2 { margin: 6px 0 0; font-family: Marcellus, Georgia, serif; font-weight: 400; font-size: 36px; line-height: 1.1; }
.close {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 22px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.panel-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 16px; color: var(--muted); }
.panel-summary { margin: 0; font-size: 18px; line-height: 1.65; color: #EDE5D5; max-width: 62ch; }
.themes { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.themes li { padding: 6px 14px; border-radius: 999px; background: var(--line); border: 1px solid var(--line-strong); font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.btn-primary, .btn-outline {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 24px;
  border-radius: 24px; font-size: 16px; text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--ground); font-weight: 700; }
.btn-primary:hover { color: var(--ground); background: #F6B866; }
.btn-outline { border: 1px solid var(--gold); color: var(--gold); }


@keyframes bookIn { from { opacity: 0; transform: translateY(60px) scale(.5) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Very short screens (e.g. phone in landscape): allow scrolling */
@media (max-height: 520px) {
  body { height: auto; min-height: 100svh; overflow: auto; }
  .stage { flex: 0 0 auto; height: 92vh; min-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .book, .hint-row, .panel, .overlay { animation-duration: .01s !important; animation-delay: 0s !important; }
}
