/* Genesis: a star nursery. Deep space, glass, and light. */

:root {
  --space: #05010c;
  --space-2: #0b0418;
  --violet: #8a4dff;
  --violet-deep: #5b21d6;
  --magenta: #d13bff;
  --cyan: #38d6ff;
  --amber: #ffc266;
  --lavender: #b9b4ff;
  --text: #f4f1ff;
  --text-muted: rgba(244, 241, 255, 0.74);
  --glass: rgba(20, 12, 38, 0.66);
  --glass-solid: #150c26;
  --line: rgba(190, 170, 255, 0.16);
  --radius: 18px;
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--space);
  color: var(--text);
  line-height: 1.55;
  overflow: hidden; /* the canvas and panels handle everything */
  -webkit-font-smoothing: antialiased;
}

/* ---- Space ------------------------------------------------------------------------------------------------------- */

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(91, 33, 214, 0.34), transparent 62%),
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(56, 214, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 60% 50% at 60% 8%, rgba(209, 59, 255, 0.14), transparent 62%),
    linear-gradient(180deg, #080314 0%, var(--space) 60%, #02000a 100%);
}

.nebula {
  position: fixed;
  z-index: -2;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
  will-change: transform;
}
.nebula.a {
  top: -22vmax; left: -18vmax;
  background: radial-gradient(circle, rgba(138, 77, 255, 0.55), rgba(209, 59, 255, 0.18) 45%, transparent 70%);
  animation: drift-a 70s ease-in-out infinite alternate;
}
.nebula.b {
  bottom: -26vmax; right: -20vmax;
  background: radial-gradient(circle, rgba(56, 214, 255, 0.4), rgba(91, 33, 214, 0.18) 48%, transparent 70%);
  animation: drift-b 90s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate3d(9vmax, 6vmax, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-8vmax, -7vmax, 0) scale(1.06); } }

#nursery-canvas {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
  touch-action: none; /* a finger drags and pinches the nursery instead of scrolling the page */
}

/* ---- Header ------------------------------------------------------------------------------------------------------ */

header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 36px;
  z-index: 10;
  pointer-events: none; /* clicks pass through except on the controls */
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.logo-star { filter: drop-shadow(0 0 10px rgba(56, 214, 255, 0.55)); }
.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: 0.01em;
}
.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(56, 214, 255, 0.5);
  color: var(--cyan);
  background: rgba(56, 214, 255, 0.08);
}

.tools {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  pointer-events: auto;
}

.status {
  font-family: var(--sans); /* these are sentences: a plain, readable face, not the monospace */
  font-size: 0.84rem;
  color: var(--text-muted);
  max-width: 28ch;
}

/* ---- Buttons ----------------------------------------------------------------------------------------------------- */

.btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  background: rgba(24, 14, 44, 0.7);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.2s;
}
.btn:hover {
  border-color: rgba(56, 214, 255, 0.7);
  background: rgba(56, 214, 255, 0.1);
  box-shadow: 0 0 22px rgba(56, 214, 255, 0.18);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  font-weight: 600;
  border-color: transparent;
  background: linear-gradient(135deg, var(--violet-deep), var(--magenta));
  box-shadow: 0 6px 24px rgba(138, 77, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #6c33f0, #e260ff);
  box-shadow: 0 8px 32px rgba(209, 59, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.quiet:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); box-shadow: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); background: rgba(24, 14, 44, 0.7); box-shadow: none; }
.btn[aria-pressed="true"] {
  border-color: var(--cyan);
  background: rgba(56, 214, 255, 0.16);
  box-shadow: 0 0 20px rgba(56, 214, 255, 0.2);
}
a.btn { text-decoration: none; }
#signin-link[hidden], #delete-btn[hidden] { display: none; }

.hint { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.hint[hidden] { display: none; }

/* ---- Overlays and the glass card ----------------------------------------------------------------------------------- */

#question-overlay, #forcing-overlay, #settings-overlay, #holes-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(5, 1, 12, 0.55), rgba(5, 1, 12, 0.86));
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.6s ease, backdrop-filter 0.6s ease;
}
#question-overlay.hidden, #forcing-overlay.hidden, #settings-overlay.hidden, #holes-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0);
}
#forcing-overlay.hidden .card { transform: translateY(40px) scale(0.94); opacity: 0; filter: blur(6px); }
#question-overlay.hidden .card { transform: translateY(18px) scale(0.98); }

.card {
  position: relative;
  width: 100%;
  max-width: 640px;
  display: grid;
  gap: 18px;
  padding: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(140deg, rgba(138, 77, 255, 0.75), rgba(56, 214, 255, 0.28) 45%, rgba(209, 59, 255, 0.55)) border-box;
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 90px rgba(138, 77, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.05), opacity 0.5s ease, filter 0.5s ease;
}
.card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: 0.005em;
  color: var(--text);
}
.intro-card { text-align: center; max-width: 660px; margin: auto; }
.intro-card h3 {
  font-size: clamp(1.9rem, 4.6vw, 2.7rem);
  background: linear-gradient(180deg, #ffffff 30%, #cdbdff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#slide-desc { margin: -6px auto 2px; max-width: 46ch; color: var(--text-muted); font-size: 1.02rem; }

.close-btn {
  position: absolute;
  top: 14px; right: 16px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.known {
  margin: 0;
  padding-left: 14px;
  border-left: 2px solid var(--violet);
  color: var(--text-muted);
  font-size: 0.95rem;
}
.known b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lavender);
}

/* ---- Intro: the constellation of steps ---------------------------------------------------------------------------- */

.steps {
  list-style: none;
  margin: 0 auto 4px;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
}
.steps li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 92px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.steps li::before {
  content: "";
  width: 11px; height: 11px;
  border-radius: 50%;
  background: rgba(190, 170, 255, 0.28);
  box-shadow: 0 0 0 3px rgba(190, 170, 255, 0.08);
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
}
.steps li::after { /* the thread to the next star */
  content: "";
  position: absolute;
  top: 5px; left: calc(50% + 12px);
  width: calc(100% - 24px); height: 1px;
  background: linear-gradient(90deg, rgba(190, 170, 255, 0.45), rgba(190, 170, 255, 0.12));
}
.steps li:last-child::after { display: none; }
.steps li span { margin-top: 8px; }
.steps li.done::before { background: var(--violet); box-shadow: 0 0 12px rgba(138, 77, 255, 0.8); }
.steps li.current { color: var(--text); }
.steps li.current::before {
  background: #fff;
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(56, 214, 255, 0.25), 0 0 20px rgba(56, 214, 255, 0.95);
}

#slide-content { display: grid; gap: 14px; text-align: left; }
.options { display: grid; gap: 10px; }

.option {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.2s;
}
.option::before { /* a small star that wakes up on hover and when chosen */
  content: "\2726" / "";
  flex: none;
  font-size: 1rem;
  color: rgba(190, 170, 255, 0.55);
  transition: color 0.2s, text-shadow 0.2s, transform 0.3s;
}
.option:hover {
  border-color: rgba(56, 214, 255, 0.55);
  background: rgba(56, 214, 255, 0.07);
  box-shadow: 0 0 28px rgba(56, 214, 255, 0.12);
  transform: translateX(2px);
}
.option:hover::before { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); }
.option[aria-pressed="true"] {
  border-color: var(--violet);
  background: linear-gradient(90deg, rgba(138, 77, 255, 0.22), rgba(209, 59, 255, 0.08));
  box-shadow: 0 0 34px rgba(138, 77, 255, 0.28), inset 0 0 0 1px rgba(138, 77, 255, 0.4);
}
.option[aria-pressed="true"]::before { color: #fff; text-shadow: 0 0 14px var(--magenta), 0 0 4px #fff; transform: rotate(45deg) scale(1.15); }

.reroll-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.reroll::before { content: "\21BB" / ""; font-size: 1.05rem; }

.slide-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ---- Forms and chips ----------------------------------------------------------------------------------------------- */

textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: rgba(3, 0, 10, 0.5);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.25s;
}
textarea::placeholder { color: rgba(244, 241, 255, 0.5); }
textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(138, 77, 255, 0.25); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.88rem;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s;
}
.chip:hover { border-color: rgba(56, 214, 255, 0.6); background: rgba(56, 214, 255, 0.09); box-shadow: 0 0 18px rgba(56, 214, 255, 0.14); }

.exits { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions { text-align: right; }

/* ---- Focus: the controls reset the browser ring, so draw ours -------------------------------------------------------- */

.btn:focus-visible, .chip:focus-visible, .option:focus-visible, .close-btn:focus-visible,
.q-index-item:focus-visible, #slide-title:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
#slide-title:focus-visible { border-radius: 6px; outline-offset: 8px; }

/* ---- The star chart (the keyboard and screen-reader route to every star) ------------------------------------------- */

#q-index {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 15;
  width: min(340px, calc(100vw - 48px));
  max-height: 46vh;
  overflow-y: auto;
  padding: 16px 16px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(150deg, rgba(138, 77, 255, 0.55), rgba(56, 214, 255, 0.2)) border-box;
  backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(138, 77, 255, 0.5) transparent;
}
#q-index[hidden] { display: none; }
#q-index h2 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lavender);
}
#q-open-count { font-weight: 400; text-transform: none; letter-spacing: 0.02em; color: var(--text-muted); }
#build-note { margin: 0 0 10px; font-size: 0.85rem; color: var(--text-muted); }
#q-index ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#delete-btn { margin-top: 12px; }

.q-index-item {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.88rem;
  line-height: 1.35;
  transition: border-color 0.2s, background 0.2s;
}
.q-index-item::before { /* the star's own colour, repeated in the text label as well */
  content: "";
  flex: none;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}
.q-index-item[data-state="answered"]::before { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.q-index-item[data-state="parked"]::before { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.q-index-item[data-state="mystery"]::before { background: var(--lavender); box-shadow: 0 0 10px var(--lavender); }
.q-index-item:hover { border-color: rgba(56, 214, 255, 0.55); background: rgba(56, 214, 255, 0.07); }
.q-index-item .q-text { flex: 1; }
.q-index-item .q-state {
  flex: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.tooltip {
  position: fixed;
  left: 0;
  top: 0; /* placed with a transform from script, so it can follow its star without reflowing */
  z-index: 20;
  max-width: 300px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(14, 8, 28, 0.92);
  backdrop-filter: blur(10px);
  font-size: 0.86rem;
  pointer-events: none;
  transition: opacity 0.2s ease;
  will-change: transform;
}
.tooltip.hidden { opacity: 0; }

/* ---- Small screens ------------------------------------------------------------------------------------------------ */

@media (max-width: 720px) {
  header { padding: 14px 16px; }
  .wordmark { font-size: 1.4rem; }
  .status { max-width: none; }
  .card { padding: 24px 20px; gap: 16px; }
  #q-index { left: 12px; right: 12px; bottom: 12px; width: auto; max-height: 38vh; }
  .steps li { width: 76px; }
  .slide-actions { justify-content: center; }
}

/* ---- Reduced motion: nothing drifts, glows pulse or slides ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  #forcing-overlay.hidden .card, #question-overlay.hidden .card { transform: none; filter: none; }
  .option:hover { transform: none; }
}

/* ---- Settings (admins only) ----------------------------------------------------------------------------------------- */
.settings-card { max-width: min(1180px, 96vw); gap: 14px; }
/* Use the room there is: sections sit side by side on a wide screen and stack on a narrow one. */
#settings-body:not([hidden]) { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 8px 36px; align-items: start; }
#settings-body > section { min-width: 0; }
.settings-card h3 { font-size: 1.6rem; }
.settings-card h4 { margin: 18px 0 6px; font-family: var(--display); font-size: 1.15rem; color: var(--text); }
.settings-card section { display: grid; gap: 8px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.settings-card label { color: var(--text-muted); font-size: 0.92rem; margin-top: 6px; }
.settings-card select, .settings-card input {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22);
}
.settings-card select option { color: #14091f; }
.settings-card .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.settings-card table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.settings-card th, .settings-card td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.settings-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.settings-card li .btn { min-height: 36px; padding: 4px 12px; margin-left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Moving around the nursery ------------------------------------------------------------------------------------- */
#view-controls { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 8px; }
#view-controls .btn { min-height: 44px; min-width: 44px; padding: 8px 14px; }
.view-hint { color: var(--text-muted); font-size: 0.8rem; margin-right: 6px; }
@media (max-width: 720px) { .view-hint { display: none; } }

/* ---- Black Hole scan list ------------------------------------------------------------------------------------------------ */
.hole-card { display: grid; gap: 8px; padding: 16px 18px; margin: 10px 0; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.hole-card h4 { margin: 0; font-family: var(--display); font-size: 1.1rem; color: var(--text); }
.hole-card p { margin: 0; }
.hole-card input { min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22); }
.hole-where { display: grid; gap: 6px; }
.hole-quote { font-style: italic; margin: 2px 0 0 4px; }
#holes-tabs .btn[aria-pressed="true"] { background: rgba(138, 77, 255, 0.35); border-color: rgba(185, 160, 255, 0.7); }
#holes-list { max-height: 55vh; overflow-y: auto; padding-right: 4px; }
