/* Tavern Chronicle lobby sticky note (always-visible link → /chronicle).
   Standalone stylesheet loaded by the terminal layout. Kept OUT of the
   terminal/ bundle on purpose so the lobby affordance doesn't grow the
   terminal CSS rule-block count. Reuses the .postit visual classes; only
   positioning lives here. */

/* THE NOTE IS LOBBY-ONLY, AND UNTIL #11411 ONLY THE SERVER BELIEVED THAT.
   ======================================================================
   `terminal/_floating_postits.html.erb` opens with

     return unless @session.current_room == 'lobby' || @session.current_room.nil?

   so the room scope is already declared, already shipped, and named in every
   other signal this note carries: the file header above, `.chronicle-note`'s
   dismiss key `lobby-chronicle`, its testid `lobby-chronicle-note`, and
   #10569's own commit subject ("lift LOBBY chronicle post-it clear of the
   action dock").

   That gate cannot hold, because the partial renders into `#postit-portal`,
   which lives in the LAYOUT (`layouts/terminal.html.erb`) and is therefore
   rendered exactly ONCE, at page load. A client-side room transition re-renders
   `terminal/grid_layout` only (`RoomTransitioner#broadcast_room_content`), and
   the portal is not in it — the same never-re-rendered hazard the RENDERED IN
   EVERY ROOM note in `terminal/panels/_contextual_actions.html.erb` warns about
   for the left zone. So a player who loads the page in the lobby and walks into
   the game room carries every lobby post-it with them.

   The floating cluster survives that harmlessly: #3731 ships it
   `postit-group--stripped`, i.e. `display:none`. This note was deliberately put
   OUTSIDE that group so it paints on first frame — which makes it the one lobby
   affordance that arrives in the game room as a VISIBLE, `pointer-events:auto`,
   viewport-fixed 212x123 card anchored at `left: 1rem`: directly on top of the
   left zone.

   #10569 met this as a VERTICAL collision with the action dock and answered it
   with a vertical offset plus a "keep this in sync" comment (see `bottom:`
   below). #11391 then moved the dock out of `.input-area` and into the left-zone
   Contextual Sheet, and an offset tuned against `.input-area` cannot know that.
   Measured 2026-08-21, 1280x720, game room, `.terminal-container[data-room=game]`:

     elementFromPoint over .action-dock__more-summary -> P.postit__body
     elementFromPoint over .action-dock__suggest      -> P.postit__title

   both of them this note — a control the player can see, cannot press, and gets
   no explanation for. So gate on the ROOM, which is what the server already
   gates on, instead of tuning the offset a third time against whatever surface
   moves next.

   `.terminal-container[data-room]` is the SINGLE client-side room signal:
   stamped by `terminal/show.html.erb` at render and updated on every transition
   by `room_controller.js` and `lib/state_reconciler.ts`. `:has()` reads that one
   existing value rather than introducing a second copy that could disagree with
   it — the same idiom `terminal/components/_contextual_chips_docked.css` uses
   for its empty-state hint.

   Two cases this deliberately leaves alone:
   - No `.terminal-container` (the welcome page, no session) matches nothing and
     keeps the note. That is the `current_room.nil?` half of the server's gate.
   - The SEAMLESS transition path is already covered, by accident and not by this
     rule: `room_transition_coordinator.ts#_swapDOM` clears `#postit-portal` and
     re-inserts only `.postit-group--floating` from the new room HTML — which
     never contains any post-it, since `_floating_postits` renders from the
     layout alone. On that path the whole portal is simply wiped. Do not read
     this rule as restoring the note when the player walks back to the lobby;
     on the seamless path there is nothing left to restore (#11412). */
body:has(.terminal-container:not([data-room="lobby"])) .chronicle-note {
  display: none;
}

.chronicle-note {
  position: fixed;
  left: var(--space-4, 1rem);
  /* #10569: sit ABOVE the input area, never over it — this is a SPATIAL fix, not a
     z-index or pointer-events one. `.input-area` is pinned to the bottom of the
     narrative panel (just above the hotbar) and is capped at min(42vh, 320px) by
     #10530. When the DM's action dock inflated it, a note anchored just above the
     hotbar landed on top of the dock's contextual offers and — being a VISIBLE,
     interactive card — ate their clicks (measured 2026-08-11: elementFromPoint over a
     `.action-dock__suggest` returned `.chronicle-note`). A stacking fix cannot solve
     this: the note is `position:fixed` in #postit-portal (a body child, root z=1) while
     the dock is buried inside the isolated `.zone--main` stacking context (root z=0),
     so nothing on the dock side can be raised above the note, and dropping the note
     below `.zone--main` would hide it behind the opaque panel. #10515's control also
     requires a visible post-it to catch its OWN click, so pointer-events is off the
     table. Clearing the input area's maximum height is the only fix that keeps the note
     visible AND leaves the dock clickable.

     #11411 NARROWED WHAT THIS OFFSET IS RESPONSIBLE FOR. It no longer protects the
     action dock at all — the dock moved to the left-zone Contextual Sheet in #11391,
     and the room gate at the top of this file is what keeps the note off it. This
     offset now governs the LOBBY layout only: it keeps the note clear of the lobby's
     own input area and chip row, in the one room where the note renders. The old
     instruction here — "keep this offset in sync with the `.input-area` max-height" —
     is exactly the kind of coupling that cannot report itself stale, and it did not:
     #11391 moved the surface and this comment kept asserting an adjacency that had
     stopped existing. Kept for the lobby, but do not restore an action-dock
     responsibility to it; if a lobby surface moves, re-measure rather than
     re-synchronising against a value in another file. */
  bottom: calc(var(--hotbar-height, 56px) + min(42vh, 320px) + var(--space-4, 1rem));
  width: 13rem;
  max-width: 42vw;
  z-index: var(--z-raised, 50);
  text-decoration: none;
  cursor: pointer;
  transform: rotate(2deg);
  transition: transform var(--timing-fast, 120ms) var(--ease-default, ease);
}
.chronicle-note:hover {
  transform: rotate(2deg) translateY(-3px) scale(1.03);
  text-decoration: none;
}
/* Inner link carries the clickable card content; the wrapper owns the
   .postit visual + the dismiss button. Reset link styling so the card looks
   unchanged from the previous single-<a> markup. */
.chronicle-note__link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.chronicle-note__link:hover { text-decoration: none; }
.chronicle-note .postit__command { cursor: pointer; }

/* Desktop affordance only — the chronicle is reachable at /chronicle directly. */
@media (max-width: 767px) {
  .chronicle-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chronicle-note,
  .chronicle-note:hover { transform: rotate(2deg); }
}
