:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: rgba(18, 18, 18, 0.78);
  --ink: #f4f1eb;
  --muted: #aaa39a;
  --line: rgba(244, 241, 235, 0.16);
  --accent: #d7ea00;
  --gold: #c8a66a;
  --yellow-soft: #f2ff3b;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 16% 18%, rgba(215, 234, 0, 0.16), transparent 28rem),
    radial-gradient(circle at 84% 8%, rgba(242, 255, 59, 0.08), transparent 26rem),
    var(--bg);
  background-size: 72px 72px, 72px 72px, auto, auto, auto;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 44%, rgba(200, 166, 106, 0.08) 44.4% 44.9%, transparent 45.2%),
    linear-gradient(155deg, transparent 0 60%, rgba(215, 234, 0, 0.1) 60.2% 60.8%, transparent 61.1%);
  opacity: 0.85;
  animation: drift-lines 18s ease-in-out infinite alternate;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #101010, var(--accent), var(--yellow-soft));
  transition: width 160ms linear;
}

.topbar {
  position: fixed;
  top: 18px;
  left: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.brand-mark,
.controls {
  pointer-events: auto;
  border: 1px solid var(--line);
  background: rgba(8, 8, 8, 0.72);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.brand-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}

.brand-mark span {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark small {
  color: var(--muted);
  font-size: 0.78rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px;
  border-radius: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.page-readout {
  min-width: 66px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.rail {
  position: fixed;
  top: 86px;
  bottom: 28px;
  left: 20px;
  z-index: 70;
  width: 194px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 8, 8, 0.58);
  backdrop-filter: blur(18px);
  overflow: auto;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.76rem;
  line-height: 1.1;
  transition:
    transform 180ms ease,
    color 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.nav-link span:first-child {
  color: rgba(244, 241, 235, 0.42);
  font-variant-numeric: tabular-nums;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--ink);
  border-color: rgba(215, 234, 0, 0.38);
  background: rgba(215, 234, 0, 0.12);
  transform: translateX(2px);
}

.viewer {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100vw - 290px));
  margin-left: clamp(260px, 22vw, 330px);
  padding: 112px 36px 86px 0;
}

.page-stack {
  display: grid;
  gap: clamp(34px, 6vw, 82px);
}

.page-card {
  position: relative;
  opacity: 0;
  transform: translateY(56px) scale(0.965);
  transform-style: preserve-3d;
  transition:
    opacity 720ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 720ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 720ms ease;
  filter: saturate(0.84) brightness(0.78);
  scroll-margin-top: 98px;
}

.page-card.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: saturate(1) brightness(1);
}

.page-card.is-current .canvas-shell {
  border-color: rgba(215, 234, 0, 0.5);
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(215, 234, 0, 0.08),
    0 0 54px rgba(215, 234, 0, 0.14);
}

.page-number {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.page-number::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(244, 241, 235, 0.22), transparent);
}

.canvas-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 841.89 / 595.276;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: #141414;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform:
    perspective(1400px)
    rotateX(calc(var(--tilt-y, 0) * -1deg))
    rotateY(calc(var(--tilt-x, 0) * 1deg));
  transition:
    transform 240ms ease,
    box-shadow 240ms ease,
    border-color 240ms ease;
}

.canvas-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    120deg,
    transparent 0 38%,
    rgba(255, 255, 255, 0.16) 45%,
    transparent 52% 100%
  );
  transform: translateX(-120%);
  opacity: 0;
}

.page-card.is-visible .canvas-shell::before {
  animation: sheen 1100ms 240ms ease-out;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}

.page-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.loader {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 8, 8, 0.76);
  color: var(--muted);
  font-size: 0.82rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  transition:
    opacity 240ms ease,
    transform 240ms ease;
}

.loader.is-done {
  opacity: 0;
  transform: translateY(12px);
  visibility: hidden;
  pointer-events: none;
}

.loader-ring {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(244, 241, 235, 0.2);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes drift-lines {
  from {
    transform: translate3d(-1.5rem, -1rem, 0);
  }

  to {
    transform: translate3d(1.5rem, 1rem, 0);
  }
}

@keyframes sheen {
  0% {
    opacity: 0;
    transform: translateX(-120%);
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@media (max-width: 920px) {
  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .brand-mark small {
    display: none;
  }

  .rail {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 64px;
    padding: 8px 12px;
    border-right: 0;
    border-left: 0;
    border-bottom: 0;
    border-radius: 0;
  }

  .rail nav {
    display: flex;
    gap: 7px;
  }

  .nav-link {
    min-width: 58px;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 7px;
    font-size: 0.7rem;
  }

  .nav-link span:last-child {
    display: none;
  }

  .viewer {
    width: 100%;
    margin-left: 0;
    padding: 96px 14px 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .canvas-shell {
    transform: none !important;
  }
}
