/* ASMODEVS palette and type (same base as asmodevs-alchemy) */

@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/chakra-petch-400.woff2") format("woff2");
}

@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/chakra-petch-600.woff2") format("woff2");
}

:root {
  --bg: #070405;
  --panel: rgba(16, 9, 10, 0.9);
  --line: #2a1416;
  --line-strong: #4a2226;
  --text: #e8d4d0;
  --text-muted: #8e6f6b;
  --red: #ff4034;
  --red-deep: #b00e16;
  --ghost-dark: #6c060e;
  --ghost-pink: #ff3460;
  /* Cut corners, like the demo's buttons */
  --cut: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  --cut-sm: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
}

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

::selection { background: var(--red-deep); color: var(--text); }

* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }

button { font: inherit; }

/* Scene */

.scene {
  position: fixed;
  inset: 0;
}

.scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.scene-labels { position: absolute; inset: 0; pointer-events: none; }

.body-label {
  margin-bottom: 4px;
  padding: 1px 6px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
}

.body-label:hover, .body-label.is-focused { color: var(--text); background: rgba(16, 9, 10, 0.75); }
.body-label.is-focused { border-left-color: var(--c); }

.constellation-label {
  color: rgba(255, 110, 100, 0.6);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.star-label {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: -4px; /* Centres the marker, not the label's edge, on the star. */
  padding: 0 5px 0 0;
  border: 0;
  background: transparent;
  color: rgba(232, 212, 208, 0.85);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
}
/* Star colour stays physical (B−V); the ring is a diamond, like the demo's slider thumb */
.star-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border: 1px solid var(--c);
  transform: rotate(45deg);
  box-shadow: 0 0 4px var(--c);
}
.star-label:hover { color: var(--text); }

/* Panels */

.panel {
  position: fixed;
  left: 16px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--red-deep);
  border-radius: 0;
  backdrop-filter: blur(8px);
  z-index: 10;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* The diamond from the demo's slider thumb */
.panel-title::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--red);
  transform: rotate(45deg);
}

/* Cut corners (--cut-sm) with the border closed across them: a gradient draws each diagonal in the border colour,
   --edge, so states change --edge (and --fill for the background) rather than border-color and background. */
.panel button {
  --edge: var(--line-strong);
  --fill: transparent;
  padding: 3px 9px;
  border: 1px solid var(--edge);
  border-radius: 0;
  background:
    linear-gradient(to bottom right, transparent 50%, var(--edge) 50%, var(--edge) calc(50% + 1px), transparent calc(50% + 1px))
      top left / 5px 5px no-repeat border-box,
    linear-gradient(to top left, transparent 50%, var(--edge) 50%, var(--edge) calc(50% + 1px), transparent calc(50% + 1px))
      bottom right / 5px 5px no-repeat border-box,
    var(--fill);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  clip-path: var(--cut-sm);
}
.panel button:hover { --edge: var(--red); color: var(--text); }
.panel button:active { transform: translateY(1px); }

/* Collapsible panels (js/panel.js): the header stays, the body hides */

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.panel.is-collapsed { width: auto; }
.panel.is-collapsed .panel-body { display: none; }

.panel .panel-toggle {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  clip-path: none;
  background: var(--fill); /* Square: no diagonals. */
}
.panel .panel-toggle:hover { --edge: var(--red-deep); --fill: var(--red-deep); }

/* Bodies panel */

/* Above the time panel (its height, --time-height, is set from index.html), with its list scrolling and the header kept. */
.bodies {
  top: 16px;
  width: min(240px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 16px - var(--time-height, 0px) - 16px - 12px);
}
.bodies .panel-body { min-height: 0; overflow-y: auto; }

.bodies-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.bodies-list button {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bodies-list button::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--c);
  transform: rotate(45deg);
}
.bodies-list button.is-active { --edge: var(--c); --fill: rgba(176, 14, 22, 0.12); color: var(--text); }

.moons { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.moons[hidden] { display: none; }
.moons-title { margin: 0; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }

.sky-toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.panel .sky-toggles button[aria-pressed="true"] { --edge: var(--red); --fill: rgba(255, 64, 52, 0.14); color: var(--text); }

.credits { margin: 8px 0 0; color: var(--text-muted); font-size: 10.5px; }
.credits a { color: inherit; text-decoration-color: var(--red-deep); }
.credits a:hover { color: var(--red); }

/* Info panel */

.info {
  top: 16px;
  right: 16px;
  left: auto;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 12px 14px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.info[hidden] { display: none; }

.info-header { display: flex; align-items: flex-start; gap: 6px; }
.info-header > .info-dot { margin-right: 4px; }
.info-header > div { min-width: 0; }
.info-header > .panel-toggle { margin-left: auto; }
.info-symbol {
  flex: none;
  width: 30px;
  height: 30px;
  margin: 5px 8px 0 8px;
  color: var(--c);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.info-dot { flex: none; width: 10px; height: 10px; margin: 6px 2px 0; background: var(--c); transform: rotate(45deg); }
.info-name { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.06em; }
.info-kind { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }

.info-section {
  margin: 12px 0 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.info-rows { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 12px; }
.info-rows dt { color: var(--text-muted); }
.info-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.info-text { margin: 0; font-size: 12px; line-height: 1.45; }
.info-source { margin: 12px 0 0; color: var(--text-muted); font-size: 10.5px; }
.info-source a { color: inherit; text-decoration-color: var(--red-deep); }
.info-source a:hover { color: var(--red); }

.info-composition { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 12px; }
.info-composition li { display: grid; grid-template-columns: 34px 1fr 52px; align-items: center; gap: 8px; }
.info-gas { color: var(--text); }
.info-bar { height: 6px; background: var(--line); overflow: hidden; }
.info-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--red-deep), var(--red)); }
.info-pct { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Time panel */

.time { bottom: 16px; width: min(290px, calc(100vw - 32px)); }

.time-date { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; }
/* Slot as wide as "0", the widest digit */
.time-digit { display: inline-block; width: calc(1ch + 0.04em); text-align: center; }

.time-controls { display: flex; gap: 6px; margin: 8px 0 4px; }
.time-controls button:first-child, .time-controls button:nth-child(3) { width: 30px; }

/* Pause / Play is the main action: filled red, like the demo's buttons */
.panel #time-pause { --edge: var(--red); --fill: var(--red); color: var(--bg); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.panel #time-pause:hover { --edge: #ff5a4f; --fill: #ff5a4f; }

.time-speed { color: var(--text-muted); font-size: 12px; }

.help {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.help dt { color: var(--text-muted); white-space: nowrap; }
.help dd { margin: 0; color: var(--text); }

.help kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 10px;
}

/* Brand: ASMODEVS logo with the demo's ghost glitch */

.brand {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  z-index: 10;
}

.brand-logo { display: block; width: 64px; height: auto; }
.brand:hover .brand-logo, .brand:focus-visible .brand-logo { animation: brand-glitch-burst 0.42s steps(1, end) 1; }

.brand-text { display: grid; gap: 2px; line-height: 1; }
.brand-name { color: var(--text); font-size: 15px; font-weight: 600; letter-spacing: 0.24em; }
.brand:hover .brand-by { color: var(--red); }

/* Only on hover, so it doesn't distract. Ghosts sit left (maroon) and right (pink), as in the demo's glitch stack */
@keyframes brand-glitch-burst {
  0%   { filter: drop-shadow(-3px 0 var(--ghost-dark)) drop-shadow(3px 0 var(--ghost-pink)); transform: translateX(2px); }
  20%  { filter: none; transform: none; }
  35%  { filter: drop-shadow(-4px 0 var(--ghost-dark)) drop-shadow(2px 0 var(--ghost-pink)); transform: translateX(-3px) skewX(-8deg); }
  60%  { filter: drop-shadow(-2px 0 var(--ghost-dark)) drop-shadow(4px 0 var(--ghost-pink)); transform: translateX(1px); }
  80%, 100% { filter: none; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .brand:hover .brand-logo, .brand:focus-visible .brand-logo { animation: none; }
}

/* No room next to the time panel on narrow screens */
@media (max-width: 760px) {
  .brand { display: none; }
}
