/*
 * THE WORMHOLE — RESPONSIVE LAYOUT v1.0.0
 * Additive layout-only overlay. CSS loaded last on each public page.
 * Specific page identifiers are set on the <html> element by the CLI installer.
 * At widths under 1100px, existing touch / mobile breakpoints remain in charge.
 * Deliberately excludes shared header, puzzle cell internals and account area.
 */

html[data-wh-layout] {
  --wh-rsp-max: 1440px;
  --wh-rsp-outer-gap: clamp(16px, 2.15vw, 36px);
}

@media screen and (min-width: 1100px) {
  /* Landing page and Follow the Threads: wider shell, readable inner panels. */
  html[data-wh-layout="index"] body > .site,
  html[data-wh-layout="explore"] body > .site {
    box-sizing: border-box;
    width: calc(100% - var(--wh-rsp-outer-gap) - var(--wh-rsp-outer-gap)) !important;
    max-width: var(--wh-rsp-max) !important;
    margin-inline: auto !important;
  }

  /* Dedicated puzzle pages: enlarge the outer game workspace only. */
  html[data-wh-layout="wordsearch"] main.page,
  html[data-wh-layout="crossword"] main.wrap,
  html[data-wh-layout="scramble"] main.wrap,
  html[data-wh-layout="cipher"] main.wrap,
  html[data-wh-layout="wordchain"] main.wrap,
  html[data-wh-layout="timeslip"] main.wrap,
  html[data-wh-layout="casefile"] main.wrap,
  html[data-wh-layout="nightmaze"] main.wrap,
  html[data-wh-layout="sixdegrees"] main.six-wrap {
    box-sizing: border-box;
    width: calc(100% - var(--wh-rsp-outer-gap) - var(--wh-rsp-outer-gap)) !important;
    max-width: var(--wh-rsp-max) !important;
    margin-inline: auto !important;
  }

  /* Timeline is primarily a linear reading task; wider without ultra-long lines. */
  html[data-wh-layout="timeslip"] main.wrap {
    max-width: 1280px !important;
  }

  /* Crossword: allocate room to BOTH puzzle and clues, not just empty padding. */
  html[data-wh-layout="crossword"] .layout {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr) !important;
    gap: clamp(18px, 1.7vw, 26px);
    align-items: start;
  }
  html[data-wh-layout="crossword"] .board-panel,
  html[data-wh-layout="crossword"] .clues-panel {
    min-width: 0;
  }

  /* Crossword cells scale with the existing CSS grid; preserve 11x11/15x15 logic. */
  html[data-wh-layout="crossword"] .crossword-grid {
    max-width: 650px !important;
  }

  /* Word Chain's answer area otherwise remains limited to only 500px. */
  html[data-wh-layout="wordchain"] .chain {
    max-width: 600px;
  }

  /* Night Maze SVG scales without changing its viewBox or movement logic. */
  html[data-wh-layout="nightmaze"] #maze {
    max-width: 880px;
  }
}

/* Tablet portrait / mobile: keep each game's tested stacking breakpoints.
 * Only prevent select controls from exceeding the available container. */
@media screen and (max-width: 1099px) {
  html[data-wh-layout] select {
    max-width: 100%;
  }
}

/* Reading passages should remain legible even when their page becomes wider. */
html[data-wh-layout="explore"] .main-card .story-text {
  max-width: 80ch;
}

/* Print remains governed by the original game-specific print rules. */
@media print {
  html[data-wh-layout="crossword"] .crossword-grid { max-width: 540px !important; }
}
