/**
 * GLO-1.0 — Living Observatory habitat layout
 * Spatial layers per Genesis Spatial Constitution Article II
 */
:root {
  --glo-silence-ratio: 0.55;
  --glo-motion-weight: 0.3;
  --glo-center-warmth: 0.85;
  --glo-env-glow: 0.1;
  --glo-type-greeting: clamp(1.5rem, 4vw, 2.25rem);
  --glo-type-orientation: var(--text-base);
  --glo-space-center: var(--space-8);
  --glo-space-near: var(--space-6);
}

/* Habitat root — not a dashboard grid */
#glo-observatory {
  position: relative;
  min-height: min(72vh, 720px);
  display: grid;
  grid-template-areas:
    "sky sky sky"
    ". center ."
    "near near near"
    "mission mission mission"
    "depth depth depth";
  grid-template-rows: 1fr auto auto auto 0.6fr;
  grid-template-columns: 1fr minmax(280px, 480px) 1fr;
  gap: var(--glo-space-near);
  padding: var(--space-6) var(--space-4);
  isolation: isolate;
}

.glo-layer {
  position: relative;
  pointer-events: none;
}
.glo-layer > * { pointer-events: auto; }

/* Center — Human sovereignty (Article III) */
#glo-center {
  grid-area: center;
  text-align: center;
  align-self: center;
  justify-self: center;
  padding: var(--glo-space-center);
  z-index: 2;
}
.glo-human-greeting {
  font-size: var(--glo-type-greeting);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}
.glo-human-orientation {
  font-size: var(--glo-type-orientation);
  color: var(--color-muted);
  margin: 0;
  max-width: 36ch;
  margin-inline: auto;
}

/* Near Space — Iskra presence field (Article V) */
#glo-near-space {
  grid-area: near;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 120px;
  padding-bottom: var(--space-4);
}
#glo-iskra-presence {
  position: relative;
  width: 88px;
  height: 88px;
}
.glo-iskra-field {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%,
    rgba(101, 232, 255, 0.35) 0%,
    rgba(139, 92, 246, 0.15) 45%,
    transparent 70%);
  animation: glo-breathe 4.8s ease-in-out infinite;
  box-shadow: 0 0 48px rgba(101, 232, 255, calc(0.08 + var(--glo-env-glow)));
}
.glo-iskra-core {
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(101, 232, 255, 0.5), rgba(139, 92, 246, 0.2));
}
.glo-iskra-whisper {
  position: absolute;
  bottom: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  color: var(--color-muted);
  white-space: nowrap;
}

/* Intent at Near Space edge — never Center */
#glo-intent-edge {
  grid-area: near;
  align-self: end;
  justify-self: center;
  width: min(100%, 420px);
  margin-top: calc(88px + var(--space-4));
  display: flex;
  gap: var(--space-2);
  z-index: 3;
}
#glo-intent-input {
  flex: 1;
  background: rgba(12, 16, 32, 0.6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  font-family: var(--font);
  font-size: var(--text-sm);
}
#glo-intent-input:focus {
  outline: none;
  box-shadow: var(--gpui-focus-ring);
}

/* Mission Field */
#glo-mission-field {
  grid-area: mission;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.8s ease, max-height 0.8s ease;
}
#glo-observatory[data-glo-scene="home_active"] #glo-mission-field,
#glo-observatory[data-glo-scene="mission_focus"] #glo-mission-field {
  max-height: 200px;
  opacity: 1;
  min-height: 80px;
}
.glo-mission-seed {
  text-align: center;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: rgba(12, 16, 32, 0.5);
  animation: glo-emergence 1.2s ease-out;
}

/* Knowledge Sky */
#glo-knowledge-sky {
  grid-area: sky;
  min-height: 80px;
  opacity: 0.5;
  transition: opacity 0.6s ease;
}
.glo-constellation {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  padding: var(--space-2);
}
.glo-star-node {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--star-glow);
  box-shadow: 0 0 12px var(--star-glow);
  animation: glo-unfold 2s ease-out backwards;
}
.glo-star-node[data-verified="true"] { opacity: 1; }
.glo-star-node[data-verified="false"] { opacity: 0.4; }

/* Memory Depth */
#glo-memory-depth {
  grid-area: depth;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.8s ease, max-height 0.8s ease;
}
#glo-observatory[data-glo-depth="open"] #glo-memory-depth {
  max-height: 240px;
  opacity: 1;
  min-height: 100px;
}
.glo-memory-whisper {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-muted);
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  animation: glo-descent 1s ease-out;
}

/* Civilization Horizon */
#glo-horizon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(101, 232, 255, 0.08), transparent);
  opacity: 0.4;
}

/* GUX primitives */
.glo-gux-bar {
  position: fixed;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-2);
  z-index: 8000;
  padding: var(--space-2);
  background: rgba(12, 16, 32, 0.85);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  backdrop-filter: blur(12px);
}
.glo-gux-btn {
  background: transparent;
  border: none;
  color: var(--color-muted);
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-full);
}
.glo-gux-btn:hover, .glo-gux-btn:focus-visible {
  color: var(--color-primary);
  background: rgba(101, 232, 255, 0.08);
  outline: none;
}

/* Hide legacy dashboard on constitutional Home (GUIR-B002) */
#view-home.glo-active .glo-legacy-hidden,
body.gpe-wave1-home #view-home.glo-active .glo-legacy-hidden {
  display: none !important;
}

/* GUIR-B012 — Center sovereignty: Human at grid center, nothing overrides */
#glo-center {
  z-index: 10;
}
body.gpe-wave1-home #view-home.glo-active #glo-center {
  position: relative;
}
body.gpe-wave1-home #view-home.glo-active .personal-iskra-hero,
body.gpe-wave1-home #view-home.glo-active #greeting {
  pointer-events: none;
}
body.gpe-wave1-home #view-home.glo-active #btn-top-iskra {
  opacity: 0.85;
}
body.gpe-wave1-home #view-home.glo-active #glo-observatory [data-guir-state="Focused"] {
  outline: none;
}
#view-home.glo-active #glo-observatory {
  min-height: min(78vh, 760px);
}

/* Atmosphere modes */
[data-glo-atmosphere="night"] #glo-observatory {
  --glo-env-glow: 0.06;
  --glo-center-warmth: 0.6;
}
[data-glo-atmosphere="morning"] #glo-observatory {
  --glo-env-glow: 0.14;
}
[data-glo-atmosphere="guardian_protection"] #glo-observatory {
  --glo-motion-weight: 0.4;
}
[data-glo-atmosphere="offline"] #glo-observatory {
  filter: saturate(0.85);
}

/* GMA motion — no bounce, no gamification */
@keyframes glo-breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.04); opacity: 1; }
}
@keyframes glo-emergence {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes glo-descent {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes glo-unfold {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .glo-iskra-field, .glo-star-node, .glo-mission-seed, .glo-memory-whisper {
    animation: none !important;
  }
}

@media (max-width: 768px) {
  #glo-observatory {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sky"
      "center"
      "near"
      "mission"
      "depth";
    min-height: 60vh;
  }
  #glo-intent-edge { width: 100%; }
}
