/*
 * netheremp.com homepage (docs/glass-design-spec.md section 5): the orbit
 * concept in the shared Liquid Glass language. Tokens from tokens.css, glass
 * from glass.css, system type, light/dark following the system. The core is
 * the one prominent control; destinations are glass pills on the orbit.
 * "Lights out" (void mode) is a session-only easter egg on the identity pill.
 */
:root {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  color-scheme: light dark;
  font-family: var(--font-family);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line-height);
  letter-spacing: var(--text-body-tracking);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-background-primary);
  color: var(--color-label-primary);
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--color-accent-text);
  outline-offset: 3px;
}

.world {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100svh;
  overflow: hidden;
  background: var(--color-background-primary);
  color: var(--color-label-primary);
  transition:
    background-color var(--motion-duration-standard) var(--motion-easing-standard),
    color var(--motion-duration-standard) var(--motion-easing-standard);
}

/* The field canvas sits behind everything on the page (drawn by app.js). */
.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Page content above the field; the panel keeps its fixed position. */
.world > :not(.field, .panel) {
  position: relative;
}

/* --- corners ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: max(var(--space-4), env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right)) 0
    max(var(--space-4), env(safe-area-inset-left));
}

.sigil {
  gap: var(--space-2);
  padding: 0 var(--space-4) 0 var(--space-1);
  font-size: var(--text-subheadline-size);
  font-weight: var(--font-weight-semibold);
}

.sigil-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: var(--font-weight-bold);
}

.status {
  margin: 0;
  gap: var(--space-2);
  font-size: var(--text-subheadline-size);
  cursor: default;
}

.status:active {
  transform: none;
}

.pulse {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-success);
  animation: ping 2.4s var(--motion-easing-standard) infinite;
}

/* --- stage ---------------------------------------------------------------------- */

.stage {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4) var(--space-4);
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--color-label-secondary);
  font-size: var(--text-subheadline-size);
  font-weight: var(--font-weight-semibold);
}

h1 {
  margin: 0;
  font-size: clamp(3.5rem, 11vw, 7.5rem);
  line-height: 1;
  letter-spacing: -0.045em;
  font-weight: 800;
}

/* The two-tone wordmark: emp in the brand accent (a quieter label in dark). */
h1 span {
  color: var(--color-accent);
}

@media (prefers-color-scheme: dark) {
  h1 span {
    color: var(--color-label-secondary);
  }
}

.intro {
  max-width: 30rem;
  margin: 0;
  color: var(--color-label-secondary);
  font-size: var(--text-title3-size);
  line-height: var(--text-title3-line-height);
  letter-spacing: var(--text-title3-tracking);
}

/* --- the orbit ------------------------------------------------------------------- */

.system {
  position: relative;
  width: min(80vw, 32rem, 58svh);
  aspect-ratio: 1;
  /* Planets on the outer orbit ride the edge: keep them clear of the text. */
  margin: calc(var(--size-control) / 2 + var(--space-6)) 0;
  transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  transition: transform var(--motion-duration-quick) var(--motion-easing-standard);
}

/* Rings, one per planet orbit, drawn from app.js. */
.orbits {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--orbit-size);
  aspect-ratio: 1;
  border: 1px solid var(--color-separator);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.orbit:nth-child(2) {
  border-style: dashed;
}

/*
 * The star: a clear glass sphere. The field canvas beneath draws its dark
 * core, twin flame (Pantone 7476 C and 7665 C), corona and the lensed
 * lattice; this element adds only the glass itself (rim, highlight, depth)
 * and the label.
 */
.portal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  --_tint: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background-image:
    radial-gradient(circle at 32% 24%, rgb(255 255 255 / 0.32), rgb(255 255 255 / 0) 36%),
    radial-gradient(circle at 50% 50%, rgb(255 255 255 / 0) 62%, rgb(255 255 255 / 0.1) 100%);
  color: #ffffff;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
  transform: translate(-50%, -50%);
  transition:
    transform var(--motion-duration-standard) var(--motion-easing-spring),
    filter var(--motion-duration-quick) var(--motion-easing-standard);
}

.portal:active {
  transform: translate(-50%, -50%) scale(0.96);
}

.system.is-open .portal {
  transform: translate(-50%, -50%) scale(0.88);
}

.portal-label {
  display: grid;
  gap: 2px;
}

.portal-label strong {
  font-size: var(--text-title2-size);
  line-height: var(--text-title2-line-height);
  letter-spacing: var(--text-title2-tracking);
  font-weight: var(--font-weight-semibold);
}

.portal-label small {
  font-size: var(--text-footnote-size);
  opacity: 0.8;
}

/*
 * Destinations are planets: glass pills that app.js moves along their orbits
 * through --x/--y. Opening and closing are drawn frame by frame too: --stretch
 * lengthens a planet along the line to the star (--rot) and --squeeze thins it
 * across, for the white-hole release and the spaghettifying fall; --o and
 * --glow fade and brighten it. Only fully open planets take pointer events.
 */
.nodes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.node {
  position: absolute;
  z-index: var(--node-layer);
  top: 50%;
  left: 50%;
  gap: var(--space-2);
  min-width: 8.5rem;
  padding: var(--space-2) var(--space-4);
  justify-content: flex-start;
  text-align: start;
  opacity: var(--o, 1);
  filter: brightness(var(--glow, 1)) blur(var(--blur, 0px));
  transform:
    translate(calc(-50% + var(--x, 0px)), calc(-50% + var(--y, 0px)))
    rotate(var(--rot, 0deg))
    scale(var(--stretch, 1), var(--squeeze, 1))
    rotate(calc(-1 * var(--rot, 0deg)));
  transition: none;
}

.node[data-phase="closed"] {
  visibility: hidden;
}

.node[data-phase="open"] {
  pointer-events: auto;
}

.node[data-phase="open"]:active {
  transform:
    translate(calc(-50% + var(--x, 0px)), calc(-50% + var(--y, 0px)))
    scale(0.96);
}

.node span {
  display: grid;
}

.node strong {
  font-size: var(--text-headline-size);
  line-height: var(--text-headline-line-height);
  font-weight: var(--font-weight-semibold);
}

/* On glass, secondary text keeps the label colour (grey fails over busy content). */
.node small {
  opacity: 0.85;
  font-size: var(--text-footnote-size);
  line-height: var(--text-footnote-line-height);
}

.node .icon {
  color: var(--color-accent-text);
}


.hint {
  margin: 0;
  color: var(--color-label-secondary);
  font-size: var(--text-footnote-size);
}

/* --- panel: the shared glass sheet ------------------------------------------------ */

.panel {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  display: grid;
  gap: var(--space-2);
  width: min(26rem, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-5) var(--space-5) var(--space-6);
  transform: translateX(-50%);
  animation: sheet-in var(--motion-duration-standard) var(--motion-easing-spring);
}

.panel[hidden] {
  display: none;
}

.panel-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}

.panel-index {
  margin: 0;
  color: var(--color-accent-text);
  font-size: var(--text-subheadline-size);
  font-weight: var(--font-weight-semibold);
}

.panel h2 {
  margin: 0;
  padding-right: var(--size-control);
  font-size: var(--text-title2-size);
  line-height: var(--text-title2-line-height);
  letter-spacing: var(--text-title2-tracking);
  font-weight: var(--font-weight-bold);
}

.panel > p:not(.panel-index) {
  margin: 0;
}

.panel-state {
  color: var(--color-label-secondary);
  font-size: var(--text-footnote-size);
}

footer {
  padding: var(--space-4) var(--space-4) max(var(--space-4), env(safe-area-inset-bottom));
  color: var(--color-label-secondary);
  font-size: var(--text-footnote-size);
  text-align: center;
}

/*
 * Lights out: true black whatever the system appearance; the words dim, the
 * glass goes clearest and catches a faint #0D5257 glow, the only colour left.
 */
.world.void-mode {
  --color-background-primary: #000000;
  --color-label-primary: #ffffff;
  --color-label-secondary: #ebebf599;
  --color-label-tertiary: #ebebf54d;
  --color-label-vibrant: #f5f5f5;
  --color-separator: #ffffff1f;
  --color-accent-text: #ffffff;
  --glass-effective: 0;
  --glass-tint-clear: #1a1a1a59;
  --glass-control-tint-clear: #99999926;
  --glass-ring: #00000059;
  --glass-highlight: #ffffff1a;
  --glass-shadow: #00000073;
  --void-glow: color-mix(in srgb, var(--color-accent) 70%, transparent);
  color-scheme: dark;
}

.world.void-mode h1,
.world.void-mode .intro,
.world.void-mode .eyebrow {
  color: var(--color-label-secondary);
}

.world.void-mode h1 span {
  color: var(--color-label-tertiary);
}

.world.void-mode .glass-control,
.world.void-mode .glass {
  box-shadow:
    0 0 1.75rem var(--void-glow),
    0 0 0 0.5px var(--void-glow),
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -1px 0 var(--glass-highlight);
}

/* --- motion ---------------------------------------------------------------------- */

@keyframes ping {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-success) 60%, transparent);
  }

  70%,
  100% {
    box-shadow: 0 0 0 0.5rem transparent;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translate(-50%, 1.5rem);
  }
}

@media (max-width: 640px) {
  .sigil span:last-child {
    display: none;
  }

  .sigil {
    padding: 0 var(--space-1);
  }

  /* Room for planets on the outer orbit at the screen edges. */
  .system {
    width: min(70vw, 52svh);
  }

  /* A smaller star, so the inner planet clears it passing the sides. */
  .portal {
    width: 30%;
  }

  /* On a phone the star says only Enter or Close; the subtitle crowded it. */
  .portal-label small {
    display: none;
  }

  .node {
    min-width: 0;
    padding: var(--space-1) var(--space-3);
  }

  .node small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse {
    animation: none;
  }

  .system,
  .portal,
  .world {
    transition: none;
  }

  .panel {
    animation: none;
  }
}
