/* Screens and overlays built by src/screens.js.
   Colours come from the tokens defined in styles.css (no :root here). */

/* ---------- shared ---------- */

.orders-screen,
.station-screen,
.album-screen {
  box-sizing: border-box;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  overflow-wrap: anywhere;
}

/* Overlays are centred by their container (#overlay), so they never force min-height. */
.overlay-screen {
  box-sizing: border-box;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  overflow-wrap: anywhere;
}

.scr-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.scr-head .eyebrow { margin: 0 0 2px; }
.scr-title { flex: 1; min-width: 0; }
.scr-head h1 {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.15;
}
.scr-tag {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

/* Bottom action row, pushed to the foot of the screen. */
.scr-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.scr-actions .btn,
.fin-actions .btn {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-size: 16px;
}

.orders-screen button:focus-visible,
.station-screen button:focus-visible,
.album-screen button:focus-visible,
.overlay-screen button:focus-visible,
.tx-card button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* Piece chip: a tier-coloured square with its short name. Size and colour are set inline. */
.chip {
  box-sizing: border-box;
  flex-shrink: 0;
  width: var(--chip-size, 40px);
  height: var(--chip-size, 40px);
  padding: 2px;
  border-radius: 9px;
  background: var(--chip-color);
  color: #0E1424;
  font-size: max(8px, calc(var(--chip-size, 40px) * 0.22));
  font-weight: 700;
  line-height: 1.1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  position: relative;
}
.chip .glyph { width: 62%; height: 62%; fill: #0E1424; opacity: .6; }
.chip .chip-tier { position: absolute; top: 1px; right: 3px; font-size: max(8px, calc(var(--chip-size, 40px) * 0.2)); opacity: .8; }
.chip.chip-missing {
  background: transparent;
  border: 2px dashed var(--chip-color);
  color: var(--chip-color);
}
.chip.chip-missing .glyph { fill: var(--chip-color); opacity: .55; }

/* ---------- Contrôle de mission (orders) ---------- */

.orders-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.orders-pill {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.orders-pill.on {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 700;
}

.orders-list { display: flex; flex-direction: column; gap: 10px; }
.orders-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.orders-card.ready { border-color: var(--accent); }
.orders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.orders-title {
  margin: 0;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}
.orders-ready {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #0E1424;
  font-size: 12px;
  font-weight: 700;
}
.orders-count {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.orders-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.orders-reward {
  margin-left: auto;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.orders-xp { color: var(--teal); }
.orders-energy { color: var(--gold); }
.orders-memory {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  vertical-align: middle;
}
.orders-deliver {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  font-size: 14px;
}
.orders-footer {
  margin: auto 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Station (Stella-1) ---------- */

.station-art svg {
  display: block;
  height: min(34vh, 290px);
  width: auto;
  max-width: 100%;
  aspect-ratio: 358 / 290;
  margin: 0 auto;
}
.station-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.station-item,
.station-mystery {
  min-height: 56px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.station-item.station-waiting { border-color: var(--accent); }
.station-swatch {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--swatch);
}
.station-text { flex: 1; min-width: 0; }
.station-name {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.station-sub {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.station-link {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #8FB8FF;
  font: 600 13px Inter, system-ui, sans-serif;
  cursor: pointer;
}
.station-list .station-install {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 14px;
}
.station-mystery.locked {
  background: var(--surface-2);
  border: 1px dashed var(--accent);
}
.station-mystery.locked .station-sub { color: var(--text-2); }
.station-mystery.open {
  background: var(--surface-2);
  border: 1px solid var(--gold);
}
.station-mystery.open .station-name { color: var(--gold); }
.station-mystery > svg { flex-shrink: 0; }
.station-empty {
  padding: 4px 2px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Album ---------- */

.album-count {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
}
.album-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.album-card {
  box-sizing: border-box;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  font: inherit;
  text-align: left;
}
button.album-card { cursor: pointer; }
.album-card.locked { border-style: dashed; }
.album-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: #222C47;
  color: var(--muted);
  overflow: hidden;
}
.album-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.album-locked-thumb { background: var(--surface-2); color: var(--muted); }
.album-num {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}
.album-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.album-card.locked .album-name { color: var(--text-2); }
.album-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* ---------- Niveau supérieur (level-up) ---------- */

.levelup {
  align-items: center;
  gap: 18px;
}
.lvl-eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}
.lvl-levels {
  display: flex;
  align-items: center;
  gap: 16px;
}
.lvl-box {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
}
.lvl-old {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 32px;
}
.lvl-new {
  width: 96px;
  height: 96px;
  border-radius: 26px;
  background: var(--teal);
  color: #0E1424;
  font-size: 46px;
}
.lvl-arrow { display: flex; }
.lvl-title {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}
.lvl-orbit { width: 100%; max-width: 300px; }
.lvl-orbit svg { display: block; width: 100%; height: auto; }
.lvl-unlocked {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lvl-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lvl-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.lvl-row-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lvl-row-text { min-width: 0; }
.lvl-row-title {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.lvl-row-sub {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.lvl-foot { width: 100%; margin-top: auto; }
.lvl-continue {
  width: 100%;
  min-height: 56px;
  border-radius: 16px;
  font-size: 16px;
}

/* ---------- Transmission reçue (memory card) ---------- */

.tx-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 24px;
  animation: tx-slide-up 0.4s ease-out both;
}
.tx-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tx-kicker {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tx-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--muted);
}
.tx-photo {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 230px;
  border-radius: 16px;
  object-fit: cover;
}
.tx-placeholder {
  background: #222C47;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tx-placeholder svg { width: 100%; height: 100%; }
.tx-name {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.tx-sub {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.tx-message {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}
.tx-sign {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.tx-actions {
  display: flex;
  gap: 10px;
}
.tx-actions .btn {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 14px;
}

/* ---------- Finale ---------- */

.fin {
  align-items: center;
  gap: 18px;
  padding-top: calc(40px + env(safe-area-inset-top));
}
.fin-eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}
.fin-h1 {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 8.5vw, 34px);
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}
.fin-station { width: 100%; }
.fin-station svg {
  display: block;
  width: 100%;
  max-width: 350px;
  height: auto;
  margin: 0 auto;
}
.fin-open,
.fin-card {
  box-sizing: border-box;
  width: 100%;
  border-radius: 20px;
  border: 2px solid var(--gold);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.fin-open {
  background: var(--surface-2);
  color: var(--text);
  font: 700 16px Inter, system-ui, sans-serif;
  cursor: pointer;
  min-height: 44px;
}
.fin-card { background: var(--surface-2); }
.fin-kicker {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.fin-title {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.fin-message {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.fin-actions {
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fin-actions .btn { min-height: 54px; }

/* ---------- animations ---------- */

@keyframes lvl-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes lvl-pop {
  0% { opacity: 0; transform: scale(0.6); }
  70% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes tx-slide-up {
  from { opacity: 0; transform: translateY(32px); }
  to { opacity: 1; transform: none; }
}
@keyframes fin-reveal {
  0% { opacity: 0; transform: scale(0.85); box-shadow: 0 0 0 0 rgba(255, 209, 102, 0); }
  60% { opacity: 1; transform: scale(1.02); box-shadow: 0 0 28px 4px rgba(255, 209, 102, 0.35); }
  100% { opacity: 1; transform: scale(1); box-shadow: 0 0 16px 0 rgba(255, 209, 102, 0.18); }
}
@keyframes just-installed-pop {
  0% { opacity: 0; transform: scale(0.4); filter: drop-shadow(0 0 0 rgba(255, 209, 102, 0)); }
  60% { opacity: 1; transform: scale(1.12); filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.9)); }
  100% { opacity: 1; transform: scale(1); filter: drop-shadow(0 0 4px rgba(255, 209, 102, 0.4)); }
}

.levelup > * {
  animation: lvl-fade-up 0.5s ease-out both;
}
.levelup > :nth-child(2) { animation-delay: 0.08s; }
.levelup > :nth-child(3) { animation-delay: 0.16s; }
.levelup > :nth-child(4) { animation-delay: 0.24s; }
.levelup > :nth-child(5) { animation-delay: 0.32s; }
.levelup > :nth-child(6) { animation-delay: 0.4s; }
.lvl-new {
  animation: lvl-pop 0.5s ease-out 0.2s both;
}
.fin .fin-card.reveal {
  animation: fin-reveal 0.8s ease-out both;
}

/* Rect of the module just installed, inside the station drawing (class set by station.js). */
.just-installed {
  transform-box: fill-box;
  transform-origin: center;
  animation: just-installed-pop 0.7s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  .levelup > *,
  .lvl-new,
  .tx-card,
  .fin .fin-card.reveal,
  .just-installed {
    animation: none !important;
  }
}

/* Short phones (360 x 640 and similar): compact the overlays so Continuer / Fermer stay on screen. */
@media (max-height: 880px) {
  .levelup { gap: 10px; padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .lvl-levels { gap: 12px; }
  .lvl-old { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; }
  .lvl-new { width: 72px; height: 72px; border-radius: 20px; font-size: 36px; }
  .lvl-title { font-size: 22px; }
  .lvl-orbit svg { width: auto; max-width: 100%; height: 90px; }
  .lvl-unlocked { gap: 4px; }
  .lvl-label { margin-bottom: 2px; }
  .lvl-row { padding: 6px 10px; gap: 10px; }
  .lvl-row-icon { width: 32px; height: 32px; }
  .lvl-row-title { font-size: 13px; }
  .lvl-continue { min-height: 48px; }

  .tx-card { padding: 16px; gap: 10px; }
  .tx-photo { height: 160px; }

  .fin { gap: 10px; padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .fin-h1 { font-size: 28px; }
  .fin-station svg { width: auto; max-width: 100%; height: 170px; }
  .fin-open, .fin-card { padding: 14px; gap: 8px; }
  .fin-actions .btn { min-height: 48px; }
}
