/* 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 play upright (docs/UI-PLAN.md, Phone layout: areas, portrait): a phone on its side sees only this, and an
   upright phone never does. iPads and laptops are taller than 500 px and keep the landscape stage. UI-14. */
[data-rotate] { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  [data-rotate] { display: grid; place-items: center; position: fixed; inset: 0; z-index: 90; }
}

/* The game's colours (DESIGN.md, Colour). Day and Night set the surfaces, never the OS: the stage carries
   data-round="day" or "night". */
:root {
  --ground: #2b1310; --parchment: #e8dcb9; --parchment-deep: #cdb98a; --gold: #c9a24a; --heading: #8c1d16;
  --logo-red: #a8201a; --lightning: #5fd0ee; --day: #d9d68a; --night: #1e2a4a; --legal: #f5c542;
  --mana-red: #c6262e; --mana-blue: #2f6fc4; --mana-white: #efe9dd; --mana-green: #3f9b3a; --mana-gold: #e0b32b; --mana-black: #1a1a1a;
  --surface: var(--day);
  color-scheme: only light;
}
[data-round="night"] { --surface: var(--night); }
body { background: var(--ground); color: var(--parchment); font-family: 'EB Garamond', Georgia, serif; }
[data-prompt] { font-family: Marcellus, Georgia, serif; }

/* 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 stage's grid (docs/UI-PLAN.md, Phone layout and Where controls sit). Desktop and iPad, as the sketch: the strip
   and the prompt line along the top, your rail on the left, the Units on the right, the map in the middle with the play
   row, the commit spot and the hand under it. Each view names its own area (view-*.css). */
[data-stage] {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 260px 190px;
  grid-template-rows: auto minmax(0, 1fr) 110px 170px;
  grid-template-areas:
    "strip strip prompt prompt"
    "rail  board board  units"
    "rail  play  commit units"
    "rail  hand  hand   units";
  background: var(--ground);
}
[data-stage] > .strip { grid-area: strip; min-width: 0; }
[data-stage] > [data-area-tabs] { display: none; }
[data-stage][data-busy] [data-key] { pointer-events: none; }

/* An upright phone: the strip, the map, the area tabs, the lower area (one of hand, play, you, units) and the prompt row. */
@media (max-width: 820px) and (orientation: portrait) {
  [data-stage] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 44px minmax(0, 1fr) 44px 240px 48px;
    grid-template-areas: "strip" "board" "tabs" "lower" "promptrow";
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  [data-stage] > [data-area-tabs] { display: flex; grid-area: tabs; }
  [data-stage] [data-view="hand"], [data-stage] [data-view="play"], [data-stage] [data-view="rail"], [data-stage] [data-view="units"] {
    grid-area: lower; width: auto; min-width: 0; border-right: 0;
  }
  [data-stage]:not([data-area="hand"]) [data-view="hand"], [data-stage]:not([data-area="play"]) [data-view="play"],
  [data-stage]:not([data-area="you"]) [data-view="rail"], [data-stage]:not([data-area="units"]) [data-view="units"] { display: none; }
}
