/* HAIZ · 自由共游 — the margin of the picture. No glass cards over the world: ink on the edge of the
   painting, a seal-like glyph for each way of moving, and only what the moment needs. */
:root { --fr-ink: #2a2620; --fr-paper: #f1e8d4; --fr-red: #b0201c; --fr-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif; --fr-hand: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", serif; }

/* ---- the four ways: four characters at the foot of the picture, the current one stamped in red */
.fr-modes { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: none; gap: 6px; z-index: 3; }
body.fr-on[data-stage="stroll"] .fr-modes { display: flex; }
.fr-modes button { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 2px; width: 46px; padding: 4px 0 3px; color: rgba(255, 252, 244, .92); text-shadow: 0 1px 2px rgba(20, 16, 10, .55), 0 0 10px rgba(20, 16, 10, .25); transition: transform .25s, color .25s; }
.fr-modes button b { display: grid; place-items: center; width: 32px; height: 32px; font: 600 19px/1 var(--fr-hand); border: 1.5px solid currentColor; border-radius: 4px; box-shadow: 0 1px 3px rgba(20, 16, 10, .25), inset 0 0 0 1px rgba(20, 16, 10, .08); transition: background .3s, border-color .3s, color .3s, transform .3s; }
.fr-modes button span { font: 12px/1 var(--fr-serif); letter-spacing: .1em; opacity: .85; }
.fr-modes button:hover b { transform: translateY(-2px); }
.fr-modes button[aria-pressed="true"] b { background: var(--fr-red); border-color: var(--fr-red); color: #fbf2e4; transform: rotate(-3deg); text-shadow: none; }
.fr-modes button:focus-visible b { outline: 2px solid #fff; outline-offset: 2px; }
/* while riding, the walk's tool chips step back */
body[data-ride="bike"] .rh-tools, body[data-ride="board"] .rh-tools, body[data-ride="broom"] .rh-tools { opacity: 0; pointer-events: none; transition: opacity .6s; }

/* ---- the right thumb's buttons (touch screens; each way shows its own) */
.fr-pad { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px); display: none; grid-template-columns: repeat(2, 58px); gap: 12px; z-index: 3; touch-action: none; }
@media (pointer: coarse) { body.fr-on[data-stage="stroll"] .fr-pad:not([data-mode="none"]) { display: grid; } }
.fr-pad button { all: unset; display: none; place-items: center; width: 58px; height: 58px; border-radius: 50%; font: 600 20px/1 var(--fr-hand); color: #fff; background: rgba(30, 26, 20, .22); border: 1.5px solid rgba(255, 255, 255, .7); text-shadow: 0 1px 2px rgba(0, 0, 0, .4); -webkit-user-select: none; user-select: none; }
.fr-pad button.on { background: rgba(176, 32, 28, .75); border-color: rgba(255, 230, 220, .9); }
.fr-pad[data-mode="bike"] [data-for~="bike"], .fr-pad[data-mode="board"] [data-for~="board"], .fr-pad[data-mode="broom"] [data-for~="broom"] { display: grid; }

.fr-prompt { position: absolute; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 66px); transform: translateX(-50%); margin: 0; font: 15px/1.3 var(--fr-serif); color: #fffaf0; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); letter-spacing: .06em; z-index: 3; }

@media (max-width: 560px) {
  .fr-modes { bottom: max(10px, env(safe-area-inset-bottom)); gap: 2px; }
  .fr-modes button { width: 44px; }
  body.fr-on[data-stage="stroll"] .rh-tools { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px); }
}

/* ---- the compass and the reading: ink at the lower left, never a card */
.fr-hud { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); display: none; align-items: flex-end; gap: 12px; z-index: 3; transition: opacity .2s; }
#rh-ui > .fr-hud { pointer-events: none; }                 /* only the compass takes a tap (set on the canvas by hud.js) */
body.fr-on[data-stage="stroll"] .fr-hud { display: flex; }
.fr-hud canvas { display: block; cursor: pointer; filter: drop-shadow(0 2px 6px rgba(20, 14, 6, .25)); }
.fr-read { display: grid; gap: 2px; padding-bottom: 6px; color: #fffaf0; text-shadow: 0 1px 2px rgba(20, 14, 6, .7), 0 0 12px rgba(20, 14, 6, .35); }
.fr-read p { margin: 0; }
.fr-speed b { font: 600 38px/1 var(--fr-serif); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fr-speed small { font: 13px/1 var(--fr-serif); margin-left: 4px; opacity: .85; }
.fr-line { font: 16px/1.2 var(--fr-hand); letter-spacing: .08em; min-height: 1.2em; }
.fr-place { font: 13px/1.3 var(--fr-serif); opacity: .9; letter-spacing: .05em; }
.fr-dest { font: 600 14px/1.3 var(--fr-serif); color: #ffd8c8; letter-spacing: .04em; min-height: 1.3em; }
/* altitude: an ink scale with a red tick, only on the broom */
.fr-alt { position: relative; width: 26px; height: 128px; margin-bottom: 8px; --alt: 0; }
.fr-alt::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(rgba(255, 250, 240, .9), rgba(255, 250, 240, .5)); box-shadow: 0 0 4px rgba(20, 14, 6, .5); border-radius: 1px; }
.fr-alt i { position: absolute; left: 0; width: 14px; height: 3px; background: var(--fr-red); top: calc(6px + (1 - var(--alt)) * (100% - 12px)); transform: translateY(-50%); box-shadow: 0 0 0 1px rgba(255, 245, 230, .8); transition: top .2s; }
.fr-alt span { position: absolute; left: 14px; font: 10px/1 var(--fr-serif); color: #fffaf0; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }
.fr-alt span:nth-of-type(1) { top: 2px; } .fr-alt span:nth-of-type(2) { top: calc(50% - 5px); } .fr-alt span:nth-of-type(3) { bottom: 2px; }
/* the slip of places: paper, not glass */
.fr-slip { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 170px); width: min(320px, calc(100vw - 32px)); padding: 12px 14px 10px; background: var(--fr-paper); color: var(--fr-ink); border-radius: 2px; box-shadow: 0 10px 30px rgba(20, 14, 6, .3), inset 0 0 40px rgba(160, 120, 60, .12); z-index: 5; transform: rotate(-.6deg); }
.fr-slip header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid rgba(42, 38, 32, .25); padding-bottom: 4px; margin-bottom: 8px; }
.fr-slip h2 { margin: 0; font: 600 18px/1 var(--fr-hand); letter-spacing: .15em; }
.fr-slip header button { all: unset; cursor: pointer; font-size: 20px; padding: 0 4px; }
.fr-slip ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px; }
.fr-slip li button { all: unset; cursor: pointer; display: block; width: 100%; padding: 5px 2px; font: 15px/1.2 var(--fr-serif); border-bottom: 1px dotted rgba(42, 38, 32, .25); }
.fr-slip li button:hover, .fr-slip li button[aria-pressed="true"] { color: var(--fr-red); }
.fr-slip li button[aria-pressed="true"]::after { content: " ·"; }
.fr-slip footer { margin-top: 8px; display: grid; gap: 4px; }
.fr-slip footer button { all: unset; cursor: pointer; font: 13px/1.3 var(--fr-serif); color: #6a5a40; }
.fr-slip footer p { margin: 0; font: 11px/1.4 var(--fr-serif); color: #8a7a60; }
@media (max-width: 560px) {
  .fr-hud { left: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px); gap: 8px; }
  .fr-speed b { font-size: 30px; }
  .fr-line { font-size: 14px; } .fr-place { font-size: 12px; }
  .fr-slip { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 200px); }
}
/* on touch screens the left thumb's stick lives where the compass is: the compass moves up out of its way */
@media (pointer: coarse) { body[data-ride="bike"] .fr-hud, body[data-ride="board"] .fr-hud, body[data-ride="broom"] .fr-hud { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px); } }

/* ---- 海中八景: the prompt at the top of the picture, the page that flies into the book, the book */
.fr-vista { position: absolute; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 56px)); transform: translate(-50%, -8px); opacity: 0; display: flex; align-items: center; gap: 14px; z-index: 4; transition: opacity .5s, transform .5s; color: #fffaf0; text-shadow: 0 1px 3px rgba(20, 14, 6, .7); }
.fr-vista.on { opacity: 1; transform: translate(-50%, 0); }
.fr-vista p { margin: 0; display: grid; justify-items: center; }
.fr-vista b { font: 600 22px/1.2 var(--fr-hand); letter-spacing: .12em; }
.fr-vista span { font: 13px/1.3 var(--fr-serif); opacity: .9; letter-spacing: .1em; }
.fr-vista button { all: unset; cursor: pointer; padding: 7px 14px; background: var(--fr-red); color: #fbf2e4; font: 600 15px/1 var(--fr-hand); letter-spacing: .1em; border-radius: 2px; box-shadow: 0 2px 8px rgba(20, 14, 6, .35); text-shadow: none; }
.fr-vista kbd { font: 11px/1 var(--fr-serif); opacity: .8; margin-left: 4px; }
@media (pointer: coarse) { .fr-vista kbd { display: none; } }
.fr-fly { position: fixed; left: 50%; top: 50%; width: min(56vw, 480px); transform: translate(-50%, -50%) rotate(-2deg); box-shadow: 0 18px 50px rgba(20, 14, 6, .45); z-index: 6; transition: all 1.1s cubic-bezier(.6, 0, .3, 1); pointer-events: none; border: 6px solid #f1e8d4; }
.fr-book-btn i { display: inline-block; width: 12px; height: 15px; margin-right: 6px; vertical-align: -2px; background: #8e2a17; border-radius: 1px 2px 2px 1px; box-shadow: inset 2px 0 0 rgba(0, 0, 0, .25); }
.fr-book { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20, 14, 6, .35); z-index: 8; padding: 16px; }
.fr-book[hidden] { display: none; }
.fr-book-page { width: min(920px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--fr-paper); color: var(--fr-ink); padding: 18px 20px 14px; border-radius: 2px; box-shadow: 0 20px 60px rgba(20, 14, 6, .4), inset 0 0 60px rgba(160, 120, 60, .14); }
.fr-book-page header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid rgba(42, 38, 32, .25); padding-bottom: 6px; margin-bottom: 12px; }
.fr-book-page h2 { margin: 0; font: 600 22px/1 var(--fr-hand); letter-spacing: .15em; }
.fr-book-page h2 small { font: 13px/1 var(--fr-serif); letter-spacing: 0; color: #8a7a60; margin-left: 8px; }
.fr-book-page header button { all: unset; cursor: pointer; font: 14px/1 var(--fr-serif); color: #6a5a40; padding: 4px 8px; }
.fr-book-page ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.fr-book-page figure { margin: 0; }
.fr-book-page img, .fr-blank { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; box-shadow: 0 1px 4px rgba(20, 14, 6, .2); }
.fr-blank { display: grid; place-items: center; border: 1px dashed rgba(42, 38, 32, .3); padding: 10px; box-sizing: border-box; }
.fr-blank p { margin: 0; font: 14px/1.5 var(--fr-hand); color: #6a5a40; text-align: center; }
.fr-book-page figcaption { display: grid; margin-top: 4px; }
.fr-book-page figcaption b { font: 600 15px/1.3 var(--fr-hand); letter-spacing: .1em; }
.fr-book-page figcaption span { font: 11px/1.3 var(--fr-serif); color: #8a7a60; }
.fr-book-note { margin: 12px 0 0; font: 12px/1.5 var(--fr-serif); color: #8a7a60; }
@media (max-width: 720px) { .fr-book-page ol { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
