/* Settings bottom sheet (js/settings-sheet.js) + the first-run tour
   (js/onboarding.js) + the reader loading state. Dark ink default, washi
   light overrides at the end. */

/* ----- Settings sheet ---------------------------------------------------- */
.settings-sheet { position: fixed; inset: 0; z-index: 85; }
.settings-sheet[hidden] { display: none !important; }
.ss-backdrop { position: absolute; inset: 0; background: rgba(13, 15, 24, 0.6); }
.ss-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #232739;
  border-top: 1px solid var(--brass, #c9a464);
  border-radius: 18px 18px 0 0;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom, 0px));
}
.ss-grip { width: 38px; height: 4px; border-radius: 2px; background: rgba(232,220,196,0.3); margin: 2px auto 12px; }
.ss-title {
  font-family: var(--font-jp, serif);
  font-size: 1.15rem;
  color: #e8dcc4;
  margin: 0 0 14px;
}
.ss-title-en { font-family: var(--font-ui, sans-serif); font-size: 0.72rem; color: #a89f8a; letter-spacing: 0.08em; margin-left: 8px; }
.ss-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid rgba(232, 220, 196, 0.1);
}
.ss-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ss-label { font-family: var(--font-ui, sans-serif); font-size: 0.92rem; color: #f0e8d3; }
.ss-hint { font-family: var(--font-ui, sans-serif); font-size: 0.74rem; color: #a89f8a; }
.ss-btn {
  flex: 0 0 auto;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.8rem;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--brass, #c9a464);
  background: transparent;
  color: var(--brass, #c9a464);
  cursor: pointer;
}
.ss-btn:disabled { opacity: 0.4; }
.ss-btn.is-danger { border-color: rgba(212, 74, 58, 0.7); color: #d44a3a; }
.ss-toggle {
  flex: 0 0 auto;
  width: 46px; height: 27px;
  border-radius: 14px;
  border: 1px solid rgba(232, 220, 196, 0.35);
  background: rgba(232, 220, 196, 0.12);
  position: relative;
  cursor: pointer;
  padding: 0;
}
.ss-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #a89f8a;
  transition: left 0.16s ease, background 0.16s ease;
}
.ss-toggle.is-on { background: rgba(201, 164, 100, 0.3); border-color: var(--brass, #c9a464); }
.ss-toggle.is-on .ss-knob { left: 21px; background: var(--brass, #c9a464); }
.ss-about {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 0 2px;
  border-top: 1px solid rgba(232, 220, 196, 0.1);
  margin-top: 4px;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.74rem;
  color: #a89f8a;
}
.ss-about a { color: var(--brass, #c9a464); text-decoration: none; }

/* ----- First-run tour ----------------------------------------------------- */
.tour-overlay {
  position: fixed; inset: 0; z-index: 86;
  background: rgba(13, 15, 24, 0.78);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.tour-overlay[hidden] { display: none !important; }
.tour-card {
  position: relative;
  width: min(92vw, 360px);
  min-height: 540px;                 /* equal height across all 3 steps — no jump on Next */
  max-height: calc(100vh - 40px);    /* never taller than the screen … */
  max-height: calc(100dvh - 40px);   /* … so the footer button is never clipped (cards 2/3 have longer text) */
  display: flex; flex-direction: column;
  background: #1f2433;
  border: 1px solid #333a4d;
  border-radius: 22px;
  padding: 0;
  overflow: hidden;
}
.tour-skip {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 32px; height: 32px;
  border: none; background: rgba(20,23,31,0.5); color: #cdbf9f; cursor: pointer;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.tour-skip svg { width: 15px; height: 15px; }
/* Hero zone — the focal illustration on a darker panel, uniform height. */
.tour-art {
  background: #191d2b;
  border-bottom: 1px solid #2c3346;
  padding: 32px 18px 28px;
}
.tour-art svg { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto; }
.tour-text { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 24px 24px 8px; }
.tour-jp { font-family: var(--font-jp, serif); font-size: 1.75rem; color: #f3ecdb; margin: 0 0 6px; line-height: 1.2; }
.tour-en { font-family: var(--font-ui, sans-serif); font-size: 0.82rem; font-weight: 500; color: var(--vermilion, #d44a3a); margin: 0 0 14px; letter-spacing: 0.04em; }
.tour-body { font-family: var(--font-ui, sans-serif); font-size: 0.92rem; line-height: 1.6; color: #bcb6a6; margin: 0; }
/* Footer is pinned (flex: none) so the button + dots are always on-screen, never clipped. */
.tour-foot { flex: none; padding: 14px 24px 22px; }
.tour-next {
  font-family: var(--font-ui, sans-serif);
  font-size: 1rem; font-weight: 600;
  margin: 0;
  padding: 14px 0; width: 100%;
  border-radius: 13px;
  border: none;
  background: var(--brass, #c9a464);
  color: #1a1d2c;
  cursor: pointer;
}
/* Override the global `button:hover { color: var(--brass) }` (design.css) — it
   recolors the label to the brass BACKGROUND, so "Next" went gold-on-gold and
   vanished after the button was tapped (iOS keeps :hover sticky). Keep it dark. */
.tour-next:hover, .tour-next:active, .tour-next:focus { color: #1a1d2c; border: none; }
.tour-dots { display: flex; gap: 8px; justify-content: center; margin: 16px 0 0; }
.tour-dot { width: 7px; height: 7px; border-radius: 50%; background: #444c63; }
.tour-dot.is-on { background: var(--vermilion, #d44a3a); }

/* ----- Reader loading state ----------------------------------------------- */
.reader-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18vh 0 0;
}
.rl-ring {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(201, 164, 100, 0.25);
  border-top-color: var(--brass, #c9a464);
  animation: rl-spin 0.9s linear infinite;
}
.rl-text { font-family: var(--font-jp, serif); font-size: 0.95rem; color: #a89f8a; }
@keyframes rl-spin { to { transform: rotate(360deg); } }

/* ----- Light (washi) theme ------------------------------------------------ */
body[data-theme="light"] .ss-panel,
body[data-theme="light"] .tour-card { background: #efe6d2; border-color: #8a6f3c; }
body[data-theme="light"] .ss-title, body[data-theme="light"] .tour-jp { color: #2b2620; }
body[data-theme="light"] .ss-label { color: #2b2620; }
body[data-theme="light"] .ss-hint, body[data-theme="light"] .ss-about, body[data-theme="light"] .tour-body { color: #6e6147; }
body[data-theme="light"] .ss-row, body[data-theme="light"] .ss-about { border-top-color: rgba(43, 38, 32, 0.12); }
body[data-theme="light"] .ss-btn { border-color: #8a6f3c; color: #8a6f3c; }
body[data-theme="light"] .ss-btn.is-danger { border-color: #b03a2c; color: #b03a2c; }
body[data-theme="light"] .ss-toggle { background: rgba(43, 38, 32, 0.1); border-color: rgba(43, 38, 32, 0.3); }
body[data-theme="light"] .ss-toggle.is-on { background: rgba(138, 111, 60, 0.25); border-color: #8a6f3c; }
body[data-theme="light"] .ss-toggle.is-on .ss-knob { background: #8a6f3c; }
body[data-theme="light"] .ss-about a, body[data-theme="light"] .tour-en, body[data-theme="light"] .tour-next { color: #8a6f3c; }
body[data-theme="light"] .tour-next { border-color: #8a6f3c; background: rgba(138, 111, 60, 0.1); }
body[data-theme="light"] .tour-next:hover, body[data-theme="light"] .tour-next:active, body[data-theme="light"] .tour-next:focus { color: #8a6f3c; }
body[data-theme="light"] .tour-dot.is-on { background: #8a6f3c; }
/* tour art panel stays ink (fixed plate, same rule as story art) */
