/* There's More to Me: a cozy flipbook. Colours come from the cover: paper, butter-yellow wash, sage meadow,
   terracotta lettering, warm brown ink. */
:root {
  --paper: #fbf7ec;
  --table: #f2e9d4;          /* behind the book: a shade deeper than the pages so they stand out */
  --paper-deep: #f4ecd9;
  --card: rgba(255, 252, 244, 0.92);
  --line: #eadcbf;
  --ink: #6b4f3c;
  --ink-soft: #9a7f68;
  --terracotta: #c27a4e;
  --peach: #f3cfae;
  --peach-deep: #ebbb92;
  --sage: #cbd3a0;
  --butter: #eedc97;
  --daisy-heart: #ecc45c;
  --shadow: 0 10px 30px rgba(112, 82, 50, 0.13), 0 2px 6px rgba(112, 82, 50, 0.08);
  --radius: 22px;
  --dock-h: 76px;
  --side: clamp(10px, 6vw, 88px);
  --ease: cubic-bezier(.3, .7, .3, 1);
  --hand: "Gaegu", "Comic Sans MS", "Chalkboard SE", cursive;
  --ui: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);   /* nothing may make the page wider than the screen */
  overflow: hidden;
  font-family: var(--ui);
  color: var(--ink);
  background:
    radial-gradient(58vmax 34vmax at 8% 100%, rgba(203, 211, 160, 0.55), transparent 62%),
    radial-gradient(46vmax 30vmax at 96% 4%, rgba(238, 220, 151, 0.45), transparent 62%),
    radial-gradient(36vmax 26vmax at 92% 96%, rgba(243, 207, 174, 0.35), transparent 62%),
    radial-gradient(30vmax 22vmax at 4% 6%, rgba(243, 207, 174, 0.22), transparent 62%),
    var(--table);
  -webkit-tap-highlight-color: transparent;
}
/* paper grain over everything, never in the way */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.55;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .32  0 0 0 0 .22  0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

button { font: inherit; color: inherit; }
.ic {
  width: 24px; height: 24px;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; border-radius: 14px; }

/* --- top bar --------------------------------------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-daisy { width: 34px; height: 34px; flex: none; animation: sway 6s ease-in-out infinite; transform-origin: 50% 60%; }
.brand-title {
  margin: 0; font-family: var(--hand); font-weight: 700; color: var(--terracotta);
  font-size: clamp(24px, 3.2vw, 36px); line-height: 1; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.about-btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  min-height: 44px; padding: 8px 16px 8px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); box-shadow: var(--shadow);
  font-family: var(--hand); font-weight: 700; font-size: 20px; color: var(--ink); cursor: pointer;
  transition: transform .2s var(--ease), background .2s;
}
.about-btn .ic { color: var(--terracotta); width: 22px; height: 22px; }
.about-btn:hover { background: #fff8ea; transform: translateY(-1px); }

/* --- the stage and the book ------------------------------------------------------------------------------------ */
.stage {
  position: relative; min-height: 0; min-width: 0;
  overflow-x: clip;        /* a phone must never widen the page to fit the book */
  display: flex; align-items: center; justify-content: center;
  padding: 10px var(--side) 14px;
}
.book-sizer {
  position: relative;
  width: 280px;            /* set by book.js to fit the window */
  max-width: 100%; min-width: 0; flex: none;
  transition: transform .7s var(--ease);
  will-change: transform;
}
/* a soft shadow under the open book, like it is resting on a table */
.book-sizer::after {
  content: ""; position: absolute; left: 4%; right: 4%; bottom: -14px; height: 28px; z-index: -1;
  background: radial-gradient(closest-side, rgba(110, 80, 45, 0.22), transparent);
  filter: blur(4px);
  transition: left .7s var(--ease), right .7s var(--ease), opacity .4s;
}
.book-sizer[data-alone="right"]::after { left: 52%; }
.book-sizer[data-alone="left"]::after { right: 52%; }
.book-sizer[data-orientation="portrait"]::after { left: 6%; right: 6%; }
.book { min-width: 0 !important; margin: 0 auto; }

.page {
  background-color: var(--paper);
  box-shadow: 0 1px 2px rgba(92, 64, 36, 0.10), 0 16px 30px -12px rgba(92, 64, 36, 0.30);
  background-position: center; background-size: cover; background-repeat: no-repeat;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.page img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .35s ease;
  pointer-events: none; -webkit-user-drag: none;
}
.page img.is-loaded { opacity: 1; }
/* the fold in the middle of the book */
.page:not(.page--hard)::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.page.--left:not(.page--hard)::after {
  background: linear-gradient(to left, rgba(92, 64, 36, 0.2), rgba(92, 64, 36, 0.06) 3%, rgba(92, 64, 36, 0) 10%);
}
.page.--right:not(.page--hard)::after {
  background: linear-gradient(to right, rgba(92, 64, 36, 0.2), rgba(92, 64, 36, 0.06) 3%, rgba(92, 64, 36, 0) 10%);
}
/* one page at a time: just a whisper of the spine, since a wide page would show the full fold as a heavy band */
.book-sizer[data-orientation="portrait"] .page.--right:not(.page--hard)::after {
  background: linear-gradient(to right, rgba(92, 64, 36, 0.12), rgba(92, 64, 36, 0.03) 1.2%, rgba(92, 64, 36, 0) 4%);
}
.page--hard { box-shadow: inset 0 0 0 1px rgba(140, 105, 70, 0.12); }

/* the round arrows either side of the book (AnyFlip's edge tabs, made soft) */
.edge {
  position: absolute; top: 50%; z-index: 5;
  width: 58px; height: 58px; margin-top: -29px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
  opacity: .82; transition: opacity .25s, transform .25s var(--ease), background .2s;
}
.edge .ic { width: 30px; height: 30px; stroke-width: 2.4; }
.edge--prev { left: max(12px, calc(var(--side) / 2 - 29px)); }
.edge--next { right: max(12px, calc(var(--side) / 2 - 29px)); }
.edge:hover { opacity: 1; background: #fff8ea; }
.edge--prev:hover { transform: translateX(-3px); }
.edge--next:hover { transform: translateX(3px); }
.edge:disabled { opacity: 0; pointer-events: none; }
.stage[data-edges="tight"] .edge { display: none; }   /* no room beside the book: the toolbar is enough */

.hint {
  position: absolute; left: 50%; bottom: 10px; margin: 0; z-index: 3;
  transform: translateX(-50%);
  padding: 6px 16px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
  font-family: var(--hand); font-size: 19px; font-weight: 700; color: var(--ink);
  white-space: nowrap; pointer-events: none;
  animation: hint-in .6s var(--ease) both, bob 2.6s ease-in-out 1s infinite;
}
.hint.is-leaving { animation: hint-out .4s ease both; }
.noscript { font-family: var(--hand); font-size: 24px; }

/* --- the dock and toolbar -------------------------------------------------------------------------------------- */
.dock {
  position: relative; z-index: 10;   /* the volume pop-up stays over the book's turning pages */
  display: flex; justify-content: center;
  padding: 2px 12px max(14px, env(safe-area-inset-bottom));
}
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.tb {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink); cursor: pointer;
  transition: background .2s, transform .2s var(--ease), color .2s, opacity .2s;
}
.tb:hover { background: #f6ead0; }
.tb:active { transform: scale(.94); }
.tb:disabled { opacity: .35; cursor: default; background: transparent; transform: none; }
.tb--main { width: 52px; height: 52px; background: var(--peach); }
.tb--main .ic { width: 28px; height: 28px; stroke-width: 2.5; }
.tb--main:hover { background: var(--peach-deep); }
.tb--main:disabled { background: var(--peach); }
.tb[aria-pressed="false"] { color: var(--ink-soft); }
.tb[aria-pressed="true"] { color: var(--ink); }
#meadowBtn[aria-pressed="true"] { background: #e7ecc9; color: #5f6b33; }
.tb--plain { width: 40px; height: 40px; }

/* the volume: a little slider pops up over the sound button on hover (or keyboard focus) */
.vol { position: relative; display: grid; }
.vol-pop {
  position: absolute; left: 50%; bottom: calc(100% + 18px); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 54px; padding: 8px 0 12px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transform: translate(-50%, 8px) scale(.96); transform-origin: 50% 100%;
  transition: opacity .18s ease, transform .28s var(--ease), visibility 0s linear .28s;
}
.vol.is-open .vol-pop {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
  transition: opacity .18s ease, transform .28s var(--ease), visibility 0s;
}
.vol-pop::before {   /* the little point under it, towards the button */
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px;
  background: #fffcf4; border: 1.5px solid var(--line); border-top: 0; border-left: 0;
  transform: translateX(-50%) rotate(45deg); border-radius: 0 0 3px 0;
}
.vol-pop::after {    /* an invisible bridge, so the mouse can travel from the button up to the slider */
  content: ""; position: absolute; left: -10px; right: -10px; top: 100%; height: 26px;
}
.vol-num {
  font-family: var(--hand); font-weight: 700; font-size: 18px; line-height: 1; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.vol-track { position: relative; width: 34px; height: 118px; }
.vol-range {
  --v: 80%;
  position: absolute; left: 50%; top: 50%; width: 118px; height: 34px; margin: 0;
  transform: translate(-50%, -50%) rotate(-90deg);   /* a sideways slider stood upright: louder is up */
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
  touch-action: none;
}
.vol-range:focus { outline: none; }
.vol-range::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right, var(--terracotta) 0 var(--v), var(--line) var(--v) 100%);
}
.vol-range::-moz-range-track { height: 8px; border-radius: 999px; background: var(--line); }
.vol-range::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--terracotta); }
.vol-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -7px; border-radius: 50%;
  background: radial-gradient(circle, var(--daisy-heart) 0 4px, var(--paper) 4.5px);
  border: 3px solid var(--terracotta); box-shadow: 0 2px 6px rgba(112, 82, 50, 0.25);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.vol-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle, var(--daisy-heart) 0 4px, var(--paper) 4.5px);
  border: 3px solid var(--terracotta); box-shadow: 0 2px 6px rgba(112, 82, 50, 0.25);
}
.vol-range:active::-webkit-slider-thumb { transform: scale(1.12); }
.vol-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(194, 122, 78, 0.28); }
.vol-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px rgba(194, 122, 78, 0.28); }
.tb-sep { width: 1.5px; height: 26px; margin: 0 4px; background: var(--line); border-radius: 2px; }
.pager {
  min-width: 92px; padding: 0 8px; text-align: center;
  font-family: var(--hand); font-weight: 700; font-size: 24px; line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.pager-of { color: var(--ink-soft); font-weight: 400; font-size: 20px; }

/* --- all the pages --------------------------------------------------------------------------------------------- */
.thumbs {
  position: fixed; z-index: 20; left: 50%;
  bottom: calc(var(--dock-h) + 8px + env(safe-area-inset-bottom));
  width: min(980px, calc(100vw - 24px));
  transform: translateX(-50%);
  padding: 10px 14px 14px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: panel-in .35s var(--ease) both;
}
.thumbs[hidden] { display: none; }
.thumbs-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--hand); font-weight: 700; font-size: 22px; color: var(--ink-soft); padding: 0 2px 6px 6px;
}
.thumbs-scroll {
  display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 8px;
  scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.thumb-item {
  flex: none; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px; border-radius: 14px; border: 2px solid transparent; background: transparent; cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s var(--ease);
}
.thumb-item:hover { background: #f6ead0; transform: translateY(-2px); }
.thumb-item[aria-current="true"] { border-color: var(--peach-deep); background: #fbecd9; }
.thumb-imgs { display: flex; box-shadow: 0 3px 10px rgba(112, 82, 50, 0.15); border-radius: 4px; overflow: hidden; }
.thumb-imgs img { display: block; height: 78px; width: auto; background: var(--paper-deep); }
.thumb-label { font-family: var(--hand); font-weight: 700; font-size: 18px; color: var(--ink-soft); line-height: 1; }

/* --- about ----------------------------------------------------------------------------------------------------- */
.about {
  width: min(500px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 28px 28px 24px; border: 1.5px solid var(--line); border-radius: 28px;
  background: #fffcf4; color: var(--ink); box-shadow: 0 24px 60px rgba(90, 62, 35, 0.25);
  text-align: center;
}
.about[open] { animation: pop-in .4s var(--ease) both; }
.about::backdrop { background: rgba(80, 58, 36, 0.28); backdrop-filter: blur(2px); }
.about-close { position: absolute; top: 12px; right: 12px; }
.about-daisy { width: 48px; height: 48px; }
.about h2 { margin: 6px 0 2px; font-family: var(--hand); font-weight: 700; font-size: 38px; color: var(--terracotta); line-height: 1.05; }
.about-by { margin: 0 0 14px; font-family: var(--hand); font-size: 22px; color: var(--ink-soft); }
.about-blurb { margin: 0 0 10px; font-size: 17px; line-height: 1.55; }
.about-note { margin: 0 0 16px; font-size: 15px; color: var(--ink-soft); }
.about-note:empty, .about-by:empty { display: none; }
.about-how { text-align: left; background: #f8efdc; border-radius: 18px; padding: 12px 18px 10px; }
.about-how h3 { margin: 0 0 6px; font-family: var(--hand); font-size: 22px; color: var(--ink); }
.about-how ul { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.7; }
kbd {
  font-family: var(--ui); font-size: 13px; padding: 1px 7px; border-radius: 6px;
  background: #fffcf4; border: 1.5px solid var(--line); box-shadow: 0 1.5px 0 var(--line);
}

/* --- motion ---------------------------------------------------------------------------------------------------- */
@keyframes sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes hint-out { to { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes panel-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .book-sizer, .book-sizer::after { transition: none; }
}

/* --- smaller screens ------------------------------------------------------------------------------------------- */
@media (max-width: 760px) {
  :root { --side: 10px; --dock-h: 68px; }
  .edge { display: none; }
  .tb--side { display: none; }
  .about-btn span { display: none; }
  .about-btn { padding: 8px 11px; }
  .brand-daisy { width: 28px; height: 28px; }
}
@media (max-width: 420px) {
  #fsBtn { display: none; }   /* phones: the browser bar already folds away; iPhones can't go full screen at all */
  .tb { width: 42px; height: 42px; }
  .tb--main { width: 48px; height: 48px; }
  .tb-sep { margin: 0 1px; }
  .pager { min-width: 70px; font-size: 21px; padding: 0 4px; }
  .pager-of { font-size: 17px; }
  .toolbar { gap: 2px; padding: 5px; }
}
@media (max-width: 350px) {
  .dock { padding-left: 6px; padding-right: 6px; }
  .tb { width: 38px; height: 38px; }
  .tb--main { width: 44px; height: 44px; }
  .pager { min-width: 58px; font-size: 19px; }
  .brand-title { font-size: 21px; }
}
@media (max-height: 520px) {
  .topbar { padding-top: 6px; }
  .brand-title { font-size: 22px; }
  .dock { padding-bottom: 8px; }
  .hint { display: none; }
}

/* --- small rules that must win --------------------------------------------------------------------------------- */
[hidden] { display: none !important; }
.book-sizer:not(.is-ready), .book-sizer:not(.is-ready)::after { transition: none; }
.tb, .edge, .about-btn, .thumb-item { touch-action: manipulation; }
