/* ATPL flip-book (partials/atpl-ebook.blade.php): .eb-stage (zoom viewport) > .eb-zoom > .eb-book (perspective)
   > .eb-pose (tilt) > .eb-slide > .eb-sheet (turn) > .eb-face. No JS (no .eb-on): flat cover only. */
.atpl-ebook {
    --w: min(86vw, 360px, max(240px, calc((100vh - 130px) / 1.41667)));
    --t: .75px; --tc: 2px; --dur: .72s; --ease: cubic-bezier(.45, .05, .2, 1);
    --bg: #F3F4F6; --spot: #fff; --ink: #182333; --muted: #5C687B; --accent: #1470A9; --tint: rgba(23, 130, 197, .1);
    --bar: #fff; --line: #DCE3EB; --paper: #F7F6F2; --edge: #E9E6DF; --sh: 24, 35, 51; --sa: .3;
    padding: 72px 0 80px;
    background: radial-gradient(64% 40% at 50% 54%, var(--spot), transparent 72%), var(--bg);
}
.atpl-ebook .eb-head { margin-bottom: 6px; }
.atpl-ebook .site-title { text-wrap: balance; }
.atpl-ebook .eb-desc { max-width: 620px; margin: 14px auto 0; font-size: 16px; line-height: 1.65; color: var(--muted); }

/* Clip x only (turns need vertical room); both axes while zoomed. */
.atpl-ebook .eb-stage { position: relative; overflow: hidden; overflow: clip visible; touch-action: pan-y; }
.atpl-ebook.is-clip .eb-stage { overflow: hidden; overflow: clip; }
/* Padding = headroom for a turning page swelling toward the camera. */
.atpl-ebook .eb-zoom { position: relative; padding: 64px 0 70px; transform-origin: 0 0; }
.atpl-ebook.is-zoom .eb-stage { touch-action: none; cursor: grab; }
.atpl-ebook.is-drag .eb-stage { cursor: grabbing; }
.atpl-ebook .eb-book { position: relative; width: var(--w); height: calc(var(--w) * 1.41667); margin: 0 auto; perspective: calc(var(--w) * 5.5); outline: 0; -webkit-tap-highlight-color: transparent; }
.atpl-ebook.eb-spread .eb-book { width: calc(var(--w) * 2); }
.atpl-ebook.eb-on .eb-book { cursor: pointer; -webkit-user-select: none; user-select: none; }
.atpl-ebook.is-zoom .eb-book { cursor: inherit; }
.atpl-ebook .eb-book::after { content: ""; position: absolute; inset: -10px; border: 3px solid var(--accent); border-radius: 8px; opacity: 0; pointer-events: none; }
.atpl-ebook .eb-book:focus-visible::after { opacity: 1; }
.atpl-ebook.eb-spread:is(.is-start, .is-end) .eb-book::after { inset-inline: calc(25% - 10px); }
/* Closed: real thickness. Open: sheets ~1px apart, so the pages stay flat and level. */
.atpl-ebook.is-start, .atpl-ebook.is-end { --t: var(--tc); }
.atpl-ebook .eb-pose, .atpl-ebook .eb-slide { position: absolute; inset: 0; transform-style: preserve-3d; }
.atpl-ebook.eb-on .eb-pose { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.atpl-ebook.is-zoom .eb-pose { --rx: 0deg; --ry: 0deg; }
.atpl-ebook.eb-spread.is-start .eb-slide { transform: translateX(calc(var(--w) * -.5)); }
.atpl-ebook.eb-spread.is-end .eb-slide { transform: translateX(calc(var(--w) * .5)); }

.atpl-ebook .eb-sheet { position: absolute; top: 0; left: 0; width: var(--w); height: 100%; transform-style: preserve-3d; transform-origin: 0 50%; }
.atpl-ebook.eb-spread .eb-sheet { left: 50%; }
.atpl-ebook.eb-on .eb-sheet { --tz: translateZ(calc(var(--z) * var(--t))); transform: var(--tz) rotateY(0deg); }
.atpl-ebook.eb-on .eb-sheet.is-flipped { transform: var(--tz) rotateY(-180deg); }
.atpl-ebook.eb-single .eb-sheet.is-flipped { visibility: hidden; }
.atpl-ebook .eb-face { position: absolute; inset: 0; overflow: hidden; border-radius: 0 2px 2px 0; background: var(--paper); -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.atpl-ebook .eb-back { transform: rotateY(180deg); border-radius: 2px 0 0 2px; }
.atpl-ebook .eb-face img { display: block; width: 100%; max-width: none; height: 100%; object-fit: cover; pointer-events: none; transition: none; }
.atpl-ebook .eb-face::before, .atpl-ebook .eb-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
/* Gutter shade; covers get a crease and a sheen. */
.atpl-ebook .eb-face::before { background: linear-gradient(90deg, rgba(var(--sh), .26), rgba(var(--sh), .07) 3.5%, rgba(255, 255, 255, .1) 6%, transparent 12%); }
.atpl-ebook .eb-cover::before { background: linear-gradient(90deg, rgba(var(--sh), .3), rgba(255, 255, 255, .16) 1.4%, transparent 3%), linear-gradient(118deg, rgba(255, 255, 255, .13), transparent 38%); }
.atpl-ebook .eb-back::before, .atpl-ebook .eb-back::after { transform: scaleX(-1); }
.atpl-ebook .eb-face::after { opacity: 0; }
.atpl-ebook:not(.eb-on) .eb-sheet ~ .eb-sheet, .atpl-ebook:not(.eb-on) .eb-back, .atpl-ebook .eb-edge, .atpl-ebook .eb-shadow { display: none; }
.atpl-ebook:not(.eb-on) .eb-front { box-shadow: 0 30px 50px -24px rgba(var(--sh), .55), 0 4px 12px rgba(var(--sh), .14); }

/* Page-block edges (fore-edge + foot planes) and each stack's shadow */
.atpl-ebook.eb-on .eb-edge, .atpl-ebook.eb-on .eb-shadow { display: block; position: absolute; opacity: 0; }
.atpl-ebook .eb-edge { --d: calc((var(--n) - var(--f)) * var(--t)); background-color: var(--edge); }
.atpl-ebook .eb-edge--l, .atpl-ebook .eb-edge--bl { --d: calc(var(--f) * var(--t)); }
.atpl-ebook .eb-edge--l, .atpl-ebook .eb-edge--r { top: 0; height: 100%; width: var(--d); background-image: repeating-linear-gradient(90deg, rgba(var(--sh), .1) 0 1px, transparent 1px var(--t)); }
.atpl-ebook .eb-edge--r { right: 0; transform-origin: 100% 50%; transform: rotateY(90deg); }
.atpl-ebook .eb-edge--l { left: 0; transform-origin: 0 50%; transform: rotateY(-90deg); }
.atpl-ebook .eb-edge--bl, .atpl-ebook .eb-edge--br { bottom: 0; height: var(--d); transform-origin: 50% 100%; transform: rotateX(-90deg); background-image: repeating-linear-gradient(rgba(var(--sh), .1) 0 1px, transparent 1px var(--t)); box-shadow: inset 0 0 0 99px rgba(var(--sh), .08); }
.atpl-ebook .eb-edge--bl, .atpl-ebook .eb-shadow--l { left: 0; right: 50%; }
.atpl-ebook .eb-edge--br, .atpl-ebook .eb-shadow--r { left: 50%; right: 0; }
.atpl-ebook .eb-shadow { inset-block: 0; transform: translateZ(-1px); box-shadow: var(--ps), 0 1px 3px rgba(var(--sh), calc(var(--sa) * .7)), 5px 14px 24px -6px rgba(var(--sh), var(--sa)), 16px 40px 64px -16px rgba(var(--sh), calc(var(--sa) * 1.1)); }
/* Open: the leaves below peek out as thin edges. */
.atpl-ebook .eb-shadow--r { --ps: 1px 1.5px 0 var(--edge), 2px 3px 0 rgba(var(--sh), .14), 3px 4.5px 0 var(--edge), 4px 6px 0 rgba(var(--sh), .14); }
.atpl-ebook .eb-shadow--l { --ps: -1px 1.5px 0 var(--edge), -2px 3px 0 rgba(var(--sh), .14), -3px 4.5px 0 var(--edge), -4px 6px 0 rgba(var(--sh), .14); }
.atpl-ebook.is-start .eb-shadow, .atpl-ebook.is-end .eb-shadow { --ps: 0 0 transparent; }
.atpl-ebook.has-l :is(.eb-shadow--l, .eb-edge--l, .eb-edge--bl), .atpl-ebook.has-r :is(.eb-shadow--r, .eb-edge--r, .eb-edge--br) { opacity: 1; }
/* Single: one stack, on the right; the back cover lies alone (shadow, no edges). */
.atpl-ebook.eb-single :is(.eb-edge--br, .eb-shadow--r) { left: 0; }
.atpl-ebook.eb-single :is(.eb-edge--l, .eb-edge--bl, .eb-shadow--l) { display: none; }
.atpl-ebook.eb-single.is-end .eb-shadow--r { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
    .atpl-ebook.is-start .eb-book { --rx: 20deg; --ry: -20deg; }
    .atpl-ebook.is-end .eb-book { --rx: 20deg; --ry: 20deg; }
    .atpl-ebook.eb-single.is-start .eb-book { --rx: 14deg; --ry: -16deg; }
    .atpl-ebook.eb-single.is-end .eb-book { --rx: 14deg; --ry: 16deg; }
    .atpl-ebook.is-start .eb-book:focus-visible { --rx: 8deg; --ry: -8deg; }
    .atpl-ebook.is-end .eb-book:focus-visible { --rx: 8deg; --ry: 8deg; }
    @media (hover: hover) {
        .atpl-ebook.is-start .eb-book:hover { --rx: 8deg; --ry: -8deg; }
        .atpl-ebook.is-end .eb-book:hover { --rx: 8deg; --ry: 8deg; }
    }
    /* Open: flatten fast. Close: tilt once the page lands (a raised page would swing over the text). */
    .atpl-ebook.eb-on .eb-pose { transition: transform .4s cubic-bezier(.2, .7, .2, 1); }
    .atpl-ebook:is(.is-start, .is-end) .eb-pose { transition-duration: .9s; }
    .atpl-ebook:is(.is-start, .is-end):has(.is-turning) .eb-pose { transition-delay: calc(var(--dur) * .7); }
    .atpl-ebook.is-zoom .eb-pose { transition-duration: .35s; }
    .atpl-ebook.eb-on .eb-slide, .atpl-ebook.eb-on .eb-sheet { transition: transform var(--dur) var(--ease); }
    .atpl-ebook.eb-single .eb-sheet.is-flipped { transition: transform var(--dur) var(--ease), visibility 0s var(--dur); }
    /* Stack edges/shadow leave with its last page and arrive once a page lands. */
    .atpl-ebook.eb-on .eb-edge, .atpl-ebook.eb-on .eb-shadow { transition: opacity .2s; }
    .atpl-ebook.has-l :is(.eb-shadow--l, .eb-edge--l, .eb-edge--bl), .atpl-ebook.has-r :is(.eb-shadow--r, .eb-edge--r, .eb-edge--br) { transition: opacity .3s calc(var(--dur) * .65); }
    .atpl-ebook.is-anim .eb-zoom { transition: transform .34s cubic-bezier(.2, .75, .25, 1); }
    .atpl-ebook .eb-btn { transition: background-color .2s, opacity .2s; }
    /* Shade sweeps the turning page and the page it uncovers / lands on. */
    .atpl-ebook .is-turning > .eb-face::after { background: linear-gradient(90deg, rgba(var(--sh), 0) 25%, rgba(255, 255, 255, .2) 42%, rgba(var(--sh), .3) 58%, rgba(var(--sh), .12) 80%, rgba(var(--sh), .22)) 0 0 / 260% 100%; animation: eb-turn var(--dur) var(--ease); }
    .atpl-ebook .is-under::after, .atpl-ebook .is-land::after { background: linear-gradient(90deg, rgba(var(--sh), .5), rgba(var(--sh), .14) 35%, rgba(var(--sh), 0) 72%); animation: eb-under var(--dur) ease-out; }
    .atpl-ebook .is-land::after { animation-name: eb-land; animation-timing-function: ease-in; }
    .atpl-ebook.is-peek .eb-sheet:first-of-type { animation: eb-peek 1.6s cubic-bezier(.35, .1, .3, 1); }
}
@keyframes eb-turn { 0% { opacity: 0; background-position: 100% 0; } 50% { opacity: 1; } 100% { opacity: 0; background-position: 0 0; } }
@keyframes eb-under { 0% { opacity: 1; } 65%, 100% { opacity: 0; } }
@keyframes eb-land { 0%, 40% { opacity: 0; } 86% { opacity: .8; } 100% { opacity: 0; } }
@keyframes eb-peek { 40% { transform: var(--tz) rotateY(-15deg); } 68% { transform: var(--tz) rotateY(-2deg); } 84% { transform: var(--tz) rotateY(-5deg); } }

.atpl-ebook .eb-controls { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; }
.atpl-ebook .eb-controls[hidden] { display: none; }
.atpl-ebook .eb-bar { display: flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bar); box-shadow: 0 10px 24px -16px rgba(var(--sh), .5); }
.atpl-ebook .eb-btn { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--accent); font-size: 15px; cursor: pointer; }
.atpl-ebook .eb-btn:not([aria-disabled=true]):hover { background: var(--tint); }
.atpl-ebook .eb-btn[aria-disabled=true] { opacity: .35; cursor: default; }
.atpl-ebook .eb-count, .atpl-ebook .eb-level { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.2; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.atpl-ebook .eb-count { min-width: 8.8em; padding-inline: 4px; }
.atpl-ebook .eb-level { min-width: 3.4em; font-size: 14px; }
/* Hint: touch copy on coarse/no-hover pointers; one part per line on phones. */
.atpl-ebook .eb-hint { margin-top: 12px; font-size: 13.5px; line-height: 1.5; text-align: center; color: var(--muted); }
.atpl-ebook .eb-hint span span { display: inline-block; }
.atpl-ebook .eb-hint-t { display: none; }
@media (hover: none), (pointer: coarse) {
    .atpl-ebook .eb-hint-m { display: none; }
    .atpl-ebook .eb-hint-t { display: inline; }
}
@media (max-width: 575.98px) {
    .atpl-ebook .eb-hint span span { display: block; }
    .atpl-ebook .eb-hint [aria-hidden] { display: none; }
}

.atpl-ebook .eb-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 26px; margin-top: 30px; text-align: center; }
.atpl-ebook .theme-btn.eb-download { display: inline-flex; align-items: center; gap: 14px; min-height: 50px; padding-block: 7px; padding-inline: 26px 7px; font-size: 15px; }
.atpl-ebook .eb-download i { flex: none; margin: 0; }
.atpl-ebook .eb-open { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding-inline: 4px; font-size: 15px; font-weight: 600; color: var(--accent); }
.atpl-ebook .eb-open > span:first-child { background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat; }
.atpl-ebook .eb-open:hover > span:first-child { background-size: 100% 2px; }
.atpl-ebook .eb-open i { font-size: .8em; }
.atpl-ebook .eb-meta { flex-basis: 100%; margin: 0; font-size: 13.5px; letter-spacing: .02em; color: var(--muted); }
.atpl-ebook a:focus-visible, .atpl-ebook .eb-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Phones: edge-to-edge stage. >= 768px: spreads. */
@media (max-width: 767.98px) {
    .atpl-ebook .eb-stage { margin-inline: calc(var(--bs-gutter-x, 1.5rem) * -.5); }
}
@media (min-width: 768px) {
    .atpl-ebook { --w: max(220px, min(440px, 44vw, calc((100vh - 270px) / 1.41667))); --t: 1px; --tc: 5px; padding: 110px 0 116px; }
    .atpl-ebook .eb-zoom { padding: 80px 0 88px; }
}

html[data-bs-theme=dark] .atpl-ebook {
    --bg: var(--oaa-surface-2); --spot: var(--oaa-surface-3); --ink: var(--oaa-ink); --muted: var(--oaa-ink-muted);
    --accent: var(--oaa-accent); --tint: var(--oaa-accent-tint); --bar: var(--oaa-surface); --line: var(--oaa-border-strong);
    --paper: #E2E4E8; --edge: #B4BAC4; --sh: 0, 0, 0; --sa: .62;
}
