/* Unified theme system for all pages */

:root {
  --bg-light: #faf8f3;
  --bg-dark-light: #f2eeea;
  --bg-dark: #1a1410;
  --bg-dark-light-dark: #2a211d;
  --ink-light: #1a1a1a;
  --ink-dark: #f5f0eb;
  --muted-light: #5a5a5a;
  --muted-dark: #b8a89f;
  --faint-light: #888;
  --faint-dark: #6f6560;
  --line-light: rgba(0,0,0,.08);
  --line-dark: rgba(255,255,255,.08);
  --accent: #7c3aed;
  --accent2: #6d28d9;
  --l0: #9ca3af;
  --l1: #a78bff;
  --l2: #d8b4fe;
  --l3: #7c3aed;
  --l4: #6d28d9;
  --l5: #5b21b6;
}

html {
  --bg: var(--bg-light);
  --bg2: var(--bg-dark-light);
  --ink: var(--ink-light);
  --muted: var(--muted-light);
  --faint: var(--faint-light);
  --line: var(--line-light);
}

html[data-theme="dark"] {
  --bg: var(--bg-dark);
  --bg2: var(--bg-dark-light-dark);
  --ink: var(--ink-dark);
  --muted: var(--muted-dark);
  --faint: var(--faint-dark);
  --line: var(--line-dark);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Alegreya', serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Caudex', serif;
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.04;
}

::selection {
  background: var(--accent);
  color: #fff;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity .25s;
}

a:hover {
  opacity: .8;
}

.mono {
  font-family: 'Alegreya', serif;
}

/* background */
.amb {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  transition: background .3s;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .06;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

/* Animated dots background */
.dots {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.dots-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.dot {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--accent), 0 0 30px rgba(124, 58, 237, 0.4);
  animation: float-dot 25s infinite ease-in-out;
  opacity: 0.4;
}

.dot:nth-child(1) { width: 6px; height: 6px; left: 8%; top: 12%; animation-delay: 0s; box-shadow: 0 0 20px var(--accent), 0 0 40px rgba(124, 58, 237, 0.5); }
.dot:nth-child(2) { width: 4px; height: 4px; left: 88%; top: 22%; animation-delay: 2.5s; }
.dot:nth-child(3) { width: 5px; height: 5px; left: 18%; top: 58%; animation-delay: 5s; box-shadow: 0 0 18px var(--accent), 0 0 36px rgba(124, 58, 237, 0.45); }
.dot:nth-child(4) { width: 4px; height: 4px; left: 92%; top: 72%; animation-delay: 7.5s; }
.dot:nth-child(5) { width: 5px; height: 5px; left: 12%; top: 88%; animation-delay: 10s; box-shadow: 0 0 18px var(--accent), 0 0 36px rgba(124, 58, 237, 0.45); }
.dot:nth-child(6) { width: 4px; height: 4px; left: 78%; top: 38%; animation-delay: 12.5s; }
.dot:nth-child(7) { width: 6px; height: 6px; left: 48%; top: 8%; animation-delay: 15s; box-shadow: 0 0 20px var(--accent), 0 0 40px rgba(124, 58, 237, 0.5); }
.dot:nth-child(8) { width: 4px; height: 4px; left: 32%; top: 78%; animation-delay: 17.5s; }
.dot:nth-child(9) { width: 5px; height: 5px; left: 72%; top: 52%; animation-delay: 20s; box-shadow: 0 0 18px var(--accent), 0 0 36px rgba(124, 58, 237, 0.45); }
.dot:nth-child(10) { width: 4px; height: 4px; left: 28%; top: 32%; animation-delay: 22.5s; }

@keyframes float-dot {
  0%, 100% {
    transform: translateY(0) translateX(0);
    opacity: 0.3;
  }
  25% {
    transform: translateY(-50px) translateX(40px);
    opacity: 0.6;
  }
  50% {
    transform: translateY(-100px) translateX(-50px);
    opacity: 0.4;
  }
  75% {
    transform: translateY(-50px) translateX(60px);
    opacity: 0.5;
  }
}

/* nav with theme toggle */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px clamp(20px, 5vw, 60px);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, 0.92);
  backdrop-filter: blur(6px);
  transition: background .3s;
}

html[data-theme="dark"] nav {
  background: rgba(26, 20, 16, 0.92);
}

nav .b {
  font-family: 'Caudex', serif;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  gap: 10px;
  align-items: center;
}

nav .b .d {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

nav .lk {
  display: flex;
  gap: 26px;
  font-family: 'Alegreya', serif;
  font-size: 12px;
  color: var(--muted);
}

nav .lk a {
  color: var(--muted);
  transition: color .25s;
}

nav .lk a:hover {
  color: var(--ink);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Alegreya', serif;
  font-size: 12px;
  cursor: pointer;
}

.theme-toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 50px;
  height: 28px;
  background: var(--line);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  border: 1px solid var(--line);
  transition: background .3s;
}

.theme-toggle input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  transition: left .3s;
}

.theme-toggle input:checked {
  background: var(--accent);
}

.theme-toggle input:checked::before {
  left: 27px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 60px);
}

.btn {
  padding: 15px 30px;
  border-radius: 0;
  font-family: 'Alegreya', serif;
  font-size: 13px;
  letter-spacing: .02em;
  border: 1px solid var(--line);
  transition: all .25s;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink);
}

.btn.p {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.p:hover {
  background: var(--accent2);
  border-color: var(--accent2);
}

.btn.g {
  background: transparent;
}

.btn.g:hover {
  border-color: var(--ink);
  background: rgba(0, 0, 0, .05);
}

html[data-theme="dark"] .btn.g:hover {
  background: rgba(255, 255, 255, .05);
}

footer {
  border-top: 1px solid var(--line);
  padding: 56px 0;
  margin-top: 40px;
}

footer .fx {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 30px;
  font-family: 'Alegreya', serif;
  font-size: 12.5px;
  color: var(--muted);
}

footer .fx a {
  display: block;
  margin-bottom: 8px;
  opacity: .8;
  color: var(--muted);
}

footer .fx a:hover {
  opacity: 1;
  color: var(--ink);
}

footer b {
  color: var(--ink);
  display: block;
  margin-bottom: 12px;
  font-family: 'Caudex', serif;
  font-weight: 700;
}

footer .dc {
  margin-top: 38px;
  font-size: 11px;
  color: var(--faint);
  max-width: 70ch;
  line-height: 1.6;
}

/* ===== responsive ===== */
@media(max-width:768px){
  nav{padding:16px 24px}
  .wrap{padding:0 24px}
  .btn{padding:12px 22px;font-size:12px}
  footer{padding:36px 24px}
  footer .fx{flex-direction:column;gap:24px;font-size:12px}
  footer .dc{font-size:10px}
}

@media(max-width:480px){
  nav{padding:12px 20px;font-size:12px}
  nav .b{font-size:14px}
  .theme-toggle{font-size:10px;gap:6px}
  .theme-toggle input{width:40px;height:22px}
  .theme-toggle input::before{width:16px;height:16px;top:2px;left:2px}
  .theme-toggle input:checked::before{left:22px}
  .btn{padding:10px 18px;font-size:11px}
  .wrap{padding:0 20px}
  footer{padding:28px 20px}
  footer .fx{font-size:11px}
  footer .dc{font-size:9px}
}
