:root {
  color-scheme: dark;
  --background: #080a0c;
  --foreground: #e5e7eb;
  --primary: #38bdf8;
  --muted-foreground: #71717a;
  --accent: #5eead4;
  --online: #a3e635;
  --border: rgba(148, 163, 184, 0.14);
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--background);
  font-family: var(--font-mono);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
}

button { font: inherit; }

::selection {
  background: rgba(56, 189, 248, 0.24);
  color: #f8fafc;
}

.node-page {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background: var(--background);
  font-family: var(--font-mono);
}

.network-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--background);
}

.boot-sequence {
  width: min(88vw, 430px);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.85;
  letter-spacing: 0.04em;
}

.boot-sequence > span {
  display: block;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.boot-sequence > span.is-visible { opacity: 1; transform: none; }
.boot-sequence > span.is-ready { margin-top: 0.35rem; color: var(--online); }

.node-frame {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100% - 3rem, 1120px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 1.5rem 0 1.15rem;
  grid-template-rows: auto 1fr auto;
  opacity: 0;
}

.node-frame.is-ready { opacity: 1; }
.node-frame.is-booting { pointer-events: none; }

.node-header,
.node-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.node-header {
  min-height: 2.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.node-id {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #a1a1aa;
}

.status-dot {
  display: inline-block;
  width: 0.38rem;
  height: 0.38rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--online);
  position: relative;
}

.node-identity {
  width: min(100%, 52rem);
  align-self: center;
  margin-left: clamp(0rem, 5vw, 4rem);
  padding: clamp(4.5rem, 10vh, 7.5rem) 0 clamp(5rem, 12vh, 9rem);
}

.eyebrow,
.contact-block h2 {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.domain-title {
  width: fit-content;
  max-width: 100%;
  margin: 0.95rem 0 0;
  color: var(--foreground);
  font-size: clamp(2.5rem, 6.5vw, 5.2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.065em;
  text-shadow: 0 0 32px rgba(56, 189, 248, 0.055);
}

.domain-title button {
  all: unset;
  display: block;
  max-width: 100%;
  cursor: default;
}

.domain-title button:focus-visible {
  outline: 1px solid rgba(56, 189, 248, 0.46);
  outline-offset: 0.35rem;
}

.service-list {
  display: grid;
  max-width: 25rem;
  gap: 0.68rem;
  margin: 3rem 0 0;
  font-size: 0.78rem;
}

.service-list div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: baseline;
}

.service-list dt { color: #a1a1aa; }
.service-list dt::before { color: #52525b; content: '> '; }

.service-list dd {
  position: relative;
  margin: 0;
  padding-left: 1.4rem;
  text-transform: uppercase;
}

.service-list dd::before {
  position: absolute;
  left: 0;
  color: #3f3f46;
  content: '::';
}

.service-list dd.online { color: var(--online); }
.service-list dd.unresolved { color: var(--primary); }

.contact-block {
  position: relative;
  max-width: 30rem;
  margin-top: 3.3rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
}

.contact-block h2 span,
.operator-line > span:first-child { color: var(--primary); }

.contact-email {
  position: relative;
  display: inline-block;
  margin-top: 0.95rem;
  color: var(--foreground);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  text-decoration: none;
  text-underline-offset: 0.38rem;
  transition: color 160ms ease;
}

.contact-email::before {
  position: absolute;
  right: 0;
  bottom: -0.4rem;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--primary), transparent);
  content: '';
  transform: scaleX(0.22);
  transform-origin: left;
  transition: transform 220ms ease;
}

.contact-email:hover,
.contact-email:focus-visible { color: var(--primary); }

.contact-email:focus-visible {
  outline: 1px solid rgba(56, 189, 248, 0.46);
  outline-offset: 0.5rem;
}

.contact-email:hover::before,
.contact-email:focus-visible::before { transform: scaleX(1); }

/* Preserve the original reserved feedback space and composition. */
.contact-feedback-space {
  display: block;
  height: 1rem;
  margin-top: 0.85rem;
}

.operator-line {
  margin: 2.2rem 0 0;
  color: #5d6067;
  font-size: 0.7rem;
}

.terminal-cursor {
  margin-left: 0.2rem;
  color: var(--primary);
  animation: cursor-blink 1.4s steps(1, end) infinite;
}

.node-footer {
  min-height: 2.4rem;
  border-top: 1px solid rgba(148, 163, 184, 0.09);
  color: #4b4b53;
  font-size: 0.56rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

@keyframes cursor-blink { 0%, 49.99% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* One background system: a fixed, oversized infrastructure surface. */
.network-horizon {
  position: fixed;
  left: 12vw;
  top: 57vh;
  width: 128vw;
  height: 66vh;
  overflow: visible;
  pointer-events: none;
}
.network-horizon path { fill: none; vector-effect: non-scaling-stroke; }
.network-horizon .horizon-surface { fill: url(#horizon-surface); }
.horizon-rim { stroke: url(#horizon-rim); stroke-width: 1.15; }
.horizon-atmosphere { stroke: url(#horizon-rim); stroke-width: 4; opacity: 0.3; filter: url(#rim-softness); }
.horizon-contours path {
  stroke: #789baa;
  stroke-opacity: calc(0.14 + var(--near, 0));
  stroke-width: 0.7;
  transition: stroke-opacity 220ms ease;
}
.horizon-contours path.is-signaling { animation: region-response 900ms ease-out; }
.horizon-route {
  stroke: #91afbd;
  stroke-width: 0.85;
  stroke-opacity: calc(0.12 + var(--near, 0));
  transition: stroke-opacity 220ms ease;
}
.horizon-route.is-signaling { animation: route-response 1100ms ease-out; }
.horizon-packet {
  stroke: #afcbd6;
  stroke-width: 1.25;
  stroke-dasharray: 0.08 1.08;
  stroke-dashoffset: 0.08;
  opacity: 0;
}
.horizon-packet.is-signaling { animation: horizon-transfer 1100ms linear; }
.horizon-nodes circle {
  --node-rest: 0.34;
  fill: #9cb6c2;
  opacity: calc(var(--node-rest) + var(--near, 0));
  transition: opacity 220ms ease;
}
.horizon-nodes circle:nth-child(3), .horizon-nodes circle:nth-child(5) { --node-rest: 0.44; }
.horizon-nodes circle.is-signaling { animation: horizon-response 1000ms ease-out; }
.node-halo {
  fill: none;
  stroke: #94b7c7;
  stroke-width: 0.65;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
}
.node-halo.is-signaling { animation: surface-pulse 1000ms ease-out; }
.horizon-search { stroke: #a0bdca; stroke-width: 1; stroke-dasharray: 0.14 1.14; stroke-dashoffset: 0.14; opacity: 0; }
.surface-search.is-signaling .horizon-search { animation: horizon-search 1100ms ease-in-out; }
.surface-search.is-signaling .search-echo { animation-delay: 180ms; }
.search-region { stroke: #819eac; stroke-width: 0.7; opacity: 0; }
.surface-search.is-signaling .search-region { animation: local-reveal 1350ms ease-out; }
@keyframes region-response {
  0%, 100% { stroke-opacity: 0.14; }
  35% { stroke-opacity: 0.25; }
}
@keyframes route-response {
  0%, 100% { stroke-opacity: calc(0.12 + var(--near, 0)); }
  25%, 65% { stroke-opacity: 0.34; }
}
@keyframes horizon-response {
  0%, 100% { opacity: calc(var(--node-rest) + var(--near, 0)); }
  25% { opacity: 0.82; }
}
@keyframes surface-pulse {
  0% { opacity: 0; transform: scale(0.55); }
  20% { opacity: 0.4; }
  100% { opacity: 0; transform: scale(1.7); }
}
@keyframes horizon-transfer {
  0% { opacity: 0; stroke-dashoffset: 0.08; }
  12%, 80% { opacity: 0.64; }
  100% { opacity: 0; stroke-dashoffset: -1; }
}
@keyframes horizon-search {
  0% { opacity: 0; stroke-dashoffset: 0.14; }
  30%, 65% { opacity: 0.36; }
  100% { opacity: 0; stroke-dashoffset: -1; }
}
@keyframes local-reveal {
  0%, 100% { opacity: 0; }
  40% { opacity: 0.22; }
}
@media (max-width: 800px) {
  .network-horizon {
    left: -40vw;
    top: max(71vh, 580px);
    width: 220vw;
    /* Keep a broad 3:1 surface, independent of the phone's screen height. */
    height: auto;
    aspect-ratio: 3 / 1;
    opacity: 0.8;
  }
  .horizon-contours path:nth-child(3), .horizon-contours path:nth-child(4),
  .horizon-contours path:nth-child(8) { display: none; }
  .horizon-atmosphere { filter: none; opacity: 0.12; }
}

.node-id:focus-visible,
.service-list > div:focus-visible {
  outline: 1px solid rgba(56, 189, 248, 0.35);
  outline-offset: 4px;
}

.node-header { position: relative; }
.node-header::after {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148, 185, 190, 0.3), transparent);
  content: '';
  opacity: 0;
  pointer-events: none;
}
.status-dot::after {
  position: absolute;
  inset: -2px;
  border: 1px solid rgba(163, 230, 53, 0.32);
  border-radius: inherit;
  content: '';
  opacity: 0;
}
.node-header.is-signaling .status-dot::after { animation: node-heartbeat 850ms cubic-bezier(0.2, 0, 0.4, 1); }
.node-header.is-signaling::after { animation: header-packet 950ms 100ms linear both; }
@keyframes node-heartbeat {
  0% { opacity: 0; transform: scale(0.7); }
  20% { opacity: 0.6; }
  100% { opacity: 0; transform: scale(1.7); }
}
@keyframes header-packet {
  0% { opacity: 0; transform: translateX(0); }
  18%, 65% { opacity: 0.65; }
  100% { opacity: 0; transform: translateX(180px); }
}

.node-frame.is-ready .node-header,
.node-frame.is-ready .eyebrow,
.node-frame.is-ready .domain-title,
.node-frame.is-ready .service-list,
.node-frame.is-ready .contact-block,
.node-frame.is-ready .operator-line,
.node-frame.is-ready .node-footer {
  animation: interface-ready 760ms var(--reveal-delay, 0ms) cubic-bezier(0.2, 0.65, 0.3, 1) backwards;
}
.eyebrow { --reveal-delay: 80ms; }
.domain-title { --reveal-delay: 160ms; }
.service-list { --reveal-delay: 240ms; }
.contact-block { --reveal-delay: 320ms; }
.operator-line, .node-footer { --reveal-delay: 400ms; }
@keyframes interface-ready {
  from { opacity: 0; transform: translateY(6px); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.domain-title button > span { position: relative; display: block; }
.domain-title button > span::after {
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke: 0.5px var(--primary);
  content: attr(data-signal);
  opacity: 0;
  pointer-events: none;
  text-shadow: none;
}
.domain-title button.is-signaling > span::after { animation: identity-signal 180ms ease-out; }
@keyframes identity-signal {
  0%, 100% { opacity: 0; transform: translateX(0); }
  25%, 55% { opacity: 0.5; transform: translateX(1px); }
}

.email-packet {
  position: absolute;
  bottom: -0.4rem;
  left: 0;
  width: 100%;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}
.email-packet::after {
  display: block;
  width: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(142, 213, 240, 0.6), transparent);
  content: '';
  opacity: 0;
}
.contact-email.is-signaling .email-packet::after { animation: email-transmission 420ms linear; }
@keyframes email-transmission {
  0% { opacity: 0; transform: translateX(-16px); }
  15%, 75% { opacity: 0.7; }
  100% { opacity: 0; transform: translateX(var(--packet-distance, 200px)); }
}

/* Pause CSS activity too; JS clears signals and proximity when hidden. */
.motion-paused *, .motion-paused *::before, .motion-paused *::after { animation-play-state: paused !important; }

@media (max-width: 800px) {
  .node-frame { width: min(100% - 2.5rem, 42rem); padding-top: 1rem; }
  .node-identity { margin-left: 0; padding: 4.5rem 0 5.5rem; }
}

@media (max-width: 520px) {
  .node-frame { width: calc(100% - 2rem); padding-bottom: 0.85rem; }
  .node-header { min-height: 3.1rem; gap: 1rem; font-size: 0.59rem; letter-spacing: 0.07em; }
  .node-identity { padding: 3.8rem 0 4.5rem; }
  .domain-title { font-size: clamp(1.85rem, 9.2vw, 2.8rem); }
  .service-list { margin-top: 2.5rem; }
  .contact-block { margin-top: 2.8rem; }
  .node-footer { gap: 1rem; font-size: 0.48rem; letter-spacing: 0.04em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
  .network-horizon .horizon-packet, .network-horizon .horizon-search,
  .network-horizon .node-halo, .network-horizon .search-region { opacity: 0; }
  .horizon-route { stroke-opacity: 0.12; }
  .horizon-nodes circle { opacity: var(--node-rest); }
  .horizon-contours path { stroke-opacity: 0.14; }
  .terminal-cursor { opacity: 1; }
}
