/* The book: a linen table, seven hinged sheets, and a strip layout for phones.
   Pages are designed at 420 x 532 px and scaled with zoom, so text stays live and sharp. */
.table{
  --s:1; --turn:900ms;
  position:relative; border-radius:var(--r); padding:clamp(20px,3.2vw,44px) clamp(10px,2.4vw,36px) 18px;
  background:
    repeating-linear-gradient(0deg,rgba(120,100,70,.022) 0 1px,transparent 1px 4px),
    repeating-linear-gradient(90deg,rgba(120,100,70,.02) 0 1px,transparent 1px 4px),
    radial-gradient(120% 90% at 20% 0%,#f4ecdd 0%,#e7dcc8 60%,#dccfb7 100%);
  box-shadow:var(--shadow); outline-offset:4px; overflow-x:clip;
}
.book-stage{display:grid;place-items:center;min-height:calc(532px * var(--s))}
.book{
  position:relative; width:calc(840px * var(--s)); height:calc(532px * var(--s));
  perspective:2600px; transition:transform var(--turn) cubic-bezier(.3,.1,.2,1);
  opacity:0;
}
.table.is-ready .book{opacity:1}
/* a closed book is one page wide: slide it to the middle of the table */
.table[data-mode="book"][data-index="0"] .book{transform:translateX(-25%)}
.table[data-mode="book"][data-index="7"] .book{transform:translateX(25%)}
.book::after{content:"";position:absolute;left:6%;right:6%;bottom:-18px;height:26px;border-radius:50%;
  background:rgba(60,40,10,.28);filter:blur(16px);z-index:-1;transition:left var(--turn),right var(--turn)}
.table[data-index="0"] .book::after{left:52%}
.table[data-index="7"] .book::after{right:52%}

.sheet{position:absolute;top:0;left:50%;width:50%;height:100%;transform-origin:0 50%;
  transform-style:preserve-3d;-webkit-transform-style:preserve-3d;
  transition:transform var(--turn) cubic-bezier(.3,.1,.2,1)}
/* a finger moving up or down scrolls the page and two fingers still zoom; sideways it drags the sheet */
.table[data-mode="book"] .book{touch-action:pan-y pinch-zoom}
.sheet.is-flipped{transform:rotateY(-180deg)}
.sheet.is-dragging{transition:none}
.face{position:absolute;inset:0;overflow:clip;background:#fff;
  backface-visibility:hidden;-webkit-backface-visibility:hidden}
.face--front{border-radius:2px 10px 10px 2px}
.face--back{transform:rotateY(180deg);border-radius:10px 2px 2px 10px}
/* gutter shadow near the spine, and the page darkening as it lifts */
.face::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(to right,rgba(0,0,0,.2),rgba(0,0,0,.05) 4%,transparent 11%);transition:background-color var(--turn)}
.face--back::after{background:linear-gradient(to left,rgba(0,0,0,.2),rgba(0,0,0,.05) 4%,transparent 11%)}
.sheet.is-turning .face::after,.sheet.is-dragging .face::after{background-color:rgba(0,0,0,.07)}
.sheet:not(.is-flipped) .face--front,.sheet.is-flipped .face--back{box-shadow:0 10px 30px rgba(60,40,10,.18)}
[data-spread="cover"].face,[data-spread="back"].face{border-radius:4px 12px 12px 4px}
[data-spread="back"].face{border-radius:12px 4px 4px 12px}

.page{width:420px;height:532px;zoom:var(--s);position:relative;overflow:clip}
.page--missing{display:grid;place-items:center;padding:40px;font:500 14px/1.4 var(--display);color:var(--ink-3);text-align:center}

/* controls */
.book-nav{display:flex;justify-content:center;align-items:center;gap:18px;margin-top:26px}
.book-arrow{width:44px;height:44px;border-radius:50%;border:0;background:rgba(255,255,255,.75);font:400 24px/1 var(--display);cursor:pointer;
  display:grid;place-items:center;padding-bottom:3px;transition:background .2s}
.book-arrow:hover{background:#fff}
.book-arrow:disabled{opacity:.35;cursor:default}
.book-dots{display:flex;gap:4px;align-items:center}
.book-dots button{width:28px;height:28px;border:0;background:none;padding:0;cursor:pointer;display:grid;place-items:center}
.book-dots button::before{content:"";width:11px;height:11px;border-radius:50%;background:var(--c);opacity:.45;transition:transform .2s var(--ease),opacity .2s}
.book-dots button:hover::before{opacity:.8}
.book-dots button[aria-current]::before{opacity:1;transform:scale(1.5);box-shadow:0 0 0 3px rgba(255,255,255,.8)}
.book-hint{margin-top:10px;text-align:center;font:600 12px/1 var(--display);letter-spacing:.12em;text-transform:uppercase;color:#665a40}
/* read out by screen readers when the spread changes; not drawn */
.book-status{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.book-noscript{text-align:center;padding:40px 16px;color:var(--ink-2)}

/* phones: the same pages as a swipeable strip, one page per view */
.table[data-mode="strip"]{padding-inline:0;padding-top:0;overflow:clip}
.table[data-mode="strip"] .book-stage{min-height:0}
.table[data-mode="strip"] .book{width:min(100%,420px);height:auto;perspective:none;display:flex;overflow-x:auto;
  scroll-snap-type:x mandatory;scrollbar-width:none}
.table[data-mode="strip"] .book::-webkit-scrollbar{display:none}
.table[data-mode="strip"] .book::after{display:none}
.table[data-mode="strip"] .face{position:relative;inset:auto;flex:0 0 100%;scroll-snap-align:start;transform:none;border-radius:0;height:calc(532px * var(--s))}
.table[data-mode="strip"] .face::after{display:none}

@media (prefers-reduced-motion:reduce){
  .sheet,.book{transition:none!important}
  .book{transition:opacity .18s linear!important}
  .book.is-fading{opacity:.01!important;transition:none!important}
}
