/* Frieren Desk pages: night grimoire with a retro HUD.
   Palette: deep indigo night, arcane gold, mana violet, potion green.
   Headers use a pixel font, body stays readable. No em dashes used. */

:root {
  --maxw: 1440px;
  --night: #0d0b1e;
  --night-2: #141232;
  --panel: #1a1840;
  --panel-2: #211e4e;
  --ink: #ece9ff;
  --muted: #b9b4dd;
  --faint: #847fb3;
  --gold: #f2c14e;
  --gold-soft: #3a2f10;
  --violet: #9d7bff;
  --green: #6fe3a5;
  --red: #ff8f8f;
  --blue: #7cc4ff;
  --rule: #35316b;
  --radius: 12px;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-term: "VT323", "Courier New", monospace;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -10%, #2b2670 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 20%, #3b1f5e 0%, transparent 55%),
    var(--night);
  font: 16px/1.7 var(--font-body);
  min-height: 100vh;
}

a { color: var(--gold); }
a:hover { color: #ffd97a; }

/* Scroll-driven backdrop: video overlays crossfade as you travel down */

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--night);
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  mix-blend-mode: screen;
}

.bg-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(13, 11, 30, 0.8) 0%, rgba(13, 11, 30, 0.78) 40%, rgba(13, 11, 30, 0.9) 100%),
    radial-gradient(1200px 500px at 50% 0%, rgba(43, 38, 112, 0.3), transparent 60%);
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
  mix-blend-mode: multiply;
}

.topbar, main, .footer { position: relative; z-index: 3; }

/* Top bar */

.topbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 24px;
  background: rgba(13, 11, 30, 0.78);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  border-radius: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand img {
  height: 44px;
  width: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
  animation: hop 2.4s ease-in-out infinite;
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  28% { transform: translateY(-8px); }
  52% { transform: translateY(0); }
  64% { transform: translateY(-4px); }
  76% { transform: translateY(0); }
}

.topnav { display: flex; gap: 4px; flex-wrap: wrap; }

.topnav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.topnav a:hover {
  color: var(--ink);
  border-color: var(--rule);
  background: rgba(157, 123, 255, 0.12);
}

.music-btn {
  font: inherit;
  font-size: 19px;
  line-height: 1.4;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 2px 12px 5px;
  cursor: pointer;
}

.music-btn:hover {
  color: var(--ink);
  border-color: var(--gold);
}

.music-btn[aria-pressed="true"] {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(242, 193, 78, 0.1);
  box-shadow: 0 0 14px rgba(242, 193, 78, 0.25);
}

/* Hero */

/* Hero: full-bleed cover art with the text floating over it */

.hero {
  position: relative;
  max-width: none;
  margin: 0;
  padding: 140px 40px 110px;
  overflow: hidden;
  text-align: center;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 35%;
  opacity: 0.55;
}

.hero-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(13, 11, 30, 0.52) 0%,
    rgba(13, 11, 30, 0.78) 55%,
    var(--night) 100%);
}

.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
  mix-blend-mode: screen;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
}

.hero-inner h1 {
  font-family: var(--font-pixel);
  font-size: clamp(22px, 4.5vw, 40px);
  line-height: 1.5;
  margin: 16px 0;
  text-shadow: 0 0 24px rgba(157, 123, 255, 0.55), 0 2px 18px rgba(0, 0, 0, 0.8);
}

.hero-inner h1 .gold { color: var(--gold); }

.hero-inner .hero-lede {
  max-width: 640px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 17px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.9);
}

.hud {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-family: var(--font-term);
  font-size: 21px;
}

.hud span {
  border: 1px solid var(--rule);
  background: rgba(26, 24, 64, 0.85);
  border-radius: 8px;
  padding: 2px 12px;
  color: var(--muted);
}

.hud b { color: var(--green); font-weight: normal; }

.cta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 26px 0 8px;
}

.btn {
  font-family: var(--font-pixel);
  font-size: 12px;
  text-decoration: none;
  padding: 14px 20px;
  border-radius: 10px;
  border: 2px solid var(--gold);
  background: var(--gold);
  color: #241a05;
  box-shadow: 0 4px 0 #8a6414, 0 0 24px rgba(242, 193, 78, 0.35);
}

.btn:hover { color: #241a05; filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  color: var(--gold);
  box-shadow: none;
  border: 2px solid var(--rule);
}

.btn-ghost:hover { border-color: var(--gold); color: var(--gold); background: rgba(242, 193, 78, 0.08); }

/* Install rune */

.install-rune {
  max-width: 760px;
  margin: 30px auto 0;
  text-align: left;
  background: #08071a;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.install-rune figcaption {
  font-family: var(--font-term);
  font-size: 20px;
  color: var(--faint);
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
}

.install-rune pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font: 15px/1.6 var(--font-mono);
  color: var(--green);
}

.copy-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}

.copy-btn:hover { color: var(--ink); border-color: var(--gold); }

/* Content pages */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 40px 40px;
}

.page section { margin-top: 56px; position: relative; }

.page section::after {
  content: "";
  display: block;
  clear: both;
}

/* Floating pose decorations scattered along the page */

img.deco {
  float: right;
  width: 132px;
  height: auto;
  margin: 0 0 12px 24px;
  pointer-events: none;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.55));
  animation: bob 5s ease-in-out infinite;
}

img.deco-left {
  float: left;
  margin: 0 24px 12px 0;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-12px) rotate(1.5deg); }
}

.page h2 {
  font-family: var(--font-pixel);
  font-size: 17px;
  line-height: 1.8;
  color: var(--gold);
  margin: 0 0 6px;
}

.page h2::before {
  content: "◆ ";
  color: var(--violet);
}

.page h3 {
  font-size: 18px;
  color: var(--ink);
  margin: 26px 0 8px;
}

.page p, .page li { color: var(--muted); }
.page p strong, .page li strong { color: var(--ink); }

.divider {
  border: 0;
  margin: 44px auto 0;
  max-width: var(--maxw);
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold) 20%, var(--violet) 50%, var(--gold) 80%, transparent);
  opacity: 0.6;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.card h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.card p { margin: 0; font-size: 14.5px; }
.card code { color: var(--gold); }

.page code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #08071a;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--blue);
}

.page pre {
  background: #08071a;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font: 14px/1.65 var(--font-mono);
  color: #cfe3ff;
}

.page pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

.page table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 14.5px;
}

.page th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--faint);
  border-bottom: 2px solid var(--rule);
  padding: 8px 10px;
}

.page td {
  border-bottom: 1px solid var(--rule);
  padding: 9px 10px;
  color: var(--muted);
  vertical-align: top;
}

.page td:first-child { color: var(--ink); white-space: nowrap; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.gallery figure {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.gallery img { width: 100%; height: auto; display: block; }

.gallery figcaption {
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--muted);
}

.note {
  border-left: 3px solid var(--gold);
  background: rgba(242, 193, 78, 0.07);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14.5px;
}

.note.safe { border-color: var(--green); background: rgba(111, 227, 165, 0.07); }
.note code { color: var(--gold); }

/* Footer */

.footer {
  border-top: 1px solid var(--rule);
  margin-top: 20px;
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 40px 40px;
  font-size: 14px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-inner strong { color: var(--muted); }
.footer-inner p { margin: 0; }

/* Draggable page mascot (moved with transform for smooth dragging) */

#mascot {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 5;
  width: 96px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  will-change: transform;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.55));
}

#mascot.dragging {
  cursor: grabbing;
}

#mascot img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  animation: bob 4s ease-in-out infinite;
}

#mascot.dragging img {
  animation-play-state: paused;
}

/* Mascot chat panel */

#mascot-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 7;
  width: min(300px, calc(100vw - 40px));
  background: var(--panel-2);
  border: 1px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  padding: 12px 14px 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

#mascot-chat.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#mascot-chat .chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

#mascot-chat .chat-head strong {
  font-family: var(--font-term);
  font-size: 22px;
  font-weight: normal;
  color: var(--gold);
  letter-spacing: 1px;
}

#mascot-chat .chat-close {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

#mascot-chat .chat-close:hover {
  color: var(--ink);
  border-color: var(--gold);
}

#mascot-chat .q {
  display: block;
  width: 100%;
  text-align: left;
  margin: 4px 0;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13.5px;
  cursor: pointer;
}

#mascot-chat .q:hover {
  color: var(--ink);
  border-color: var(--gold);
}

#mascot-chat .q.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(242, 193, 78, 0.08);
}

#mascot-chat .a {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
  min-height: 48px;
}

#mascot-chat .a code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #08071a;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--blue);
}

/* Back to top */

#to-top {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 6;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: rgba(26, 24, 64, 0.9);
  color: var(--gold);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, border-color 0.15s;
}

#to-top.show {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#to-top:hover {
  border-color: var(--gold);
}

@media (max-width: 900px) {
  img.deco { display: none; }
  #mascot { width: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  img.deco, #mascot img, .brand img { animation: none; }
  .hero-video { display: none; }
  #to-top { transition: none; }
  #mascot-chat { transition: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; top: 8px; }
  .hero { padding: 90px 16px 70px; }
  .page { padding-left: 16px; padding-right: 16px; }
  .footer-inner { padding-left: 16px; padding-right: 16px; }
}
