/* ==========================================================================
   SPACE THEME — inspired by the attached Lively Wallpaper HUD
   (pure-black cosmos, twinkling particle starfield, film grain,
   Doto HUD typography — all white on black).
   --------------------------------------------------------------------------
   This file layers OVER css/styles.css. Layout and class names are untouched;
   only palette, typography accents, and background layers change.
   The starfield itself is injected by js/space.js as:
     <div class="space-bg"><div class="particle-field">…spans…</div></div>
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Doto:wght@100..900&display=swap");

:root,
[data-theme="dark"] {
  --font-dot: "Doto", "Space Mono", monospace;

  /* Pure-black cosmos (single dark mode — no light variant). */
  --background: #000000;
  --foreground: #ffffff;
  --card: rgba(255, 255, 255, 0.03);
  --card-foreground: #ffffff;
  --popover: #050505;
  --muted: rgba(255, 255, 255, 0.08);
  --muted-foreground: rgba(255, 255, 255, 0.62);
  --accent: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.14);
  --ring: #ffffff;
  --gradient-card-bg: rgba(255, 255, 255, 0.03);
  --gradient-card-border: rgba(255, 255, 255, 0.13);
  --input-bg: rgba(255, 255, 255, 0.05);
  --shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
  --nav-bg: rgba(0, 0, 0, 0.72);
  --space-glow: rgba(255, 255, 255, 0.16);
}

/* ---------- base ---------- */
html {
  background: #000;
}
body {
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection {
  background: #fff;
  color: #000;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
}
:focus-visible {
  outline: 2px solid #fff;
}

/* All content floats above the fixed cosmos. */
body > header,
body > main,
body > footer,
body > nav,
.nav-spacer {
  position: relative;
  z-index: 1;
}

/* ---------- COSMOS BACKGROUND (fixed, non-interactive) ---------- */
.space-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--background);
  overflow: hidden;
  pointer-events: none;
}

.particle-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.particle-field span {
  position: absolute;
  top: var(--top);
  left: var(--left);
  width: var(--size, 2px);
  height: var(--size, 2px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.45);
  animation:
    var(--path, particleDriftA) calc(var(--duration, 18s) - 9s) ease-in-out
      var(--delay, 0s) infinite alternate,
    particleTwinkle var(--twinkle-duration, 7s) ease-in-out
      var(--twinkle-delay, 0s) infinite;
}

/* A few brighter "hero" stars get a wider halo. */
.particle-field span.bright {
  box-shadow:
    0 0 4px 1px rgba(255, 255, 255, 0.7),
    0 0 14px 3px rgba(255, 255, 255, 0.16);
}

@keyframes particleDriftA {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(24px, -31px, 0); }
}
@keyframes particleDriftB {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(-32px, 22px, 0); }
}
@keyframes particleDriftC {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(18px, 36px, 0); }
}
@keyframes particleDriftD {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(-26px, -28px, 0); }
}
@keyframes particleTwinkle {
  0%, 100% { opacity: 0.3; }
  38% { opacity: 0.48; }
  50% { opacity: 1; }
  64% { opacity: 0.52; }
}

/* Film grain over the cosmos (same SVG noise as the inspiration). */
.space-bg::after {
  position: absolute;
  inset: -50%;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.05;
  pointer-events: none;
}

/* ---------- HUD typography accents (Doto) ---------- */
.eyebrow,
.exp-head p,
.page-kicker,
.pal-sec,
.mono,
.gh-lab,
.t-year {
  font-family: var(--font-dot) !important;
  font-variation-settings: "ROND" 100;
  font-optical-sizing: auto;
  letter-spacing: 0.14em;
}

/* Big titles get a faint starlight glow like the wallpaper clock. */
.hero-name,
.page-title,
.detail-title {
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.7);
}
.hero-tag {
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

/* ---------- glass star-cards ---------- */
.g-card,
.d-card,
.p-card,
.preview,
.m-preview,
.resume-card,
.prevnext a,
.x-pos {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.055),
    rgba(255, 255, 255, 0.02)
  ) !important;
  border-color: rgba(255, 255, 255, 0.13) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}
.g-card:hover::before {
  opacity: 1;
}
.g-card::before {
  background: radial-gradient(
      120px circle at var(--glow-x) var(--glow-y),
      rgba(255, 255, 255, 0.55),
      transparent 70%
    )
    border-box;
}
.tag,
.x-skills span,
.pill,
.skill-badge .glyph {
  border-color: rgba(255, 255, 255, 0.22) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  font-family: var(--font-dot);
  font-variation-settings: "ROND" 100;
  letter-spacing: 0.06em;
}

/* ---------- nav: mission-control pill ---------- */
#site-nav.scrolled .nav-shell {
  background: rgba(0, 0, 0, 0.66) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.55),
    0 0 18px rgba(255, 255, 255, 0.06) !important;
}
#site-nav.scrolled .nav-mobile:not(.open) {
  background: rgba(0, 0, 0, 0.66) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
}
.nav-mobile.open {
  background: rgba(0, 0, 0, 0.94) !important;
}
.nav-logo {
  font-family: var(--font-dot) !important;
  font-variation-settings: "ROND" 100;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.25);
}
.nav-icon-btn {
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* ---------- hero avatar: orbital portrait ---------- */
.avatar-frame {
  background: #000 !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 24px rgba(255, 255, 255, 0.14),
    0 18px 50px rgba(0, 0, 0, 0.7) !important;
}
.avatar-tilt {
  position: relative;
}
.avatar-tilt::before {
  content: "";
  position: absolute;
  width: min(19rem, 70vw);
  aspect-ratio: 1;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1.12);
  pointer-events: none;
  animation: orbitSpin 40s linear infinite;
}
@keyframes orbitSpin {
  to { transform: translate(-50%, -50%) scale(1.12) rotate(360deg); }
}

/* ---------- sections ---------- */
.x-item {
  border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}
.x-logo {
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.x-pos-head .chev {
  color: rgba(255, 255, 255, 0.6) !important;
}
.t-dot {
  background: rgba(255, 255, 255, 0.35) !important;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.9), 0 0 8px rgba(255, 255, 255, 0.3) !important;
}
.t-item.first .t-dot {
  background: #fff !important;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8) !important;
}
.t-line {
  background: rgba(255, 255, 255, 0.16) !important;
}
.gh-bar {
  background: rgba(255, 255, 255, 0.85) !important;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.25);
}
.skill-badge {
  color: rgba(255, 255, 255, 0.66) !important;
}
.skill-badge:hover {
  color: #fff !important;
  filter: brightness(1.25) drop-shadow(0 0 8px rgba(255, 255, 255, 0.35));
}

/* ---------- buttons / forms ---------- */
.btn.solid {
  background: #fff !important;
  color: #000 !important;
  border-color: #fff !important;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.28);
}
.btn:not(.solid) {
  border-color: rgba(255, 255, 255, 0.28) !important;
  background: rgba(255, 255, 255, 0.04);
}
.btn:not(.solid):hover {
  background: rgba(255, 255, 255, 0.1);
}
#toast {
  background: #fff !important;
  color: #000 !important;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.3);
}

/* ---------- overlays that must stay readable ---------- */
#loader {
  background: #000 !important;
}
#loader .l-logo {
  font-family: var(--font-dot);
  font-variation-settings: "ROND" 100;
  letter-spacing: 0.1em;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.35);
}
#loader .l-bar {
  background: rgba(255, 255, 255, 0.18) !important;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}
#loader .l-fill {
  background: #fff !important;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}
#pal .pal-card,
#pal-back {
  border-color: rgba(255, 255, 255, 0.16) !important;
}
#pal .pal-card {
  background: rgba(5, 5, 8, 0.92) !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255,255,255,0.06) !important;
}
#pal-fab {
  background: rgba(0, 0, 0, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}
footer {
  border-top-color: rgba(255, 255, 255, 0.12) !important;
  background: linear-gradient(to top, rgba(255,255,255,0.03), transparent);
}

/* ---------- legacy decorations re-skinned ---------- */
.gridbg {
  display: none !important;
}
#lightrays {
  opacity: 0.35 !important;
}
#lightrays::before,
#lightrays::after {
  background: linear-gradient(rgba(255,255,255,0.7), transparent) !important;
}
#toc .dash {
  background: rgba(255, 255, 255, 0.35) !important;
}
#toc a.active .dash {
  background: #fff !important;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}
.sidenav {
  background: rgba(0, 0, 0, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Project detail templates keep their flavor but float over space. */
.paper {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255,255,255,0.05);
}
.tv {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 0 40px rgba(255,255,255,0.07);
}
.spot {
  background:
    radial-gradient(600px circle at 20% 0%, rgba(255,255,255,0.09), transparent 60%),
    rgba(255,255,255,0.03) !important;
}
.detail-hero {
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6), 0 0 24px rgba(255,255,255,0.06);
}
.nf {
  background: #000 !important;
}

/* ---------- accessibility: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .particle-field span,
  .avatar-tilt::before {
    animation: none !important;
  }
  .particle-field span {
    opacity: 0.8 !important;
  }
}
