/* ---------- Light theme tokens ---------- */
:root[data-theme="light"] {
  --bg: #eef0f8;
  --fg: #14112b;
  --dim: #575184;
  --ascii: #e5380a;
  color-scheme: light;
}
:root[data-theme="light"] .panel {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(40, 30, 100, 0.35);
}
:root[data-theme="light"] main section {
  background: rgba(255, 255, 255, 0.28);
  border-top-color: rgba(40, 30, 100, 0.2);
}
:root[data-theme="light"] .ph,
:root[data-theme="light"] button {
  border-color: rgba(40, 30, 100, 0.4);
}
:root[data-theme="light"] .post {
  border-top-color: rgba(40, 30, 100, 0.2);
}
:root[data-theme="light"] .site-foot {
  border-color: rgba(255, 255, 255, 0.7);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0.2)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 20px 60px rgba(60, 40, 140, 0.18);
}
:root[data-theme="light"] .foot-mark {
  color: rgba(20, 17, 43, 0.82);
}
:root[data-theme="light"] .foot-line {
  background: linear-gradient(
    90deg,
    rgba(20, 17, 43, 0.5),
    rgba(20, 17, 43, 0.05)
  );
  box-shadow: none;
}
:root[data-theme="light"] .foot-copy {
  color: rgba(87, 81, 132, 0.9);
}
/* The About page keeps its own dark look in both themes */
#about-page {
  color: #f2f0ff;
  --fg: #f2f0ff;
  --dim: #a99fd0;
}
body.about-open .theme-btn {
  display: none;
}

/* ---------- Toggle button ---------- */
.theme-btn {
  position: relative;
  align-self: center;
  width: 38px;
  height: 38px;
  padding: 0;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  transition:
    transform 0.3s,
    background 0.3s;
}
:root[data-theme="light"] .theme-btn {
  border-color: rgba(40, 30, 100, 0.3);
  background: rgba(255, 255, 255, 0.5);
}
.theme-btn:hover,
.theme-btn:focus-visible {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.18);
}
.theme-btn svg {
  position: absolute;
  width: 18px;
  height: 18px;
  transition:
    transform 0.6s cubic-bezier(0.65, 0, 0.35, 1),
    opacity 0.4s;
}
.theme-btn .sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
}
:root[data-theme="light"] .theme-btn .sun {
  opacity: 1;
  transform: none;
}
:root[data-theme="light"] .theme-btn .moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.4);
}

/* ---------- Circular reveal from the button (View Transitions) ---------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  z-index: 1;
}
::view-transition-new(root) {
  z-index: 2;
  clip-path: circle(var(--r, 0px) at var(--tx, 50%) var(--ty, 50%));
}

/* ---------- Chromatic aberration + wave on EVERYTHING during the switch ---------- */
/* The #ca-wave SVG filter (in index.html) is animated by theme.js */
::view-transition-image-pair(root) {
  filter: url(#ca-wave);
}

/* ---------- Floating nav: three separate glass boxes ---------- */
body header,
body.scrolled header {
  top: 0;
  padding: calc(14px + env(safe-area-inset-top, 0px)) clamp(12px, 2vw, 24px) 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
header .brand,
header nav.links,
header .tools {
  pointer-events: auto;
  display: flex;
  align-items: center;
  height: 48px;
  background: rgba(26, 26, 26, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
header .brand {
  flex: 0 0 auto;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
header nav.links {
  flex: 1;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(18px, 3vw, 40px);
  padding: 0 24px;
}
header nav.links a {
  font-size: 15px;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.2s;
}
header nav.links a:hover,
header nav.links a:focus-visible {
  text-decoration: none;
  opacity: 0.65;
}
header .tools {
  flex: 0 0 auto;
  width: 48px;
  justify-content: center;
}
header .tools .theme-btn {
  margin: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
header .tools .theme-btn:hover,
header .tools .theme-btn:focus-visible {
  transform: none;
  background: rgba(255, 255, 255, 0.1);
}
:root[data-theme="light"] header .brand,
:root[data-theme="light"] header nav.links,
:root[data-theme="light"] header .tools {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(20, 17, 43, 0.12);
  box-shadow: 0 10px 30px rgba(60, 40, 140, 0.12);
}
:root[data-theme="light"] header .tools .theme-btn:hover,
:root[data-theme="light"] header .tools .theme-btn:focus-visible {
  background: rgba(20, 17, 43, 0.08);
}
@media (max-width: 720px) {
  body header,
  body.scrolled header {
    flex-wrap: wrap;
  }
  header .brand {
    flex: 1;
  }
  header .tools {
    order: 2;
  }
  header nav.links {
    order: 3;
    flex: 1 1 100%;
    height: 44px;
    justify-content: flex-start;
    gap: 22px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  header nav.links::-webkit-scrollbar {
    display: none;
  }
}

/* ---------- Glowing edges on hover (follows the cursor) ---------- */
header .brand,
header nav.links,
header .tools {
  position: relative;
  transition:
    box-shadow 0.35s,
    border-color 0.35s;
}
header .brand::before,
header nav.links::before,
header .tools::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1.5px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
  background: radial-gradient(
    190px circle at var(--mx, 50%) var(--my, 50%),
    rgba(176, 120, 255, 1),
    rgba(90, 140, 255, 0.55) 40%,
    transparent 72%
  );
  /* keep only the 1.5px edge of the gradient */
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
}
header .brand:hover::before,
header nav.links:hover::before,
header .tools:hover::before,
header .brand:focus-within::before,
header nav.links:focus-within::before,
header .tools:focus-within::before {
  opacity: 1;
}
header .brand:hover,
header nav.links:hover,
header .tools:hover {
  border-color: rgba(176, 120, 255, 0.35);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.25),
    0 0 26px rgba(150, 90, 255, 0.3),
    inset 0 0 20px rgba(150, 90, 255, 0.08);
}
:root[data-theme="light"] header .brand:hover,
:root[data-theme="light"] header nav.links:hover,
:root[data-theme="light"] header .tools:hover {
  box-shadow:
    0 10px 30px rgba(60, 40, 140, 0.12),
    0 0 22px rgba(130, 80, 255, 0.28);
}
/* ---------- Slot-machine roll on nav links ---------- */
header nav.links a {
  display: inline-flex;
  align-items: center;
}
header nav.links a:hover,
header nav.links a:focus-visible {
  opacity: 1;
}
.roll {
  position: relative;
  display: block;
  overflow: hidden;
  height: 1.4em;
  line-height: 1.4em;
}
.roll > span {
  display: block;
  white-space: nowrap;
  transition: transform 0.65s cubic-bezier(0.34, 1.25, 0.64, 1);
  will-change: transform;
}
.roll > span:last-child {
  position: absolute;
  left: 0;
  top: 100%;
}
@media (hover: hover) {
  header nav.links a:hover .roll > span,
  header nav.links a:focus-visible .roll > span {
    transform: translateY(-100%);
  }
}
header .brand,
header nav.links a {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
header .brand {
  font-size: 13px;
  font-weight: 500;
}
header nav.links a {
  font-size: 12px;
  font-weight: 500;
  color: var(--dim);
}
header nav.links a:hover,
header nav.links a:focus-visible {
  color: var(--fg);
}
@media (max-width: 720px) {
  header nav.links a {
    font-size: 11px;
    letter-spacing: 0.14em;
  }
  header .brand {
    font-size: 12px;
    letter-spacing: 0.14em;
  }
}

/* ---------- Footer: same glass + glowing edge as the nav boxes ---------- */
.site-foot {
  background: rgba(26, 26, 26, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition:
    box-shadow 0.35s,
    border-color 0.35s;
}
.site-foot::before {
  display: none; /* drop the old white highlight */
}
.site-foot::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1.5px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
  background: radial-gradient(
    190px circle at var(--mx, 50%) var(--my, 50%),
    rgba(176, 120, 255, 1),
    rgba(90, 140, 255, 0.55) 40%,
    transparent 72%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
}
.site-foot:hover::after,
.site-foot:focus-within::after {
  opacity: 1;
}
.site-foot:hover {
  border-color: rgba(176, 120, 255, 0.35);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.25),
    0 0 26px rgba(150, 90, 255, 0.3),
    inset 0 0 20px rgba(150, 90, 255, 0.08);
}
:root[data-theme="light"] .site-foot {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(20, 17, 43, 0.12);
  box-shadow: 0 10px 30px rgba(60, 40, 140, 0.12);
}
:root[data-theme="light"] .site-foot:hover {
  box-shadow:
    0 10px 30px rgba(60, 40, 140, 0.12),
    0 0 22px rgba(130, 80, 255, 0.28);
}
