/*
 * Maths HQ cockpit: three truly independent columns on wide screens.
 *
 * The page itself stops scrolling when there is a full three-column
 * cockpit. The centre workspace owns its scrollbar, so rolling the wheel
 * over a lesson never moves the radar or Granny's defence forge.
 * At narrower widths we preserve the ordinary responsive page layout.
 */

@media (min-width: 1321px) and (min-height: 600px) {
  body.mission-mode {
    height: 100dvh;
    overflow: hidden;
  }

  body.mission-mode #app {
    height: calc(100dvh - var(--gb-sticky-header-height));
    min-height: 0;
    padding: 10px clamp(12px, 1.45vw, 26px) 12px;
    overflow: hidden;
  }

  body.mission-mode .mission-shell {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  body.mission-mode .mission-control,
  body.mission-mode .mission-power {
    position: static;
    top: auto;
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: #80699e #161221;
  }

  body.mission-mode .mission-workspace {
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: #9672b4 #181226;
    padding: clamp(12px, 1.5vw, 22px);
  }

  body.mission-mode .mission-shell :is(button, summary) {
    scroll-margin-block: 12px;
  }

  body.mission-mode .mission-workspace::-webkit-scrollbar,
  body.mission-mode .mission-control::-webkit-scrollbar,
  body.mission-mode .mission-power::-webkit-scrollbar {
    width: 7px;
  }

  body.mission-mode .mission-workspace::-webkit-scrollbar-thumb,
  body.mission-mode .mission-control::-webkit-scrollbar-thumb,
  body.mission-mode .mission-power::-webkit-scrollbar-thumb {
    background: #80699e;
    border-radius: 10px;
  }

  /* The sections were stacked with wide margins and oversized illustrations.
     Trim redundant space, not the choices themselves. */
  body.mission-mode .mission-home {
    min-width: 0;
  }

  body.mission-mode .mission-workspace-heading {
    margin-bottom: 10px;
  }

  body.mission-mode .mission-workspace-heading h1 {
    margin: 2px 0 3px;
    font-size: clamp(1.65rem, 1.9vw, 2.05rem);
  }

  body.mission-mode .mission-workspace-heading p {
    font-size: .77rem;
    line-height: 1.3;
  }

  body.mission-mode .mission-mixed-card {
    margin-bottom: 12px;
    padding: 12px 13px;
    gap: 9px;
  }

  body.mission-mode .mission-topic-heading {
    gap: 6px 12px;
    margin-bottom: 10px;
  }

  body.mission-mode .mission-topic-heading h2 {
    margin-bottom: 2px;
    font-size: 1.5rem;
  }

  body.mission-mode .mission-topic-heading p {
    font-size: .74rem;
    line-height: 1.25;
  }

  body.mission-mode .mission-level-option {
    min-height: 46px;
    width: 55px;
    padding: 3px 4px;
    gap: 1px;
  }

  body.mission-mode .mission-level-number {
    font-size: 1.17rem;
  }

  body.mission-mode .mission-level-reward {
    font-size: .63rem;
  }

  body.mission-mode .mission-level-hint {
    font-size: .68rem;
  }

  body.mission-mode .mission-more-button {
    min-height: 32px;
    margin: 8px auto 6px;
    padding: 5px 14px;
    font-size: .78rem;
  }

  body.mission-mode .mission-extra-topics {
    margin-top: 8px;
  }

  body.mission-mode .mission-map-details {
    margin-top: 10px;
    padding: 8px 11px;
  }

  body.mission-mode .mission-map-details summary {
    font-size: .76rem;
  }

  /* Armory stays a meaningful visual advertisement, not an oversized block
     that hides the maths choices below the fold. */
  body.mission-mode .armory-promo {
    margin-bottom: 12px;
    padding: 11px 12px;
    gap: 10px;
    border-radius: 12px;
    grid-template-columns: minmax(90px, 30%) minmax(0, 1fr);
  }

  body.mission-mode .armory-promo-art {
    min-height: 124px;
  }

  body.mission-mode .armory-promo-art img {
    max-height: 120px;
    width: min(100%, 145px);
  }

  body.mission-mode .armory-promo-copy h2 {
    font-size: clamp(1.24rem, 1.5vw, 1.65rem);
    margin: 4px 0;
  }

  body.mission-mode .armory-promo-eyebrow {
    font-size: .64rem;
  }

  body.mission-mode .armory-promo-featured {
    font-size: .89rem;
    margin: 4px 0;
  }

  body.mission-mode .armory-promo-featured span,
  body.mission-mode .armory-promo-description {
    display: none;
  }

  body.mission-mode .armory-promo-progress {
    margin-bottom: 7px;
  }

  body.mission-mode .armory-promo-progress-label {
    font-size: .67rem;
  }

  body.mission-mode .armory-promo-track {
    height: 8px;
    margin-top: 4px;
  }

  body.mission-mode .armory-promo-cta {
    min-height: 36px;
    font-size: .98rem;
  }

  body.mission-mode .armory-promo-footnote {
    margin-top: 5px;
    font-size: .62rem;
  }

  body.mission-mode .armory-promo-complete {
    min-height: 120px;
    grid-template-columns: 60px minmax(0, 1fr);
  }

  body.mission-mode .armory-promo-complete-art {
    font-size: 3rem;
  }
}

/* On a proper wide display, place the Mixed Maths and Armory promotions
   side by side. The topic choices sit immediately beneath them, so the
   three primary Maths HQ sections can be seen at a glance. */
@media (min-width: 1600px) and (min-height: 600px) {
  body.mission-mode #screen-home .mission-home {
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
    grid-template-areas:
      "intro intro"
      "mixed armory"
      "topics topics"
      "map map";
    align-items: stretch;
    gap: clamp(7px, .65vw, 11px);
  }

  body.mission-mode #screen-home .mission-workspace-heading {
    grid-area: intro;
    margin-bottom: 0;
  }

  body.mission-mode #screen-home .mission-mixed-card {
    grid-area: mixed;
    min-width: 0;
    min-height: 164px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    justify-content: space-between;
    margin: 0;
    padding: 11px 13px;
    gap: 4px;
  }

  body.mission-mode #screen-home .mission-mixed-symbol {
    display: none;
  }

  body.mission-mode #screen-home .mission-mixed-copy {
    flex: 0 1 auto;
    min-width: 0;
  }

  body.mission-mode #screen-home .mission-mixed-copy h2 {
    font-size: 1.45rem;
    margin: 3px 0;
  }

  body.mission-mode #screen-home .mission-mixed-copy p {
    font-size: .76rem;
    line-height: 1.27;
  }

  body.mission-mode #screen-home .mission-mixed-card .gb-forge-btn {
    flex: 0 0 auto;
    width: 100%;
    min-height: 39px;
    font-size: .94rem;
  }

  body.mission-mode #screen-home .armory-promo {
    grid-area: armory;
    min-height: 164px;
    margin: 0;
    grid-template-columns: minmax(75px, 29%) minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  body.mission-mode #screen-home .armory-promo-art {
    min-height: 122px;
  }

  body.mission-mode #screen-home .armory-promo-art img {
    max-height: 116px;
  }

  body.mission-mode #screen-home .armory-promo-art-badge {
    font-size: .56rem;
    padding: 4px 6px;
  }

  body.mission-mode #screen-home .armory-promo-copy h2 {
    font-size: clamp(1.14rem, 1.25vw, 1.45rem);
  }

  body.mission-mode #screen-home .armory-promo-complete {
    grid-template-columns: 55px minmax(0, 1fr);
  }

  body.mission-mode #screen-home .armory-promo-complete .armory-promo-cta {
    grid-column: 1 / -1;
  }

  body.mission-mode #screen-home .mission-topic-section {
    grid-area: topics;
    min-width: 0;
  }

  body.mission-mode #screen-home .mission-map-details {
    grid-area: map;
    margin: 0;
  }
}

/* Do not freeze page scrolling for stacked laptop/mobile layouts or
   very short windows: there, seeing all content takes priority. */
@media (max-width: 1320px), (max-height: 599px) {
  body.mission-mode {
    height: auto;
    overflow-y: auto;
  }
}
