/* Calypso HTML overlay screens — shared component library (Phase 41, plan §5.4).
   Vanilla CSS only — behaviour lives in screens/*.js. Reuses the visual tokens
   from menu.css: accent #74ffb0, fonts ('Saira Condensed' headers, 'Chakra Petch'
   body, 'Share Tech Mono' meta/numbers), panel gradient, 1px borders, 3px left
   accent. Class prefix: cax-scr-. No innerHTML / no behaviour here.

   The single fixed container (#cax-screen) is appended to #main-menu by
   screens/common.js; per-screen DOM is built inside it with DOM methods. While a
   screen is open the .cax-menu list + .cax-logo-wrap stay hidden (plan §5.3). */

/* ---- container (one fixed <div id="cax-screen" hidden> inside #main-menu) ---- */
#cax-screen {
  position: absolute;
  inset: 0;
  z-index: 9100;            /* above the #main-menu backdrop (9000), below intro (9999) */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 6vw;
  box-sizing: border-box;
  font-family: 'Chakra Petch', sans-serif;
  color: #cfe9e0;
  overflow: auto;
}
#cax-screen[hidden] { display: none !important; }

/* While a screen is open, hide the main-menu list + logo (plan §5.3); the
   backdrop (video + FX) stays visible behind the panel. */
#main-menu.screen-open .cax-menu,
#main-menu.screen-open .cax-logo-wrap { display: none !important; }

/* In-game entry (Pause → Load/Save/Options, slice A2 §5.3): #main-menu is
   un-hidden directly by showInGameShell() in screens/common.js — NOT via
   show()/calypsoShowMainMenu(), which would mute music and restart the bg
   video. Keep the dark backdrop but hide the logo, item list, footer, sound
   button, and bg video (no autoplay flicker mid-battle). */
#main-menu.in-game-screen .cax-logo-wrap,
#main-menu.in-game-screen .cax-menu,
#main-menu.in-game-screen .cax-version,
#main-menu.in-game-screen #cax-sound-btn,
#main-menu.in-game-screen #menu-bg-video { display: none !important; }

/* ---- panel ---- */
.cax-scr-panel {
  position: relative;
  width: min(960px, 88vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 26px 26px;
  background: linear-gradient(90deg, rgba(10,28,32,0.85), rgba(8,20,26,0.55));
  border: 1px solid rgba(116,255,176,0.2);
  border-left: 3px solid var(--acc, #74ffb0);
  backdrop-filter: blur(4px);
  box-sizing: border-box;
}

/* ---- title bar ---- */
.cax-scr-title {
  font-family: 'Saira Condensed', sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #e8fff5;
  text-shadow: 0 0 18px rgba(116,255,176,0.3);
  line-height: 1;
}
.cax-scr-subtitle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6f8a84;
  margin-top: -8px;
}

/* ---- two-column form row (label | control) ---- */
.cax-scr-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) 1fr;
  align-items: center;
  gap: 16px;
  padding: 8px 4px;
}
.cax-scr-label {
  font-family: 'Saira Condensed', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #cfe9e0;
}
.cax-scr-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- scrollable list (row hover mirrors .cax-item from menu.css) ---- */
.cax-scr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 55vh;
  overflow-y: auto;
}
.cax-scr-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  cursor: pointer;
  color: #cfe9e0;
  border: 1px solid rgba(116,255,176,0.12);
  border-left: 3px solid rgba(116,255,176,0.4);
  background: linear-gradient(90deg, rgba(10,28,32,0.5), rgba(8,20,26,0.08));
  transition: transform .28s ease, background .28s ease, border-color .28s ease, box-shadow .28s ease, color .28s ease;
}
.cax-scr-item:hover, .cax-scr-item:focus-visible {
  transform: translateX(10px);
  outline: none;
  border-left-color: var(--acc, #74ffb0);
  border-color: rgba(116,255,176,0.45);
  background: linear-gradient(90deg, rgba(20,56,47,0.9), rgba(10,28,32,0.15));
  box-shadow: 0 0 30px rgba(116,255,176,0.18), inset 0 0 26px rgba(116,255,176,0.06);
  color: #eafff6;
}
.cax-scr-item.is-selected {
  border-left-color: var(--acc, #74ffb0);
  border-color: rgba(116,255,176,0.45);
  background: linear-gradient(90deg, rgba(20,56,47,0.9), rgba(10,28,32,0.15));
  color: #eafff6;
}

/* ---- buttons ---- */
.cax-scr-btn {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .18em;
  text-transform: uppercase;
  padding: 10px 22px;
  cursor: pointer;
  color: #cfe9e0;
  border: 1px solid rgba(116,255,176,0.2);
  background: linear-gradient(90deg, rgba(10,28,32,0.6), rgba(8,20,26,0.2));
  transition: border-color .2s, box-shadow .2s, color .2s, transform .2s;
}
.cax-scr-btn:hover, .cax-scr-btn:focus-visible {
  outline: none;
  color: #eafff6;
  border-color: rgba(116,255,176,0.55);
  box-shadow: 0 0 24px rgba(116,255,176,0.18);
}
.cax-scr-btn:active { transform: translateX(2px); }
.cax-scr-btn:disabled { opacity: .4; cursor: not-allowed; }
.cax-scr-btn-primary {
  border-left: 3px solid var(--acc, #74ffb0);
  color: #e8fff5;
}
.cax-scr-btn-primary:hover, .cax-scr-btn-primary:focus-visible {
  border-left-color: #74ffb0;
  box-shadow: 0 0 30px rgba(116,255,176,0.28), inset 0 0 18px rgba(116,255,176,0.07);
}
.cax-scr-btn-secondary { /* quieter — no left accent bar */ }
.cax-scr-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ---- toggle (checkbox-driven switch) ----
   Built by JS as: <label class="cax-scr-toggle"><input type="checkbox"><span class="cax-scr-track"></span>…</label> */
.cax-scr-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #cfe9e0;
}
.cax-scr-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.cax-scr-track {
  width: 44px; height: 22px;
  border: 1px solid rgba(116,255,176,0.3);
  background: rgba(8,20,26,0.6);
  border-radius: 11px;
  position: relative;
  transition: background .2s, border-color .2s;
}
.cax-scr-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #6f8a84;
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.cax-scr-toggle input:checked + .cax-scr-track {
  background: rgba(116,255,176,0.18);
  border-color: var(--acc, #74ffb0);
}
.cax-scr-toggle input:checked + .cax-scr-track::after {
  transform: translateX(22px);
  background: var(--acc, #74ffb0);
}
.cax-scr-toggle input:focus-visible + .cax-scr-track {
  outline: 2px solid rgba(116,255,176,0.5);
  outline-offset: 2px;
}

/* ---- range slider (restyled <input type=range>) ---- */
.cax-scr-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(116,255,176,0.2);
  border-radius: 2px;
  outline: none;
}
.cax-scr-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--acc, #74ffb0);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(116,255,176,0.5);
}
.cax-scr-range::-moz-range-thumb {
  width: 16px; height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--acc, #74ffb0);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(116,255,176,0.5);
}
.cax-scr-range:focus-visible { outline: 2px solid rgba(116,255,176,0.4); outline-offset: 4px; }

/* ---- custom select (DOM-built — native <select> is unstylable) ----
   Built by JS as a relatively-positioned wrapper holding a button.cax-scr-select
   and an absolutely-positioned ul.cax-scr-select-options. The wrapper carries
   .cax-scr-select-wrap. */
.cax-scr-select-wrap { position: relative; display: inline-block; }
.cax-scr-select {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 14px;
  letter-spacing: .1em;
  color: #e8fff5;
  background: linear-gradient(90deg, rgba(10,28,32,0.7), rgba(8,20,26,0.3));
  border: 1px solid rgba(116,255,176,0.25);
  border-left: 3px solid rgba(116,255,176,0.5);
  padding: 8px 30px 8px 14px;
  cursor: pointer;
  position: relative;
  min-width: 160px;
  text-transform: uppercase;
}
.cax-scr-select::after {
  content: '▾';
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--acc, #74ffb0);
  pointer-events: none;
}
.cax-scr-select-options {
  position: absolute;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  left: 0;
  min-width: 100%;
  max-height: 240px;
  overflow-y: auto;
  background: #0a1c20;
  border: 1px solid rgba(116,255,176,0.3);
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.cax-scr-select-options[hidden] { display: none; }
.cax-scr-select-options li {
  padding: 7px 14px;
  cursor: pointer;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 13px;
  letter-spacing: .08em;
  color: #cfe9e0;
  text-transform: uppercase;
  white-space: nowrap;
}
.cax-scr-select-options li:hover { background: rgba(116,255,176,0.12); color: #eafff6; }
.cax-scr-select-options li.is-selected { color: var(--acc, #74ffb0); }
.cax-scr-select-options li.is-disabled {
  color: rgba(180, 207, 220, 0.45); cursor: not-allowed;
}
.cax-scr-select-options li.is-disabled:hover { background: transparent; }

/* ---- tab bar ---- */
.cax-scr-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(116,255,176,0.2);
}
.cax-scr-tab {
  font-family: 'Saira Condensed', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 9px 18px;
  cursor: pointer;
  color: #6f8a84;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .2s, border-color .2s;
}
.cax-scr-tab:hover { color: #cfe9e0; }
.cax-scr-tab.is-active {
  color: var(--acc, #74ffb0);
  border-bottom-color: var(--acc, #74ffb0);
}

/* ---- modal confirm box ----
   Built by JS as: <div class="cax-scr-modal-backdrop"><div class="cax-scr-modal">…</div></div> */
.cax-scr-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 9200;
  background: rgba(2,7,10,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cax-scr-modal-backdrop[hidden] { display: none !important; }
.cax-scr-modal {
  width: min(440px, 80vw);
  padding: 22px 24px;
  background: linear-gradient(90deg, rgba(10,28,32,0.95), rgba(8,20,26,0.8));
  border: 1px solid rgba(116,255,176,0.3);
  border-left: 3px solid var(--acc, #74ffb0);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cax-scr-modal-text {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 15px;
  color: #cfe9e0;
  line-height: 1.5;
}

/* ---- restart-required banner (amber) ---- */
.cax-scr-banner {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 9px 14px;
  border: 1px solid rgba(255,193,77,0.4);
  border-left: 3px solid #ffc14d;
  background: linear-gradient(90deg, rgba(60,40,8,0.7), rgba(40,28,6,0.4));
  color: #ffd98a;
}

/* ---- utility: meta / mono numeric labels ---- */
.cax-scr-meta {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: .14em;
  color: #6f8a84;
  text-transform: uppercase;
}
.cax-scr-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: var(--acc, #74ffb0);
}

/* ---- New Game HD layout ---------------------------------------------------
   Desktop keeps the established two-column composition. The compact landscape
   media block below promotes all five difficulty choices into one always-visible
   strip and pins Back / Start Campaign to the bottom action row. */
.cax-newgame-panel { flex-direction: row; gap: 28px; }
.cax-newgame-left {
  flex: 1 1 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.cax-newgame-right {
  flex: 1 1 300px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.cax-newgame-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.cax-newgame-step {
  color: #6f8a84;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cax-newgame-difficulty-index {
  min-width: 28px;
  color: var(--acc, #74ffb0);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
}
.cax-newgame-difficulty-name { font-size: 16px; }
.cax-newgame-briefing,
.cax-newgame-ironman {
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid rgba(116,255,176,.15);
  background: rgba(5,18,23,.55);
}
.cax-newgame-briefing-title {
  color: #e8fff5;
  font-family: 'Saira Condensed', sans-serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1;
  text-transform: uppercase;
}
.cax-newgame-briefing-meta {
  margin-top: 5px;
  color: #6f8a84;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.cax-newgame-briefing-list { display: grid; gap: 7px; margin-top: 14px; }
.cax-newgame-briefing-row {
  display: flex;
  gap: 10px;
  color: #cfe9e0;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  line-height: 1.25;
}
.cax-newgame-briefing-row > span:first-child { color: var(--acc, #74ffb0); }
.cax-newgame-ironman { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.cax-newgame-toggle { min-height: 44px; justify-content: space-between; flex-direction: row-reverse; font-size: 16px; }
.cax-newgame-ironman-description { color: #6f8a84; font-size: 15px; line-height: 1.3; }
.cax-newgame-tutorial-description { color: #6f8a84; font-size: 15px; line-height: 1.3; }
.cax-newgame-ironman-state {
  margin-top: 6px;
  color: var(--acc, #74ffb0);
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.cax-newgame-actions { justify-content: space-between; align-items: stretch; }
.cax-newgame-action-cluster { display: flex; align-items: stretch; gap: 10px; }
.cax-newgame-selection-note {
  display: flex;
  align-items: center;
  color: #6f8a84;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

@media (orientation: landscape) and (max-height: 500px),
       (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
  #cax-screen {
    align-items: stretch;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    overflow: hidden;
  }

  #main-menu.screen-open .cax-depth,
  #main-menu.screen-open .cax-version,
  #main-menu.screen-open #cax-sound-btn,
  #main-menu.screen-open #cax-footer-links { display: none !important; }

  .cax-newgame-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(208px, .8fr);
    grid-template-rows: 34px 54px minmax(0, 1fr) 46px;
    gap: 8px 9px;
    padding: 12px 14px;
  }
  .cax-newgame-left,
  .cax-newgame-right { display: contents; }

  .cax-newgame-header {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
  }
  .cax-newgame-title { font-size: 27px; letter-spacing: .12em; }

  .cax-newgame-difficulties {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    max-height: none;
    overflow: visible;
  }
  .cax-newgame-difficulty {
    box-sizing: border-box;
    min-width: 0;
    height: 54px;
    min-height: 54px;
    display: block;
    padding: 5px 4px 3px;
    border-left-width: 1px;
    border-bottom: 2px solid rgba(116,255,176,.3);
    text-align: center;
  }
  .cax-newgame-difficulty:hover,
  .cax-newgame-difficulty:focus-visible { transform: none; }
  .cax-newgame-difficulty.is-selected { border-bottom-color: var(--acc, #74ffb0); }
  .cax-newgame-difficulty-index {
    display: block;
    min-width: 0;
    font-size: 9px;
    line-height: 1;
  }
  .cax-newgame-difficulty-name {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .03em;
    line-height: 1;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .cax-newgame-briefing {
    grid-column: 1;
    grid-row: 3;
    overflow: hidden;
    padding: 10px 12px;
  }
  .cax-newgame-briefing-title { font-size: 20px; }
  .cax-newgame-briefing-meta { margin-top: 4px; font-size: 9px; }
  .cax-newgame-briefing-list { gap: 5px; margin-top: 8px; }
  .cax-newgame-briefing-row {
    gap: 7px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 16px;
    line-height: 1.08;
  }

  .cax-newgame-ironman {
    grid-column: 2;
    grid-row: 3;
    overflow-x: hidden;
    overflow-y: auto;
    justify-content: flex-start;
    gap: clamp(6px, 3vh, 18px);
    padding: 10px 12px;
  }
  .cax-newgame-toggle { font-family: 'Saira Condensed', sans-serif; }
  .cax-newgame-ironman-description {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 16px;
    line-height: 1.15;
  }
  .cax-newgame-tutorial-description {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 16px;
    line-height: 1.15;
  }
  .cax-newgame-ironman-state { margin-top: 5px; font-size: 9px; }

  .cax-newgame-actions {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 0;
    flex-wrap: nowrap;
  }
  .cax-newgame-actions .cax-scr-btn {
    min-width: 112px;
    min-height: 44px;
    padding: 8px 16px;
    font-family: 'Saira Condensed', sans-serif;
    font-size: 16px;
  }
  .cax-newgame-actions .cax-scr-btn-primary { min-width: 146px; }
  .cax-newgame-action-cluster { gap: 7px; }
}
