/* Star Atlas — cinematic dark panel chrome (site tokens) */
.atlas-page {
  --atlas-panel-w: min(22rem, 92vw);
  --atlas-accent: var(--accent, #c9a36a);
  --atlas-bg: var(--bg, #0e0d0b);
  --atlas-raised: var(--bg-raised, #161512);
  --atlas-ink: var(--ink, #ece7dc);
  --atlas-muted: var(--ink-muted, #9a9488);
  --atlas-faint: var(--ink-faint, #6a655c);
  --atlas-rule: var(--rule, #2c2a24);
}

.atlas-page main#text {
  padding-block: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.atlas-shell {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100dvh - 8.5rem);
  background: #050504;
  border-top: 1px solid var(--atlas-rule);
  border-bottom: 1px solid var(--atlas-rule);
}

@media (min-width: 900px) {
  .atlas-shell {
    grid-template-columns: 1fr var(--atlas-panel-w);
  }
}

.atlas-stage {
  position: relative;
  min-height: 52vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, #12101a 0%, #050504 70%);
  overflow: hidden;
}

#atlas-canvas-host {
  position: absolute;
  inset: 0;
}

#atlas-canvas-host canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  cursor: grab;
}

#atlas-canvas-host canvas:active {
  cursor: grabbing;
}

.atlas-hud {
  position: absolute;
  z-index: 2;
  left: 0.85rem;
  top: 0.75rem;
  right: 0.85rem;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--atlas-faint);
}

.atlas-hud strong {
  color: var(--atlas-accent);
  font-weight: 500;
}

.atlas-hud .hint {
  max-width: 18rem;
  color: var(--atlas-muted);
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 0.78rem;
}

#atlas-panel {
  background: linear-gradient(180deg, #14120e 0%, var(--atlas-bg) 40%);
  border-left: 1px solid var(--atlas-rule);
  color: var(--atlas-ink);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
}

@media (max-width: 899px) {
  #atlas-panel {
    border-left: 0;
    border-top: 1px solid var(--atlas-rule);
    max-height: 46vh;
  }
}

.atlas-panel-scroll {
  overflow: auto;
  padding: 1.1rem 1.15rem 1.4rem;
  flex: 1;
  overscroll-behavior: contain;
}

.atlas-panel-kicker {
  color: var(--atlas-faint);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.68rem;
  margin: 0 0 0.55rem;
}

#atlas-panel h1,
#atlas-panel .panel-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 0.35rem;
  color: var(--atlas-ink);
}

.panel-type {
  color: var(--atlas-muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.85rem;
}

.panel-swatch {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
  box-shadow: 0 0 0 1px #ffffff22;
}

.panel-blurb {
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--atlas-ink);
  margin: 0 0 1rem;
  max-width: none;
}

.panel-section {
  margin: 1rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--atlas-rule);
}

.panel-section h2 {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--atlas-faint);
  margin: 0 0 0.55rem;
}

.panel-facts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.panel-facts li {
  margin: 0 0 0.7rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--atlas-muted);
}

.panel-facts .cite {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--atlas-faint);
}

.panel-facts .uncertain {
  color: var(--atlas-accent);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 0.35rem;
}

.panel-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.panel-links a {
  display: block;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--atlas-rule);
  color: var(--atlas-accent);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.panel-links a:hover {
  border-color: var(--atlas-accent);
  background: #c9a36a14;
  color: var(--accent-hover, #e0c48a);
}

.panel-empty {
  color: var(--atlas-muted);
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0.5rem 0 0;
}

/* Floating Locations on stage (left) */
.atlas-stage .atlas-locations-float {
  position: absolute;
  z-index: 3;
  left: 0.75rem;
  top: 2.65rem; /* under HUD */
  bottom: 10px; /* 10px from stage bottom */
  width: min(14.5rem, calc(100% - 1.5rem));
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--atlas-rule) 80%, transparent);
  border-radius: 0.45rem;
  background: rgba(10, 9, 8, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  overflow: hidden;
  display: block;
  max-height: none;
  pointer-events: auto;
}
.atlas-locations-float > summary {
  position: relative;
  z-index: 2;
  display: block;
  background: rgba(10, 9, 8, 0.5);
  list-style: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--atlas-faint);
  padding: 0.65rem 0.85rem 0.5rem;
  font-weight: 500;
  user-select: none;
}
.atlas-locations-float > summary::-webkit-details-marker { display: none; }
.atlas-locations-float > summary::after {
  content: " ▾";
  float: right;
  opacity: 0.7;
}
.atlas-locations-float:not([open]) > summary::after { content: " ▸"; }
.atlas-locations-scroll {
  position: absolute;
  left: 0;
  right: 0;
  top: 2.2rem; /* below summary */
  bottom: 0;
  overflow-x: hidden;
  overflow-y: scroll; /* always show scroll affordance where supported */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  pointer-events: auto;
}
.atlas-locations-float:not([open]) .atlas-locations-scroll {
  display: none;
}
.atlas-locations-float #atlas-node-list {
  position: static;
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
  margin: 0;
  padding: 0 0.45rem 0.75rem;
  list-style: none;
  display: grid;
  gap: 0.2rem;
}
/* Mobile: bottom sheet style */
@media (max-width: 899px) {
  .atlas-stage .atlas-locations-float {
    left: 0.5rem;
    right: auto;
    top: 2.5rem;
    bottom: 10px;
    width: min(14.5rem, calc(100% - 1rem));
    max-height: none;
  }
  .atlas-locations-float #atlas-node-list {
    max-height: none !important;
  }
}
/* Embed: slightly smaller */
.atlas-shell--embed .atlas-locations-float {
  top: 2.4rem;
  bottom: 10px;
  width: min(12.5rem, calc(100% - 1.2rem));
  max-height: none;
  font-size: 0.95em;
}
.atlas-shell--embed .atlas-locations-float #atlas-node-list {
  max-height: none !important;
}
/* Reduced / no-webgl: keep usable */
.atlas-reduced .atlas-locations-float,
.atlas-no-webgl .atlas-locations-float,
[data-atlas-root].atlas-reduced .atlas-locations-float,
[data-atlas-root].atlas-no-webgl .atlas-locations-float {
  position: relative;
  left: auto; top: auto; bottom: auto;
  width: min(22rem, 100%);
  max-height: none;
  margin: 0.75rem var(--gutter, 1.5rem);
}

#atlas-node-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.2rem;
  max-height: min(62vh, 32rem);
  overflow: auto;
}

#atlas-node-list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--atlas-muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  letter-spacing: 0.02em;
}

#atlas-node-list button:hover,
#atlas-node-list button[aria-current="true"] {
  color: var(--atlas-ink);
  border-color: var(--atlas-rule);
  background: #c9a36a10;
}

#atlas-node-list button[aria-current="true"] {
  border-color: var(--atlas-accent);
  color: var(--atlas-accent);
}

#atlas-node-list .dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* Reduced-motion / no-WebGL fallback */
#atlas-fallback {
  display: none;
  padding: 1.25rem var(--gutter, 1.5rem) 2rem;
  max-width: 58rem;
  margin-inline: auto;
}

.atlas-reduced #atlas-canvas-host,
.atlas-no-webgl #atlas-canvas-host,
.atlas-reduced .atlas-hud .hint-3d {
  display: none !important;
}

.atlas-reduced #atlas-fallback,
.atlas-no-webgl #atlas-fallback {
  display: block;
}

.atlas-reduced .atlas-shell,
.atlas-no-webgl .atlas-shell {
  grid-template-columns: 1fr;
  min-height: 0;
}

.atlas-reduced .atlas-stage,
.atlas-no-webgl .atlas-stage {
  min-height: 0;
  height: auto;
  background: transparent;
}

.atlas-reduced #atlas-panel,
.atlas-no-webgl #atlas-panel {
  max-height: none;
  border-top: 0;
}

.atlas-fallback-svg {
  width: 100%;
  max-width: 40rem;
  margin: 0 0 1.25rem;
  border: 1px solid var(--atlas-rule);
  background: #0a0908;
}

.atlas-fallback-svg text {
  fill: #9a9488;
  font-family: var(--sans);
  font-size: 10px;
}

.atlas-fallback-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.atlas-fallback-list button {
  width: 100%;
  text-align: left;
  background: var(--atlas-raised);
  border: 1px solid var(--atlas-rule);
  color: var(--atlas-ink);
  font-family: var(--sans);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.atlas-fallback-list button:hover,
.atlas-fallback-list button[aria-current="true"] {
  border-color: var(--atlas-accent);
  color: var(--atlas-accent);
}

.atlas-spoiler-note {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--atlas-faint);
  margin: 0.85rem 0 0;
  letter-spacing: 0.02em;
}

.atlas-page .colophon {
  margin-top: 0;
}

@media (prefers-reduced-motion: reduce) {
  .atlas-shell,
  #atlas-panel,
  .panel-links a {
    transition: none !important;
  }
}

/* ---------- Dual-mode: CSS vars on full page OR embed root ---------- */
.atlas-page,
[data-atlas-root],
.home-atlas-embed {
  --atlas-panel-w: min(22rem, 92vw);
  --atlas-accent: var(--accent, #c9a36a);
  --atlas-bg: var(--bg, #0e0d0b);
  --atlas-raised: var(--bg-raised, #161512);
  --atlas-ink: var(--ink, #ece7dc);
  --atlas-muted: var(--ink-muted, #9a9488);
  --atlas-faint: var(--ink-faint, #6a655c);
  --atlas-rule: var(--rule, #2c2a24);
}

/* ---------- Homepage embed ---------- */
.home-atlas-embed {
  display: block;
  width: 100%;
  margin: 0;
  --atlas-panel-w: min(18rem, 92vw);
}

body:not(.atlas-page) .home-atlas-embed {
  margin: 0;
}

.atlas-shell--embed {
  /* Locked height — selecting worlds must not expand the embed */
  --atlas-embed-h: calc(min(64vh, 680px) + 200px);
  height: var(--atlas-embed-h);
  min-height: var(--atlas-embed-h);
  max-height: var(--atlas-embed-h);
  flex: none;
  border-top: 0;
  border-bottom: 1px solid var(--atlas-rule);
  overflow: hidden;
  align-content: stretch;
}

/* Laptop short viewports (MBA 13" etc.): always 600px — do not let a tighter
   max-height band override this (browser chrome often makes innerHeight ≤860). */
@media (max-height: 1050px) and (min-width: 1024px) and (max-width: 1680px) {
  .atlas-shell--embed {
    --atlas-embed-h: 600px !important;
    height: 600px !important;
    min-height: 600px !important;
    max-height: 600px !important;
  }
}


.atlas-shell--embed > * {
  min-height: 0;
}

.atlas-shell--embed .atlas-stage {
  min-height: 0;
  height: auto;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.atlas-shell--embed #atlas-canvas-host {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.atlas-shell--embed #atlas-panel {
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.atlas-shell--embed .atlas-panel-scroll {
  overflow: auto;
  overscroll-behavior: contain;
}

/* Tablet / narrow: -100px vs desktop */
@media (max-width: 1023px) {
  .atlas-shell--embed {
    --atlas-embed-h: calc(min(64vh, 680px) + 0px); /* was +100; -100 more */
    height: var(--atlas-embed-h);
    min-height: var(--atlas-embed-h);
    max-height: var(--atlas-embed-h);
  }
}

/* Phone / short viewport: much shorter so title+cards peek in */
@media (max-width: 599px), (max-height: 760px) and (max-width: 1023px) {
  .atlas-shell--embed {
    --atlas-embed-h: max(220px, calc(min(42dvh, 380px) - 100px)); /* -100 more; floor 220 */
    height: var(--atlas-embed-h);
    min-height: var(--atlas-embed-h);
    max-height: var(--atlas-embed-h);
  }
}

@media (max-width: 899px) {
  .atlas-shell--embed {
    grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-columns: 1fr;
  }
  .atlas-shell--embed .atlas-stage {
    min-height: 0;
  }
  .atlas-shell--embed #atlas-panel {
    border-left: 0;
    border-top: 1px solid var(--atlas-rule);
    max-height: none;
    min-height: 0;
  }
}

.atlas-hud .atlas-full-link {
  pointer-events: auto;
  margin-left: 0.55rem;
  color: var(--atlas-accent);
  text-decoration: none;
  letter-spacing: 0.06em;
  border-bottom: 1px solid transparent;
}

.atlas-hud .atlas-full-link:hover {
  border-bottom-color: var(--atlas-accent);
  color: var(--accent-hover, #e0c48a);
}

.atlas-hud .atlas-seo-line {
  flex-basis: 100%;
  max-width: 36rem;
  margin-top: 0.15rem;
  color: var(--atlas-muted);
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 0.78rem;
  pointer-events: none;
}

.atlas-embed-cta {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 8px 0.85rem 20px; /* 20px to stage bottom */
  background: linear-gradient(180deg, transparent 0%, #050504ee 45%);
  pointer-events: none;
}

.atlas-embed-cta .cta {
  pointer-events: auto;
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0e0d0b;
  background: var(--atlas-accent);
  border: 1px solid var(--atlas-accent);
  padding: 0.55rem 1rem;
  text-decoration: none;
}

.atlas-embed-cta .cta:hover {
  background: var(--accent-hover, #e0c48a);
  border-color: var(--accent-hover, #e0c48a);
}

/* Reduced / no-webgl: also match when classes live on embed root */
[data-atlas-root].atlas-reduced #atlas-canvas-host,
[data-atlas-root].atlas-no-webgl #atlas-canvas-host,
[data-atlas-root].atlas-reduced .atlas-hud .hint-3d,
[data-atlas-root].atlas-no-webgl .atlas-hud .hint-3d {
  display: none !important;
}

[data-atlas-root].atlas-reduced #atlas-fallback,
[data-atlas-root].atlas-no-webgl #atlas-fallback {
  display: block;
}

[data-atlas-root].atlas-reduced .atlas-shell,
[data-atlas-root].atlas-no-webgl .atlas-shell {
  grid-template-columns: 1fr;
  min-height: 0;
  max-height: none;
}

[data-atlas-root].atlas-reduced .atlas-stage,
[data-atlas-root].atlas-no-webgl .atlas-stage {
  min-height: 0;
  height: auto;
  background: transparent;
}

[data-atlas-root].atlas-reduced #atlas-panel,
[data-atlas-root].atlas-no-webgl #atlas-panel {
  max-height: none;
  border-top: 0;
}

[data-atlas-root].atlas-reduced .atlas-embed-cta,
[data-atlas-root].atlas-no-webgl .atlas-embed-cta {
  position: static;
  background: transparent;
  padding: 0.75rem var(--gutter, 1.5rem) 1rem;
}
