/* GAME: the app's styles. These rules come from the UI catalog (references/ui-spec.md) and stay whatever the look. */

/* Netlify's hosting badge, added to every page on the free plan, stays out of the game. sw.js also answers its
   script with an empty one. UI-12. */
#nl-badge-frame, #nl-hud-frame { display: none !important; }

/* A native app's feel: no text selection or iOS callouts on a press, no page scroll. UI-16, UI-24. */
html, body { height: 100%; margin: 0; overflow: clip; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
img, svg, [data-key], [data-previewable] { -webkit-touch-callout: none; -webkit-user-drag: none; }
[data-stage] { position: fixed; inset: 0; overflow: clip; touch-action: none; }
[data-rulebook], [data-journal], [data-credits] { -webkit-user-select: text; user-select: text; }

/* Phones are upright (docs/UI-PLAN.md, Phone layout: measured, portrait only). A phone on its side sees only the
   turn-your-phone screen; an upright phone, a tablet or a window never does. UI-14. */
[data-rotate] { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  [data-rotate] { display: grid; place-items: center; position: fixed; inset: 0; z-index: 90; }
}

/* The board is clipped to its own frame; the camera moves [data-board] with a transform. UI-26, UI-89.
   No standing will-change: it keeps the whole board one composited layer at the device's pixel ratio, which for a
   board many screens wide is more memory than an iPhone gives a tab (Oath gap 121: about 1.5 GB of layers, Safari
   killed the page; 47 MB without it). A motion may set will-change for its own duration only. UI-135. */
[data-board-frame] { position: relative; overflow: clip; }
[data-board] { transform-origin: 0 0; }

/* A legal target's glow inside the board: its outline's colour pulses, paint only. Never fade it by opacity or scale
   it there: a composited loop inside a board bigger than the screen keeps a board-size layer at the phone's pixel
   ratio for every lit target (Oath gap 121: 50 MB each, 300 MB on one region tab, iPhone Safari killed the page).
   For anything bigger than an outline, draw it in a screen-space overlay above the board instead. UI-125, UI-135. */
[data-legal] { outline: 3px solid var(--legal, #f5c542); outline-offset: 2px; animation: legal-glow 1.6s ease-in-out infinite; }
@keyframes legal-glow { 50% { outline-color: transparent; } }
@media (prefers-reduced-motion: reduce) { [data-legal] { animation: none; } }

/* Reduced motion keeps short fades: never cut durations to zero. anim.js reads the same setting. UI-59. */

/* The table (docs/UI-PLAN.md, Phone layout; the sketch's grid): the strip above, the bot's card with its play area
   row under it on the left, the map on the right, the prompt row below. On a phone, upright, one column: strip, map
   (its tab row included), card, play area, prompt. main.js mounts each view in the stage; the title, setup, end and
   menu screens stand over it. */
[data-stage] {
  display: grid; box-sizing: border-box; gap: 16px; background: #588143;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  grid-template-columns: 540px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "strip strip" "card map" "area map" "prompt prompt";
}
[data-stage] > [data-view="area"] { grid-area: area; }
@media (max-width: 1100px), (max-height: 620px) {
  [data-stage] { gap: 8px; padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); grid-template-columns: 404px minmax(0, 1fr); }
}
@media (max-width: 600px) {
  [data-stage] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1.2fr) minmax(200px, 1fr) auto auto;
    grid-template-areas: "strip" "map" "card" "area" "prompt";
  }
}
