/* =========================================================
   [GLOBAL RULE] Legend of Master K — VVIP Manifesto
   Forced identically on KO / EN / JA `/legend`
========================================================= */

.legend-page {
  margin: 0;
  min-height: 100vh;
  background: #050505;
  color: #e8e0d0;
  font-family: 'Cormorant Garamond', 'Noto Serif KR', 'Noto Serif JP', Georgia, serif;
  overflow-x: hidden;
}

html[lang="ko"] .legend-page,
body[data-ui-language="ko"].legend-page {
  font-family: 'Noto Serif KR', 'Cormorant Garamond', Georgia, serif;
}
html[lang="ja"] .legend-page,
body[data-ui-language="ja"].legend-page {
  font-family: 'Noto Serif JP', 'Cormorant Garamond', Georgia, serif;
}

.legend-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(255, 215, 0, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 85% 90%, rgba(90, 50, 140, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 50% 35% at 10% 75%, rgba(40, 80, 160, 0.05) 0%, transparent 48%),
    linear-gradient(180deg, #030303 0%, #0a0a12 45%, #050505 100%);
}

.legend-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.legend-shell {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 88px 24px 72px;
}

.legend-logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}

.legend-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 0 22px rgba(255, 215, 0, 0.28));
}

.legend-header {
  text-align: center;
  margin-bottom: 36px;
}

.legend-page-title {
  margin: 0;
  font-family: 'Cinzel', serif;
  font-size: clamp(1.65rem, 4.5vw, 2.65rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.35;
  text-transform: uppercase;
  color: #FFD700;
  text-shadow:
    0 0 40px rgba(255, 215, 0, 0.22),
    0 2px 24px rgba(0, 0, 0, 0.85);
}

/* [2] Glassmorphism manifesto container — KO / EN / JA */
.legend-scroll,
.legend-page .legend-scroll.reading-room-panel {
  position: relative;
  padding: 48px 40px 44px !important;
  border: 1px solid rgba(212, 175, 55, 0.35) !important;
  border-radius: 16px !important;
  background: rgba(15, 15, 15, 0.7) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  box-shadow:
    inset 0 0 20px rgba(212, 175, 55, 0.05),
    0 10px 30px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(212, 175, 55, 0.08) !important;
  overflow: visible;
  animation: none;
}

.legend-scroll::before,
.legend-scroll::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  height: 1px;
  border-radius: 0;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.45), transparent);
  opacity: 0.7;
  pointer-events: none;
}

.legend-scroll::before { top: 18px; }
.legend-scroll::after { bottom: 18px; }

/* [3] Speaker / play emblem — gold pulse ring */
.legend-scroll .reading-room-voice-actions,
.legend-page .reading-room-voice-actions--top {
  display: flex;
  justify-content: center;
  padding-top: 8px;
  padding-bottom: 32px;
}

.legend-page .tts-play-btn--legend.oracle-voice-btn,
.legend-page .tts-play-btn--legend {
  position: relative;
  width: 64px !important;
  height: 64px !important;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50% !important;
  border: 1px solid rgba(212, 175, 55, 0.65) !important;
  background: linear-gradient(145deg, rgba(212, 175, 55, 0.28), rgba(80, 60, 10, 0.55), rgba(20, 16, 8, 0.9)) !important;
  box-shadow:
    0 0 0 1px rgba(255, 215, 0, 0.12) inset,
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 0 20px rgba(212, 175, 55, 0.25) !important;
  color: #FFE9A8 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.legend-page .tts-play-btn--legend::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.45);
  animation: legend-emblem-pulse 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

.legend-page .tts-play-btn--legend::after {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 215, 0, 0.18);
  animation: legend-emblem-pulse 2.4s ease-in-out infinite 0.35s;
  pointer-events: none;
  z-index: -2;
}

.legend-page .tts-play-btn--legend:hover,
.legend-page .tts-play-btn--legend:focus-visible {
  transform: scale(1.05);
  border-color: #FFD700 !important;
  box-shadow:
    0 0 0 1px rgba(255, 215, 0, 0.2) inset,
    0 10px 28px rgba(0, 0, 0, 0.6),
    0 0 28px rgba(255, 215, 0, 0.4) !important;
  outline: none;
}

.legend-page .tts-play-btn--legend .oracle-voice-icon,
.legend-page .tts-play-btn--legend .legend-emblem-glyph {
  font-size: 1.45rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.35));
}

@keyframes legend-emblem-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.25;
  }
}

/* [1] Typography — manifesto weight (no center body) */
.legend-body,
.legend-page #chapter-body.legend-body,
.legend-page .reading-room-body.legend-body {
  max-width: 100%;
  margin: 0;
  padding: 4px 4px 8px;
  text-align: justify !important;
  text-justify: inter-character;
  hyphens: auto;
}

.legend-body p,
.legend-page .legend-body p,
.legend-page #chapter-body p {
  margin: 0 0 1.5em;
  font-size: clamp(1.12rem, 2.2vw, 1.32rem) !important;
  line-height: 1.85 !important;
  color: #ebe4d6 !important;
  text-align: justify !important;
  letter-spacing: 0.015em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

html[lang="en"] .legend-body p,
body[data-ui-language="en"] .legend-body p {
  word-break: normal;
  overflow-wrap: break-word;
}

/* Breathing space: last paragraph closes flush (no stacked bottom gap) */
.legend-body > p:last-child,
.legend-page .legend-body > p:last-child,
.legend-page #chapter-body > p:last-child {
  margin-bottom: 0;
}

/*
 * Drop Cap — ONLY the first paragraph's first letter (KO / EN / JA).
 * Never apply to p:nth-of-type(n+2) or .legend-body-lead if reused later.
 */
.legend-body > p:first-of-type::first-letter,
.legend-page #chapter-body.legend-body > p:first-of-type::first-letter {
  float: left;
  font-family: 'Cinzel', 'Noto Serif KR', 'Noto Serif JP', serif !important;
  font-size: 3em !important;
  font-weight: 700;
  line-height: 0.85 !important;
  padding: 0.08em 0.14em 0.02em 0;
  margin: 0.05em 0.08em 0 0;
  color: #D4AF37 !important;
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.35);
}

.legend-body > p:not(:first-of-type)::first-letter,
.legend-page #chapter-body.legend-body > p:not(:first-of-type)::first-letter {
  float: none;
  font-size: inherit !important;
  font-weight: inherit;
  line-height: inherit !important;
  padding: 0;
  margin: 0;
  color: inherit !important;
  text-shadow: none;
}

html[lang="ko"] .legend-body p,
html[lang="ja"] .legend-body p,
body[data-ui-language="ko"] .legend-body p,
body[data-ui-language="ja"] .legend-body p {
  text-align: justify !important;
  line-height: 1.9 !important;
}

html[lang="en"] .legend-body p,
body[data-ui-language="en"] .legend-body p {
  text-align: justify !important;
  line-height: 1.85 !important;
}

.legend-page .reading-room-voice-hint,
.legend-scroll .reading-room-voice-hint {
  margin: 28px 0 0 !important;
  text-align: left !important;
  font-size: 0.88rem;
  line-height: 1.6;
  color: rgba(220, 210, 180, 0.55);
  letter-spacing: 0.03em;
  font-style: normal;
}

.legend-nav {
  display: flex;
  justify-content: center;
  margin-top: 44px;
}

.legend-back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: #FFD700;
  border: 1px solid rgba(255, 215, 0, 0.42);
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.04);
  transition: color 0.22s ease, border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease, transform 0.2s ease;
}

.legend-back-link:hover,
.legend-back-link:focus-visible {
  color: #ffe566;
  border-color: rgba(255, 215, 0, 0.72);
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.2);
  transform: translateY(-1px);
  outline: none;
}

@media (max-width: 640px) {
  .legend-shell {
    padding-top: 76px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .legend-scroll,
  .legend-page .legend-scroll.reading-room-panel {
    padding: 40px 22px 34px !important;
  }

  .legend-page-title {
    letter-spacing: 0.1em;
  }

  .legend-body p,
  .legend-page .legend-body p {
    font-size: 1.08rem !important;
    line-height: 1.85 !important;
  }

  /* Narrow screens: float drop-cap still works; keep left-leaning justify */
  .legend-body,
  .legend-page .legend-body {
    text-align: left !important;
  }
  .legend-body p,
  .legend-page .legend-body p {
    text-align: left !important;
  }
}
