/* Shared base for the five ryokan designs: page basics, how the tatami floor
   is placed, and how the board is sized so that it always sits on the mats.
   Nothing here paints the tatami or the board (core/tatami.css and
   core/board.css are verbatim copies of the original's rules); each design
   draws its own architecture round them.

   A design gives its .tatami four sizes:
     --tat-w     floor width          --tat-h     floor height (it grows if a page
     --pad-x  board margin sides   --pad-y  board margin top and bottom
   and everything else follows: the full board fills the floor's width less
   the margins, the compact board's beads are sized to the floor's height
   (through the board's own --chrome allowance), and a page taller than the
   floor (Settings, or a compact board on a phone held sideways, which keeps
   the original's big beads and scrolls) simply makes the floor taller. */

/* The layout sizes are registered lengths, so each is worked out once,
   where it is set (100cqw there means the page's width), and reaches the
   board as plain pixels rather than as a formula its own rules would
   re-read against the board's container. */
@property --vh { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --avail-w { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --avail-h { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --tat-w { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --tat-h { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --unit { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --pad-x { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --pad-y { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --board-h { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --stage-w { syntax: "<length>"; inherits: true; initial-value: 0px; }

:root {
  --preview-h: 0px; /* the design bar above the page (preview/switcher.css) */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --vh: calc(100vh - var(--preview-h));
}
@supports (height: 100dvh) {
  :root { --vh: calc(100dvh - var(--preview-h)); }
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; -webkit-font-smoothing: antialiased; }
body { padding-top: var(--preview-h); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.brand { min-width: 44px; } /* the seal alone, on narrow phones, is still a 44 px target */
[hidden] { display: none !important; }
/* The compact board's soft floor shadow reaches a little past the board (4% each side), where the original's room
   clipped it. Here the page clips it at the window's edge, so a phone never widens its layout or zooms out for it.
   The full board on a 320 px screen is the one exception: it is wider than the window, and the page scrolls to it. */
body:not([data-rods="17"]) .app { overflow-x: clip; }
/* on 360 px phones the full board just fits: the mats keep only a narrow margin round it, and the page clips the
   surround's last pixel or two rather than scroll; only below 350 px does the page scroll sideways to the board */
@media (max-width: 370px) { body[data-rods="17"][data-work="board"] .tatami { --pad-x: 4px; } }
@media (min-width: 350px) { body[data-rods="17"] .app { overflow-x: clip; } }

.visually-hidden, .settings-title.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- The tatami floor ---------- */
/* .tatami is the floor's box; .tatami-floor (the protected mats inside it,
   class "scene" for the original's edging and seam colours) fills it exactly
   and lies under its content. Nothing is drawn over the mats except the
   board and the page content placed on them. */
.tatami {
  --pad-x: 40px;
  --pad-y: 36px;
  --board-h: calc(var(--tat-h) - 2 * var(--pad-y));
  position: relative;
  isolation: isolate;
  width: var(--tat-w);
  min-height: var(--tat-h);
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
.tatami > * { grid-area: 1 / 1; }

.tatami-floor {
  --beam-h: 0px; /* the original's mats sat inside its timber; here the floor is the mats' whole box */
  --skirt-h: 0px;
  --post-w: 0px;
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  container-type: size; /* the mats turn on their side on a wide floor, as on the original's wide walls */
  color: #e8e1d6; /* the original's text colour round the mats, so even their unused currentColor is the original's */
}

/* ---------- Board ---------- */
.stage {
  --stage-w: calc(var(--tat-w) - 2 * var(--pad-x));
  align-self: center;
  justify-self: center;
  width: var(--stage-w);
  max-width: 100%;
  padding: var(--pad-y) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.stage::before { content: ""; flex: none; height: var(--tb-fit-top, 0px); }
.stage::after { content: ""; flex: none; height: var(--tb-fit, 0px); }

/* compact board: as wide as the floor allows, and never taller than it */
.stage[data-rods="4"] { --stage-w: min(calc(var(--tat-w) - 2 * var(--pad-x)), calc(var(--board-h) * 1.062 + 4px)); }
.frame[data-rods="4"] { --chrome: calc(100vh - var(--board-h)); }
@supports (height: 100dvh) {
  .frame[data-rods="4"] { --chrome: calc(100dvh - var(--board-h)); }
}
/* phones on their side keep the original's big compact beads; the board is
   taller than the screen and the page scrolls (7087e29's side gutters) */
@media (orientation: landscape) and (max-height: 500px) {
  .stage[data-rods="4"] { --stage-w: calc(var(--tat-w) - 2 * var(--pad-x)); }
  .frame[data-rods="4"] { --chrome: 186px; }
}

/* ---------- Chooser ---------- */
.chooser { align-self: center; justify-self: center; padding: var(--pad-y) var(--pad-x); }
.choices { display: flex; flex-wrap: wrap; justify-content: center; }
.choice { cursor: pointer; -webkit-tap-highlight-color: transparent; font: inherit; color: inherit; text-align: center; }
.choice-art { display: grid; place-items: center; }
.choice-art svg { display: block; width: auto; max-width: 100%; }
.choice-art .art-frame { fill: rgba(10, 8, 6, 0.35); stroke: rgba(184, 154, 106, 0.5); stroke-width: 1.5; }
.choice-art .art-beam { stroke: rgba(184, 154, 106, 0.5); stroke-width: 2; }
.choice-art line:not(.art-beam) { stroke: rgba(150, 128, 98, 0.55); stroke-width: 1; }
.choice-art rect:not(.art-frame) { fill: #7a5d45; }

/* ---------- Settings (filled in by core/soroban.js) ---------- */
.setting-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.setting-group legend { padding: 0 0 12px; }
.wood-options { display: flex; flex-wrap: wrap; gap: 12px; }
.wood-option { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.wood-option input { position: absolute; opacity: 0; pointer-events: none; }
.wood-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.wood-check { visibility: hidden; }
.wood-option input:checked ~ .wood-card .wood-check { visibility: visible; }
.tabs { display: flex; gap: 4px; }
.tab { background: none; border: 0; cursor: pointer; }

/* ---------- Lessons: nothing to open yet, said plainly ---------- */
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }

/* A sheet's catch area for clicks outside it: transparent, it darkens nothing */
.sheet-catch { display: none; position: fixed; inset: 0; z-index: 30; background: transparent; }
.sheet-open .sheet-catch { display: block; }
