/* 茶想 — 本の形で読むページ（縦書き・左から右へめくる） */

:root {
  --desk: #0E0D0B;
  --accent: #D4A35A;
  --paper: #E9E1CD;
  --paper-deep: #DDD3BC;
  --ink: #2A251F;
  --ink-2: #6C6356;
  --rule: rgba(42, 37, 31, .2);
  --grain: url("/_chaso/paper.svg");
  --ui: #EDE7DB;
  --ui-2: #A69F92;
  --mincho: 'Shippori Mincho B1', 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', serif;
  --serif: 'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --latin: 'Bodoni Moda', Didot, 'Times New Roman', serif;
}
html[data-theme="night"] {
  --paper: #1D1B18;
  --paper-deep: #171512;
  --ink: #DDD4C3;
  --ink-2: #978D7D;
  --rule: rgba(221, 212, 195, .16);
  --grain: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--desk); color-scheme: dark; }
body { overflow: hidden; color: var(--ui); font-family: var(--serif); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
html:not(.js) body { overflow: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ---------- 机とランプ ---------- */
.bk-desk { position: fixed; inset: 0; background: var(--desk); }
.bk-desk__lamp {
  position: absolute; left: 50%; top: -38vh; width: 150vmax; height: 120vh; transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 50% at 50% 50%, color-mix(in oklab, var(--accent) 15%, transparent) 0%, color-mix(in oklab, var(--accent) 6%, transparent) 40%, transparent 72%);
  animation: bk-lamp 2.4s ease .1s both;
}
@keyframes bk-lamp { from { opacity: 0 } to { opacity: 1 } }

/* ---------- JavaScript が使えないときは、そのまま縦書きで読める ---------- */
.bk-fallback { position: relative; z-index: 1; height: 100vh; overflow-x: auto; overflow-y: hidden; background: var(--paper); color: var(--ink); }
.bk-fallback__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.bk-fallback .bk-article { height: 100%; padding: 56px 32px; writing-mode: vertical-rl; font-family: var(--mincho); font-size: 18px; line-height: 1.9; }
html.js .bk-fallback { position: fixed; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }

/* ---------- 本 ---------- */
.bk-stage {
  position: fixed; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0; transition: opacity .9s ease;
}
html.bk-ready .bk-stage { opacity: 1; }
.bk-book { position: relative; width: var(--book-w); height: var(--page-h); perspective: var(--persp, 2600px); }
.bk-page, .bk-leaf { position: absolute; top: 0; width: var(--page-w); height: var(--page-h); }
.bk-page, .bk-face { background-color: var(--paper); background-image: var(--grain); overflow: hidden; }
.bk-page { z-index: 1; }
html.bk-spread .bk-page[data-slot="a"] { right: 0; }
html.bk-spread .bk-page[data-slot="b"] { left: 0; }
html.bk-single .bk-page[data-slot="a"] { left: 0; }
html.bk-single .bk-page[data-slot="b"] { display: none; }
html.bk-spread .bk-book, html.bk-framed .bk-book { filter: drop-shadow(0 36px 46px rgba(0, 0, 0, .55)); }
html.bk-framed .bk-page, html.bk-spread .bk-page { border-radius: 2px; }

/* 綴じ目の影（右綴じ） */
.bk-view::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.bk-view[data-side="r"]::after { background: linear-gradient(to right, rgba(0, 0, 0, .2), rgba(0, 0, 0, .05) 4%, transparent 11%); }
.bk-view[data-side="l"]::after { background: linear-gradient(to left, rgba(0, 0, 0, .2), rgba(0, 0, 0, .05) 4%, transparent 11%); }
.bk-view[data-side="s"]::after { background: linear-gradient(to left, rgba(0, 0, 0, .12), transparent 7%); }
html.bk-spread .bk-view::before { content: ""; position: absolute; top: 0; bottom: 0; width: 6px; pointer-events: none; }
html.bk-spread .bk-view[data-side="r"]::before { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .08), transparent); }
html.bk-spread .bk-view[data-side="l"]::before { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .08), transparent); }

/* めくっているページ */
.bk-leaf { display: none; z-index: 5; transform-style: preserve-3d; will-change: transform; --sh: 0; }
.bk-leaf.is-on { display: block; }
.bk-leaf.is-left { left: 0; transform-origin: right center; }
.bk-leaf.is-right { right: 0; transform-origin: left center; }
.bk-face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.bk-face--back { transform: rotateY(180deg); }
.bk-shade { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: calc(var(--sh) * .5); }
.bk-leaf.is-left .bk-face--front .bk-shade { background: linear-gradient(to left, rgba(0, 0, 0, .35), rgba(0, 0, 0, .08) 60%, rgba(255, 250, 235, .05)); }
.bk-leaf.is-left .bk-face--back .bk-shade { background: linear-gradient(to right, rgba(0, 0, 0, .3), rgba(0, 0, 0, .04) 55%); }
.bk-leaf.is-right .bk-face--front .bk-shade { background: linear-gradient(to right, rgba(0, 0, 0, .35), rgba(0, 0, 0, .08) 60%, rgba(255, 250, 235, .05)); }
.bk-leaf.is-right .bk-face--back .bk-shade { background: linear-gradient(to left, rgba(0, 0, 0, .3), rgba(0, 0, 0, .04) 55%); }
html.bk-single .bk-face--back { background-color: var(--paper-deep); }

/* めくる下のページに落ちる影 */
.bk-cast { position: absolute; top: 0; z-index: 3; width: var(--page-w); height: var(--page-h); pointer-events: none; opacity: 0; }
.bk-cast[data-side="l"] { left: 0; background: linear-gradient(to left, rgba(0, 0, 0, .34), rgba(0, 0, 0, .08) 35%, transparent 70%); }
.bk-cast[data-side="r"] { right: 0; background: linear-gradient(to right, rgba(0, 0, 0, .34), rgba(0, 0, 0, .08) 35%, transparent 70%); }
.bk-cast[data-side="s"] { left: 0; background: linear-gradient(to left, rgba(0, 0, 0, .3), rgba(0, 0, 0, .06) 40%, transparent 75%); }

/* 端まで来たときの小さな揺れ */
.bk-book.bump-next { animation: bk-bump-next .45s ease; }
.bk-book.bump-prev { animation: bk-bump-prev .45s ease; }
@keyframes bk-bump-next { 30% { transform: translateX(8px) } 60% { transform: translateX(-3px) } }
@keyframes bk-bump-prev { 30% { transform: translateX(-8px) } 60% { transform: translateX(3px) } }

/* ---------- 1 ページの中身 ---------- */
.bk-view { position: absolute; inset: 0; }
.bk-area { position: absolute; top: var(--pad-t); bottom: var(--pad-b); left: var(--pad-x); right: var(--pad-x); display: flex; justify-content: center; }
.bk-clip { position: relative; width: var(--clip-w); height: 100%; overflow: hidden; }
.bk-special { position: absolute; inset: 0; }
.bk-folio { position: absolute; left: 0; right: 0; bottom: calc(var(--pad-b) * .36); text-align: center; font-family: var(--latin); font-style: italic; font-size: 12px; letter-spacing: .1em; color: var(--ink-2); }

/* 縦書きの組版（1 行の幅 = --p にそろえて、ページの境目で行が切れないようにしている） */
.bk-strip {
  position: absolute; top: 0; right: 0; height: 100%;
  writing-mode: vertical-rl; text-orientation: mixed;
  font-family: var(--mincho); font-size: var(--f); line-height: var(--p); color: var(--ink);
  line-break: strict; word-break: normal; overflow-wrap: break-word; font-kerning: normal;
  text-spacing-trim: space-first;
}
.bk-strip .bk-article { display: block; height: 100%; }
.bk-strip p { margin: 0; text-align: justify; }
.bk-strip h2 { margin: 0 0 0 var(--p); padding-top: 2.6em; font-family: var(--mincho); font-size: 1.3em; font-weight: 600; line-height: calc(var(--p) * 2); letter-spacing: .14em; color: var(--ink); }
.bk-strip h3 { margin: 0; padding-top: 1.2em; font-size: 1.06em; font-weight: 600; line-height: var(--p); letter-spacing: .1em; }
.bk-strip .bk-break { line-height: calc(var(--p) * 2); text-align: center; font-size: .72em; letter-spacing: 0; color: var(--ink-2); }
.bk-strip .bk-gap { width: var(--p); }
.bk-strip .bk-spacer { height: 100%; }
.bk-strip .bk-figure { width: var(--clip-w); height: 100%; margin: 0; writing-mode: horizontal-tb; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.bk-strip .bk-figure img { max-width: 100%; max-height: 86%; object-fit: contain; box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .5); }
.bk-strip .bk-figure figcaption { font-family: var(--serif); font-size: 12px; letter-spacing: .14em; color: var(--ink-2); }
.tcy { text-combine-upright: all; -webkit-text-combine: horizontal; }
.upr { text-orientation: upright; -webkit-text-orientation: upright; letter-spacing: 0; }
.bouten { font-style: normal; -webkit-text-emphasis: sesame; text-emphasis: sesame; }
.bk-strip em { font-style: normal; }
.bk-strip strong { font-weight: 600; }
ruby rt { font-size: .5em; }

/* 測るための見えない置き場 */
.bk-measure { position: fixed; top: 0; right: 0; width: var(--clip-w); height: var(--text-h); visibility: hidden; pointer-events: none; overflow: visible; z-index: -1; }
.bk-measure .bk-clip { height: 100%; overflow: visible; }

/* ---------- 扉 ---------- */
.bk-front { position: absolute; top: var(--pad-t); bottom: var(--pad-b); left: var(--pad-x); right: var(--pad-x); display: flex; flex-direction: column; align-items: center; gap: 7%; }
.bk-front--plain { justify-content: center; }
.bk-front__plate { flex: none; margin: 0; width: 100%; aspect-ratio: 16 / 9; padding: 5px; background: var(--paper-deep); box-shadow: 0 14px 30px -16px rgba(0, 0, 0, .55); }
.bk-front__plate img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bk-front__text { flex: 1; min-height: 0; width: 100%; writing-mode: vertical-rl; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 1.1em; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
.bk-front__kind { margin: 0; font-family: var(--serif); font-size: 12px; letter-spacing: .4em; color: var(--ink-2); }
.bk-front__title { margin: 0; font-family: var(--mincho); font-size: clamp(20px, calc(var(--text-h) * .05), 40px); font-weight: 600; letter-spacing: .16em; line-height: 1.5; }
.bk-front__author { margin: 0; padding-top: 34%; font-family: var(--mincho); font-size: calc(var(--f) * 1.05); letter-spacing: .32em; }
/* 挿絵のない扉：題名をページの中央に大きく置き、著者名を左下に添える */
.bk-front--plain .bk-front__text { flex: none; height: 100%; justify-content: center; gap: 2.4em; }
.bk-front--plain .bk-front__kind { padding-top: 6%; }
.bk-front--plain .bk-front__title { padding-top: 14%; font-size: clamp(24px, calc(var(--text-h) * .064), 46px); letter-spacing: .2em; }
.bk-front--plain .bk-front__author { padding-top: 62%; }
.bk-colophon { word-break: keep-all; overflow-wrap: anywhere; }

/* ---------- 奥付 ---------- */
.bk-back { position: absolute; top: var(--pad-t); bottom: var(--pad-b); left: var(--pad-x); right: var(--pad-x); display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.bk-colophon { flex: 1; min-height: 0; writing-mode: vertical-rl; display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: .9em; padding-top: 6%; font-family: var(--serif); font-size: 13px; letter-spacing: .2em; line-height: 1.6; color: var(--ink-2); }
.bk-colophon p { margin: 0; }
.bk-colophon__title { font-family: var(--mincho); font-size: calc(var(--f) * 1.1); font-weight: 600; letter-spacing: .14em; color: var(--ink); margin-left: .8em !important; }
.bk-colophon__site { margin-right: auto !important; padding-top: 50%; font-family: var(--mincho); font-size: 15px; letter-spacing: .3em; color: var(--ink); }
.bk-back__nav { display: flex; flex-direction: column; gap: 10px; }

.bk-link { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border: 1px solid var(--rule); border-radius: 999px; font-family: var(--serif); font-size: 13px; letter-spacing: .16em; color: var(--ink); text-decoration: none; transition: background-color .4s, color .4s, border-color .4s; }
.bk-link:hover { border-color: var(--ink); }
.bk-link--fill { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- 画面の上下の操作 ---------- */
.bk-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 128px 0;
  pointer-events: none; text-align: center;
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, .7, .1, 1);
}
.bk-top__title { margin: 0; max-width: 100%; font-size: 13px; letter-spacing: .2em; color: var(--ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-top__meta { margin: 0; font-size: 11px; letter-spacing: .2em; color: var(--ui-2); white-space: nowrap; }
.bk-aa {
  position: fixed; z-index: 22; top: calc(10px + env(safe-area-inset-top)); right: 14px;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(237, 231, 219, .18); background: rgba(18, 16, 14, .7); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-family: var(--latin); font-style: italic; font-size: 17px; color: var(--ui);
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, .7, .1, 1), border-color .4s;
}
.bk-aa:hover { border-color: var(--accent); }
.bk-settings {
  position: fixed; z-index: 23; top: calc(64px + env(safe-area-inset-top)); right: 14px; width: 220px;
  padding: 16px; border-radius: 18px; background: rgba(18, 16, 14, .94); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid rgba(237, 231, 219, .12); box-shadow: 0 24px 50px -16px rgba(0, 0, 0, .6);
  animation: bk-pop .45s cubic-bezier(.16, .8, .2, 1) both; transform-origin: top right;
}
@keyframes bk-pop { from { opacity: 0; transform: translateY(-8px) scale(.97) } to { opacity: 1; transform: none } }
.bk-settings__label { margin: 0 0 8px; font-size: 11px; letter-spacing: .24em; color: var(--ui-2); }
.bk-settings__label + .bk-seg { margin-bottom: 16px; }
.bk-seg:last-child { margin-bottom: 0; }
.bk-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(237, 231, 219, .06); }
.bk-seg button { min-height: 40px; border-radius: 9px; font-size: 14px; letter-spacing: .1em; color: var(--ui-2); transition: background-color .3s, color .3s; }
.bk-seg button[aria-pressed="true"] { background: rgba(237, 231, 219, .14); color: var(--ui); }

.bk-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, .7, .1, 1);
}
.bk-progress { position: relative; width: min(420px, 64vw); height: 2px; border-radius: 2px; background: rgba(237, 231, 219, .14); overflow: hidden; }
.bk-progress__bar { position: absolute; top: 0; right: 0; bottom: 0; width: 0; background: var(--accent); box-shadow: 0 0 10px color-mix(in oklab, var(--accent) 70%, transparent); transition: width .6s cubic-bezier(.2, .7, .1, 1); }
.bk-bottom__row { display: flex; align-items: center; gap: 18px; }
.bk-nav { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(237, 231, 219, .14); background: rgba(18, 16, 14, .55); color: var(--ui-2); transition: color .3s, border-color .3s, opacity .3s; }
.bk-nav:hover:not(:disabled) { color: var(--ui); border-color: var(--accent); }
.bk-nav:disabled { opacity: .3; cursor: default; }
.bk-count { margin: 0; min-width: 88px; text-align: center; font-family: var(--latin); font-style: italic; font-size: 15px; letter-spacing: .06em; color: var(--ui); }
.bk-count__sep { margin: 0 .5em; color: var(--ui-2); }

/* スマホでは、操作は紙の上に重なるので暗い帯にして、読むときは隠す */
html.bk-single:not(.bk-framed) .bk-top,
html.bk-single:not(.bk-framed) .bk-bottom { background: rgba(14, 13, 11, .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
html.bk-single:not(.bk-framed):not(.bk-chrome) .bk-top { opacity: 0; transform: translateY(-100%); }
html.bk-single:not(.bk-framed):not(.bk-chrome) .bk-bottom { opacity: 0; transform: translateY(100%); pointer-events: none; }
html.bk-single:not(.bk-framed):not(.bk-chrome) .bk-aa { opacity: 0; transform: translateY(-12px); pointer-events: none; }

/* ---------- お知らせ・使い方 ---------- */
.bk-toast {
  position: fixed; z-index: 24; left: 50%; top: calc(76px + env(safe-area-inset-top)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px; border-radius: 999px;
  background: rgba(18, 16, 14, .92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid rgba(237, 231, 219, .12);
  font-size: 12px; letter-spacing: .14em; color: var(--ui); white-space: nowrap;
  animation: bk-pop .5s cubic-bezier(.16, .8, .2, 1) both;
}
.bk-toast button { min-height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(237, 231, 219, .1); font-size: 12px; letter-spacing: .14em; }
.bk-hint {
  position: fixed; z-index: 24; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-radius: 999px;
  background: rgba(18, 16, 14, .9); border: 1px solid rgba(237, 231, 219, .12); color: var(--ui);
  font-size: 12px; letter-spacing: .12em; white-space: nowrap; pointer-events: none;
  animation: bk-pop .6s cubic-bezier(.16, .8, .2, 1) .8s both;
}
.bk-hint__arrow { display: grid; place-items: center; color: var(--accent); animation: bk-nudge 1.6s ease-in-out infinite; }
@keyframes bk-nudge { 0%, 100% { transform: translateX(-4px) } 50% { transform: translateX(6px) } }

/* ---------- ページを離れるとき（灯りが火種にまとまって暗転） ---------- */
.bk-curtain { position: fixed; inset: 0; z-index: 200; background: var(--desk); opacity: 0; visibility: hidden; pointer-events: none; }
.bk-ember { position: absolute; left: 50%; top: 40%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 40px 14px color-mix(in oklab, var(--accent) 45%, transparent); opacity: 0; }
html.bk-leaving .bk-curtain { visibility: visible; pointer-events: auto; animation: bk-out .75s cubic-bezier(.65, 0, .35, 1) both; }
html.bk-leaving .bk-ember { animation: bk-ember .75s ease both; }
@keyframes bk-out { from { opacity: 0 } to { opacity: 1 } }
@keyframes bk-ember { 0% { opacity: 0; transform: scale(7) } 55% { opacity: 1 } 100% { opacity: 1; transform: scale(1) } }

@media (max-width: 640px) {
  /* スマホの上の帯は「茶想」ボタンと設定だけにする（題名は扉に大きく出ている） */
  .bk-top__title, .bk-top__meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---------- 記事（横書き） ---------- */
html.hz body { overflow: auto; background: var(--desk); }
.hz-main { max-width: 720px; margin: 0 auto; padding: calc(96px + env(safe-area-inset-top)) 22px 160px; color: var(--ui); }
.hz-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 40px; }
.hz-kind { margin: 0; font-size: 12px; letter-spacing: .3em; color: var(--accent); }
.hz-title { margin: 0; font-family: var(--mincho); font-size: clamp(30px, 6vw, 46px); font-weight: 600; line-height: 1.35; letter-spacing: .04em; word-break: keep-all; overflow-wrap: anywhere; }
.hz-meta { display: flex; gap: 18px; margin: 0; font-size: 13px; letter-spacing: .14em; color: var(--ui-2); }
.hz-plate { margin: 0 0 40px; }
.hz-plate img { width: 100%; border-radius: 3px; }
.hz-article { font-family: var(--serif); font-size: 17px; line-height: 2.1; letter-spacing: .04em; color: #DDD6C9; }
.hz-article p { margin: 0 0 1.1em; }
.hz-article h2 { margin: 2.4em 0 .8em; font-family: var(--mincho); font-size: 1.4em; font-weight: 600; line-height: 1.5; color: var(--ui); }
.hz-article h3 { margin: 2em 0 .6em; font-size: 1.15em; font-weight: 600; color: var(--ui); }
.hz-article .bk-break { margin: 2.4em 0; text-align: center; font-size: .8em; letter-spacing: 1em; color: var(--ui-2); }
.hz-article .bk-gap { height: 1.4em; }
.hz-article .bk-figure { margin: 2em 0; }
.hz-article .bk-figure img { width: 100%; border-radius: 3px; }
.hz-article .bk-figure figcaption { margin-top: 10px; font-size: 13px; color: var(--ui-2); text-align: center; }
.hz-end { display: flex; flex-direction: column; gap: 10px; margin-top: 72px; --ink: var(--ui); --rule: rgba(237, 231, 219, .2); }
