/* =============================================================================
 * FROM FIRE TO ORBIT — THE SKY ATLAS (Phase 16)
 * css/atlas.css  ·  the Fireworks campaign front-end (mission select + design desk)
 * ===========================================================================*/

.sa-root {
  position: fixed; inset: 0; z-index: 95;
  font-family: "Sarabun", system-ui, sans-serif;
  color: #e7eefc;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(60,90,160,0.30), transparent 60%),
    linear-gradient(180deg, #060a16 0%, #0a1122 55%, #0c0f1e 100%);
  overflow-y: auto;
}
.sa-root[hidden] { display: none; }

.sa-screen {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: clamp(18px, 4vw, 54px);
}
.sa-screen[hidden] { display: none; }

/* twinkling starfield */
.sa-stars {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 78% 14%, #cfe0ff, transparent),
    radial-gradient(1.6px 1.6px at 40% 62%, #fff, transparent),
    radial-gradient(1.1px 1.1px at 66% 78%, #b9ccff, transparent),
    radial-gradient(1.3px 1.3px at 24% 88%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 90% 46%, #dbe7ff, transparent),
    radial-gradient(1.1px 1.1px at 54% 32%, #fff, transparent);
  opacity: 0.6;
  animation: sa-twinkle 6s ease-in-out infinite alternate;
}
@keyframes sa-twinkle { from { opacity: 0.35; } to { opacity: 0.7; } }

.sa-head {
  position: relative; z-index: 1;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: clamp(20px, 5vh, 46px);
}
.sa-kicker {
  margin: 0 0 4px; font-family: "JetBrains Mono", monospace;
  font-size: 12px; letter-spacing: 0.32em; color: #7fa8e6;
}
.sa-title { margin: 0; font-size: clamp(28px, 5vw, 46px); font-weight: 700; letter-spacing: 0.01em; }
.sa-lede { margin: 8px 0 0; max-width: 60ch; color: #9db0d4; font-size: 14px; line-height: 1.6; }
.sa-x {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid rgba(150,180,240,0.3); background: rgba(12,20,40,0.7);
  color: #b9c9e8; font-size: 16px; cursor: pointer;
  transition: background .2s, transform .2s;
}
.sa-x:hover { background: rgba(40,60,110,0.8); transform: rotate(90deg); }

/* ---- the mission constellation ---- */
.sa-grid {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 18px;
  align-content: flex-start; flex: 1;
}
.sa-stamp {
  position: relative;
  width: 150px; min-height: 168px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px 12px 16px; border-radius: 16px;
  border: 1.5px dashed rgba(150,180,240,0.28);
  background: linear-gradient(180deg, rgba(16,26,48,0.9), rgba(10,16,32,0.85));
  color: #dbe6fb; cursor: pointer; text-align: center;
  transition: transform .18s, box-shadow .25s, border-color .25s;
}
.sa-stamp.open {
  border-color: var(--sa-accent, #8fd0ff);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sa-accent, #8fd0ff) 40%, transparent),
              0 14px 40px rgba(0,0,0,0.45);
}
.sa-stamp.open:hover { transform: translateY(-4px); box-shadow: 0 0 34px color-mix(in srgb, var(--sa-accent,#8fd0ff) 45%, transparent); }
.sa-stamp.done { border-style: solid; border-color: #5fe0a8; }
.sa-stamp.done .sa-stamp-ic { color: #5fe0a8; }
.sa-stamp.locked { opacity: 0.42; cursor: not-allowed; border-color: rgba(120,140,180,0.22); }
.sa-stamp-ic { font-size: 40px; line-height: 1; }
.sa-stamp-code {
  font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 0.14em;
  color: var(--sa-accent, #9db4d8);
}
.sa-stamp-name { font-size: 15px; font-weight: 600; }
.sa-stamp.open::after {
  content: ""; position: absolute; inset: -1.5px; border-radius: 16px; pointer-events: none;
  border: 1.5px solid var(--sa-accent, #8fd0ff); opacity: 0.35;
  animation: sa-pulse 2.4s ease-in-out infinite;
}
@keyframes sa-pulse { 0%,100% { opacity: 0.18; } 50% { opacity: 0.5; } }

.sa-foot {
  position: relative; z-index: 1;
  margin: 22px 0 0; font-size: 12px; color: #7d8fb4;
}

/* ---- the cultural brief ---- */
#fw-cultural { align-items: center; justify-content: center; }
.sa-brief-card {
  position: relative; z-index: 1;
  max-width: 560px; width: 100%;
  padding: 40px 34px 30px; border-radius: 20px; text-align: center;
  border: 1px solid color-mix(in srgb, var(--sa-accent, #8fd0ff) 40%, rgba(150,180,240,0.25));
  background: linear-gradient(180deg, rgba(18,28,52,0.96), rgba(10,16,32,0.94));
  box-shadow: 0 24px 70px rgba(0,0,0,0.55), 0 0 40px color-mix(in srgb, var(--sa-accent,#8fd0ff) 14%, transparent);
}
.sa-brief-stamp {
  font-size: 54px; line-height: 1;
  filter: drop-shadow(0 4px 18px color-mix(in srgb, var(--sa-accent,#8fd0ff) 55%, transparent));
}
.sa-brief-code {
  margin: 10px 0 2px; font-family: "JetBrains Mono", monospace;
  font-size: 12px; letter-spacing: 0.2em; color: var(--sa-accent, #9db4d8);
}
.sa-brief-name { margin: 0 0 6px; font-size: 30px; font-weight: 700; }
.sa-brief-npc { margin: 0 0 16px; font-size: 13px; color: #9db0d4; }
.sa-brief-body { margin: 0 auto 16px; max-width: 46ch; font-size: 15px; line-height: 1.75; color: #d6e0f4; }
.sa-brief-goal {
  margin: 0 auto 22px; max-width: 44ch; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  background: color-mix(in srgb, var(--sa-accent,#8fd0ff) 14%, rgba(10,16,32,0.6));
  border: 1px solid color-mix(in srgb, var(--sa-accent,#8fd0ff) 32%, transparent);
}
.sa-brief-actions, .fwd-actions, .fw-sci-actions, .sa-brief-actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}

.sa-btn {
  font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: 0.01em;
  padding: 12px 24px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(150,180,240,0.35); background: rgba(16,26,48,0.8); color: #cdd9f2;
  transition: transform .16s, box-shadow .22s, background .22s, filter .18s;
}
.sa-btn:hover { transform: translateY(-2px); }
.sa-btn.ghost:hover { background: rgba(30,44,78,0.9); }
.sa-btn.primary {
  border-color: #7bd0ff; color: #06121f;
  background: linear-gradient(180deg, #a9e2ff, #6cb8ee);
  box-shadow: 0 10px 30px rgba(108,184,238,0.4);
}
.sa-btn.primary:hover { filter: brightness(1.06); box-shadow: 0 14px 40px rgba(108,184,238,0.55); }
.sa-btn.big { font-size: 16px; padding: 15px 34px; }

/* ---- the firework design desk ---- */
#fw-desk { align-items: center; justify-content: center; }
.fwd-card {
  position: relative; z-index: 1;
  max-width: 720px; width: 100%;
  padding: 28px 28px 24px; border-radius: 20px;
  border: 1px solid rgba(150,180,240,0.25);
  background: linear-gradient(180deg, rgba(16,24,46,0.97), rgba(9,14,28,0.95));
  box-shadow: 0 24px 70px rgba(0,0,0,0.55);
}
.fwd-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.fwd-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.fwd-goal {
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: rgba(127,208,255,0.14); border: 1px solid rgba(127,208,255,0.32); color: #a9def7;
}
.fwd-row { margin-bottom: 16px; }
.fwd-row-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.fwd-row-h b { font-size: 14px; }
.fwd-row-h span { font-size: 11px; color: #8296bb; font-family: "JetBrains Mono", monospace; letter-spacing: 0.08em; }
.fwd-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fwd-opt {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 8px 12px; border-radius: 12px; cursor: pointer; text-align: center;
  border: 1px solid rgba(150,180,240,0.22); background: rgba(12,20,38,0.7); color: #cdd9f2;
  transition: transform .14s, border-color .2s, background .2s, box-shadow .22s;
}
.fwd-opt:hover { transform: translateY(-2px); border-color: rgba(150,180,240,0.5); }
.fwd-opt.on {
  border-color: #7bd0ff; background: rgba(40,70,120,0.55);
  box-shadow: 0 0 0 1px rgba(123,208,255,0.5), 0 10px 26px rgba(0,0,0,0.4);
}
.fwd-opt-big { font-size: 20px; line-height: 1; letter-spacing: 0.12em; color: #a9def7; }
.fwd-opt-l { font-size: 15px; font-weight: 700; }
.fwd-opt-s { font-size: 10px; color: #8296bb; font-family: "JetBrains Mono", monospace; }
.fwd-opt-h { font-size: 11px; color: #9db0d4; margin-top: 2px; line-height: 1.35; }
.fwd-opt-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--fwd-c, #ffc247);
  box-shadow: 0 0 16px var(--fwd-c, #ffc247), inset 0 0 6px rgba(255,255,255,0.4);
}

.fwd-preview {
  --fwd-c: #ffc247;
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin: 4px 0 18px; padding: 12px 16px; border-radius: 12px;
  font-size: 13px; color: #cdd9f2;
  background: rgba(10,16,32,0.7); border: 1px dashed rgba(150,180,240,0.28);
}
.fwd-preview b { color: #fff; }
.fwd-preview-shell {
  font-size: 22px;
  filter: drop-shadow(0 0 14px var(--fwd-c, #ffc247));
}
.fwd-actions { margin-top: 4px; }

/* ---- the "WHY?" science card ---- */
.fw-sci-overlay {
  position: fixed; inset: 0; z-index: 130;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4,7,14,0.82); backdrop-filter: blur(3px);
}
.fw-sci-overlay[hidden] { display: none; }
.fw-sci-card {
  max-width: 520px; width: 100%;
  padding: 30px 28px 24px; border-radius: 18px;
  border: 1px solid rgba(127,208,255,0.4);
  background: linear-gradient(180deg, rgba(16,28,52,0.98), rgba(9,14,28,0.97));
  box-shadow: 0 26px 80px rgba(0,0,0,0.6), 0 0 44px rgba(127,208,255,0.14);
  animation: fw-sci-in .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes fw-sci-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.fw-sci-tag {
  margin: 0 0 12px; font-family: "JetBrains Mono", monospace;
  font-size: 12px; letter-spacing: 0.12em; color: #7bd0ff; text-transform: none;
}
.fw-sci-context {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.6;
  color: #ffe0b0; background: rgba(255,180,80,0.1); border: 1px solid rgba(255,180,80,0.28);
}
.fw-sci-context[hidden] { display: none; }
.fw-sci-body { margin: 0 0 22px; font-size: 15px; line-height: 1.8; color: #dde6f6; }
.fw-sci-actions { justify-content: flex-end; }

/* ---- M03 · THE SEQUENCER DESK — Tube 1 / Tube 2 / Tube 3 (Phase 18) ---- */
.fwd-seq-lockbar {
  margin: 0 0 14px; padding: 8px 12px; border-radius: 9px;
  font-size: 11.5px; letter-spacing: 0.02em; color: #9db0d4; text-align: center;
  background: rgba(10,16,32,0.6); border: 1px dashed rgba(150,180,240,0.22);
}
.fwd-tubes { display: flex; flex-direction: column; gap: 12px; }
.fwd-tube {
  padding: 12px 12px 12px; border-radius: 13px;
  border: 1px solid rgba(150,180,240,0.2);
  border-left: 3px solid var(--sa-accent, #5c8cff);
  background: linear-gradient(180deg, rgba(14,22,44,0.7), rgba(10,15,30,0.55));
}
.fwd-tube-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.fwd-tube-n { font-size: 14px; font-weight: 700; color: #eaf1ff; }
.fwd-tube-tag {
  font-family: "JetBrains Mono", monospace; font-size: 10.5px; letter-spacing: 0.14em;
  color: #7fa8e6; text-transform: uppercase;
}
.fwd-opts-seq { grid-template-columns: repeat(5, 1fr); gap: 7px; }
.fwd-opts-seq .fwd-opt { padding: 10px 5px 9px; gap: 2px; }
.fwd-opts-seq .fwd-opt-swatch { width: 20px; height: 20px; }
.fwd-opts-seq .fwd-opt-l { font-size: 13px; }
.fwd-opts-seq .fwd-opt-s { font-size: 8.5px; line-height: 1.2; }
.fwd-opts-seq .fwd-opt-h { display: none; }   /* keep the tube cards compact */

.fwd-card:has(.fwd-tubes) { max-width: 760px; }

/* ---- M04 · CARNIVAL — 5 tubes, colour + fuse (Phase 19) ---- */
.fwd-card:has(.fwd-tubes.five) { max-width: 920px; }
.fwd-tubes.five {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.fwd-tubes.five .fwd-tube:nth-child(5) { grid-column: 1 / -1; }  /* 5th spans full width */
.fwd-tubes.five .fwd-tube { padding: 10px 10px 9px; }
.fwd-tubes.five .fwd-opts-seq.compact { grid-template-columns: repeat(5, 1fr); gap: 5px; }
.fwd-opts-seq.compact .fwd-opt { padding: 7px 3px 6px; }
.fwd-opts-seq.compact .fwd-opt-swatch { width: 17px; height: 17px; }
.fwd-opts-seq.compact .fwd-opt-l { font-size: 11.5px; }

/* the per-tube fuse chips */
.fwd-fuserow { display: flex; gap: 6px; margin-top: 8px; }
.fwd-fusechip {
  flex: 1; font-family: inherit; font-size: 11.5px; font-weight: 600;
  padding: 6px 4px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(150,180,240,0.22);
  background: rgba(12,20,38,0.7); color: #b9c9e8;
  transition: border-color .16s, background .16s, transform .12s;
}
.fwd-fusechip:hover { transform: translateY(-1px); border-color: rgba(150,180,240,0.5); }
.fwd-fusechip.on {
  border-color: var(--sa-accent, #ff7ac0); color: #fff;
  background: color-mix(in srgb, var(--sa-accent, #ff7ac0) 34%, rgba(12,20,38,0.7));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sa-accent, #ff7ac0) 55%, transparent);
}

.fwd-preview-tally {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  background: rgba(255,120,120,0.14); border: 1px solid rgba(255,120,120,0.3); color: #ffb3b3;
}
.fwd-preview-tally.ok {
  background: rgba(95,224,168,0.14); border-color: rgba(95,224,168,0.34); color: #7de8b6;
}

/* ---- M05 · HANABI BURST DESK — locked-value chips (Phase 20) ---- */
.fwd-locked {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 11px;
  border: 1px solid rgba(150,180,240,0.18);
  background: repeating-linear-gradient(45deg,
    rgba(14,22,44,0.6) 0 10px, rgba(18,26,50,0.6) 10px 20px);
}
.fwd-locked-ic { font-size: 15px; opacity: 0.8; }
.fwd-locked-l { font-size: 14px; font-weight: 700; color: #eaf1ff; }
.fwd-locked-s {
  font-size: 11px; color: #8296bb; font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.06em; margin-left: auto;
}

@media (max-width: 780px) {
  .fwd-tubes.five { grid-template-columns: 1fr; }
  .fwd-tubes.five .fwd-tube:nth-child(5) { grid-column: auto; }
}

@media (max-width: 620px) {
  .fwd-opts-seq { grid-template-columns: repeat(3, 1fr); }
  .fwd-opts-seq.compact { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 560px) {
  .fwd-opts { grid-template-columns: 1fr; }
  .fwd-opt { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; text-align: left; gap: 8px; }
  .fwd-opts-seq { grid-template-columns: repeat(3, 1fr); }
  .fwd-opts-seq .fwd-opt { flex-direction: column; text-align: center; }
  .sa-stamp { width: calc(50% - 9px); }
}
