/* ============================================================
   WEB-ONLY: phone-landscape treatment (2026-11-28).

   The web demo's own short-landscape rules (in index.html) kept
   the portrait control column beside the board — toolbar, HUD
   with the Daily description paragraph, action row, pad — and
   in a 360–390px-tall viewport the pad's last rows fell off the
   bottom (layout proof: padClip 7.9–103.2 on the 844×390 and
   800×360 web cells, pre-existing since before the date-tap
   parity port).

   This sheet ports the Android app's proven landscape
   arrangement (the app patch layer's layout.fill.css, Jordan's
   vc15/vc16 design) to the web page at the same band:
     - the mode switch and the HUD stats ride in the header row
       (relocated by web-landscape.js, which wraps placeHud);
     - the toolbar leaves the layout and the HUD leaves the
       column — the Daily description paragraph is not part of
       this layout (in the app the strip lands off-canvas in
       this band; here it is display:none — game messages still
       reach the aria live region via the separate sr-only
       #live-region that renderMsg() mirrors into, and the
       mistakes pill returns with the portrait/desktop layouts);
     - the game becomes a three-column grid: board left sized
       by height, pad column centre at full height with its rows
       sharing the tray (every key on screen, nothing scrolls),
       and the four action buttons as a vertical rail at the
       right edge.
   Portrait, tablet and desktop renderings are untouched: every
   rule lives inside the landscape band below.

   Every rule is gated on the `wl` class, which
   web-landscape.js adds to <html> only after it has verified
   it can perform the relocation. If the script does not run,
   no rule here applies and the page keeps the canonical
   landscape layout — defective pad, but fully functional —
   instead of hiding the toolbar/HUD with the mode switch and
   stats stranded inside them.

   This file is web-only. The app build strips the <link> (see
   tools/patches.mjs in sixways-android:
   web.landscape.css.remove), so the generated app page is
   byte-identical with or without this sheet.
   ============================================================ */

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1023px) {
  /* Header homes (the stats keep the pill styling the phone
     toolbar gave them; the mode switch keeps its own look). */
  html.wl header .mode-switch { flex: none; }
  html.wl header .mode-switch button { white-space: nowrap; }
  html.wl header .hud-stats { display: inline-flex; align-items: center; gap: 6px; flex: none; }
  html.wl header .hud-stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    padding: 3px 9px; gap: 5px; font-size: 12.5px; font-variant-numeric: tabular-nums;
    height: 34px; min-height: 34px; white-space: nowrap;
  }
  html.wl header .hud-stat svg { display: block; width: 12px; height: 12px; }

  /* Three-column grid: board | pad | action rail. One row —
     the pad tray and the rail take the full game height. */
  html.wl body > main.game {
    grid-template-columns: minmax(0, 1fr) 332px 78px;
    grid-template-rows: minmax(0, 1fr);
    column-gap: 10px; row-gap: 8px;
  }
  html.wl .board-wrap { grid-column: 1; grid-row: 1 / -1; min-width: 0; min-height: 0; }
  html.wl .toolbar { display: none; }
  html.wl .hud { display: none; }

  /* Action rail: the four buttons share the right edge,
     icon over short label, as in the app. (The FR min-height
     below outranks the canonical ≤430px FR rule, whose higher
     specificity would otherwise keep the buttons at 48px and
     overflow a short rail.) */
  html.wl .actions {
    grid-column: 3; grid-row: 1 / -1;
    flex-direction: column; gap: 8px; min-width: 0; min-height: 0;
  }
  html.wl .action-btn {
    flex: 1 1 0; width: 100%; min-height: 0;
    flex-direction: column; gap: 3px; padding: 5px 2px;
    font-size: 11.5px; line-height: 1.15;
  }
  html.wl[lang="fr"] .action-btn { min-height: 0; }
  html.wl .action-btn svg { width: 18px; height: 18px; }
  html.wl .action-btn .lbl-full { display: none; }
  html.wl .action-btn .lbl-short { display: inline; }

  /* Pad column: head fixed, keys share the remaining height
     exactly — the pad never scrolls and never clips. */
  html.wl .pad-tray {
    grid-column: 2; grid-row: 1; align-self: stretch;
    display: flex; flex-direction: column;
    min-width: 0; min-height: 0; max-height: none;
  }
  html.wl .pad-head { flex: none; margin-bottom: 4px; gap: 3px; }
  /* The FR placement prompt is the widest pad-head content:
     steppers and the direction toggle slim a step so the head
     fits the pad column; the prompt ellipsises as a backstop. */
  html.wl .pad-head .stepper { width: 30px; }
  html.wl .pad-head .dir-toggle { padding: 2px 8px; font-size: 12.5px; }
  html.wl .pad-head .pad-now { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  html.wl .pad-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  html.wl #pad { height: 100%; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(0, 1fr); }
  html.wl #pad .chip { height: auto; min-height: 0; font-size: 13px; line-height: 1.15; }

  /* While the invite/coach/guide bar is up it takes an auto
     row above the whole grid, spanning every column (the
     demo's own :has() rules would otherwise retake the
     template, the tray's row and the key height — re-assert
     the layout for that state). The app confines the bar to
     the pad column, where the ~95px guide bar compresses the
     keys to ~17px at 800×360; spanning the bar full-width
     keeps its height to one line and the keys above the 24px
     floor in this transient state too. */
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) {
    grid-template-rows: auto minmax(0, 1fr);
    row-gap: 4px;
  }
  /* The rail drops to the second row too — left spanning, it
     would overlap the bar's right end and intercept its
     buttons. */
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) .actions { grid-row: 2; }
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) #tutorial-invite,
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) #coach,
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) #guide {
    grid-column: 1 / -1; grid-row: 1; min-width: 0;
  }
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) .board-wrap { grid-row: 2; }
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) .pad-tray { grid-row: 2; }
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) #pad .chip {
    height: auto; min-height: 0;
  }
  /* In this transient state the keys also keep the 24px
     floor: where the tray is tall enough the 1fr share is
     already larger and nothing changes; at very short heights
     the rows stop at 24px and the pad scrolls the difference
     instead of compressing the keys below the floor. */
  html.wl .game:has(> #tutorial-invite.show, > #coach.show, > #guide.show) #pad {
    grid-auto-rows: minmax(24px, 1fr);
  }
}

/* Narrow landscape (≤767px wide): the pad column and the rail
   slim a step, as in the app. The header row slims a step too:
   the five header groups at full size need ~690px, which would
   overflow the narrowest real phone landscape viewports
   (iPhone SE class, 667px) — the demo's own ≤767px rules
   already slim these same elements in the portrait toolbar, so
   the header home gets the same step here. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 767px) {
  html.wl body > main.game { grid-template-columns: minmax(0, 1fr) 296px 68px; }
  html.wl .pad-head .stepper { width: 28px; }
  html.wl .pad-head .dir-toggle { padding: 2px 6px; }
  html.wl header .brand { font-size: 1rem; }
  html.wl header .brand img { width: 24px; height: 24px; }
  html.wl header .pill { padding: 0 8px; }
  html.wl header .mode-switch button { padding: 4px 7px; }
  html.wl header .hud-stats { gap: 4px; }
  html.wl header .hud-stat { padding: 3px 6px; gap: 4px; font-size: 12px; }
  html.wl header .header-actions { gap: 6px; }
  html.wl header .tool-btn { padding: 4px 7px; }
}

/* Very narrow landscape (≤680px wide): one more header step —
   the brand keeps its icon and drops the wordmark, and the
   header groups slim again, so the row still fits the smallest
   swept boxes (600px) instead of clipping its last controls. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 680px) {
  html.wl header .brand { font-size: 0.95rem; }
  html.wl header .brand span { display: none; }
  html.wl header .pill { padding: 0 7px; font-size: 12px; }
  html.wl header .mode-switch button { padding: 4px 6px; }
  html.wl header .hud-stat { padding: 3px 5px; font-size: 11.5px; }
  html.wl header .tool-btn { padding: 4px 6px; }
}

/* Very short landscape (≤320px tall): the store handoff strip
   leaves the height budget (it is web-only chrome — the app
   has none) and the pad gaps tighten a step, so the six key
   rows still clear the 24px floor at the shortest swept
   heights (250–300px) instead of compressing below it. */
@media (orientation: landscape) and (max-height: 320px) and (max-width: 1023px) {
  html.wl .store-handoff { display: none; }
  html.wl body > main.game { padding-bottom: 4px; }
  html.wl #pad { gap: 4px; }
}
