/* PASSPORT BOOK (2026-10-30) — js/passport-book.js. Your stamp pages drawn as a
   flip-book passport: hard cover, laminated ID page, the Visa Approved page,
   then your pages exactly as you laid them out. Also used by passport-view.html
   (the page a shared link opens). Demo: /static/passport-profile-preview.html */
.ppb-ov {
    position: fixed; inset: 0; z-index: 100000;
    display: none; flex-direction: column; align-items: center;
    background: radial-gradient(120% 80% at 50% 0%, #24304d, #121a2c);
    overflow-x: hidden; overflow-y: auto;
    padding-top: var(--safe-top, env(safe-area-inset-top, 0px));
    padding-bottom: var(--safe-bottom, env(safe-area-inset-bottom, 0px));
}
.ppb-ov.on { display: flex; }
.ppb-top { width: 100%; max-width: 880px; display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; color: #fff; }
.ppb-top b { flex: 1; min-width: 0; font: 900 16px var(--font-ui, Figtree, sans-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ppb-top small { display: block; font: 600 11.5px var(--font-ui, Figtree, sans-serif); opacity: .7; }
.ppb-x { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font: 700 18px var(--font-ui, Figtree, sans-serif); cursor: pointer; display: grid; place-items: center; }
.ppb-x svg { width: 20px; height: 20px; }
.ppb-host { padding: 6px 8px; box-sizing: border-box; display: flex; justify-content: center; width: 100%; }
.ppb-ctl { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px 16px 18px; color: #fff; }
.ppb-ctl button { border: 0; border-radius: 100px; background: #fff; color: #1a1a1a; font: 800 13px var(--font-ui, Figtree, sans-serif); padding: 10px 16px; cursor: pointer; }
.ppb-ctl button:disabled { opacity: .3; }
.ppb-ctl span { font: 700 12px 'JetBrains Mono', monospace; min-width: 92px; text-align: center; opacity: .85; }
.ppb-msg { color: #fff; text-align: center; padding: 60px 24px; font: 600 14px/1.5 var(--font-ui, Figtree, sans-serif); opacity: .85; max-width: 360px; }

/* pages */
.ppb-page { background: #f5edd6; overflow: hidden; position: relative; font-family: var(--font-ui, Figtree, sans-serif); }
.ppb-in { position: absolute; inset: 0; padding: 22px 20px; }
.ppb-paper::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0,0,0,.08), transparent 7%, transparent 93%, rgba(0,0,0,.05)); }
.ppb-foil { background: linear-gradient(135deg,#bf953f 0%,#fcf6ba 40%,#b38728 60%,#fbf5b7 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }

.ppb-cover { background: radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--cv) 87%, #fff), var(--cv) 55%, color-mix(in srgb, var(--cv) 70%, #000)); color: #d9b45a; }
.ppb-cover::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35; background: repeating-linear-gradient(45deg, rgba(255,255,255,.025) 0 2px, transparent 2px 5px); }
.ppb-cover .ppb-in { display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 40px 24px 34px; text-align: center; }
.ppb-t1 { font-weight: 900; font-size: 13px; letter-spacing: .42em; }
.ppb-crest { width: 52%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 2px solid rgba(217,180,90,.7); box-shadow: inset 0 0 0 6px rgba(217,180,90,.12); }
.ppb-crest i, .ppb-logo { display: block; width: 62%; aspect-ratio: 1; background: linear-gradient(135deg,#bf953f,#fcf6ba 40%,#b38728 60%,#fbf5b7);
    -webkit-mask: var(--ppb-logo) center/contain no-repeat; mask: var(--ppb-logo) center/contain no-repeat; }
.ppb-t2 { font-weight: 900; font-size: 34px; letter-spacing: .12em; line-height: 1; }
.ppb-t3 { font-weight: 700; font-size: 10px; letter-spacing: .3em; opacity: .85; margin-top: 8px; }
.ppb-holder { font-weight: 800; font-size: 11px; letter-spacing: .24em; opacity: .8; }

.ppb-id { background:
    radial-gradient(90% 60% at 80% 10%, rgba(255,217,61,.22), transparent 60%),
    radial-gradient(70% 50% at 10% 90%, rgba(41,128,185,.16), transparent 60%),
    repeating-radial-gradient(circle at 30% 40%, transparent 0 6px, rgba(22,35,63,.05) 6px 7px), #f3eedf; }
.ppb-id::after { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, rgba(170,220,255,.25) 50%, transparent 62%);
    background-size: 260% 100%; animation: ppb-sheen 6s ease-in-out infinite; }
@keyframes ppb-sheen { 0%,100% { background-position: 110% 0; } 50% { background-position: -10% 0; } }
.ppb-id .ppb-in { display: flex; flex-direction: column; padding: 18px 16px 14px; color: #16233f; }
.ppb-idtop { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5px solid #16233f; padding-bottom: 6px; }
.ppb-idtop b { font-weight: 900; font-size: 12px; letter-spacing: .18em; }
.ppb-idtop small { font: 700 9px 'JetBrains Mono', monospace; }
.ppb-idbody { display: grid; grid-template-columns: 38% 1fr; gap: 12px; margin-top: 12px; }
.ppb-photo { aspect-ratio: 3/4; border-radius: 6px; position: relative; overflow: hidden; background: linear-gradient(160deg,#dfe8f1,#c8d4e2); box-shadow: inset 0 0 0 1px rgba(22,35,63,.25); }
.ppb-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.85) contrast(1.05); }
.ppb-photo svg { position: absolute; inset: auto 0 0 0; width: 100%; }
.ppb-ghost { position: relative; width: 56%; aspect-ratio: 3/4; margin-top: 8px; border-radius: 4px; opacity: .28; overflow: hidden; background: linear-gradient(160deg,#dfe8f1,#c8d4e2); }
.ppb-ghost img { position: absolute; inset: 0; }
.ppb-ghost img, .ppb-ghost svg { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); display: block; }
.ppb-f { margin-bottom: 7px; min-width: 0; }
.ppb-f i { display: block; font: normal 700 7.5px var(--font-ui, Figtree, sans-serif); letter-spacing: .14em; color: #6f6a5c; text-transform: uppercase; }
.ppb-f span { display: block; font-weight: 800; font-size: 13px; line-height: 1.15; overflow-wrap: anywhere; }
.ppb-f.mono span { font: 700 11.5px 'JetBrains Mono', monospace; }
.ppb-stats { display: flex; gap: 6px; margin-top: 4px; }
.ppb-stats div { flex: 1; background: rgba(22,35,63,.07); border-radius: 6px; padding: 5px 2px; text-align: center; }
.ppb-stats b { display: block; font-weight: 900; font-size: 15px; }
.ppb-stats small { font-weight: 700; font-size: 7px; letter-spacing: .1em; color: #6f6a5c; }
.ppb-motto { margin-top: 10px; font: italic 600 12px/1.35 var(--font-ui, Figtree, sans-serif); border-left: 3px solid #d9b45a; padding-left: 8px; }
.ppb-mrz { margin-top: auto; padding-top: 10px; font: 700 10px/1.45 'JetBrains Mono', monospace; letter-spacing: .06em; white-space: pre; overflow: hidden; border-top: 1px dashed rgba(22,35,63,.3); }
.ppb-holo { position: absolute; right: 16px; top: 150px; width: 58px; height: 58px; border-radius: 50%; opacity: .55; pointer-events: none;
    background: conic-gradient(from 0deg,#ffd93d,#7fd3ff,#d9a7ff,#9cf2c4,#ffd93d); mix-blend-mode: multiply;
    -webkit-mask: radial-gradient(circle,transparent 34%,#000 35%,#000 48%,transparent 49%,transparent 60%,#000 61%);
            mask: radial-gradient(circle,transparent 34%,#000 35%,#000 48%,transparent 49%,transparent 60%,#000 61%); }
.ppb-head { display: flex; justify-content: space-between; font-weight: 800; font-size: 9px; letter-spacing: .22em; color: #a89c82; text-transform: uppercase; position: relative; z-index: 2; }
.ppb-no { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font: 700 10px 'JetBrains Mono', monospace; color: #a89c82; letter-spacing: .15em; z-index: 2; }
.ppb-visa { position: absolute; left: 50%; top: 46%; width: 64%; transform: translate(-50%,-50%) rotate(-6deg); border: 0; background: none; padding: 0; cursor: pointer; }
.ppb-visa img { width: 100%; display: block; mix-blend-mode: multiply; }

/* A stamp page: positions are % of the page, sizes scale with its width
   (--pk = width / 390), so a passport looks the same on every phone. */
.ppb-sheet { position: absolute; inset: 0; }
.ppb-sheet::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(212,201,168,.5); pointer-events: none; }
.ppb-sheet::after { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(180,170,140,.04) 8px, rgba(180,170,140,.04) 9px); }
.ppb-sheet .stamp { position: absolute; cursor: pointer; z-index: 3; touch-action: auto; }
.ppb-sheet .stamp img, .ppb-sheet .stamp video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.ppb-sheet .stamp-remove { display: none !important; }
.ppb-blank { position: absolute; inset: 30% 18%; display: grid; place-items: center; text-align: center; font: 800 9px var(--font-ui, Figtree, sans-serif); letter-spacing: .16em; color: #b8ab8d; border: 2px dashed #d3c7ab; border-radius: 50%; aspect-ratio: 1; margin: auto; height: auto; }

/* close-up */
.ppb-zoom { position: fixed; inset: 0; z-index: 100001; background: rgba(14,23,48,.6); display: none; place-items: center; padding: 16px; }
.ppb-zoom.on { display: grid; }
.ppb-card { background: #F4F1EA; border-radius: 22px; padding: 22px 20px 18px; width: min(340px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: ppb-pop .25s ease-out; font-family: var(--font-ui, Figtree, sans-serif); color: #1a1a1a; }
@keyframes ppb-pop { from { transform: scale(.9); opacity: 0; } }
.ppb-card img, .ppb-card video { width: 74%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.25)); }
.ppb-card h4 { margin: 10px 0 2px; font-weight: 900; font-size: 20px; }
.ppb-card p { margin: 0; color: #7a7263; font-size: 13px; }
.ppb-card .ppb-btns { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.ppb-card button { border: 0; border-radius: 100px; background: #1a1a1a; color: #fff; font: 800 13px var(--font-ui, Figtree, sans-serif); padding: 10px 18px; cursor: pointer; }
.ppb-card button.alt { background: #e9e2d3; color: #1a1a1a; }

/* Page turn (js/passport-turn.js): each page is a leaf hinged on the spine.
   Used by the viewer above and by the passport on the Passport tab. */
.pt-book { position: relative; perspective: 2400px; perspective-origin: 15% 50%; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.pt-book::before { content: ""; position: absolute; inset: 0; border-radius: 0 8px 8px 0; background: #e6dcc0; pointer-events: none;
    box-shadow: 2px 1px 0 #efe6cd, 4px 2px 0 #d8cdae, 6px 3px 0 #cbbf9d, 0 18px 40px rgba(0,0,0,.35); }
.pt-leaf { position: absolute !important; inset: 0 !important; width: auto !important; height: auto !important; margin: 0 !important;
    transform-origin: 0 50%; will-change: transform; overflow: hidden; border-radius: 0 8px 8px 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.pt-leaf.ppb-cover { border-radius: 0 12px 12px 0; }
.pt-spine, .pt-shade, .pt-cast { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
.pt-spine { background: linear-gradient(90deg, rgba(0,0,0,.2), rgba(0,0,0,.04) 5%, transparent 9%); }
.pt-shade { opacity: 0; background: linear-gradient(90deg, rgba(0,0,0,.05), rgba(0,0,0,.5)); }
.pt-cast { opacity: 0; background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.15) 40%, transparent 75%); }

/* ── Record of travel (2026-11-02, factsHTML in js/passport-book.js) — owner only ── */
.ppb-rec { margin-top: 12px; }
.ppb-rech { font: 800 8px var(--font-ui, Figtree, sans-serif); letter-spacing: .18em; color: #6f6a5c; margin-bottom: 5px; }
.ppb-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.ppb-facts div { background: rgba(22,35,63,.07); border-radius: 6px; padding: 5px 4px 4px; text-align: center; min-width: 0; }
.ppb-facts div.w { grid-column: span 3; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; text-align: left; padding: 6px 8px; }
.ppb-facts div.w small { order: -1; flex: none; }
.ppb-facts b { display: block; font-weight: 900; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ppb-facts div.w b { font-size: 13px; }
.ppb-facts b em { font-style: normal; font-weight: 700; color: #6f6a5c; font-size: 11px; }
.ppb-facts small { display: block; font-weight: 700; font-size: 6.5px; letter-spacing: .08em; color: #6f6a5c; margin-top: 2px; }
.ppb-mi { display: inline-flex; align-items: center; gap: 2px; }
.ppb-mi .rw-dpad { width: 13px; height: 13px; fill: currentColor; }
/* Short screens: the record takes the space left and scrolls inside it, so
   the motto and the code lines at the foot of the page always stay in view. */
.ppb-id .ppb-idtop, .ppb-id .ppb-idbody, .ppb-id .ppb-motto, .ppb-id .ppb-mrz { flex: none; }
.ppb-rec { flex: 0 1 auto; min-height: 60px; display: flex; flex-direction: column; }
.ppb-rec .ppb-facts { min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  -webkit-overflow-scrolling: touch; padding-bottom: 2px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 14px), transparent); mask-image: linear-gradient(#000 calc(100% - 14px), transparent); }

/* Duty Free upgrades (2026-11-16): cover textures, class band, title */
[data-tex="denim"] .ppb-cover::before { opacity: 1; background: repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 2px, transparent 2px 5px), repeating-linear-gradient(-45deg, rgba(0,0,0,.1) 0 2px, transparent 2px 5px); }
[data-tex="leather"] .ppb-cover::before { opacity: 1; background: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1.6px) 0 0/5px 5px, radial-gradient(rgba(0,0,0,.14) 1px, transparent 1.6px) 0 0/7px 7px; }
[data-tex="worn"] .ppb-cover::before { opacity: 1; background: radial-gradient(ellipse at 20% 15%, rgba(255,255,255,.2), transparent 40%), radial-gradient(ellipse at 85% 90%, rgba(0,0,0,.32), transparent 45%), linear-gradient(transparent 48%, rgba(255,255,255,.08) 50%, transparent 52%); }
[data-tex="holo"] .ppb-cover::before { opacity: 1; mix-blend-mode: screen;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%),
              linear-gradient(125deg, rgba(255,60,172,.55), rgba(120,75,255,.5) 22%, rgba(43,180,255,.5) 44%, rgba(0,245,160,.45) 66%, rgba(255,217,61,.5) 88%, rgba(255,60,172,.55));
  background-size: 300% 300%, 250% 250%; animation: ppbHolo 6s ease-in-out infinite alternate; }
[data-tex="holo"] .ppb-cover::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background: repeating-linear-gradient(60deg, rgba(255,255,255,.6) 0 1px, transparent 1px 4px); mix-blend-mode: overlay; }
@keyframes ppbHolo { 0% { background-position: 100% 0, 0 50%; } 100% { background-position: -100% 0, 100% 50%; } }
.ppb-band { position: absolute; left: 0; right: 0; top: 2.6%; height: 1.4%; min-height: 4px; background: var(--ppb-band, #c9ccd3); pointer-events: none; }
[data-pclass="business"] { --ppb-band: #d9b65a; }
[data-pclass="first"] { --ppb-band: linear-gradient(90deg, #fff, #f3e2a8, #fff); }
.ppb-class { display: block; margin-top: 6px; font: 900 .78em var(--font-mono, monospace); letter-spacing: .24em; opacity: .9; }
[data-pclass="business"] .ppb-id .ppb-f:nth-of-type(-n+2) span, [data-pclass="first"] .ppb-id .ppb-f:nth-of-type(-n+2) span { color: #a8801f; }
.ppb-title-f span { color: #8a6a12; }
@media (prefers-reduced-motion: reduce) { [data-tex="holo"] .ppb-cover::before { animation: none; } }

/* A cover earned by finishing a series (Story Worlds, 2026-11-17): its emblem in place of the crest. */
.ppb-emb { width: 60%; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%;
  color: var(--foil, #d9b65a); border: 2px solid var(--foil, #d9b65a); border-radius: 6px; box-shadow: inset 0 0 0 5px rgba(0,0,0,.12); }
.ppb-emb b { font: 900 calc(34px * var(--pk, 1)) / 1 var(--font-ui, 'Figtree', sans-serif); letter-spacing: .03em; }
.ppb-emb small { font: 800 calc(8px * var(--pk, 1)) var(--font-mono, monospace); letter-spacing: .22em; }

/* Drawn finishing cover (2026-11-19, demo /static/series-cover-art-preview.html option A):
   the picture fills the front, D-PAD / PASSPORT / the name sit over its calm top and bottom. */
.ppb-cimg .ppb-cart { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.ppb-cimg .ppb-cart img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ppb-cimg .ppb-cart::after { content: ""; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.42) 0, transparent 22%, transparent 70%, rgba(0,0,0,.5) 100%); }
.ppb-cimg .ppb-in > :not(.ppb-cart) { position: relative; z-index: 1; }
.ppb-cimg .ppb-cgap { flex: 1; }
.ppb-cimg .ppb-t3, .ppb-cimg .ppb-holder { text-shadow: 0 1px 3px rgba(0,0,0,.6); }

/* ── Cover v3 (2026-11-20; /static/passport-cover-v3-preview.html): like a real passport.
   One gold D-PAD in the middle, the words centred under it, the chip at the bottom. */
.ppb-v3 .ppb-in { justify-content: flex-end; padding: 34px 6% 7%; container-type: inline-size; }
.ppb-v3 .ppb-mid { margin: auto 0; display: flex; flex-direction: column; align-items: center; width: 100%; }
.ppb-mark { width: 50%; aspect-ratio: 1; background: linear-gradient(135deg,#bf953f,#fcf6ba 40%,#b38728 60%,#fbf5b7);
    -webkit-mask: var(--ppb-logo) center/contain no-repeat; mask: var(--ppb-logo) center/contain no-repeat;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.ppb-v3 .ppb-t2 { font-size: 22px; font-size: 7.4cqw; letter-spacing: .1em; margin-top: 7%; white-space: nowrap; }
.ppb-v3 .ppb-t3 { font-weight: 800; font-size: 10px; font-size: 3.3cqw; letter-spacing: .24em; line-height: 1.6; margin-top: 3cqw; opacity: .92; }
.ppb-embw { margin-top: 3.5cqw; font: 800 9px var(--font-ui, 'Figtree', sans-serif); font-size: 2.9cqw; letter-spacing: .24em; }
.ppb-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ppb-chip { display: block; position: relative; width: 9cqw; height: 6.2cqw; border: 2px solid currentColor; border-radius: 5px; opacity: .8; }
.ppb-chip::before { content: ""; position: absolute; left: 50%; top: 50%; width: 38%; aspect-ratio: 1; border: 2px solid currentColor; border-radius: 50%; transform: translate(-50%, -50%); }
.ppb-v3 .ppb-class { margin-top: 0; font-size: 2.8cqw; }
/* a drawn cover: darken the centre a touch so the gold reads, and the bottom for the words */
.ppb-v3.ppb-cimg .ppb-cart::after { background: radial-gradient(circle at 50% 40%, rgba(0,0,0,.45) 0, rgba(0,0,0,.2) 22%, transparent 42%),
    linear-gradient(180deg, rgba(0,0,0,.3), transparent 18%, transparent 62%, rgba(0,0,0,.6)); }
.ppb-v3.ppb-cimg .ppb-t3, .ppb-v3.ppb-cimg .ppb-embw { text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.ppb-v3.ppb-cimg .ppb-chip { filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
/* Centred on the picture (2026-11-20, user: "the images aren't central"): the D-PAD's centre is
   pinned 40% down the page, exactly where the cover instructions leave the picture's empty
   centre, and the picture is cropped around that same line (object-position 50% 40%), so the
   two meet on any page shape. */
.ppb-v3 .ppb-mid { position: absolute; left: 0; right: 0; top: calc(40% - 23cqw); margin: 0; padding: 0 6%; }
.ppb-v3 .ppb-mark { width: 46cqw; }
.ppb-v3.ppb-cimg .ppb-cart img { object-position: 50% 40%; }
/* the older drawn-cover rule (position: relative on every child) must not move the D-PAD block */
.ppb-v3.ppb-cimg .ppb-in > .ppb-mid { position: absolute; }

/* a drawn cover with the D-PAD emblem in the picture itself: no shade, nothing over it */
.ppb-art .ppb-cart::after { display: none; }
.ppb-art .ppb-cart img { object-position: 50% 40%; }
