@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;500;600;700&family=Raleway:wght@300;400;500;600;700&display=swap');

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

:root {
  --c-bg: #1A1040;
  --c-accent: #6B21A8;
  --c-light: #F5F0FF;
  --c-mid: #2D1B69;
  --c-border: rgba(107, 33, 168, 0.4);
  --c-text: #E8E0FF;
  --c-muted: #A89CC8;
  --c-glass: rgba(26, 16, 64, 0.7);
  --c-hero-bg: #120B30;
  --nav-width: 220px;
  --font-head: 'Raleway', system-ui, sans-serif;
  --font-body: 'Lora', Georgia, serif;
  --radius: 10px;
  --transition: 0.35s ease;
}

html {
  scroll-behavior: smooth;
  font-size: 17px;
  line-height: 1.7;
  background: var(--c-bg);
  color: var(--c-text);
}

body.dark-page {
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ── Scroll margin for sticky nav ── */
article[id] {
  scroll-margin-top: 24px;
}

/* ══════════════════════════════════════
   PAGE WRAPPER
══════════════════════════════════════ */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════
   SIDE NAV
══════════════════════════════════════ */
.side-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-width);
  height: 100vh;
  background: rgba(18, 11, 48, 0.96);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-y: auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px 28px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 20px;
}

.brand-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  text-decoration: none;
}

.brand-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-text-logo {
  width: 44px;
  height: 44px;
  background: var(--c-accent);
  border-radius: 8px;
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--c-light);
  letter-spacing: 0.05em;
}

.nav-list {
  list-style: none;
  padding: 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--c-muted);
  text-decoration: none;
  font-family: var(--font-head);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: color var(--transition), background var(--transition), padding-left var(--transition);
  min-height: 44px;
  position: relative;
}

.nav-link::before {
  content: attr(data-index);
  font-size: 0.62rem;
  font-weight: 300;
  color: var(--c-accent);
  opacity: 0.6;
  min-width: 18px;
  font-family: var(--font-head);
  letter-spacing: 0.08em;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--c-light);
  background: rgba(107, 33, 168, 0.15);
  padding-left: 26px;
  outline: none;
}

.nav-link.active {
  color: var(--c-light);
  background: rgba(107, 33, 168, 0.22);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--c-accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  font-size: 0.88rem;
  color: var(--c-accent);
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search */
.nav-search {
  padding: 16px 16px 0;
  border-top: 1px solid var(--c-border);
  position: relative;
}

.search-input {
  width: 100%;
  background: rgba(245, 240, 255, 0.06);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 9px 34px 9px 12px;
  color: var(--c-light);
  font-family: var(--font-head);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  min-height: 40px;
}

.search-input::placeholder {
  color: var(--c-muted);
  opacity: 0.7;
}

.search-input:focus {
  border-color: var(--c-accent);
  background: rgba(107, 33, 168, 0.12);
}

.search-icon {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-20%);
  color: var(--c-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

/* ══════════════════════════════════════
   CONTENT WRAP
══════════════════════════════════════ */
.content-wrap {
  margin-left: var(--nav-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════
   HERO
══════════════════════════════════════ */
.hero-section {
  position: relative;
  min-height: 70vh;
  background: var(--c-hero-bg);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--c-border);
}

.hero-bg-text {
  position: absolute;
  right: -2%;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-head);
  font-size: clamp(120px, 20vw, 260px);
  font-weight: 700;
  color: rgba(107, 33, 168, 0.07);
  letter-spacing: 0.12em;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  z-index: 0;
}

.hero-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-layer-1 {
  background: radial-gradient(ellipse 80% 60% at 60% 50%, rgba(107,33,168,0.18) 0%, transparent 70%);
  z-index: 1;
}

.hero-layer-2 {
  background: linear-gradient(180deg, transparent 60%, rgba(26,16,64,0.9) 100%);
  z-index: 2;
}

.hero-inner {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 48px;
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 40px;
  align-items: center;
}

/* Hero aside */
.hero-aside {
  align-self: start;
  padding-top: 8px;
}

.aside-label {
  font-family: var(--font-head);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--c-accent);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-border);
}

.aside-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.aside-link {
  display: block;
  font-family: var(--font-head);
  font-size: 0.75rem;
  color: var(--c-muted);
  text-decoration: none;
  padding: 5px 0;
  transition: color var(--transition), padding-left var(--transition);
  min-height: 32px;
  line-height: 1.4;
}

.aside-link:hover {
  color: var(--c-light);
  padding-left: 6px;
}

/* Hero content */
.hero-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--c-accent);
}

.eyebrow-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--c-accent);
  border-radius: 50%;
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.hero-h1 {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  font-weight: 700;
  color: var(--c-light);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.hero-desc {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--c-muted);
  max-width: 480px;
  line-height: 1.8;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 28px;
  background: var(--c-accent);
  color: var(--c-light);
  font-family: var(--font-head);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), transform 0.2s;
  min-height: 44px;
}

.hero-cta:hover {
  background: transparent;
  border-color: var(--c-accent);
  transform: translateY(-2px);
}

/* Hero deco */
.hero-deco {
  position: relative;
  width: 140px;
  height: 200px;
  flex-shrink: 0;
}

.deco-frame {
  position: absolute;
  border: 1px solid var(--c-border);
  border-radius: 4px;
}

.deco-frame-1 {
  width: 80px;
  height: 110px;
  top: 0;
  left: 0;
  background: rgba(107,33,168,0.1);
  transform: rotate(-4deg);
}

.deco-frame-2 {
  width: 65px;
  height: 90px;
  top: 20px;
  left: 40px;
  background: rgba(107,33,168,0.06);
  transform: rotate(2deg);
}

.deco-frame-3 {
  width: 50px;
  height: 70px;
  top: 100px;
  left: 60px;
  background: rgba(107,33,168,0.14);
  transform: rotate(-1deg);
  border-color: rgba(107,33,168,0.5);
}

.deco-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}

.deco-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.deco-lines span {
  display: block;
  height: 1px;
  background: linear-gradient(90deg, var(--c-accent), transparent);
  opacity: 0.4;
}

.deco-lines span:nth-child(1) { width: 100%; }
.deco-lines span:nth-child(2) { width: 75%; }
.deco-lines span:nth-child(3) { width: 50%; }
.deco-lines span:nth-child(4) { width: 28%; }

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main-content {
  flex: 1;
  padding: 0;
}

.story-article {
  width: 100%;
}

.content-section {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 48px;
}

.section-chapter-mark {
  position: absolute;
  top: 40px;
  right: 48px;
  font-family: var(--font-head);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--c-accent);
  opacity: 0.5;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* ── Injected content styles ── */

.content-section h2,
.content-section h3 {
  font-family: var(--font-head);
  color: var(--c-light);
  margin-top: 2.4em;
  margin-bottom: 0.8em;
  line-height: 1.3;
}

.content-section h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  font-weight: 700;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-border);
}

.content-section h2 > span {
  color: var(--c-light);
}

.content-section h3 {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-weight: 600;
  color: var(--c-muted);
}

.content-section h3 > span {
  color: var(--c-muted);
}

.content-section p {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--c-text);
  margin-bottom: 1.2em;
}

.content-section ul,
.content-section ol {
  padding-left: 1.5em;
  margin-bottom: 1.2em;
  color: var(--c-text);
}

.content-section li {
  margin-bottom: 0.5em;
  line-height: 1.75;
}

.content-section a {
  color: #B57BFF;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition);
}

.content-section a:hover {
  color: var(--c-light);
}

.content-section blockquote {
  border-left: 3px solid var(--c-accent);
  margin: 1.5em 0;
  padding: 12px 20px;
  background: rgba(107,33,168,0.08);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--c-muted);
}

.content-section strong {
  color: var(--c-light);
  font-weight: 600;
}

/* ── Section[id] inside content ── */
.content-section article[id] {
  padding: 48px 0;
  border-bottom: 1px solid rgba(107,33,168,0.2);
  scroll-margin-top: 30px;
}

.content-section article[id]:last-child {
  border-bottom: none;
}

/* ── Reveal animation ── */
.reveal-section {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

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

/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 28px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(12, 6, 30, 0.8);
}

.site-footer p {
  font-family: var(--font-head);
  font-size: 0.78rem;
  color: var(--c-muted);
  line-height: 1.5;
}

.site-footer small {
  font-family: var(--font-head);
  font-size: 0.72rem;
  color: rgba(168,156,200,0.55);
  line-height: 1.4;
  max-width: 420px;
  text-align: right;
}

/* ══════════════════════════════════════
   PARALLAX / SCROLL EFFECTS
══════════════════════════════════════ */
.parallax-bg {
  will-change: transform;
}

/* Stagger for aside list items */
.aside-list li {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.aside-list.is-visible li {
  opacity: 1;
  transform: translateX(0);
}

.aside-list.is-visible li:nth-child(1) { transition-delay: 0.05s; }
.aside-list.is-visible li:nth-child(2) { transition-delay: 0.1s; }
.aside-list.is-visible li:nth-child(3) { transition-delay: 0.15s; }
.aside-list.is-visible li:nth-child(4) { transition-delay: 0.2s; }
.aside-list.is-visible li:nth-child(5) { transition-delay: 0.25s; }
.aside-list.is-visible li:nth-child(6) { transition-delay: 0.3s; }

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal-section,
  .aside-list li {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .eyebrow-dot { animation: none; }
  .hero-cta:hover { transform: none; }
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --nav-width: 190px; }
  .hero-inner {
    grid-template-columns: 160px 1fr;
    gap: 24px;
  }
  .hero-deco { display: none; }
}

@media (max-width: 768px) {
  :root { --nav-width: 0px; }

  .side-nav {
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    align-items: center;
    padding: 0 12px;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 200;
  }

  .nav-brand {
    padding: 0 12px 0 0;
    border-bottom: none;
    border-right: 1px solid var(--c-border);
    margin-bottom: 0;
    margin-right: 8px;
    flex-shrink: 0;
  }

  .nav-list {
    display: flex;
    flex-direction: row;
    flex: 1;
    gap: 0;
    overflow-x: auto;
  }

  .nav-link {
    white-space: nowrap;
    padding: 0 14px;
    min-height: 52px;
    font-size: 0.75rem;
  }

  .nav-link::before { display: none; }
  .nav-link.active::after {
    top: auto;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 2px;
  }

  .nav-search {
    padding: 8px 0 8px 12px;
    border-top: none;
    border-left: 1px solid var(--c-border);
    flex-shrink: 0;
    width: 140px;
  }

  .content-wrap {
    margin-left: 0;
    margin-top: 52px;
  }

  .hero-section {
    min-height: 85vh;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    padding: 40px 24px;
    gap: 28px;
  }

  .hero-aside {
    display: none;
  }

  .hero-bg-text {
    font-size: clamp(80px, 28vw, 140px);
    opacity: 0.5;
  }

  .hero-h1 {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
  }

  .content-section {
    padding: 40px 24px;
  }

  .section-chapter-mark {
    right: 20px;
  }

  .site-footer {
    padding: 20px 24px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .site-footer small {
    text-align: left;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  html { font-size: 16px; }

  .hero-cta {
    width: 100%;
    justify-content: center;
  }

  .content-section {
    padding: 32px 16px;
  }

  .nav-link .nav-text {
    display: none;
  }

  .nav-link {
    padding: 0 10px;
    min-width: 40px;
    justify-content: center;
  }
}

button[aria-expanded]{min-width:44px;min-height:44px}
