/* ==========================================================================
   きかせて — the paper table and the opening sequence (2026-11 overhaul)
   Loaded after styles.css on the home page and the book pages. The ground is
   photographed paper (assets/tex); on it lies the book as a real 3D object
   (scene/), seen from straight above. The type is the book's own typeface,
   set large and vertical. Without JavaScript or WebGL the sequence is the
   same words as a plain page, with a still of the book.
   ========================================================================== */

@view-transition { navigation: auto; }

body.ov {
  --washi: #efebe2;
  --soft: #6a645b;
  --ui: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --head: 96px;                    /* the height the header keeps clear at the top */
  background: var(--washi) url("assets/tex/washi.jpg") 0 0 / 440px 440px;
}
@media (min-width: 641px) { body.ov { --head: 76px; } }

/* ---- the header stays at the top of every page ------------------------------------------------- */

.ov .site-header {
  position: sticky; top: 0; z-index: 20;
  max-width: none; min-height: var(--head);
  padding-inline: max(var(--gutter), calc((100vw - var(--container)) / 2));
  align-items: center;
  background: var(--washi) url("assets/tex/washi.jpg") 0 0 / 440px 440px;
  transition: background-color 0.3s;
}
.ov.over-table .site-header { background: none; }          /* over the table it is only its words */
@media (max-width: 640px) { .ov .site-header { align-items: flex-start; justify-content: center; } }

/* ---- the sequence ---------------------------------------------------------------------------- */

.seq { position: relative; }
.seq-canvas { display: none; }
.seq-pin { position: relative; padding-bottom: 56px; }
.seq-still { display: block; width: min(72%, 340px); height: auto; margin: 28px auto 0; }

.seq-anchor { display: block; }
.seq.is-live .seq-anchor { position: absolute; top: calc(2 * 96svh); }
.seq.is-still .seq-anchor { position: static; }

/* live: one screen held in place while the scroll plays the book */
.seq.is-live { height: calc(100svh + var(--stops) * 96svh); margin-top: calc(-1 * var(--head)); }
.seq.is-live .seq-pin { position: sticky; top: 0; height: 100svh; padding: 0; overflow: hidden; }
.seq.is-live .seq-canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.5s ease; }
.seq.is-ready .seq-canvas { opacity: 1; }
.seq.is-live .seq-still { display: none; }

/* first screen: what it is, in the book's own type */
.sq-hero { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; padding: 20px var(--gutter) 0; }
.sq-title {
  grid-column: 2; grid-row: 1;
  writing-mode: vertical-rl;
  font-weight: var(--w-medium);
  font-size: clamp(2.4rem, 11.6vw, 3.4rem);
  line-height: 1.34;
  letter-spacing: 0.14em;
  white-space: nowrap;
  word-break: normal;
}
.sq-say { grid-column: 1; grid-row: 1; display: grid; gap: 12px; align-content: start; justify-items: start; }
.sq-what { font-size: clamp(1.125rem, 5.1vw, 1.5rem); font-weight: var(--w-medium); line-height: 1.62; letter-spacing: 0.06em; text-wrap: balance; }
.sq-who { font-size: 0.9375rem; line-height: 1.8; }
.sq-status { display: flex; align-items: center; gap: 12px; font-size: 0.875rem; letter-spacing: 0.1em; }
.sq-price { display: grid; gap: 2px; width: 100%; padding-top: 12px; border-top: 1px solid currentColor; font-size: 0.875rem; line-height: 1.8; }
.sq-price .yen { font-size: clamp(1.0625rem, 5.3vw, 1.375rem); letter-spacing: 0.04em; line-height: 1.5; white-space: nowrap; }

/* which book lies on the table */
.sq-pick { display: flex; flex-wrap: nowrap; gap: 6px; pointer-events: auto; }
.sq-pick[hidden] { display: none; }
.sq-pick button {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 10px 6px 8px;
  background: none; border: 1px solid var(--line); border-radius: 2px; cursor: pointer;
  font-size: 0.75rem; letter-spacing: 0.04em; white-space: nowrap; color: var(--soft);
}
.sq-pick i { width: 10px; height: 22px; background: var(--cloth); }
.sq-pick button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }

.seq.is-live .sq-hero { position: absolute; inset: 0; display: block; padding: 0; pointer-events: none; transform: translate3d(0, calc(var(--d, 0) * -30px), 0); }
.seq.is-live .sq-title { position: absolute; top: calc(var(--head) + 18px); right: var(--gutter); }
.seq.is-live .sq-say { position: absolute; top: calc(var(--head) + 26px); left: var(--gutter); width: min(21rem, calc(100% - 2 * var(--gutter) - 2 * 1.34 * clamp(2.4rem, 11.6vw, 3.4rem) - 14px)); }
.seq.is-live .sq-pick { margin-top: 4px; }

/* the stops: one real question each. The question is read on the page of the book; here it is named. */
.stops { display: grid; gap: 48px; padding: 56px var(--gutter) 0; }
.stops[hidden] { display: none; }
.stop { display: grid; gap: 10px; }
.stop-meta { display: flex; gap: 1.2em; font-family: var(--ui); font-size: 0.75rem; letter-spacing: 0.16em; line-height: 1.6; color: var(--soft); }
.stop-no { font-family: var(--font-min); font-size: 0.875rem; letter-spacing: 0.2em; }
.stop-q { font-size: clamp(1.375rem, 6vw, 1.75rem); font-weight: var(--w-medium); line-height: 1.6; letter-spacing: 0.1em; }

.seq.is-live .stops { position: absolute; inset: 0; display: block; padding: 0; z-index: 2; pointer-events: none; }
.seq.is-live .stops[hidden] { display: none; }
.seq.is-live .stop {
  position: absolute; left: 50%; bottom: max(26px, calc(env(safe-area-inset-bottom, 0px) + 20px)); width: max-content; max-width: 92%;
  display: block; text-align: center;
  opacity: 0; visibility: hidden; will-change: opacity;
  transform: translate3d(-50%, 0, 0);
}
.seq.is-live .stop-meta { display: block; white-space: nowrap; }
.seq.is-live .stop-meta > span + span { margin-inline-start: 1.4em; }
.seq.is-live .stop-q { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.seq.is-live .stop-first .stop-q { position: static; width: auto; height: auto; clip-path: none; font-size: 0.9375rem; font-weight: var(--w-regular); letter-spacing: 0.1em; margin-top: 4px; }
.seq.is-live .stop-first .stop-q br { display: none; }

.seq-cue { display: none; }
.seq.is-live .seq-cue {
  display: flex; align-items: center; gap: 10px;
  position: absolute; left: var(--gutter); bottom: max(22px, calc(env(safe-area-inset-bottom, 0px) + 14px)); z-index: 2;
  writing-mode: vertical-rl;
  font-family: var(--ui); font-size: 0.6875rem; letter-spacing: 0.22em; white-space: nowrap; color: var(--soft);
  opacity: calc(1 - var(--p, 0) * 7); pointer-events: none;
}
.seq-cue::after { content: ""; width: 1px; height: 26px; background: currentColor; }
.seq.no-cue .seq-cue { visibility: hidden; }   /* set by scene/stage.js when the hint would run into the words */

/* reduced motion: the book lies still, and the questions follow as a plain list */
.seq.is-still { height: auto; }
.seq.is-still .seq-pin { position: relative; height: auto; overflow: visible; }
.seq.is-still .seq-canvas { height: 100svh; }
.seq.is-still .sq-hero { height: 100svh; transform: none; }
.seq.is-still .seq-cue { display: none; }
.seq.is-still .stops { position: relative; inset: auto; display: grid; padding: 24px var(--gutter) 64px; }
.seq.is-still .stop { position: static; width: auto; max-width: none; display: grid; text-align: left; opacity: 1 !important; visibility: visible !important; transform: none; }
.seq.is-still .stop-q { position: static; width: auto; height: auto; clip-path: none; white-space: normal; font-size: 1.5rem; }

/* wide screens */
@media (min-aspect-ratio: 4/5) and (min-width: 860px) {
  .seq.is-live .sq-title { top: 13svh; right: max(var(--gutter), calc((100vw - var(--container)) / 2)); font-size: clamp(3.6rem, 5vw + 4svh, 7.75rem); letter-spacing: 0.16em; }
  .seq.is-live .sq-say { top: 20svh; left: max(var(--gutter), calc((100vw - var(--container)) / 2)); width: min(21rem, 22vw); gap: 16px; }
  /* never larger than lets its longest unbroken run (nine characters) fit the column, so no line is left holding only 「。」 */
  .sq-what { font-size: min(clamp(1.5rem, 1.1rem + 1.2vw, 2rem), calc(min(21rem, 22vw) / 9.6)); }
  .sq-who { font-size: 1.0625rem; }
  .sq-price { font-size: 1rem; padding-top: 16px; }
  .sq-price .yen { font-size: 1.75rem; }
  .seq.is-live .seq-cue { left: max(var(--gutter), calc((100vw - var(--container)) / 2)); bottom: 7svh; writing-mode: horizontal-tb; font-size: 0.75rem; }
  .seq.is-live .seq-cue::after { width: 40px; height: 1px; }
  .sq-pick button { font-size: 0.8125rem; padding: 6px 14px 6px 10px; letter-spacing: 0.08em; }
  .seq.is-live .stop { left: max(var(--gutter), calc((100vw - var(--container)) / 2)); bottom: 7svh; text-align: left; transform: none; }
  .seq.is-live .stop-meta { font-size: 0.8125rem; }
}

/* ---- the quiet pages after it -------------------------------------------------------------------- */

.ov .edition .still, .ov .other-editions .still { display: block; width: 100%; height: auto; margin-bottom: 4px; }
.ov .other-editions { grid-template-columns: repeat(3, minmax(0, 190px)); }
@media (max-width: 640px) {
  .ov .other-editions { grid-template-columns: 1fr; }
  .ov .other-editions .edition { grid-template-columns: 96px minmax(0, 1fr); column-gap: 16px; }
  .ov .other-editions .edition .still { grid-row: span 2; margin: 0; }
}
.ed-intro .measure { display: grid; gap: 16px; }
.ov .site-footer { position: relative; }

/* ---- tablets held upright: the phone arrangement, at a larger size ------------------------------------ */
@media (min-width: 700px) and (max-aspect-ratio: 4/5) {
  .sq-title { font-size: 5.25rem; }
  .sq-what { font-size: 1.875rem; }
  .sq-who { font-size: 1.125rem; }
  .sq-price { font-size: 1rem; }
  .sq-price .yen { font-size: 1.75rem; }
  .sq-pick button { font-size: 0.875rem; padding: 8px 16px 8px 12px; }
  .seq.is-live .sq-say { width: min(27rem, calc(100% - 2 * var(--gutter) - 2 * 1.34 * 5.25rem - 28px)); gap: 16px; }
}

/* ---- the smallest phones ---------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .ov .site-nav { font-size: 0.75rem; gap: 0 10px; letter-spacing: 0; }
  .sq-what { font-size: 0.9375rem; letter-spacing: 0.03em; }
  .sq-title { font-size: 2.2rem; }
  .seq.is-live .sq-say { width: calc(100% - 2 * var(--gutter) - 2 * 1.34 * 2.2rem - 10px); }
}
