/* ============================================================
   Noetic — Compute Network
   Palette   void #04070F · panel-ink rgba(8,15,30,.78)
             cobalt #2F6BFF · ice #E6F1FF · amber #FFB65C · slate #64748E
   Type      Suisse Intl → Space Grotesk fallback (display)
             Anka Coder → IBM Plex Mono fallback (data)
   ============================================================ */

/* Licensed brand fonts (local). Google fonts remain as loading fallbacks. */
@font-face {
  font-family: "Suisse Intl";
  src: url("../fonts/SuisseIntl-Regular.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Suisse Intl";
  src: url("../fonts/SuisseIntl-Medium.otf") format("opentype");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Anka Coder";
  src: url("../fonts/AnkaCoder-b.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --void: #04070F;
  --ink: rgba(8, 15, 30, 0.78);
  --line: rgba(120, 150, 200, 0.16);
  --cobalt: #2F6BFF;
  --ice: #E6F1FF;
  --amber: #FFB65C;
  --slate: #64748E;
  --display: "Suisse Intl", "Space Grotesk", system-ui, sans-serif;
  --mono: "Anka Coder", "IBM Plex Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--void);
  color: var(--ice);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); }
.hidden { opacity: 0 !important; pointer-events: none !important; }

/* ---------- parallax background + starfield ---------- */
/* #bg is oversized and translated by JS so edges never show while it drifts */
#bg {
  position: fixed; inset: -3%;
  background: url("../assets/bg-space.png") center / cover no-repeat;
  will-change: transform;
  z-index: 0;
}

#stars { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
/* Each layer is a 2px dot whose box-shadow carries all its stars (set by JS).
   Layers twinkle at different rates; data-depth drives parallax strength. */
.star-layer {
  position: absolute; top: 0; left: 0;
  width: 2px; height: 2px; border-radius: 50%;
  background: transparent;
  will-change: transform, opacity;
}
.star-layer:nth-child(1) { animation: twinkle 7.5s ease-in-out infinite; }
.star-layer:nth-child(2) { animation: twinkle 5s   ease-in-out infinite 1.2s; }
.star-layer:nth-child(3) { animation: twinkle 3.4s ease-in-out infinite 0.5s; }

/* A handful of individually timed bright stars for irregular sparkle */
#star-sparks { position: absolute; inset: 0; will-change: transform; }
.spark {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 6px 1px rgba(230, 241, 255, 0.7);
  animation: sparkle var(--dur, 4s) ease-in-out infinite var(--delay, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
@keyframes sparkle {
  0%, 100% { opacity: 0.1; transform: scale(0.7); }
  50%      { opacity: 1;   transform: scale(1); }
}

#stage, #labels { position: fixed; inset: 0; }
#stage { z-index: 2; }
#stage canvas { display: block; }
#labels { pointer-events: none; z-index: 3; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--void);
  transition: opacity 0.6s ease;
}
.loader-mark { display: block; height: 18px; width: auto; opacity: 0.85; }
.loader-bar { width: 180px; height: 1px; background: rgba(120,150,200,0.2); }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--cobalt); transition: width 0.2s; }
.loader-pct { font-size: 11px; color: var(--slate); }

/* ---------- brand / hint / credit ---------- */
#brand { position: fixed; top: 28px; left: 32px; z-index: 5; }
.brand-logo { display: block; height: 20px; width: auto; }
.brand-sub { margin-top: 8px; font-size: 10px; letter-spacing: 0.24em; color: var(--slate); }

#hint {
  position: fixed; bottom: 30px; left: 32px; z-index: 5;
  font-size: 10.5px; letter-spacing: 0.12em; color: var(--slate);
}

#credit {
  position: fixed; bottom: 30px; right: 32px; z-index: 5;
  font-size: 9.5px; letter-spacing: 0.06em; color: rgba(100, 116, 142, 0.55);
}

/* ---------- view controls ---------- */
#viewctl {
  position: fixed; right: 32px; bottom: 64px; z-index: 6;
  display: flex; flex-direction: column; gap: 8px;
}
#viewctl button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--ink); border: 1px solid var(--line);
  color: var(--slate); font-size: 9.5px; letter-spacing: 0.18em;
  cursor: pointer; backdrop-filter: blur(10px);
  transition: color 0.15s, border-color 0.15s;
}
#viewctl button:hover { color: var(--ice); border-color: rgba(47, 107, 255, 0.55); }
#viewctl button.busy { color: var(--cobalt); pointer-events: none; }
#viewctl svg { flex: none; }

/* ---------- region panel ---------- */
#panel {
  position: fixed; top: 96px; right: 32px; z-index: 6;
  width: 296px; max-height: calc(100vh - 230px);
  display: flex; flex-direction: column;
  background: var(--ink);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateX(0);
}
#panel.hidden { transform: translateX(10px); }

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--line);
}
.panel-eyebrow { font-size: 9px; letter-spacing: 0.3em; color: var(--cobalt); margin-bottom: 6px; }
.panel-title { font-size: 19px; font-weight: 500; letter-spacing: 0.02em; }
#panel-close {
  background: none; border: 1px solid var(--line); color: var(--slate);
  width: 24px; height: 24px; font-size: 10px; cursor: pointer; visibility: hidden;
}
#panel.locked #panel-close { visibility: visible; }
#panel-close:hover { color: var(--ice); border-color: var(--slate); }

.panel-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.stat { padding: 12px 10px 12px 18px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-k { display: block; font-size: 8.5px; letter-spacing: 0.14em; color: var(--slate); margin-bottom: 5px; }
.stat-v { font-size: 15px; font-weight: 600; color: var(--amber); }

.panel-list { overflow-y: auto; padding: 6px 0; scrollbar-width: thin; scrollbar-color: rgba(100,116,142,.4) transparent; }
.row {
  display: grid; grid-template-columns: 30px 1fr auto;
  gap: 10px; align-items: baseline;
  padding: 6px 18px; font-size: 11px;
}
.row .iso { color: var(--cobalt); font-size: 9.5px; letter-spacing: 0.1em; }
.row .cname { color: var(--ice); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.row .val { color: var(--slate); font-size: 11px; }
.row.hot { background: rgba(47, 107, 255, 0.14); }
.row.hot .val { color: var(--amber); }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  min-width: 148px; padding: 10px 12px;
  background: var(--ink); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: opacity 0.12s;
}
.tt-name { font-family: var(--display); font-size: 13px; font-weight: 500; margin-bottom: 7px; }
.tt-row { display: flex; justify-content: space-between; gap: 18px; font-size: 10px; color: var(--slate); line-height: 1.7; }
.tt-row b { color: var(--amber); font-weight: 600; }

/* ---------- toast (geolocation errors etc.) ---------- */
#toast {
  position: fixed; left: 50%; bottom: 68px; z-index: 20;
  transform: translateX(-50%);
  padding: 9px 16px;
  background: var(--ink); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 10.5px; letter-spacing: 0.06em; color: var(--ice);
  transition: opacity 0.3s;
}

/* ---------- pins ---------- */
.pin { pointer-events: none; }
.pin-inner {
  display: flex; flex-direction: column; align-items: center;
  transform: translateY(-50%);              /* anchor the dot on the geographic point */
  animation: pin-in 0.3s ease backwards;
}
.pin-tag {
  display: flex; gap: 7px; align-items: baseline;
  padding: 4px 8px; white-space: nowrap;
  background: var(--ink); border: 1px solid rgba(47, 107, 255, 0.45);
  backdrop-filter: blur(8px);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em;
}
.pin-tag .p-iso { color: var(--cobalt); font-weight: 600; }
.pin-tag .p-name { color: var(--ice); }
.pin-tag .p-val { color: var(--amber); font-weight: 600; }
.pin-stem { width: 1px; height: 14px; background: linear-gradient(rgba(47,107,255,0.8), transparent); }
.pin-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px 2px rgba(255,182,92,0.5); }

/* user location marker */
.user-pin { pointer-events: none; }
.user-pin .ring {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid rgba(47, 107, 255, 0.9);
  animation: user-pulse 2s ease-out infinite;
}
.user-pin .core {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--cobalt); box-shadow: 0 0 10px 2px rgba(47,107,255,0.8);
}
@keyframes user-pulse {
  from { transform: scale(0.4); opacity: 1; }
  to   { transform: scale(1.6); opacity: 0; }
}

@keyframes pin-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .pin-inner, .star-layer, .spark, .user-pin .ring { animation: none; }
  #panel { transition: none; }
}

@media (max-width: 720px) {
  #brand { left: 20px; top: 20px; }
  #hint { display: none; }
  #panel { left: 12px; right: 12px; width: auto; top: auto; bottom: 12px; max-height: 42vh; }
  #viewctl { right: 12px; bottom: 12px; flex-direction: row; }
  #credit { display: none; }
}

/* ---------- landing hero ---------- */
#hero {
  position: fixed; inset: 0; z-index: 7;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding-bottom: 14vh;             /* sit above the globe horizon */
  pointer-events: none;             /* only the buttons are clickable */
  transition: opacity 0.45s ease, transform 0.45s ease;
}
#hero.hidden { transform: translateY(-14px); }
#hero::before {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;                     /* 壓在 hero 文字後、地球畫面前 */
  background: radial-gradient(
    ellipse 62% 48% at 50% 42%,    /* 橢圓大小(寬 高)+ 中心點位置 */
    rgba(4, 7, 15, 0.78) 0%,       /* 中心最深 */
    rgba(4, 7, 15, 0.45) 45%,
    transparent 72%                /* 邊緣淡出,不會出現生硬邊界 */
  );
}

.hero-eyebrow {
  font-size: 10px; letter-spacing: 0.34em; color: var(--cobalt);
  margin-bottom: 22px;
}
.hero-stat {
  font-size: clamp(56px, 10vw, 118px);
  font-weight: 600; line-height: 1;
  color: var(--ice);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;   /* stable width while counting up */
  text-shadow: 0 0 46px rgba(47, 107, 255, 0.35);
}
.hero-label {
  margin-top: 14px;
  font-size: 14px; color: var(--slate); letter-spacing: 0.04em;
}
.hero-label span { color: var(--amber); }

.hero-ctas {
  display: flex; gap: 12px; margin-top: 38px;
  pointer-events: auto;
}
.hero-ctas button {
  padding: 13px 24px;
  font-size: 10.5px; letter-spacing: 0.2em;
  cursor: pointer;
  border: 1px solid var(--cobalt);
  background: var(--cobalt); color: var(--ice);
  transition: filter 0.15s, border-color 0.15s, color 0.15s, background 0.15s;
}
.hero-ctas button:hover { filter: brightness(1.18); }
.hero-ctas button.ghost {
  background: rgba(8, 15, 30, 0.5); border-color: var(--line); color: var(--ice);
  backdrop-filter: blur(8px);
}
.hero-ctas button.ghost:hover { border-color: var(--cobalt); filter: none; }

/* ---------- back to landing ---------- */
#btn-back {
  position: fixed; top: 92px; left: 32px; z-index: 6;
  display: flex; align-items: center;
  padding: 8px 12px;
  background: var(--ink); border: 1px solid var(--line);
  color: var(--slate); font-size: 9.5px; letter-spacing: 0.18em;
  cursor: pointer; backdrop-filter: blur(10px);
  transition: color 0.15s, border-color 0.15s;
}
#btn-back:hover { color: var(--ice); border-color: rgba(47, 107, 255, 0.55); }
/* ---------- commit mode visibility ---------- */
body.commit #hint, body.commit #viewctl,
body.commit #panel, body.commit #tooltip { display: none; }
/* #btn-back stays visible in commit mode and doubles as Cancel */

/* ---------- commit panel ---------- */
#commit-panel {
  position: fixed; top: 50%; right: 5vw; z-index: 7;
  transform: translateY(-50%);
  width: 340px;
  background: rgba(8, 15, 30, 0.66);
  border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(16px);
  overflow: hidden;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#commit-panel.hidden { transform: translateY(calc(-50% + 12px)); }

.cp-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--slate); border-bottom: 1px solid var(--line);
}
.cp-status { display: flex; align-items: center; gap: 6px; color: #7CE38B; }
.cp-status i {
  width: 6px; height: 6px; border-radius: 50%; background: #7CE38B;
  box-shadow: 0 0 8px 1px rgba(124, 227, 139, 0.7);
}
.cp-body { padding: 16px 18px; font-size: 11px; line-height: 1.9; }
.cp-line { color: var(--ice); }
.cp-line .cp-prompt { color: #7CE38B; }
.cp-line .cp-gt { color: var(--cobalt); }
.cp-line.dim { color: var(--slate); }
.cp-line.ok { margin-top: 10px; color: var(--slate); }
.cp-line.ok b { color: #7CE38B; font-weight: 600; }

.cp-rows { margin: 12px 0 2px; }
.cp-row { display: grid; grid-template-columns: 76px 1fr; gap: 12px; }
.cp-k { color: var(--slate); }
.cp-v { color: var(--ice); }
.cp-v.blue { color: var(--cobalt); }
.cp-v.amber { color: var(--amber); }

#btn-commit-confirm {
  display: block; width: calc(100% - 36px); margin: 6px 18px 18px;
  padding: 13px 0; border-radius: 999px;
  background: var(--cobalt); border: none; color: var(--ice);
  font-size: 12px; letter-spacing: 0.06em; cursor: pointer;
  transition: filter 0.15s;
}
#btn-commit-confirm:hover { filter: brightness(1.18); }
#btn-commit-confirm.busy { opacity: 0.65; cursor: progress; filter: none; }
#btn-commit-confirm:disabled { cursor: not-allowed; }

/* Turnstile widget + consent notice inside the commit panel */
.cp-turnstile { margin: 4px 18px 0; min-height: 0; }
.cp-turnstile:empty { display: none; }
.cp-consent {
  margin: 10px 18px 4px; font-size: 9.5px; line-height: 1.6;
  color: var(--slate); letter-spacing: 0.01em;
}
.cp-consent a { color: var(--cobalt); text-decoration: underline; }

/* Honeypot: visually hidden, kept focusable-out for bots */
.hp-field {
  position: absolute !important; left: -9999px !important; top: auto !important;
  width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* ---------- device HUD pin ---------- */
.device-pin { pointer-events: none; }
.device-pin .dp-inner {
  display: flex; flex-direction: column; align-items: center;
  transform: translateY(-50%);
}
.dp-card {
  position: relative;
  width: 92px; height: 92px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(47,107,255,0.22), rgba(8,15,30,0.55));
  border: 1.5px solid rgba(90, 150, 255, 0.9);
  box-shadow: 0 0 26px 4px rgba(47, 107, 255, 0.35),
              inset 0 0 22px rgba(47, 107, 255, 0.25);
  backdrop-filter: blur(6px);
  animation: dp-breathe 2.6s ease-in-out infinite;
}
/* HUD corner ticks */
.dp-card::before, .dp-card::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  border: 1.5px solid rgba(160, 200, 255, 0.9);
}
.dp-card::before { top: -7px; left: -7px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.dp-card::after  { bottom: -7px; right: -7px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.dp-card svg { width: 46px; height: 46px; stroke: #BFDBFF; fill: none;
  stroke-width: 1.6; filter: drop-shadow(0 0 6px rgba(120, 170, 255, 0.8)); }
.dp-stem { width: 1px; height: 46px;
  background: linear-gradient(rgba(120,170,255,0.9), rgba(120,170,255,0.15)); }
.dp-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 12px 3px rgba(200, 225, 255, 0.8); }

@keyframes dp-breathe {
  0%, 100% { box-shadow: 0 0 26px 4px rgba(47,107,255,0.35), inset 0 0 22px rgba(47,107,255,0.25); }
  50%      { box-shadow: 0 0 40px 8px rgba(47,107,255,0.5),  inset 0 0 26px rgba(47,107,255,0.35); }
}

/* ---------- hero email variant ---------- */
.hero-email { display: none; margin-top: 38px; pointer-events: auto;
  padding: 18px 20px; border-radius: 16px;
  background: rgba(8, 15, 30, 0.55); border: 1px solid var(--line);
  backdrop-filter: blur(12px); }
#hero.post-commit .hero-ctas { display: none; }
#hero.post-commit .hero-email { display: block; }
.he-label { text-align: left; font-size: 10px; letter-spacing: 0.18em;
  color: var(--slate); margin-bottom: 12px; }
#hero-email-form { display: flex; gap: 10px; }
#hero-email-form input {
  width: 240px; padding: 11px 14px; border-radius: 999px;
  background: rgba(4, 7, 15, 0.6); border: 1px solid var(--line);
  color: var(--ice); font-size: 11px; outline: none;
}
#hero-email-form input:focus { border-color: var(--cobalt); }
#hero-email-form button {
  padding: 11px 20px; border-radius: 999px; border: none;
  background: var(--ice); color: var(--void);
  font-size: 10.5px; letter-spacing: 0.08em; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) { .dp-card { animation: none; } }
.hero-stat.neon {
  color: #fff;
  animation: neon-breathe 2.8s ease-in-out infinite;
}
@keyframes neon-breathe {
  0%, 100% {
    text-shadow:
      0 0 6px  rgba(230, 241, 255, 0.7),
      0 0 22px rgba(47, 107, 255, 0.55),
      0 0 60px rgba(47, 107, 255, 0.3);
  }
  50% {
    text-shadow:
      0 0 10px rgba(230, 241, 255, 0.95),
      0 0 34px rgba(47, 107, 255, 0.85),
      0 0 90px rgba(47, 107, 255, 0.5);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hero-stat.neon { animation: none; }
}
.hero-ctas.cta-fade {
  animation: cta-fade 1.4s ease both;
}
@keyframes cta-fade {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-ctas.cta-fade { animation: none; }
}

/* ---------- mode visibility ----------
   body.landing = hero view; without it = explore view */
body.landing #viewctl,
body.landing #btn-back,
body.landing #hint,
body.landing #panel,
body.landing #tooltip { display: none; }
/* #hero is hidden via the .hidden class so its fade transition can play */

@media (max-width: 720px) {
  #hero { padding-bottom: 10vh; padding-left: 20px; padding-right: 20px; }
  .hero-ctas { flex-direction: column; width: 100%; max-width: 320px; }
  #btn-back { top: auto; bottom: 64px; left: 12px; }
}
