/* ------------------------------------------------------------------
   Core Shift — randolf.dev game styles
   Industrial spacecraft maintenance bay. The page shell (typography,
   header, footer, buttons' shape language) comes from style.css; this
   file owns the bay itself.

   Colour rule for this game: the site's lime stays the interface
   colour, cyan belongs to power and only to power.
   ------------------------------------------------------------------ */

.cs {
  max-width: 40rem;
  margin: 0 auto;
  /* the bay wants the room more than the section wants its breathing space */
  padding-top: clamp(1.25rem, 2.5vw, 2rem);
}

.cs-page {
  padding-top: clamp(4.75rem, 8vh, 6rem);
}

.cs-page .page-head {
  margin-bottom: clamp(0.9rem, 2vw, 1.5rem);
}

.cs-page .page-title {
  margin: 0.35rem 0 0.6rem;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.cs-page .page-lede {
  font-size: clamp(0.98rem, 1.5vw, 1.1rem);
}

.cs-title-alt {
  display: block;
  margin-top: 0.5rem;
  font-size: clamp(0.75rem, 1.6vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.cs-page .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.cs [hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------
   Shell — board, HUD and controls share one grid so the short-landscape
   layout can move the readouts beside the bay instead of above it
   ------------------------------------------------------------------ */

.cs-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
}

/* ------------------------------------------------------------------
   HUD
   ------------------------------------------------------------------ */

.cs-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.cs-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.cs-stat .mono {
  font-size: 9px;
}

.cs-stat-value {
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--fg);
  white-space: nowrap;
}

.cs-stat-power .cs-stat-value {
  color: #cfeff6;
}

.cs-power-bar {
  display: block;
  position: relative;
  height: 2px;
  margin-top: 0.1rem;
  background: rgba(236, 236, 240, 0.10);
  border-radius: 1px;
  overflow: hidden;
}

.cs-power-bar i {
  display: block;
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #4d97a6, #a7e9f5);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s var(--ease);
}

/* ------------------------------------------------------------------
   Stage and canvas
   ------------------------------------------------------------------ */

.cs-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  height: clamp(220px, calc(100dvh - 420px), 620px);
  border: 1px solid var(--line);
  border-radius: 4px;
  background:
    radial-gradient(ellipse 78% 88% at 50% 42%, rgba(126, 152, 176, 0.07), transparent 72%),
    radial-gradient(ellipse 110% 110% at 50% 50%, #101319, #0a0a0c 78%);
  overflow: hidden;
}

.cs-canvas {
  display: block;
  max-width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.cs-canvas:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

/* Visible hint feedback pill — bottom of the board, transient */
.cs-hint-msg {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  max-width: calc(100% - 24px);
  padding: 5px 12px;
  border: 1px solid rgba(143, 230, 242, 0.45);
  border-radius: 3px;
  background: rgba(10, 12, 16, 0.86);
  color: #cdeef4;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: none;
  text-align: center;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.cs-hint-msg.is-shown {
  opacity: 1;
}

.cs-hint-msg.is-warn {
  border-color: rgba(232, 163, 61, 0.6);
  color: #f0cf9d;
}

.cs-hint-msg[hidden] {
  display: none;
}

/* ------------------------------------------------------------------
   Overlay panels
   ------------------------------------------------------------------ */

.cs-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 9, 12, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

.cs-overlay.is-shown {
  opacity: 1;
  pointer-events: auto;
}

.cs-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: min(92%, 320px);
  max-height: 100%;
  overflow: auto;
  padding: 1.4rem 1.2rem;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.cs-panel-wide {
  width: min(96%, 400px);
}

.cs-panel-eyebrow {
  font-size: 9px;
}

.cs-panel-title {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #cfeff6;
}

.cs-panel-note {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0.08em;
}

.cs-panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

/* ------------------------------------------------------------------
   Level selector
   ------------------------------------------------------------------ */

.cs-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
  gap: 0.4rem;
  width: 100%;
  margin: 0.2rem 0 0.4rem;
}

.cs-level-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg);
  background: rgba(236, 236, 240, 0.03);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease),
    background 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.cs-level-btn:hover:not([disabled]) {
  border-color: var(--accent);
  color: var(--accent);
}

.cs-level-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.cs-level-btn[aria-current="true"] {
  border-color: rgba(167, 233, 245, 0.7);
  background: rgba(143, 230, 242, 0.08);
  color: #d8f7ff;
}

.cs-level-tick {
  position: absolute;
  top: 0.28rem;
  right: 0.28rem;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(236, 236, 240, 0.22);
}

.cs-level-btn.is-done .cs-level-tick {
  background: #8fe6f2;
  box-shadow: none;
}

.cs-level-btn[disabled] {
  opacity: 0.3;
  cursor: default;
}

.cs-level-btn[disabled] .cs-level-tick {
  box-shadow: none;
  background: rgba(236, 236, 240, 0.14);
}

/* ------------------------------------------------------------------
   Controls
   ------------------------------------------------------------------ */

.cs-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cs-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.68rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease),
    background 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cs-btn:hover:not([disabled]) {
  border-color: var(--accent);
  color: var(--accent);
}

.cs-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.cs-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.cs-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.cs-btn-primary:hover:not([disabled]) {
  color: var(--accent-ink);
  filter: brightness(1.08);
}

.cs-hint {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  line-height: 1.6;
  text-transform: none;
  color: var(--muted);
}

.cs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: none;
}

.cs-meta span:empty {
  display: none;
}

/* ------------------------------------------------------------------
   Help / credits
   ------------------------------------------------------------------ */

.cs-help-line {
  margin: 0.2rem 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: none;
}

.cs-credits {
  margin-top: 1.4rem;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--dim);
}

/* ------------------------------------------------------------------
   Narrow screens — reclaim the page gutter for the bay
   ------------------------------------------------------------------ */

@media (max-width: 480px) {
  .cs {
    margin-inline: -0.625rem;
  }

  .cs-hud {
    gap: 0.35rem;
  }

  .cs-stat {
    padding: 0.45rem 0.5rem;
  }

  .cs-stat-value {
    font-size: 12px;
  }

  .cs-btn {
    padding: 0.62rem 0.8rem;
  }
}

/* ------------------------------------------------------------------
   Short landscape — the readouts move beside the bay, because a phone
   held sideways has almost no vertical room to stack them
   ------------------------------------------------------------------ */

@media (orientation: landscape) and (max-height: 600px) {
  .cs-page {
    padding-top: 4.6rem;
  }

  .cs-page .crumbs {
    display: none;
  }

  .cs-page .page-head {
    margin-bottom: 0.5rem;
  }

  .cs-page .section-label,
  .cs-page .page-lede,
  .cs-title-alt {
    display: none;
  }

  .cs-page .page-title {
    font-size: 1.15rem;
    margin: 0;
  }

  .cs-shell {
    grid-template-columns: minmax(0, 1fr) minmax(10rem, 14rem);
    grid-template-rows: auto 1fr;
    gap: 0.7rem;
  }

  .cs-stage {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .cs-hud {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .cs-stat {
    padding: 0.4rem 0.5rem;
  }

  .cs-controls {
    grid-column: 2;
    grid-row: 2;
    align-content: start;
    gap: 0.4rem;
  }

  .cs-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .cs-btn {
    padding: 0.55rem 0.4rem;
    font-size: 9px;
  }

  .cs-hint {
    display: none;
  }
}

/* ------------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .cs-overlay,
  .cs-power-bar i,
  .cs-btn,
  .cs-level-btn {
    transition: none;
  }
}
