/* foshserver — Infrastructure Atlas
   Deliberately single-theme: this page is a dark technical instrument, not a
   document. Every colour is painted explicitly so it holds on any host ground. */

:root {
  --ground:   #080b10;
  --surface:  #0f141c;
  --raised:   #161d27;
  --line:     #232c39;
  --line-hi:  #33404f;

  --text:     #e4eaf2;
  --muted:    #8794a6;
  --faint:    #5d6878;

  --cyan:     #45d9e8;
  --cyan-dim: #1d8d9d;
  --cyan-ghost: rgba(69, 217, 232, 0.11);

  --amber:    #f2a950;
  --amber-ghost: rgba(242, 169, 80, 0.12);

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, Segoe UI, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --topbar-h: 60px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--cyan);
  color: var(--ground);
  padding: 10px 16px;
  font: 600 14px/1 var(--body);
}
.skip:focus { left: 8px; top: 8px; }

/* ---------- top bar ---------- */

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(12px, 3vw, 28px);
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0b1017, var(--surface));
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 10px;
  height: 26px;
  flex: none;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--cyan-dim) 60%, var(--amber));
  box-shadow: 0 0 14px rgba(69, 217, 232, 0.45);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }

.brand-text strong {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar { display: flex; gap: 8px; flex: none; }

.tool {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--raised);
  border: 1px solid var(--line-hi);
  color: var(--muted);
  border-radius: 6px;
  padding: 8px 13px;
  font: 500 12.5px/1 var(--body);
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.tool:hover { color: var(--text); border-color: var(--faint); }
.tool[aria-pressed="true"] {
  color: var(--cyan);
  border-color: var(--cyan-dim);
  background: var(--cyan-ghost);
}

.tool-key {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 2px 4px;
  line-height: 1;
}
.tool[aria-pressed="true"] .tool-key { color: var(--cyan); border-color: var(--cyan-dim); }

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

main {
  flex: 1 1 auto;
  position: relative;
  min-height: 62svh;
  display: flex;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background:
    radial-gradient(120% 90% at 50% 15%, #101825 0%, var(--ground) 62%);
  touch-action: none;
}

#scene { display: block; width: 100%; height: 100%; cursor: grab; }
#scene.grabbing { cursor: grabbing; }
#scene.pickable { cursor: pointer; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--faint);
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity .5s var(--ease);
  text-align: center;
  padding: 0 12px;
}
.hint.gone { opacity: 0; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  justify-items: center;
  background: var(--ground);
  z-index: 5;
  transition: opacity .5s var(--ease);
}
.loading.gone { opacity: 0; pointer-events: none; }
.loading p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.loading-bar {
  width: 148px; height: 2px;
  background: var(--line);
  overflow: hidden;
  border-radius: 2px;
}
.loading-bar i {
  display: block; width: 40%; height: 100%;
  background: var(--cyan);
  animation: slide 1.1s var(--ease) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.noscript {
  position: absolute;
  inset: auto 16px 16px 16px;
  background: var(--raised);
  border: 1px solid var(--amber);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
}

/* ---------- floating labels ---------- */

.labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.labels.hidden { display: none; }

.lbl {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(8, 11, 16, 0.82);
  border: 1px solid var(--line-hi);
  border-left: 2px solid var(--cyan);
  border-radius: 3px;
  padding: 4px 8px;
  white-space: nowrap;
  transition: opacity .2s var(--ease);
}
.lbl.amber { border-left-color: var(--amber); }
.lbl.dim { opacity: 0.32; }

/* ---------- info panel ---------- */

.panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(400px, 82vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform .42s var(--ease);
  z-index: 12;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: -20px 0 46px rgba(0, 0, 0, 0.5);
}
.panel.open { transform: translateX(0); }

.panel-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 10px 10px 0 0;
  z-index: 2;
  appearance: none;
  background: var(--raised);
  border: 1px solid var(--line-hi);
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.panel-close:hover { color: var(--text); border-color: var(--faint); }

.panel-body { padding: 22px clamp(18px, 4vw, 26px) 34px; }

.p-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 10px;
}
.p-label.amber { color: var(--amber); }

.p-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(21px, 4.4vw, 26px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
  text-wrap: balance;
}

.p-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
}

.p-status {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid var(--amber);
  background: var(--amber-ghost);
  border-radius: 3px;
  padding: 3px 7px;
  margin: 0 0 14px;
}

.p-facts { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.p-facts li {
  background: var(--raised);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.p-desc { font-size: 14.5px; line-height: 1.62; color: #c3ccd9; margin: 0 0 18px; }
.p-desc:last-child { margin-bottom: 0; }

/* HBA current -> incoming timeline */
.p-swap {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin: 0 0 20px;
}
.p-swap-row { padding: 13px 14px; background: var(--raised); }
.p-swap-row + .p-swap-row { border-top: 1px solid var(--line); }
.p-swap-row.next { background: linear-gradient(90deg, var(--amber-ghost), var(--raised) 70%); }
.p-swap-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  display: block;
  margin-bottom: 5px;
}
.p-swap-row.next .p-swap-tag { color: var(--amber); }
.p-swap-name { font-weight: 600; font-size: 14px; display: block; margin-bottom: 3px; }
.p-swap-spec { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ---------- component rail ---------- */

.rail-wrap {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 18px clamp(12px, 3vw, 28px) 22px;
}

.rail-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 12px;
}

.rail { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--raised);
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  color: var(--muted);
  padding: 8px 12px;
  font: 500 12.5px/1 var(--body);
  cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.active { color: var(--cyan); border-color: var(--cyan-dim); background: var(--cyan-ghost); }
.chip.amber.active { color: var(--amber); border-color: var(--amber); background: var(--amber-ghost); }

.chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan-dim);
  flex: none;
}
.chip.amber .chip-dot { background: var(--amber); }
.chip.active .chip-dot { box-shadow: 0 0 8px currentColor; background: currentColor; }

/* ---------- footer ---------- */

.foot {
  flex: none;
  padding: 16px clamp(12px, 3vw, 28px) calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--ground);
}
.foot-note {
  margin: 0 0 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.foot-meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.04em;
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .topbar { height: auto; padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 10px; flex-wrap: wrap; }
  .toolbar { width: 100%; }
  .tool { flex: 1 1 auto; justify-content: center; padding: 9px 8px; font-size: 12px; }
  .tool-key { display: none; }

  main { min-height: 56svh; }

  /* panel becomes a bottom sheet */
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 74svh;
    border-left: none;
    border-top: 1px solid var(--line-hi);
    border-radius: 14px 14px 0 0;
    transform: translateY(102%);
    box-shadow: 0 -18px 46px rgba(0, 0, 0, 0.6);
  }
  .panel.open { transform: translateY(0); }

  .hint { font-size: 9.5px; bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
