/* ── Reset ── */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  cursor: none !important;
}

/* ── CSS Variables ── */
:root {
  --bg: #1A1714;
  --cursor-color: #C4B99A;
  --highlight: #E04A12;
  --cursor-rgb: 196, 185, 154;
  --highlight-rgb: 224, 74, 18;
  --bg-rgb: 26, 23, 20;
  --font-mono: 'Space Mono', monospace;
  --font-code: 'IBM Plex Mono', monospace;
  --font-display: 'Bebas Neue', sans-serif;
}

/* ── Scroll setup ── */
html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  overflow-x: hidden;
}

body { background: var(--bg); }

/* ── Sections ── */
section {
  width: 100vw;
  height: 100vh;
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: background 0.4s;
}

canvas { position: absolute; inset: 0; }

/* ── S2 Spotlight ── */
#s2-bg {
  position: absolute; inset: 0;
  display: flex; flex-wrap: wrap;
  gap: 2px; padding: 3rem;
  align-content: flex-start;
  overflow: hidden;
}
#s2-bg span {
  font-family: var(--font-code); font-size: 0.65rem;
  color: rgba(var(--cursor-rgb), 0.7);
  white-space: nowrap; padding: 2px 6px;
  transition: color 0.4s;
}
#s2-ov { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
#s2-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(var(--cursor-rgb), 0.9);
  position: fixed; pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%);
}

/* ── S5 Magnetic Repel ── */
#mag {
  display: flex; flex-wrap: nowrap;
  font-family: var(--font-display);
  font-size: clamp(5rem, 13vw, 12rem);
  color: var(--cursor-color);
  z-index: 5; position: relative;
  transition: color 0.4s;
}
#mag span {
  display: inline-block;
  transition: transform 0.18s cubic-bezier(0.25,0.46,0.45,0.94);
  will-change: transform;
  text-shadow: 0 0 30px rgba(var(--highlight-rgb), 0.25);
}

/* ── Ghost Echo rings ── */
.ghost-ring {
  position: fixed; border-radius: 50%;
  border: 1px solid var(--cursor-color);
  pointer-events: none; z-index: 50;
  transform: translate(-50%, -50%); display: none;
}

/* ── Header ── */
#header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 600;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: start;
  padding: 1.5rem 2rem 2rem;
  pointer-events: none;
  background: linear-gradient(to bottom,
    rgba(var(--bg-rgb), 0.82) 0%,
    rgba(var(--bg-rgb), 0.45) 70%,
    transparent 100%);
  transition: background 0.4s;
}

/* ── Header left (logo only) ── */
#header-left {
  pointer-events: all;
}

#logo {
  height: 18px; width: auto;
  transition: opacity 0.3s;
}
#logo:hover { opacity: 0.65; }

/* ── Header center ── */
#header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: all;
}

/* ── Custom dropdown ── */
#nav-dropdown {
  position: relative;
  display: flex;
  justify-content: center;
}

#nav-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  color: var(--cursor-color);
  font-family: var(--font-code);
  font-size: clamp(0.7rem, 1.4vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: none !important;
  padding: 0;
  line-height: 1.2;
  transition: color 0.4s;
}

#nav-trigger:hover { opacity: 0.8; }

#nav-chevron {
  width: 14px; height: 14px;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0.55;
}

#nav-trigger[aria-expanded="true"] #nav-chevron {
  transform: rotate(180deg);
}

#nav-list {
  position: absolute;
  top: calc(100% + 0.65rem);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  min-width: 240px;
  max-height: 65vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--cursor-rgb), 0.18) transparent;
  background: rgba(var(--bg-rgb), 0.96);
  border: 1px solid rgba(var(--cursor-rgb), 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  list-style: none;
  z-index: 800;
  padding: 0.35rem 0;
}

#nav-list.open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}

#nav-list li {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.45rem 1.25rem;
  font-family: var(--font-code);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(var(--cursor-rgb), 0.45);
  cursor: none !important;
  opacity: 0;
  transform: translateY(-4px);
  transition: color 0.15s ease, background 0.15s ease,
              opacity 0.18s ease, transform 0.18s ease;
}

#nav-list.open li {
  opacity: 1;
  transform: translateY(0);
}

#nav-list li:hover {
  color: var(--cursor-color);
  background: rgba(var(--cursor-rgb), 0.06);
}

#nav-list li.active {
  color: var(--cursor-color);
}

.nav-num {
  font-size: 0.48rem;
  color: rgba(var(--highlight-rgb), 0.5);
  letter-spacing: 0.06em;
  min-width: 1.5rem;
  font-style: italic;
  transition: color 0.15s;
}

#nav-list li.active .nav-num { color: rgba(var(--highlight-rgb), 0.9); }

/* ── Nav subtext ── */
#nav-sub {
  font-family: var(--font-code);
  font-size: 0.58rem;
  color: rgba(var(--highlight-rgb), 0.5);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.4rem;
  text-align: center;
  transition: opacity 0.2s ease;
}

/* ── Settings panel (bottom-left) ── */
#settings-panel {
  position: fixed;
  bottom: 1.75rem;
  left: 1.75rem;
  z-index: 600;
  pointer-events: all;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.setting-label {
  font-family: var(--font-code);
  font-size: 0.5rem;
  color: rgba(var(--cursor-rgb), 0.38);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.4s;
}

input[type="color"] {
  width: 20px; height: 20px;
  border: 1px solid rgba(var(--cursor-rgb), 0.18);
  border-radius: 3px;
  background: transparent;
  padding: 1px;
  cursor: none !important;
  transition: border-color 0.3s;
}
input[type="color"]:hover { border-color: rgba(var(--cursor-rgb), 0.55); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

/* ── Swap button ── */
#light-switch {
  width: 28px; height: 28px;
  border: 1px solid rgba(var(--cursor-rgb), 0.22);
  border-radius: 50%;
  background: rgba(var(--bg-rgb), 0.5);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.3s, background 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin-left: 0.25rem;
}
#light-switch:hover { border-color: rgba(var(--cursor-rgb), 0.55); }
#light-switch svg {
  width: 12px; height: 12px;
  color: var(--cursor-color);
  transition: color 0.4s;
}

/* ── PIP Counter (left side) ── */
#pip {
  position: fixed; left: 1.75rem; top: 50%;
  transform: translateY(-50%);
  z-index: 600;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.4rem;
}
#pip-dots { display: flex; flex-direction: column; gap: 0.28rem; }
.pip-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(var(--cursor-rgb), 0.25);
  transition: all 0.3s;
  cursor: none !important;
}
.pip-dot.active {
  background: var(--cursor-color);
  border-color: var(--cursor-color);
  box-shadow: 0 0 6px rgba(var(--cursor-rgb), 0.45);
}
#pip-count {
  font-family: var(--font-code); font-size: 0.46rem;
  color: rgba(var(--cursor-rgb), 0.25);
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  margin-top: 0.2rem;
  transition: color 0.4s;
}

/* ── Code panel (bottom-right) ── */
#code-panel {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 600;
  width: 380px;
  background: rgba(var(--bg-rgb), 0.82);
  border: 1px solid rgba(var(--cursor-rgb), 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background 0.4s, border-color 0.4s;
}

#code-pre {
  font-family: var(--font-code);
  font-size: 0.56rem;
  line-height: 1.65;
  color: rgba(var(--cursor-rgb), 0.65);
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 170px;
  padding: 2.2rem 0.85rem 0.85rem;
  tab-size: 2;
  transition: color 0.4s;
}

#copy-btn {
  position: absolute;
  top: 0.45rem; right: 0.55rem;
  z-index: 1;
  font-family: var(--font-code);
  font-size: 0.48rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(var(--highlight-rgb), 0.6);
  background: transparent;
  border: 1px solid rgba(var(--highlight-rgb), 0.18);
  padding: 0.18rem 0.5rem;
  cursor: none !important;
  transition: color 0.2s, border-color 0.2s;
}
#copy-btn:hover { color: var(--highlight); border-color: rgba(var(--highlight-rgb), 0.5); }
#copy-btn.copied { color: rgba(var(--cursor-rgb), 0.8); border-color: rgba(var(--cursor-rgb), 0.3); }

/* ── How to use button ── */
#how-btn {
  display: block;
  width: 100%;
  font-family: var(--font-code);
  font-size: 0.48rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(var(--cursor-rgb), 0.35);
  background: transparent;
  border: none;
  border-top: 1px solid rgba(var(--cursor-rgb), 0.08);
  padding: 0.55rem 0.85rem;
  text-align: left;
  cursor: none !important;
  transition: color 0.2s, background 0.2s;
}
#how-btn:hover {
  color: rgba(var(--cursor-rgb), 0.75);
  background: rgba(var(--cursor-rgb), 0.04);
}

/* ── Modal ── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(var(--bg-rgb), 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#modal-box {
  position: relative;
  width: min(480px, 90vw);
  background: rgba(var(--bg-rgb), 0.98);
  border: 1px solid rgba(var(--cursor-rgb), 0.15);
  padding: 2.5rem 2rem 2rem;
  transform: translateY(12px);
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}
#modal-overlay.open #modal-box {
  transform: translateY(0);
}

#modal-close {
  position: absolute;
  top: 0.75rem; right: 0.85rem;
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: rgba(var(--cursor-rgb), 0.4);
  background: transparent;
  border: none;
  cursor: none !important;
  line-height: 1;
  transition: color 0.2s;
}
#modal-close:hover { color: var(--cursor-color); }

#modal-title {
  font-family: var(--font-code);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(var(--highlight-rgb), 0.7);
  margin-bottom: 1.25rem;
}

#modal-steps {
  list-style: none;
  counter-reset: steps;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
#modal-steps li {
  counter-increment: steps;
  display: flex;
  gap: 0.85rem;
  font-family: var(--font-code);
  font-size: 0.58rem;
  line-height: 1.6;
  color: rgba(var(--cursor-rgb), 0.6);
  transition: color 0.4s;
}
#modal-steps li::before {
  content: counter(steps, decimal-leading-zero);
  font-size: 0.46rem;
  color: rgba(var(--highlight-rgb), 0.45);
  font-style: italic;
  white-space: nowrap;
  margin-top: 0.1em;
  min-width: 1.5rem;
}
#modal-steps code {
  font-family: var(--font-code);
  color: rgba(var(--highlight-rgb), 0.75);
  background: rgba(var(--highlight-rgb), 0.06);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}
#modal-steps strong {
  color: var(--cursor-color);
}
