/*
 * The room (Dec 2, 2026; docs/room2-contract.md), a topic's page since the old room was retired the same
 * day (archive/site-2026-11/). Every rule hangs off html.room2, which the page's head sets. Colours are the site's (css/site.css),
 * day and night.
 *
 * Narrow (under 700 px): the top, then the picture (about half the screen), then the reading, which
 * scrolls with the page; an open story's card rises over the lower part of the picture. Wide: the
 * reading is a card beside the picture, the room fills the screen under the site header.
 */

html.room2 {
  --r2-main: var(--line);
  --r2-card: clamp(300px, 32vw, 420px);
}
html.room2[data-theme="dark"] { --r2-main: #8b93a0; }   /* the main line grey at night, not the brightest thing */
/* the story lines' strength on the canvas (room2-draw.js): the night colours stand about twice as far from
   their ground as the day's (contrast 9.3 to 4.6, on average); at 0.72 they come to about 5.2 (round two, 12) */
html.room2 { --r2-story-ink: 1; }
html.room2[data-theme="dark"] { --r2-story-ink: 0.72; }

/* the page's own text (templates/topic.html: for search and for a reader without scripts) is not shown
   under the room; if the room cannot start it takes `room2` off <html> and the text shows */
html.room2 body.line-page > #main { display: none !important; }

html.room2 body.line-page { overflow-x: hidden; }

.r2 {
  position: relative;
  --pad: 16px;
  color: var(--text);
  -webkit-user-select: none; user-select: none;
}

/* ---------- the top: the topic small, the period as the title, Play, the span words ---------- */
.r2-top {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "head play" "spans spans";
  align-items: center;
  gap: 0 10px;
  padding: 2px var(--pad) 0 12px;   /* the left edge the picture's names start at (room2-layout.js EDGE) */
}
.r2-top-head { grid-area: head; min-width: 0; }
/* the topic's name is the title; the period sits under it, quieter and shorter (Dec 3, Mony) */
.r2-top-topic { font-size: 21px; height: 26px; line-height: 26px; font-weight: 700; letter-spacing: -0.01em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r2-top-title { font-size: 14px; line-height: 18px; font-weight: 600; color: var(--muted); margin: 1px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r2-play {
  grid-area: play;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 16px 0 13px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-weight: 650; font-size: 15px; white-space: nowrap;
}
.r2-play[hidden] { display: none; }
.r2-top-topic.r2-tight { font-size: 18px; }
.r2-top-topic.r2-tighter { font-size: 15.5px; }
.r2:focus { outline: none; }
.r2-play.r2-off { visibility: hidden; }   /* no play here: the room is kept */
.r2-play svg { fill: var(--accent); flex: none; }
.r2-play:hover { border-color: var(--tint-edge); }
.r2-spans { grid-area: spans; display: flex; gap: 2px; }
.r2-spans button {
  flex: 1 1 0; min-height: 44px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-size: 15px; padding: 0 6px;
}
.r2-spans button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 650; }
.r2-spans.r2-na button { opacity: 0.55; }
.r2-spans.r2-na button[aria-pressed] { background: transparent; }
.r2-play:focus-visible, .r2-spans button:focus-visible, .r2-sname:focus-visible .r2-pill,
.r2-mark:focus-visible i, .r2-more:focus-visible, .r2-dot:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.r2-sname:focus-visible, .r2-mark:focus-visible, .r2-dot:focus-visible { outline: none; }

/* ---------- the body: picture (and play's caption), reading ---------- */
.r2-body { position: relative; }
.r2-stage { position: relative; min-width: 0; }
.r2-picture {
  position: relative; overflow: hidden;
  touch-action: pan-y;               /* a vertical drag scrolls the page; sideways is the room's */
  height: 460px;                     /* replaced by the script; keeps the room before it draws */
}
.r2-slide { position: absolute; inset: 0; will-change: transform; }
.r2-canvas { position: absolute; left: 0; top: 0; display: block; }
.r2-names { position: absolute; inset: 0; }
.r2-caption:empty { display: none; }


/* a name: a real button, 44 px tall; the pill sits just above its line */
.r2-sname, .r2-mark, .r2-dot, .r2-more, .r2-arrow {
  position: absolute; left: 0; top: 0;
  margin: 0; padding: 0; border: 0; background: transparent; color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.r2-sname { height: 44px; display: flex; align-items: flex-start; padding-top: 4px; transition: opacity .3s; }
.r2-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: 999px;
  background: var(--bg);
  color: var(--c); font-weight: 650; font-size: 15px; line-height: 1; white-space: nowrap;
  transition: background .2s, color .2s;
}
.r2-sname:hover .r2-pill { border-color: var(--c); }
.r2-sname.is-open .r2-pill { background: var(--c); color: var(--bg); border-color: var(--c); }
/* unread, as in mail (round two, rule 9): a small filled dot before the name, the name a step bolder */
.r2-udot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; margin-left: -3px; }
.r2-sname.r2-unread .r2-udot { display: block; }
.r2-more.r2-unread { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.r2-more.r2-unread .r2-udot { display: block; background: var(--text); margin: 0; }
.r2-sname.r2-unread .r2-pill { font-weight: 780; }
.r2-sname.r2-unread.is-open .r2-udot { background: var(--bg); }
.r2-stand {
  position: absolute; left: 0; top: 0; pointer-events: none;
  font-size: 12.5px; line-height: 16px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* the selected story's line, whole: wrapped onto up to three rows (follow-up 1), on its own ground */
.r2-stand.r2-stand-whole {
  white-space: normal; text-overflow: clip; font-size: 13px; line-height: 17px; color: var(--text);
  display: block; overflow: visible;   /* never cut (follow-up 4) */
  background: color-mix(in srgb, var(--bg) 88%, transparent); border-radius: 6px; padding: 1px 4px; margin-left: -4px;
}

/* the marks on the main line: a period's reading, its date under it (the room's only date scale,
   round two, rule 5); the selected one filled */
.r2-mark { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.r2-mark i {
  display: block; width: 16px; height: 10px; border-radius: 6px;
  background: var(--bg); border: 1.5px solid var(--r2-main);
}
.r2-mark[aria-pressed="true"] i { background: var(--r2-main); }
.r2-mark em {
  position: absolute; top: 29px; left: 50%; transform: translateX(-50%);
  font-style: normal; font-size: 12px; line-height: 15px; font-weight: 600; color: var(--muted); white-space: nowrap;
  background: var(--bg); padding: 0 6px; border-radius: 6px; pointer-events: none;
}
.r2-mark[aria-pressed="true"] em { color: var(--text); }
.r2-mark[aria-pressed="true"] { z-index: 2; }
@media (hover: hover) { .r2-mark:hover em { color: var(--text); } .r2-mark:hover i { border-color: var(--accent); } .r2-mark:hover { z-index: 3; } }
.r2-mark:focus-visible { z-index: 3; }
/* a story open or a play: the dates stay, quiet; the marks take no tap */
.r2-mark.r2-quiet { pointer-events: none; }
.r2-mark.r2-quiet i { visibility: hidden; }
.r2-mark.r2-quiet em { color: var(--faint); background: var(--bg); }   /* its own ground: a dimmed line never runs through a date */

/* a one-update story: a dot on the main line */
.r2-dot { width: 44px; height: 44px; }
/* a new story's ring: its founding headline beside it, quiet, on its own ground (Dec 3) */
.r2-dlabel {
  position: absolute; left: 31px; top: 14px; white-space: nowrap; cursor: pointer;
  font-size: 11.5px; line-height: 16px; font-weight: 600; color: var(--muted);
  background: var(--bg); padding: 0 5px; border-radius: 6px;
}
.r2-dot-new:hover .r2-dlabel, .r2-dot-new:focus-visible .r2-dlabel { color: var(--text); }
.r2-dot-new.r2-unread .r2-dlabel { color: var(--text); font-weight: 780; }
.r2-dot-plain .r2-dlabel { font-weight: 450; }   /* a death: shown plainly (js/room2-names.js GRAVE) */
.r2-dot-new.r2-unread .r2-dlabel::before {   /* the unread mark, as on a name: a small filled dot */
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: 1px;
}
.r2-dot::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px;
  border-radius: 50%; background: transparent;
}

/* "+ N more stories": with the rows, its words where a pill's would start (round two, rule 10) */
.r2-more {
  margin-top: 10px;   /* clear of the last standing line above it: its words sit about 24 px under it (reviewer, Dec 2) */
  height: 44px; padding: 0 14px; border-radius: 999px;
  color: var(--muted); font-size: 14.5px; font-weight: 600; white-space: nowrap;
}
.r2-more:hover { color: var(--text); background: var(--surface-2); }

/* previous and next: a plain chevron in a quiet circle at each end of the main line (rule 4) */
.r2-arrow { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.r2-arrow::before {
  content: ""; position: absolute; inset: 7px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
}
.r2-arrow svg { position: relative; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .r2-arrow:hover { color: var(--text); } .r2-arrow:hover::before { border-color: var(--tint-edge, var(--muted)); } }
.r2-arrow:focus-visible { outline: none; }
.r2-arrow:focus-visible::before { outline: 2px solid var(--accent); outline-offset: 1px; }
.r2.r2-playing .r2-arrow { display: none; }

/* a first-time tip's target (js/room2-tips.js): its name pulses once and is lit while the tip shows */
.r2-sname.r2-tip-lit .r2-pill { background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.r2-sname.r2-pulse .r2-pill { animation: r2-pulse .9s ease-in-out 1; }
@keyframes r2-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 0%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--c) 22%, transparent); }
}

/* play: gestures are off, the buttons do not take taps (play's own controls are in the caption) */
.r2.r2-playing .r2-names { pointer-events: none; }
.r2.r2-playing .r2-spans, .r2.r2-playing .r2-play { display: none; }   /* play: the topic and the period stay; the controls are the caption's */

/* ---------- the reading ---------- */
.r2-reading { position: relative; background: var(--bg); }
.r2-reading:empty { display: none; }

/* narrow: the reading is one card under the picture that rises for a story (room2-reading.css) */

/* wide: the room fills the screen under the site header; the reading is a card beside the picture */
@media (min-width: 700px) {
  .r2 { --pad: 18px; height: var(--r2-h, calc(100vh - 56px)); display: flex; flex-direction: column; }
  .r2-top { grid-template-columns: 1fr auto auto; grid-template-areas: "head play spans"; gap: 10px 14px; padding: 8px var(--pad) 4px 12px; }
  .r2-top-topic { font-size: 23px; height: 28px; line-height: 28px; }
  .r2-top-title { font-size: 14.5px; }
  .r2-spans button { flex: 0 0 auto; min-height: 44px; padding: 0 14px; }
  .r2-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--r2-card); }
  .r2-stage { display: flex; flex-direction: column; min-height: 0; }
  .r2-picture { flex: 1 1 auto; height: auto; min-height: 320px; }
  .r2-reading {
    margin: 4px var(--pad) 14px 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    overflow-y: auto; overscroll-behavior: contain; min-height: 0;
    -webkit-user-select: text; user-select: text;
  }
  .r2-reading:empty { display: block; }
}
@media (min-width: 700px) and (max-width: 759.98px) {
  .r2-top { grid-template-columns: 1fr auto; grid-template-areas: "head play" "spans spans"; }
  .r2-spans button { flex: 1 1 0; }
}
.r2-reading { -webkit-user-select: text; user-select: text; }

@media (prefers-reduced-motion: reduce) {
  .r2-sname, .r2-pill { transition: none; }
  .r2-sname.r2-pulse .r2-pill { animation: none !important; }
}
html.room2.r2-still .r2-sname, html.room2.r2-still .r2-pill { transition: none; }

/* ---------- first-time tips (js/room2-tips.js, Dec 2, 2026) ---------- */
.r2-tip {
  position: absolute; z-index: 40; box-sizing: border-box; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font-size: 15px; line-height: 1.4; box-shadow: 0 4px 14px rgba(0, 0, 0, .10); pointer-events: none;
  animation: r2-tip-in .2s ease-out 1;
}
@media (min-width: 700px) { .r2-tip { font-size: 14px; } }
.r2-tip-arrow { position: absolute; width: 10px; height: 10px; margin-left: -5px; background: var(--surface); transform: rotate(45deg); }
.r2-tip-right .r2-tip-arrow { left: -1px; margin-top: -5px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.r2-tip-above .r2-tip-arrow { bottom: -6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.r2-tipline { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.4; border: 1px solid var(--border); }
.r2-tipline-arrow { color: var(--muted); }
.r2-tip.r2-tip-still { animation: none; }
@keyframes r2-tip-in { from { opacity: 0; } to { opacity: 1; } }
.r2-tip-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.r2-newlook { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 14px; line-height: 1.4; }
.r2-newlook a { color: var(--text); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .r2-tip { animation: none; } .r2-tip-lit.r2-pulse .r2-pill { animation: none !important; } }
