/* 3D album (S7) — hardcover book in CSS 3D. Page content uses the Memory Book page styles
   (book.css), so page faces only need a size: --pw × --ph. */
.a3d { --pw: 300px; --ph: 420px; --thick: 12px; --edge-l: 0px; --edge-r: 6px;
  --cover-a: #8E4E5D; --cover-b: #6B4148; --cover-ink: #F8EDE4; --cover-line: rgb(232 201 194 / .55);
  display: grid; gap: var(--s3); justify-items: center; }
.a3d[data-material="linen-rose"]   { --cover-a: #B07D84; --cover-b: #8E5B63; }
.a3d[data-material="leather-burg"] { --cover-a: #7A4650; --cover-b: #4E2C33; }
.a3d[data-material="velvet-sage"]  { --cover-a: #8FA38E; --cover-b: #5F7461; }
.a3d[data-material="linen-ivory"]  { --cover-a: #EFE4D2; --cover-b: #D8C6AA; --cover-ink: #4E3A2A; --cover-line: rgb(122 88 67 / .4); }
.a3d[data-material="satin-lav"]    { --cover-a: #A99BC4; --cover-b: #75679A; }
.a3d[data-material="night-gold"]   { --cover-a: #2E2A45; --cover-b: #1B1830; --cover-line: rgb(212 175 55 / .6); }

.a3d-scene { width: 100%; display: grid; place-items: center; perspective: 2200px; perspective-origin: 50% 30%;
  padding: calc(var(--s6) + 8px) 0 var(--s6); outline: none; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: pointer; }
.a3d-scene:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: var(--r-lg); }
.a3d-book { --shift: 0; position: relative; width: calc(var(--pw) * 2); height: var(--ph); transform-style: preserve-3d;
  transform: translateX(calc(var(--shift) * var(--pw))) rotateX(10deg); transition: transform .7s var(--ease); }
.a3d.is-closed .a3d-book { transform: translateX(calc(var(--shift) * var(--pw))) rotateX(8deg) rotateY(24deg); }
.a3d.is-closed-back .a3d-book { transform: translateX(calc(var(--shift) * var(--pw))) rotateX(8deg) rotateY(-24deg); }
.a3d.is-single .a3d-book { transform: translateX(calc(var(--shift) * var(--pw))) rotateX(6deg); }
.a3d.is-single .a3d-scene { overflow: hidden; }
.a3d.is-single .a3d-scene > .a3d-book { margin-inline: calc(var(--pw) * -0.5); }

/* table shadow under the book */
.a3d-scene { position: relative; }
.a3d-scene::after { content: ""; position: absolute; left: 50%; bottom: calc(var(--s6) - 14px); width: min(90%, calc(var(--pw) * 2)); height: 26px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(closest-side, rgb(46 34 36 / .28), transparent); pointer-events: none; z-index: -1; }
.a3d.is-closed .a3d-scene::after, .a3d.is-single .a3d-scene::after { width: calc(var(--pw) * 1.05); }

/* leaves hinge on the spine (the centre line) */
.a3d-leaf { --z: 0px; position: absolute; top: 0; left: var(--pw); width: var(--pw); height: var(--ph);
  transform-origin: left center; transform-style: preserve-3d; transform: translateZ(var(--z)) rotateY(0deg);
  transition: transform .9s cubic-bezier(.45, .05, .3, 1); }
.a3d-leaf.is-turned { transform: translateZ(var(--z)) rotateY(-180deg); }
.a3d-leaf.is-flipping { z-index: 999 !important; }
.a3d-face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  container-type: inline-size; background: var(--bp-bg, #FBF6EF); }
.a3d-back { transform: rotateY(180deg); }
.a3d-face > .bpage { width: 100%; height: 100%; aspect-ratio: auto; max-width: none; margin: 0; border-radius: 0; box-shadow: none; }
/* paper shading near the spine and a moving shade while turning */
.a3d-front::after, .a3d-back::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.a3d-front::after { background: linear-gradient(90deg, rgb(0 0 0 / .16), rgb(0 0 0 / .03) 6%, transparent 14%, transparent 92%, rgb(255 255 255 / .06)); }
.a3d-back::after { background: linear-gradient(270deg, rgb(0 0 0 / .16), rgb(0 0 0 / .03) 6%, transparent 14%); }
.a3d-leaf.is-flipping .a3d-face::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(90deg, transparent 30%, rgb(0 0 0 / .18)); animation: a3d-shade .9s ease-in-out; opacity: 0; }
@keyframes a3d-shade { 0% { opacity: 0; } 45% { opacity: 1; } 100% { opacity: 0; } }

/* hard covers: slightly larger, rigid, cloth/leather look with a debossed frame */
.a3d-leaf.is-hard { top: -6px; height: calc(var(--ph) + 12px); width: calc(var(--pw) + 6px); }
.a3d-leaf.is-hard .a3d-face { border-radius: 0 6px 6px 0; }
.a3d-leaf.is-hard .a3d-back { border-radius: 6px 0 0 6px; }
.a3d-leaf.is-front-cover .a3d-front, .a3d-leaf.is-back-cover .a3d-back {
  background: radial-gradient(120% 90% at 30% 20%, var(--cover-a), var(--cover-b)),
              repeating-linear-gradient(45deg, rgb(255 255 255 / .03) 0 2px, transparent 2px 4px); background-blend-mode: overlay;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .15), inset 0 0 22px rgb(0 0 0 / .25); }
.a3d-leaf.is-front-cover .a3d-front::after { background: linear-gradient(90deg, rgb(0 0 0 / .35), rgb(255 255 255 / .1) 3%, transparent 9%), linear-gradient(160deg, rgb(255 255 255 / .18), transparent 40%); }
.a3d-cover-panel { position: absolute; inset: 7% 8% 7% 11%; container-type: inline-size; border-radius: 2px;
  box-shadow: 0 0 0 1px var(--cover-line), 0 0 0 6px transparent, 0 0 0 7px var(--cover-line), 0 6px 16px -6px rgb(0 0 0 / .45); overflow: hidden; }
.a3d-cover-panel > .bpage { width: 100%; height: 100%; aspect-ratio: auto; margin: 0; box-shadow: none; border-radius: 0; }
.a3d-back-panel { position: absolute; inset: 0; display: grid; place-content: end center; justify-items: center; gap: 6px; padding-bottom: 12%;
  color: var(--cover-ink); font: 600 .78rem/1 var(--f-body); letter-spacing: .08em; }
.a3d-back-mark { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.6; opacity: .85; }
.a3d-endpaper { position: absolute; inset: 0; background-color: var(--bp-mat, #FBF6EF);
  background-image: radial-gradient(circle at 25% 25%, color-mix(in srgb, var(--bp-accent, #8E4E5D) 22%, transparent) 0 1.4px, transparent 1.6px),
                    radial-gradient(circle at 75% 75%, color-mix(in srgb, var(--bp-accent, #8E4E5D) 14%, transparent) 0 1.4px, transparent 1.6px);
  background-size: 18px 18px; }
.a3d-blank { background: var(--bp-bg); }

/* spine: visible when the closed book is turned a little */
.a3d-spine { position: absolute; top: -6px; left: calc(var(--pw) - var(--thick)); width: var(--thick); height: calc(var(--ph) + 12px);
  transform-origin: right center; transform: rotateY(-90deg); background: linear-gradient(90deg, var(--cover-b), var(--cover-a) 45%, var(--cover-b));
  display: grid; place-items: center; overflow: hidden; border-radius: 3px 0 0 3px; }
.a3d-spine span { writing-mode: vertical-rl; color: var(--cover-ink); font: 600 .62rem/1 var(--f-body); letter-spacing: .1em; white-space: nowrap; opacity: .9; }
.a3d:not(.is-closed) .a3d-spine { opacity: 0; }

/* paper edges (thickness) at the outer side of each stack */
.a3d-edge { position: absolute; top: 2px; height: calc(var(--ph) - 4px); transform-style: preserve-3d; pointer-events: none;
  background: repeating-linear-gradient(90deg, #FBF7F1 0 1px, #E6DCCF 1px 2px); }
.a3d-edge-r { left: calc(var(--pw) * 2); width: var(--edge-r); transform-origin: left center; transform: rotateY(90deg); }
.a3d-edge-l { left: calc(0px - var(--edge-l)); width: var(--edge-l); transform-origin: right center; transform: rotateY(-90deg); }
.a3d.is-closed .a3d-edge-l { opacity: 0; }

.a3d-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.a3d-bar { display: flex; align-items: center; justify-content: center; gap: var(--s3); flex-wrap: wrap; }
.a3d-nav { width: 52px; padding: 0; justify-content: center; border-radius: 50%; }
.a3d-count { min-width: 9ch; text-align: center; font-weight: 600; color: var(--ink-2); }

.a3d-thumbs { display: flex; gap: var(--s2); overflow-x: auto; max-width: 100%; padding: 4px 4px var(--s2); scroll-snap-type: x proximity; }
.a3d-thumb { flex: none; display: grid; gap: 4px; justify-items: center; background: none; border: 0; padding: 0; cursor: pointer; scroll-snap-align: center; }
.a3d-thumb-page { display: block; width: 64px; aspect-ratio: 5 / 7; container-type: inline-size; overflow: hidden; border-radius: 3px;
  box-shadow: 0 0 0 1px var(--line), 0 4px 10px -6px rgb(0 0 0 / .4); pointer-events: none; }
.a3d-thumb-page > .bpage { width: 100%; height: 100%; aspect-ratio: auto; margin: 0; box-shadow: none; }
.a3d-thumb[aria-current="true"] .a3d-thumb-page { box-shadow: 0 0 0 2px var(--primary), 0 4px 10px -6px rgb(0 0 0 / .4); }
.a3d-thumb-n { font-size: var(--fs-xs); color: var(--ink-2); }
.a3d:fullscreen { background: var(--bg); align-content: center; padding: var(--s4); }

/* flat fallback: no 3D, the open spread side by side */
.a3d.is-flat .a3d-book, .a3d.is-flat.is-closed .a3d-book { transform: translateX(calc(var(--shift) * var(--pw))); }
.a3d.is-flat .a3d-leaf { transition: none; transform: none; }
.a3d.is-flat .a3d-leaf.is-turned { transform: translateX(-100%); }
.a3d.is-flat .a3d-leaf .a3d-back { transform: none; visibility: hidden; }
.a3d.is-flat .a3d-leaf.is-turned .a3d-front { visibility: hidden; }
.a3d.is-flat .a3d-leaf.is-turned .a3d-back { visibility: visible; }
.a3d.is-flat .a3d-spine, .a3d.is-flat .a3d-edge { display: none; }

@media (prefers-reduced-motion: reduce) {
  .a3d-book, .a3d-leaf { transition: none; }
  .a3d-leaf.is-flipping .a3d-face::before { animation: none; }
}
@media print { .a3d { display: none; } }

/* Albums hub */
.alb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: var(--s4); }
.alb-card { display: grid; gap: var(--s3); padding: var(--s4); border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); color: inherit; text-decoration: none; position: relative; }
a.alb-card:hover { border-color: var(--rose); }
.alb-mini { height: 128px; display: grid; place-items: center; perspective: 600px; }
.alb-mini-book { width: 84px; height: 116px; border-radius: 2px 6px 6px 2px; transform: rotateY(-22deg) rotateX(6deg); transform-style: preserve-3d;
  background: radial-gradient(120% 90% at 30% 20%, var(--cover-a), var(--cover-b)); position: relative;
  box-shadow: inset 4px 0 6px -2px rgb(0 0 0 / .35), 8px 10px 18px -8px rgb(46 34 36 / .5); display: grid; place-items: center; }
.alb-mini-book::after { content: ""; position: absolute; right: -7px; top: 3px; bottom: 3px; width: 7px; transform: rotateY(90deg); transform-origin: left;
  background: repeating-linear-gradient(90deg, #FBF7F1 0 1px, #E6DCCF 1px 2px); }
.alb-mini-book svg { width: 34px; height: 34px; stroke: var(--cover-ink); fill: none; stroke-width: 1.6; opacity: .9; }
.alb-card h2 { font-size: var(--fs-md); margin: 0; }
.alb-card p { margin: 0; }
.alb-card.is-soon { opacity: .78; }
.alb-card .tag { justify-self: start; }
.alb-view-head { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; }
.alb-opts { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.alb-opts select { min-height: 40px; }

/* voice-note play button on album pages (3D view only; print shows the note text) */
.a3d-play { float: left; margin: 0 8px 0 0; width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--bp-accent, #8E4E5D); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--bp-accent, #8E4E5D) 70%, #000); }
.a3d-play .icon { width: 16px; height: 16px; }
.a3d-play.is-playing { box-shadow: 0 0 0 4px color-mix(in srgb, var(--bp-accent, #8E4E5D) 30%, transparent); animation: a3d-pulse 1.4s ease-in-out infinite; }
@keyframes a3d-pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--bp-accent, #8E4E5D) 10%, transparent); } }
@media (prefers-reduced-motion: reduce) { .a3d-play.is-playing { animation: none; } }

/* sample albums (S12) */
.alb-sample { display: grid; gap: var(--s3); margin-top: var(--s5); }
.a3d.is-sample { position: relative; }
.a3d-sample-tag { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 5; font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: .06em; padding: 4px 14px; border-radius: var(--r-pill); background: var(--warn-bg, #FBF0DC); color: var(--warn, #8A5A12); border: 1px solid currentColor; }
