:root {
  color-scheme: dark;
  --paper: #02040b;
  --ink: #f4f6ff;
  --muted: rgba(224, 230, 248, .62);
  --faint: rgba(205, 218, 255, .38);
  --line: rgba(196, 213, 255, .17);
  --line-strong: rgba(207, 222, 255, .34);
  --accent: #9fc2ff;
  --accent-bright: #dce9ff;
  --accent-soft: rgba(99, 142, 255, .14);
  --shadow: rgba(0, 0, 0, .5);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* The persistent router owns page fades; do not start a second, native
   cross-document transition for fallback navigation or history restores. */
@view-transition { navigation: none; }

/* Preserve focus for assistive technology, not a page-sized focus ring. */
main[data-navigation-focus]:focus { outline: none; }
.cosmic-internal .site-header { animation: none; }
.cosmic-internal body > main {
  transition: opacity .16s ease;
}

.starfield-canvas { view-transition-name: cosmic-sky; }

::view-transition-group(cosmic-sky) {
  animation-duration: .32s;
  animation-timing-function: ease-out;
}

::view-transition-old(cosmic-sky),
::view-transition-new(cosmic-sky) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  animation: cosmic-page-out .13s ease-in both;
}

::view-transition-new(root) {
  animation: cosmic-page-in .28s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes cosmic-page-out {
  to { opacity: 0; }
}

@keyframes cosmic-page-in {
  from { opacity: 0; }
}

@supports (-webkit-touch-callout: none) {
  @view-transition { navigation: none; }
  .starfield-canvas { view-transition-name: none; }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

html.cosmic-page-leaving body > :not(.starfield-canvas):not(script):not(style) {
  opacity: 0 !important;
  transition: opacity .13s ease !important;
}

body.panning-stars,
body.panning-stars * {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

.starfield-canvas {
  position: fixed;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  filter: brightness(.96) saturate(1.04) contrast(1.08);
  transition: opacity 1s ease;
}

.starfield-ready .starfield-canvas { opacity: 1; }
.starfield-continuing .starfield-canvas { opacity: 1; transition: none; }

@media (prefers-reduced-motion: reduce) {
  html.cosmic-page-leaving body > :not(.starfield-canvas):not(script):not(style) { transition: none !important; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: rgba(1, 3, 10, .08);
}

a { color: inherit; }

.site-header {
  position: fixed;
  z-index: 40;
  top: 18px;
  left: 20px;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  padding: 0;
  animation: shell-arrive .65s .06s cubic-bezier(.22, 1, .36, 1) both;
}

.site-header > a:first-child {
  position: relative;
  display: block;
  width: 62px;
  height: 62px;
  overflow: visible;
  border-radius: 50%;
  background:
    url("./navigation-star.webp") center / 72px 72px no-repeat,
    radial-gradient(circle, rgba(130, 180, 255, .18), rgba(130, 180, 255, .045) 38%, transparent 70%);
  color: transparent;
  font-size: 0;
  text-indent: 100%;
  text-decoration: none;
  white-space: nowrap;
  animation: site-star-shimmer 6.8s ease-in-out infinite;
  transition: filter .45s ease, transform .7s cubic-bezier(.16, 1, .3, 1);
  will-change: filter, transform;
}

.site-header > a:first-child::after {
  content: "Home";
  position: absolute;
  top: 50px;
  left: 50%;
  color: rgba(245, 249, 255, .9);
  font: 500 15px/1 var(--serif);
  letter-spacing: .01em;
  text-indent: 0;
  text-shadow: 0 1px 5px #000, 0 2px 14px #000;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity .28s ease, transform .42s cubic-bezier(.16, 1, .3, 1);
  white-space: nowrap;
}

.site-header > a:first-child:hover,
.site-header > a:first-child:focus-visible {
  animation-play-state: paused;
  filter: brightness(1.32) drop-shadow(0 0 10px rgba(190, 224, 255, .68)) drop-shadow(0 0 24px rgba(116, 163, 255, .34));
  outline: none;
  transform: scale(1.08);
}

.site-header > a:not(:first-child) { display: none; }

.site-header.has-site-constellation { overflow: visible; }

.site-constellation {
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  width: 278px;
  height: 96px;
  pointer-events: none;
}

.site-constellation::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -14px -8px -10px -18px;
  background: radial-gradient(ellipse at 44% 48%, rgba(1, 3, 10, .82) 0 24%, rgba(1, 3, 10, .56) 48%, rgba(1, 3, 10, 0) 78%);
  filter: blur(8px);
  opacity: 0;
  transition: opacity .42s ease;
}

.site-constellation-thread {
  position: fixed;
  width: 0;
  height: .7px;
  background: linear-gradient(90deg, rgba(180, 218, 255, .04), rgba(211, 234, 255, .32), rgba(180, 218, 255, .04));
  opacity: 0;
  transform: rotate(var(--site-thread-angle, 0deg)) scaleX(0);
  transform-origin: left center;
  transition: opacity .35s ease var(--site-thread-delay), transform .68s cubic-bezier(.16, 1, .3, 1) var(--site-thread-delay);
}

.site-constellation-destination {
  --site-node-x: 100px;
  --site-node-y: 40px;
  position: absolute;
  z-index: 1;
  top: var(--site-node-y);
  left: var(--site-node-x);
  min-width: 72px;
  padding: 26px 8px 8px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 65%, rgba(1, 3, 10, .74) 0 28%, rgba(1, 3, 10, .34) 54%, transparent 76%);
  color: rgba(245, 249, 255, .92);
  font: 500 17px/1.05 var(--serif);
  letter-spacing: .015em;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 1px 5px #000, 0 2px 16px #000, 0 0 24px rgba(0, 0, 0, .92);
  opacity: 0;
  filter: blur(1px);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.9);
  transition: color .25s ease, opacity .3s ease, filter .34s ease, transform .48s cubic-bezier(.16, 1, .3, 1);
}

.site-constellation-destination::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  width: 25px;
  height: 25px;
  background: url("./navigation-star.webp") center / contain no-repeat;
  filter: brightness(.96) drop-shadow(0 0 6px rgba(164, 209, 255, .36));
  opacity: .76;
  transform: translate(-50%, -50%);
  transition: width .35s cubic-bezier(.16, 1, .3, 1), height .35s cubic-bezier(.16, 1, .3, 1), filter .35s ease, opacity .35s ease;
}

.site-constellation-destination[data-site-destination="0"] { --site-node-x: 119px; --site-node-y: 27px; transition-delay: 20ms; }
.site-constellation-destination[data-site-destination="1"] { --site-node-x: 207px; --site-node-y: 61px; transition-delay: 65ms; }

.site-header.site-constellation-open .site-constellation { z-index: 1; }
.site-header.site-constellation-open .site-constellation::before { opacity: 1; }
.site-header.site-constellation-open > a:first-child { z-index: 3; animation-play-state: paused; filter: brightness(1.3) drop-shadow(0 0 10px rgba(190, 224, 255, .68)) drop-shadow(0 0 24px rgba(116, 163, 255, .34)); transform: scale(1.06); }
.site-header.site-constellation-open > a:first-child::after { opacity: 1; transform: translate(-50%, 0); }
.site-header.site-constellation-open .site-constellation-thread { opacity: .6; transform: rotate(var(--site-thread-angle, 0deg)) scaleX(1); }
.site-header.site-constellation-open .site-constellation-destination { opacity: 1; filter: none; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.site-constellation-destination:hover,
.site-constellation-destination:focus-visible,
.site-constellation-destination.is-current { color: #fff; }

.site-constellation-destination:hover::before,
.site-constellation-destination:focus-visible::before,
.site-constellation-destination.is-current::before {
  width: 29px;
  height: 29px;
  filter: brightness(1.5) drop-shadow(0 0 8px rgba(206, 234, 255, .78)) drop-shadow(0 0 20px rgba(109, 172, 255, .4));
  opacity: 1;
}

.site-constellation-destination:focus-visible { border-radius: 10px; outline-offset: 0; }
.site-header.page-header {
  top: 18px;
  right: auto;
  bottom: auto;
  left: 20px;
  width: 64px;
  height: 64px;
  padding: 0;
  pointer-events: auto;
}

::selection { background: rgba(120, 164, 255, .48); color: #fff; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 5px; }

@keyframes shell-arrive {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes site-star-shimmer {
  0%, 42%, 58%, 100% { filter: brightness(1.08) drop-shadow(0 0 5px rgba(188, 225, 255, .5)); opacity: .93; transform: scale(.99); }
  49% { filter: brightness(1.28) drop-shadow(0 0 8px rgba(211, 238, 255, .76)) drop-shadow(0 0 17px rgba(116, 174, 255, .36)); opacity: 1; transform: scale(1.025); }
  52% { filter: brightness(1.58) drop-shadow(0 0 11px rgba(220, 242, 255, .92)) drop-shadow(0 0 24px rgba(116, 174, 255, .52)); opacity: 1; transform: scale(1.055); }
}

@media (max-width: 720px) {
  .site-header { top: 10px; left: 10px; }
  .site-header.page-header { top: 10px; left: 10px; padding: 0; }
  .site-header,
  .site-header.page-header { width: 60px; height: 60px; }
  .site-header > a:first-child { width: 58px; height: 58px; background-size: 68px 68px, auto; }
  .site-constellation { width: 258px; height: 92px; }
  .site-constellation-destination { min-width: 64px; font-size: 16px; }
  .site-header > a:first-child::after { top: 47px; font-size: 14px; }
  .site-constellation-destination[data-site-destination="0"] { --site-node-x: 106px; --site-node-y: 25px; }
  .site-constellation-destination[data-site-destination="1"] { --site-node-x: 185px; --site-node-y: 59px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-header { animation: none; }
  .site-header > a:first-child,
  .starfield-canvas { transition: none; }
}
