/* BusayoDisu.com | the book reader (js/reader.js)
   =====================================================================
   Built to feel like the Kindle apps: a page edge to edge, a toolbar and a
   progress bar that come and go, a sheet for Aa and a drawer for Go to.

   Every colour here reads the four --kr-* variables the reader sets on .kr
   for the theme, so changing the page from white to black changes the
   toolbar, the sheets and the scrubber with it, and nothing is a literal
   colour except the ribbon and the shadows. The Hub wears data-theme="dark"
   and that repoints the site's own tokens, which is why this does not use
   them.

   The motion is the half of this that makes it feel like a book. Bars slide
   rather than appear, a page follows a finger and leaves the way it was
   pushed, and a panel rises from where it was asked for. All of it stops
   under prefers-reduced-motion and under the reader's own Page turn
   animation switch (.no-motion).
   ===================================================================== */

/* The Hub's player gives the page everything: no bar, no feet, no scroll. */
.hub-stage.reading .hub-bar,
.hub-stage.reading .hub-feet { display: none; }
.hub-stage.reading .hub-play { overflow: hidden; padding: 0; }
.kr-host { position: relative; flex: 1 1 auto; min-height: 0; }

.kr {
  --kr-mx: 40px;
  --kr-measure: 46rem;
  --kr-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --kr-line: color-mix(in srgb, var(--kr-ink) 14%, transparent);
  --kr-wash: color-mix(in srgb, var(--kr-ink) 9%, transparent);
  --kr-bar: color-mix(in srgb, var(--kr-page) 94%, transparent);
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--kr-page);
  color: var(--kr-ink);
  font-family: var(--sans, "Inter", system-ui, sans-serif);
  -webkit-tap-highlight-color: transparent;
  transition: background-color .3s ease, color .3s ease;
  outline: none;
}
.kr[data-margin="narrow"] { --kr-mx: 18px; }
.kr[data-margin="medium"] { --kr-mx: 40px; }
.kr[data-margin="wide"] { --kr-mx: 96px; }
.kr[data-columns="2"] { --kr-measure: 84rem; }
@media (max-width: 600px) {
  .kr[data-margin="narrow"] { --kr-mx: 12px; }
  .kr[data-margin="medium"] { --kr-mx: 22px; }
  .kr[data-margin="wide"] { --kr-mx: 40px; }
}

.kr button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.kr button:focus-visible, .kr [tabindex]:focus-visible { outline: 2px solid var(--kr-ink); outline-offset: 2px; border-radius: 8px; }

/* ---- the page ---- */
.kr-stage { position: absolute; inset: 0; }

.kr-sheet {
  position: absolute;
  top: 40px;
  bottom: 52px;
  left: 0; right: 0;
  margin-inline: auto;
  width: min(calc(100% - 2 * var(--kr-mx)), var(--kr-measure));
  will-change: transform, opacity;
}
.kr-view { position: absolute; inset: 0; }
.kr-view .epub-container { overflow: hidden !important; }

/* One pointer over the page: taps and drags are read here, not by the
   book, so the same gesture works whatever the chapter is. Under scrolling
   it steps aside and lets the page scroll itself. */
.kr-zones { position: absolute; inset: 0; z-index: 2; touch-action: none; cursor: default; }
.kr[data-mode="scroll"] .kr-zones { pointer-events: none; }
.kr[data-mode="scroll"] .kr-sheet { top: 0; bottom: 0; width: min(calc(100% - 2 * var(--kr-mx)), var(--kr-measure)); }

.kr-edge {
  position: absolute; z-index: 3; top: 50%; width: 44px; height: 44px; margin-top: -22px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--kr-wash);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, background-color .2s ease;
}
.kr-edge svg { width: 20px; height: 20px; }
.kr-edge.back { left: 10px; }
.kr-edge.on { right: 10px; }
.kr[data-mode="scroll"] .kr-edge { display: none; }
@media (hover: hover) and (min-width: 700px) {
  .kr:hover .kr-edge { opacity: .55; pointer-events: auto; }
  .kr .kr-edge:hover { opacity: 1; background: color-mix(in srgb, var(--kr-ink) 16%, transparent); }
}

/* The bookmark ribbon drops in from above the page and settles. */
.kr-ribbon {
  position: absolute; z-index: 4; top: 0; right: 26px; width: 22px; height: 32px;
  color: #B85E3C;
  transform: translateY(-110%);
  transition: transform .34s cubic-bezier(.3, 1.5, .5, 1), top .28s var(--kr-ease);
  pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25));
}
.kr-ribbon.on { transform: translateY(-2px); }
/* With the toolbar down, the ribbon hangs from its lower edge, as it does
   in the Kindle apps, instead of hiding behind it. */
.kr[data-chrome="on"] .kr-ribbon { top: 56px; }
.kr-ribbon svg { width: 100%; height: 100%; display: block; }

/* ---- the faint line at the foot, always there ---- */
.kr-foot {
  position: absolute; z-index: 1; bottom: 16px; left: 0; right: 0; margin-inline: auto;
  width: min(calc(100% - 2 * var(--kr-mx)), var(--kr-measure));
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 12px; letter-spacing: .01em; color: var(--kr-faint);
  pointer-events: none; transition: opacity .2s ease;
}
.kr[data-chrome="on"] .kr-foot { opacity: 0; }
.kr[data-theme="black"] .kr-foot { color: #7B7B7B; }

/* ---- the toolbar ---- */
.kr-top, .kr-bottom {
  position: absolute; z-index: 6; left: 0; right: 0;
  background: var(--kr-bar);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: transform .3s var(--kr-ease), opacity .22s ease, visibility 0s .3s;
}
.kr-top {
  top: 0; display: flex; align-items: center; gap: 2px; height: 56px; padding: 0 10px;
  border-bottom: 1px solid var(--kr-line);
  transform: translateY(-100%);
}
.kr-bottom {
  bottom: 0; padding: 12px 22px 16px;
  border-top: 1px solid var(--kr-line);
  transform: translateY(100%);
}
.kr[data-chrome="on"] .kr-top, .kr[data-chrome="on"] .kr-bottom { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }

.kr-gap { flex: 1 1 auto; }
.kr-heading { min-width: 0; display: flex; flex-direction: column; margin-left: 4px; line-height: 1.2; }
.kr-book { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kr-chapter { font-size: 12px; color: var(--kr-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kr[data-theme="black"] .kr-chapter { color: #8A8A8A; }

.kr-key {
  flex: 0 0 auto; width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent;
  transition: background-color .15s ease, transform .15s ease;
}
.kr-key:hover { background: var(--kr-wash); }
.kr-key:active { transform: scale(.92); }
.kr-key svg { width: 22px; height: 22px; }
.kr-key.aa { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.kr-key.aa span { font-family: Georgia, serif; }

/* ---- the progress bar (Page Flip) ---- */
.kr-scrub { position: relative; height: 40px; cursor: pointer; touch-action: none; }
.kr-track { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: color-mix(in srgb, var(--kr-ink) 20%, transparent); }
.kr-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--kr-ink); width: 0; }
.kr-ticks i { position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px; border-radius: 1px; background: color-mix(in srgb, var(--kr-ink) 38%, var(--kr-page)); }
.kr-thumb {
  position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; left: 0;
  border-radius: 50%; background: var(--kr-ink); box-shadow: 0 0 0 3px var(--kr-page), 0 1px 4px rgba(0, 0, 0, .35);
  transition: transform .15s ease;
}
.kr-scrub.on .kr-thumb { transform: scale(1.3); }
.kr-info { display: flex; justify-content: space-between; gap: 16px; margin-top: 2px; font-size: 12px; color: var(--kr-faint); }
.kr[data-theme="black"] .kr-info { color: #8A8A8A; }

.kr-card {
  position: absolute; z-index: 2; bottom: calc(100% + 8px); transform: translateX(-50%);
  min-width: 140px; max-width: min(300px, 90%); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px; text-align: center;
  background: var(--kr-page); color: var(--kr-ink); border: 1px solid var(--kr-line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
  font-size: 12px; pointer-events: none;
}
.kr-card[hidden], .kr-back[hidden], .kr-hint[hidden], .kr-open[hidden], .kr-panel[hidden], .kr-scrim[hidden] { display: none; }
.kr-card b { font-size: 14px; font-weight: 600; }
.kr-card span { color: var(--kr-faint); }
.kr-bottom { position: absolute; }
.kr-card { left: 0; }

.kr-back {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border: 0; border-radius: 999px;
  background: var(--kr-ink); color: var(--kr-page); font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  animation: kr-rise .3s var(--kr-ease);
}

/* ---- panels: Aa and Go to ---- */
.kr-scrim { position: absolute; inset: 0; z-index: 15; background: rgba(0, 0, 0, .22); opacity: 0; transition: opacity .24s ease; }
.kr-scrim.on { opacity: 1; }

.kr-panel {
  position: absolute; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--kr-page); color: var(--kr-ink);
  border: 1px solid var(--kr-line);
  box-shadow: 0 18px 54px rgba(0, 0, 0, .34);
  opacity: 0;
  transition: transform .28s var(--kr-ease), opacity .2s ease;
}
.kr-aa {
  top: 62px; right: 12px; width: 380px; max-width: calc(100% - 24px); max-height: calc(100% - 82px);
  border-radius: 16px; transform-origin: top right; transform: translateY(-8px) scale(.96);
}
.kr-go {
  top: 0; bottom: 0; left: 0; width: 380px; max-width: 100%;
  border-radius: 0 16px 16px 0; transform: translateX(-102%);
}
.kr-panel.on { opacity: 1; transform: none; }

.kr-grab { display: none; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--kr-line); }
.kr-tabs { display: flex; align-items: center; gap: 4px; padding: 6px 8px 0 12px; border-bottom: 1px solid var(--kr-line); flex: 0 0 auto; }
.kr-tabs [role="tab"] {
  position: relative; padding: 14px 10px 12px; border: 0; background: none;
  font-size: 14px; font-weight: 600; color: var(--kr-faint);
}
.kr[data-theme="black"] .kr-tabs [role="tab"] { color: #8A8A8A; }
.kr-tabs [role="tab"][aria-selected="true"] { color: var(--kr-ink); }
.kr-tabs [role="tab"][aria-selected="true"]::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 2px 2px 0 0; background: var(--kr-ink);
}
.kr-x { margin-left: auto; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; }
.kr-x:hover { background: var(--kr-wash); }
.kr-x svg { width: 18px; height: 18px; }

.kr-body { padding: 4px 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
.kr-body.list { padding: 4px 8px 16px; }
.kr-label { margin: 18px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--kr-faint); }
.kr[data-theme="black"] .kr-label { color: #8A8A8A; }
.kr-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.kr-row.between { justify-content: space-between; font-size: 15px; }
.kr-row.bright { margin-top: 18px; }
.kr-ico { flex: 0 0 auto; width: 22px; height: 22px; display: grid; place-items: center; color: var(--kr-faint); }
.kr-ico svg { width: 22px; height: 22px; }
.kr-a { font-family: Georgia, serif; font-weight: 600; flex: 0 0 auto; line-height: 1; }
.kr-a.s { font-size: 14px; }
.kr-a.l { font-size: 28px; }

/* A drawn slider on top of the platform's own, so the thumb and the groove
   are the same in every browser. */
.kr-range { -webkit-appearance: none; appearance: none; flex: 1 1 auto; min-width: 0; height: 32px; background: transparent; cursor: pointer; }
.kr-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--kr-ink) 22%, transparent); }
.kr-range::-moz-range-track { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--kr-ink) 22%, transparent); }
.kr-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; border: 0; background: var(--kr-ink); box-shadow: 0 0 0 3px var(--kr-page), 0 1px 4px rgba(0, 0, 0, .35); }
.kr-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--kr-ink); box-shadow: 0 0 0 3px var(--kr-page), 0 1px 4px rgba(0, 0, 0, .35); }

.kr-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kr-swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: none; }
.kr-swatch span {
  width: 100%; height: 54px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid rgba(128, 128, 128, .45);
  font: 600 22px Georgia, serif;
  transition: box-shadow .15s ease, transform .15s ease;
}
.kr-swatch em { font-style: normal; font-size: 12px; color: var(--kr-faint); }
.kr-swatch[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--kr-page), 0 0 0 4px var(--kr-ink); }
.kr-swatch:active span { transform: scale(.95); }

.kr-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kr-presets button { padding: 12px; border: 1px solid var(--kr-line); border-radius: 10px; background: none; font-size: 14px; font-weight: 600; transition: background-color .15s ease; }
.kr-presets button:hover { background: var(--kr-wash); }

.kr-fonts { display: flex; flex-direction: column; margin-top: 6px; }
.kr-font {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 13px 4px; border: 0; border-bottom: 1px solid var(--kr-line); background: none;
  font-size: 18px; text-align: left;
}
.kr-font.plain { font-size: 15px; font-family: inherit; }
.kr-font:last-child { border-bottom: 0; }
.kr-font i { width: 20px; height: 20px; opacity: 0; transition: opacity .15s ease; }
.kr-font i svg { width: 20px; height: 20px; }
.kr-font[aria-pressed="true"] i { opacity: 1; }

.kr-switch { position: relative; width: 48px; height: 28px; padding: 0; border: 0; border-radius: 14px; background: color-mix(in srgb, var(--kr-ink) 24%, transparent); transition: background-color .2s ease; }
.kr-switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--kr-page); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .22s var(--kr-ease); }
.kr-switch[aria-checked="true"] { background: var(--kr-ink); }
.kr-switch[aria-checked="true"] i { transform: translateX(20px); }

.kr-seg { display: flex; border: 1px solid var(--kr-line); border-radius: 10px; overflow: hidden; }
.kr-seg button { flex: 1 1 0; padding: 11px 6px; border: 0; background: none; font-size: 14px; font-weight: 600; transition: background-color .15s ease, color .15s ease; }
.kr-seg button + button { border-left: 1px solid var(--kr-line); }
.kr-seg button[aria-pressed="true"] { background: var(--kr-ink); color: var(--kr-page); }
.kr-wideonly { display: none; }
@media (min-width: 900px) { .kr-wideonly { display: block; } }

.kr-toc { list-style: none; margin: 0; padding: 0; }
.kr-toc li { display: flex; align-items: center; }
.kr-toc li > button:first-child {
  flex: 1 1 auto; min-width: 0; display: flex; justify-content: space-between; gap: 14px; align-items: baseline;
  padding: 14px 10px; border: 0; border-bottom: 1px solid var(--kr-line); background: none; text-align: left; font-size: 15px;
}
.kr-toc li > button:first-child:hover { background: var(--kr-wash); }
.kr-toc em { font-style: normal; font-size: 13px; color: var(--kr-faint); flex: 0 0 auto; }
.kr-toc button[aria-current="true"] { font-weight: 700; }
.kr-del { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--kr-faint); }
.kr-del svg { width: 16px; height: 16px; }
.kr-empty { margin: 0; padding: 26px 16px; color: var(--kr-faint); line-height: 1.55; font-size: 15px; }

.kr-hint {
  position: absolute; z-index: 12; left: 50%; bottom: 74px; max-width: min(340px, 86%);
  padding: 12px 16px; border-radius: 12px; text-align: center;
  background: var(--kr-ink); color: var(--kr-page); font-size: 14px; line-height: 1.45;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .3);
  opacity: 0; transform: translate(-50%, 10px); transition: opacity .35s ease, transform .35s var(--kr-ease); pointer-events: none;
}
.kr-hint.on { opacity: 1; transform: translate(-50%, 0); }

.kr-dim { position: absolute; inset: 0; z-index: 40; background: #000; opacity: 0; pointer-events: none; }

/* ---- opening ---- */
.kr-open {
  position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--kr-page); padding: 24px; text-align: center;
  transition: opacity .35s ease;
}
.kr-open.gone { opacity: 0; pointer-events: none; }
.kr-cover { height: min(40vh, 300px); width: auto; max-width: 70%; border-radius: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .28); animation: kr-rise .5s var(--kr-ease) both; }
.kr-open-title { margin: 6px 0 0; font-family: var(--serif, Georgia, serif); font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 600; }
.kr-open-bar { width: 180px; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--kr-ink) 18%, transparent); overflow: hidden; }
.kr-open-bar i { display: block; height: 100%; width: 0; background: var(--kr-ink); transition: width .2s ease; }
.kr-open-word { margin: 0; font-size: 13px; color: var(--kr-faint); max-width: 36ch; }
.kr-fail { padding: 28px; color: #C6D2DC; text-align: center; }

/* ---- the Aa sheet and Go to become bottom sheets on a phone ---- */
@media (max-width: 600px) {
  .kr-aa, .kr-go {
    top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-width: 100%; max-height: 80%;
    border-radius: 18px 18px 0 0; transform: translateY(100%); border-bottom: 0;
  }
  .kr-grab { display: block; }
  .kr-top { padding: 0 4px; }
  .kr-key { width: 42px; height: 42px; }
}

@keyframes kr-rise { from { opacity: 0; transform: translate(var(--kr-from-x, 0), 12px); } to { opacity: 1; transform: translate(var(--kr-from-x, 0), 0); } }
.kr-back { --kr-from-x: -50%; }

/* Page turn animation off, or the system asks for less motion: the bars and
   panels still change, they just do not travel. */
.kr.no-motion, .kr.no-motion * { transition-duration: 0s !important; animation-duration: 0s !important; }
@media (prefers-reduced-motion: reduce) {
  .kr, .kr * { transition-duration: 0s !important; animation-duration: 0s !important; }
}
