/* The client book: the paper binder and the 3D notebook that stands in
 * for it on desktop (assets/js/book.js, assets/js/web-design-3d.js).
 *
 * Shared by every page that prints a [traxx_case_studies] book: the Web
 * Design portfolio (layout="portfolio") and the Success Stories archive
 * (layout="book"). Loaded ahead of the page's own stylesheet, which
 * styles the section the book sits in.
 */

:root {
    --wd-bg: #ffffff;
    --wd-board-bg: #faf8f3;
    --wd-card-bg: #ffffff;
    --wd-dark: #0f172a;
    --wd-text: #475569;
    --wd-text-muted: #94a3b8;
    --wd-cyan: #00d2ff;
    --wd-blue: #0284c7;
    --wd-paper: #fefdf6;
    --wd-paper-2: #f7f1de;
    --wd-paper-edge: rgba(146, 64, 14, 0.18);
    --wd-paper-ink: #4a3416;
    --wd-paper-ink-2: #78350f;
    --wd-paper-tag: #b45309;
    /* Clear packing tape: a milky film with a faint cut edge. */
    --wd-tape: rgba(236, 240, 244, 0.34);
    --wd-tape-edge: rgba(60, 70, 85, 0.22);
    --wd-gradient: linear-gradient(90deg, #0284c7 0%, #00d2ff 100%);
    --wd-font: 'Inter', system-ui, -apple-system, sans-serif;
    --wd-code: 'Fira Code', monospace;
    --wd-hand: 'Caveat', 'Inter', cursive;
    --wd-marker: 'Permanent Marker', 'Segoe Print', 'Bradley Hand', cursive;
}

/* Handwriting for the notebook captions. Self-hosted (Apache 2.0, see
   assets/fonts/LICENSE-permanent-marker.txt); latin subset only. */
@font-face {
    font-family: 'Permanent Marker';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/permanent-marker-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.wd-page * { box-sizing: border-box; }
.wd-page {
    font-family: var(--wd-font);
    -webkit-font-smoothing: antialiased;
}

/* Browser frame inside portfolio cards */
.wd-browser-frame {
    width: 100%;
    background: #ffffff;
    border-radius: 9px;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
    border: 1px solid rgba(15, 23, 42, 0.08);
}
.wd-browser-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    background: linear-gradient(180deg, #f1f3f6 0%, #e8ebef 100%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}
.wd-bdot {
    width: 11px; height: 11px;
    border-radius: 50%;
    background: #ddd;
    flex-shrink: 0;
}
.wd-bdot:nth-child(1) { background: #ff5f57; }
.wd-bdot:nth-child(2) { background: #febc2e; }
.wd-bdot:nth-child(3) { background: #28c840; }

.wd-burl {
    margin-left: 14px;
    flex: 1;
    background: #ffffff;
    border-radius: 4px;
    padding: 4px 12px;
    font-family: var(--wd-code);
    font-size: 11px;
    color: var(--wd-text);
    border: 1px solid rgba(15, 23, 42, 0.06);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 320px;
}
.wd-browser-screen {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center top;
    background-color: #0f172a;
    position: relative;
}
.wd-browser-screen--logo {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #f1f5f9;
}

/* ============================================================
   BINDER - two-page spread with a page-turn animation
   ============================================================ */
.wd-stack-stage {
    max-width: 1500px;
    margin: 0 auto;
    perspective: 2400px;
}

.wd-stack-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 56px;
    margin-bottom: 38px;
}

.wd-slot {
    position: relative;
    min-height: 460px;
    transform-style: preserve-3d;
    display: grid;
    grid-template-areas: "stack";
}
.wd-slot > .wd-port-card,
.wd-slot > .wd-slot-skeleton {
    grid-area: stack;
}

.wd-slot::before,
.wd-slot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    z-index: 0;
    pointer-events: none;
}
.wd-slot::before { transform: rotate(-3.2deg) translate(-10px, 10px); }
.wd-slot::after  { transform: rotate(2.4deg) translate(8px, 16px); background: #fdfaf1; border-color: rgba(15, 23, 42, 0.06); }

.wd-slot:nth-child(1) .wd-port-card { transform: rotate(-1.6deg); }
.wd-slot:nth-child(2) .wd-port-card { transform: rotate(1.4deg); }

.wd-slot .wd-port-card {
    position: relative;
    z-index: 2;
    will-change: transform;
    transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.42s ease;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}
.wd-slot .wd-port-card:hover {
    transform: rotate(0deg) translateY(-6px);
    box-shadow: 0 28px 56px rgba(15, 23, 42, 0.16);
}

/* Page-turn: right card pivots on its left edge and flips over the
   left card. Slot 0 (left) doesn't animate on desktop - the flipping
   slot 1 card simply covers it. New cards sit underneath, ready. */
.wd-card-emerging {
    z-index: 1 !important;
    opacity: 0;
    animation: wdEmerge 320ms ease 360ms forwards;
}
.wd-slot:nth-child(2) .wd-port-card.wd-flipping {
    transform-origin: 0% 50%;
    animation: wdPageTurnRight 720ms cubic-bezier(0.45, 0.05, 0.25, 1) forwards;
    z-index: 50;
    box-shadow:
        0 30px 70px rgba(15, 23, 42, 0.32),
        0 8px 18px rgba(15, 23, 42, 0.18);
}
@keyframes wdPageTurnRight {
    0%   { transform: rotate(1.4deg) rotateY(0deg) translateZ(0); }
    25%  { transform: rotate(1deg)   rotateY(-22deg) translateZ(18px); }
    50%  { transform: rotate(0deg)   rotateY(-90deg) translateZ(22px); }
    75%  { transform: rotate(-1deg)  rotateY(-150deg) translateZ(12px); }
    100% { transform: rotate(-1.6deg) rotateY(-180deg) translateZ(0); }
}
@keyframes wdEmerge {
    to { opacity: 1; }
}

.wd-slot:empty { background: transparent; }
.wd-slot:empty::after,
.wd-slot:empty::before { background: transparent; box-shadow: none; border: none; transform: none; }

.wd-slot-skeleton {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: linear-gradient(90deg, rgba(15,23,42,0.04) 0%, rgba(15,23,42,0.08) 50%, rgba(15,23,42,0.04) 100%);
    background-size: 200% 100%;
    animation: wdShimmer 1.6s linear infinite;
    z-index: 1;
}
@keyframes wdShimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.wd-card-pool { display: none; }

/* The full book ([traxx_case_studies layout="book"]): each picture is the
   whole desktop capture, with its tag in the bottom corner. */
.wd-stack-stage--book .wd-browser-screen,
.wd-stack-stage--book .wd-port-img-placeholder { aspect-ratio: 16 / 10; }
.wd-stack-stage--book .wd-port-tag { top: auto; right: 14px; bottom: 14px; }
/* Nothing in the book matches the filters: the page's own message stands in. */
.wd-stack-stage.is-empty { display: none; }
/* One spread: nothing to turn to. */
.wd-stack-stage.is-single .wd-stack-nav { visibility: hidden; }

.wd-stack-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    position: relative;
    z-index: 5;
}
.wd-stack-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    background: #ffffff;
    color: var(--wd-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.wd-stack-btn:hover {
    background: var(--wd-dark);
    color: var(--wd-cyan);
    border-color: var(--wd-dark);
    transform: scale(1.08);
}
.wd-stack-dots { display: flex; gap: 10px; align-items: center; }
.wd-sdot {
    width: 10px; height: 10px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.18);
    cursor: pointer;
    padding: 0;
    transition: background 0.3s ease, width 0.3s ease;
}
.wd-sdot.active {
    background: var(--wd-blue);
    width: 26px;
    border-radius: 5px;
}

/* The full book: its arrows are tabs on the outer edges of the pages,
   so a page is turned from its edge. The one with no page left to turn
   is put away. From tablets up they stand at mid-height against the
   stage: at the edges of the slots for the paper binder, and where the
   3D notebook says its pages end (--wd-edge-l / -r / -y, has-edges). */
.wd-stack-stage--book .wd-stack-btn { border-radius: 7px; padding: 0; }
.wd-stack-stage--book .wd-stack-btn[aria-disabled="true"] { visibility: hidden; }
@media (min-width: 769px) {
    .wd-stack-stage--book { position: relative; }
    .wd-stack-stage--book .wd-stack-nav { position: static; }
    .wd-stack-stage--book .wd-stack-btn,
    .wd-page.has-3d-notebook .wd-stack-stage--book .wd-stack-btn {
        position: absolute;
        z-index: 5;
        top: var(--wd-edge-y, 42%);
        width: 38px;
        height: 86px;
        margin-top: -43px;
        padding: 0;
        background: #f6f1e6;
        color: #3b3128;
        border: 1px solid rgba(59, 49, 40, 0.3);
        box-shadow: 0 3px 8px rgba(40, 30, 20, 0.2);
        font-size: 14px;
        transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, opacity 0.4s ease;
    }
    /* Each tab is clipped over its page's edge: most of it on the
       margin of the page, a third of it past the paper. */
    .wd-stack-stage--book .wd-stack-prev {
        left: var(--wd-edge-l, 0px);
        margin-left: -13px;
        border-radius: 9px 3px 3px 9px;
    }
    .wd-stack-stage--book .wd-stack-next {
        left: var(--wd-edge-r, 100%);
        margin-left: -25px;
        border-radius: 3px 9px 9px 3px;
    }
    /* The 3D book is drawn on a layer over the page, and the tabs have
       to sit on top of it: the stage's perspective (only the paper
       binder needs it) would hold them underneath. */
    .wd-page.has-3d-notebook .wd-stack-stage--book { perspective: none; }
    .wd-stack-stage--book .wd-stack-btn:hover,
    .wd-page.has-3d-notebook .wd-stack-stage--book .wd-stack-btn:hover {
        background: #3b3128;
        color: #f3eee4;
        border-color: #3b3128;
    }
    .wd-stack-stage--book .wd-stack-prev:hover,
    .wd-page.has-3d-notebook .wd-stack-stage--book .wd-stack-prev:hover { transform: translateX(-4px); }
    .wd-stack-stage--book .wd-stack-next:hover,
    .wd-page.has-3d-notebook .wd-stack-stage--book .wd-stack-next:hover { transform: translateX(4px); }
    .wd-stack-stage--book .wd-stack-btn:focus-visible { outline: 2px solid #0b5f8f; outline-offset: 3px; }
    /* The notebook's cover is still closed: no page edges yet. */
    .wd-stack-stage--book.has-edges:not(.is-open) .wd-stack-btn { opacity: 0; pointer-events: none; }
}
@media (min-width: 769px) and (prefers-reduced-motion: reduce) {
    .wd-page .wd-stack-stage--book .wd-stack-prev:hover,
    .wd-page .wd-stack-stage--book .wd-stack-next:hover,
    .wd-page.has-3d-notebook .wd-stack-stage--book .wd-stack-prev:hover,
    .wd-page.has-3d-notebook .wd-stack-stage--book .wd-stack-next:hover { transform: none; }
}

.wd-port-card {
    background: var(--wd-card-bg);
    border-radius: 12px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.10);
    position: relative;
}
.wd-port-card::before {
    content: '';
    position: absolute;
    top: -10px; left: 50%;
    transform: translateX(-50%) rotate(-2deg);
    width: 86px; height: 22px;
    background:
        linear-gradient(115deg, transparent 0 38%, rgba(255,255,255,0.55) 46%, rgba(255,255,255,0.1) 54%, transparent 62% 100%),
        var(--wd-tape);
    border: 1px solid var(--wd-tape-edge);
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.10);
    z-index: 4;
    pointer-events: none;
}
.wd-port-img-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}
.wd-port-card .wd-browser-frame {
    border-radius: 12px 12px 0 0;
    border: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.wd-port-card .wd-browser-screen { transition: transform 0.6s ease; }
.wd-port-card:hover .wd-browser-screen { transform: scale(1.04); }
/* Photo-print caption; only the notebook pages show it. */
.wd-port-caption { display: none; }

.wd-port-card[data-dev="true"] {
    background: #ffffff;
    padding: 14px 14px 0 14px;
}
.wd-port-card[data-dev="true"] .wd-browser-frame {
    border-radius: 4px;
    border: 1px solid rgba(15, 23, 42, 0.08);
}
.wd-port-card[data-dev="true"] .wd-port-img-wrap {
    border-radius: 4px;
    overflow: hidden;
}
.wd-port-img-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(135deg, #0a1628 0%, #1a2d45 60%, #243352 100%);
}
.wd-port-img-placeholder i { font-size: 40px; color: rgba(0, 210, 255, 0.7); }
.wd-port-img-placeholder span {
    font-family: var(--wd-code);
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    letter-spacing: 2px;
}
/* In development: a slim red sign-here page flag stuck in the card's top
   corner like a bookmark, its square end past the edge and its arrow
   pointing in. */
.wd-port-card[data-dev="true"]::after {
    content: 'in_development';
    position: absolute;
    top: 14px; right: -16px;
    background: linear-gradient(180deg, #e3262c, #c3141b);
    color: #fff;
    font-family: var(--wd-code);
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.2px;
    white-space: nowrap;
    padding: 4px 10px 4px 17px;
    clip-path: polygon(0 50%, 10px 0, 100% 0, 100% 100%, 10px 100%);
    filter: drop-shadow(0 2px 2px rgba(30, 10, 10, 0.25));
    transform: rotate(-6deg);
    transform-origin: 100% 50%;
    z-index: 5;
}
.wd-port-card[data-dev="true"] .wd-port-tag-pin { display: none; }
.wd-port-card[data-dev="true"] .wd-port-tag { display: none; }

.wd-port-tag {
    position: absolute;
    /* Sits on the screenshot, top-right, below the browser bar so the
       URL pill stays readable. */
    top: 52px; right: 18px;
    background: var(--wd-dark);
    color: #fff;
    padding: 5px 12px;
    font-family: var(--wd-code);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    border-radius: 4px;
    z-index: 3;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.wd-port-content {
    padding: clamp(22px, 2.6vw, 30px);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.wd-port-card[data-dev="true"] .wd-port-content { padding-top: 18px; }

.wd-port-client {
    font-size: clamp(18px, 2.1vw, 21px);
    font-weight: 800;
    color: var(--wd-dark);
    margin: 0 0 12px 0;
    letter-spacing: -0.5px;
}
/* Service line and industry; only the full book prints it. */
.wd-port-service {
    font-family: var(--wd-code);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--wd-blue);
    margin: -4px 0 12px 0;
}
.wd-port-service span { color: var(--wd-text-muted); font-weight: 500; }
.wd-port-desc {
    font-size: 0.92rem;
    color: var(--wd-text);
    line-height: 1.7;
    margin: 0 0 18px 0;
    flex-grow: 1;
}
.wd-port-caps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}
.wd-port-cap {
    font-family: var(--wd-code);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--wd-blue);
    background: rgba(2, 132, 199, 0.08);
    border: 1px solid rgba(2, 132, 199, 0.18);
    border-radius: 50px;
    padding: 3px 10px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.wd-port-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--wd-code);
    font-size: 13px;
    font-weight: 700;
    color: var(--wd-dark);
    text-decoration: none;
    transition: color 0.3s ease;
    margin-top: auto;
}
.wd-port-link i {
    color: var(--wd-cyan);
    font-size: 13px;
    transition: transform 0.3s ease;
}
.wd-port-link:hover { color: var(--wd-blue); text-decoration: none; }
.wd-port-link:hover i { transform: translateX(5px); }

/* Story link + optional "Live site" side link on one row */
.wd-port-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: auto;
    padding-top: 14px;
}
.wd-port-links .wd-port-link { margin-top: 0; }
.wd-port-link--site {
    font-weight: 600;
    font-size: 12px;
    color: var(--wd-gray, #64748b);
}
.wd-port-link--site i { color: currentColor; font-size: 11px; }
.wd-port-link--site:hover i { transform: translate(2px, -2px); }

/* Phones: story link and "Live site" on their own lines. */
@media (max-width: 480px) {
    .wd-port-links {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .wd-stack-slots {
        grid-template-columns: 1fr;
        gap: 70px;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }
    .wd-slot:last-child { display: none; }
    /* Mobile: page-turn keyframe wouldn't be visible (slot 1 hidden);
       use a quick fade on slot 0 instead. */
    .wd-slot:nth-child(1) .wd-port-card.wd-flipping {
        animation: wdMobileFade 480ms ease forwards;
        transform-origin: center;
    }
    @keyframes wdMobileFade {
        to { opacity: 0; transform: rotate(0deg) scale(0.94) translateY(14px); }
    }
}

/* ============================================================
   3D NOTEBOOK (assets/js/web-design-3d.js) - desktop only.
   A fixed WebGL + CSS3D stage follows the scroll and the notebook
   sits over the binder's slots, which keep the page layout so the
   binder above remains the fallback.
   ============================================================ */
@media (min-width: 769px) {
    /* Before first paint (inline head script) and once mounted: hide
       the binder cards but keep their boxes. */
    html.wd3d-pending .wd-slot > .wd-port-card,
    html.wd3d-pending .wd-slot::before,
    html.wd3d-pending .wd-slot::after,
    html.wd3d-pending .wd-slot-skeleton,
    .wd-page.has-3d-notebook .wd-slot > .wd-port-card,
    .wd-page.has-3d-notebook .wd-slot::before,
    .wd-page.has-3d-notebook .wd-slot::after,
    .wd-page.has-3d-notebook .wd-slot-skeleton {
        visibility: hidden;
        animation: none;
        transition: none;
    }
    .wd-page.has-3d-notebook .wd-slot { min-height: min(940px, 60vw); }

    /* Page controls under the book: pencil marks on the desk rather than
       app buttons. The pages themselves and the arrow keys turn too. */
    .wd-page.has-3d-notebook .wd-stack-nav { gap: 18px; margin-top: 40px; }
    .wd-page.has-3d-notebook .wd-stack-btn {
        width: 40px; height: 40px;
        background: transparent;
        color: #3b3128;
        border: 1.5px solid rgba(59, 49, 40, 0.55);
        box-shadow: none;
        font-size: 13px;
    }
    .wd-page.has-3d-notebook .wd-stack-btn:hover {
        background: #3b3128;
        color: #f3eee4;
        border-color: #3b3128;
        transform: none;
    }
    .wd-page.has-3d-notebook .wd-stack-dots { gap: 9px; }
    .wd-page.has-3d-notebook .wd-sdot {
        width: 8px; height: 8px;
        border-radius: 1px;
        transform: rotate(45deg);
        background: rgba(59, 49, 40, 0.28);
    }
    .wd-page.has-3d-notebook .wd-sdot.active {
        width: 8px;
        background: #3b3128;
        transform: rotate(45deg) scale(1.25);
    }
}

.wd3d-stage {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
    contain: strict;
}
.wd3d-stage.is-ready { opacity: 1; }
.wd3d-stage:not(.is-active) { visibility: hidden; }
.wd3d-css,
.wd3d-gl {
    position: absolute;
    top: 0;
    left: 0;
}
/* Two DOM layers sandwich the canvas: screens show through holes from
   below it, page text is laid over the lit paper from above it. */
.wd3d-css { z-index: 1; }
.wd3d-gl { z-index: 2; pointer-events: none; }
.wd3d-css--top { z-index: 3; }
.wd3d-css .wd3d-dom { pointer-events: auto; }

html.wd3d-cursor-pointer,
html.wd3d-cursor-pointer * { cursor: pointer !important; }

/* DOM riding on the quads. Sizes are set by the module to match the
   model's quad aspect; everything inside is laid out in CSS px. */
.wd3d-dom {
    box-sizing: border-box;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* Notebook pages: only the ink is DOM. It lies over the canvas, on the
   model's own paper, so the stock, its grid and the gutter shading are
   the book's and nothing here paints a background. The case-study card
   is laid out edge to edge (screenshot taped in at the top, notes
   below). Percent units would resolve against the CSS3D layer, so sizes
   derive from the page height the module sets. */
.wd3d-page {
    --wd3d-pad: calc(var(--wd3d-page-h, 600px) * 0.045);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    color: var(--wd-paper-ink);
    background: transparent;
}
.wd3d-page .wd-port-card,
.wd3d-page .wd-port-card[data-dev="true"] {
    width: 100%;
    height: 100%;
    max-height: none;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transform: none !important;
    animation: none !important;
}
.wd3d-page .wd-port-card::before { top: calc(var(--wd3d-pad) * 1.1); z-index: 6; }
.wd3d-page .wd-port-card[data-dev="true"]::after { top: calc(var(--wd3d-pad) * 1.2); right: 0; }
/* Each site is an instant-photo print taped into the book, the title
   handwritten on its white border. The module paints the turning leaf
   from these same rules, reading the print's transform. */
.wd3d-page .wd-port-img-wrap,
.wd3d-page .wd-port-card[data-dev="true"] .wd-port-img-wrap {
    /* The modelled print on the page is laid over this box, so the two
       must agree: the module reads the print's proportions from the
       model and sets them on the page (--wd3d-print-k its width against
       the page's height, -top / -side / -foot its borders against its
       width, -aspect its window). The fallbacks are a real instant
       print: 88 x 107 mm card, 79 mm square window 6 mm from the top. */
    --wd3d-print-w: calc(var(--wd3d-page-h, 600px) * var(--wd3d-print-k, 0.41));
    --wd3d-print-pad: calc(var(--wd3d-print-w) * var(--wd3d-print-side, 0.051));
    flex-shrink: 0;
    position: relative;
    margin: calc(var(--wd3d-pad) * 1.25) auto 0;
    width: var(--wd3d-print-w);
    padding: calc(var(--wd3d-print-w) * var(--wd3d-print-top, 0.068)) var(--wd3d-print-pad) calc(var(--wd3d-print-w) * var(--wd3d-print-foot, 0.25));
    overflow: visible;
    background: #fcfbf7;
    border-radius: 2px;
    box-shadow: 0 10px 22px rgba(60, 45, 20, 0.26), 0 1px 2px rgba(60, 45, 20, 0.22);
    transform: rotate(-3deg);
}
.wd3d-page--R .wd-port-img-wrap,
.wd3d-page--F .wd-port-img-wrap { transform: rotate(2.2deg); }
.wd3d-page .wd-browser-frame,
.wd3d-page .wd-port-card[data-dev="true"] .wd-browser-frame { border-radius: 0; border: none; background: #0f172a; }
/* A print has no browser chrome; its window shows the top of the page. */
.wd3d-page .wd-browser-bar { display: none; }
.wd3d-page .wd-port-tag { top: calc(var(--wd3d-print-w) * var(--wd3d-print-top, 0.068) + 8px); right: calc(var(--wd3d-print-pad) + 8px); }
.wd3d-page .wd-port-card .wd-browser-screen,
.wd3d-page .wd-port-card .wd-port-img-placeholder { transition: none; aspect-ratio: var(--wd3d-print-aspect, 1 / 1); background-size: cover; background-position: top center; }
.wd3d-page .wd-port-caption {
    display: block;
    position: absolute;
    left: var(--wd3d-print-pad);
    right: var(--wd3d-print-pad);
    bottom: calc(var(--wd3d-print-w) * var(--wd3d-print-foot, 0.25) / 2 - var(--wd3d-pad) * 0.575);
    height: calc(var(--wd3d-pad) * 1.15);
    line-height: calc(var(--wd3d-pad) * 1.15);
    font-family: var(--wd-marker);
    font-weight: 400;
    font-size: calc(var(--wd3d-page-h, 600px) * 0.031);
    letter-spacing: 0.2px;
    color: #2a241f;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* The heading stays for assistive tech; the caption carries it visually. */
.wd3d-page .wd-port-client {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}
.wd3d-page .wd-port-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: calc(var(--wd3d-pad) * 1.15) var(--wd3d-pad) calc(var(--wd3d-pad) * 1.2);
}
/* With a modelled print lying on the page, the DOM print keeps only its
   link (and the pin); the model carries the card, picture, caption and
   tape. The turning leaf is still painted from the full rules above. */
.wd3d-page--print .wd-port-img-wrap,
.wd3d-page--print .wd-port-card[data-dev="true"] .wd-port-img-wrap { background: transparent; box-shadow: none; }
.wd3d-page--print .wd-port-img-wrap .wd-browser-frame,
.wd3d-page--print .wd-port-caption,
.wd3d-page--print .wd-port-tag { visibility: hidden; }
.wd3d-page--print .wd-port-card::before { display: none; }
/* With a modelled page flag, the CSS flag goes. */
.wd3d-page--flag .wd-port-card[data-dev="true"]::after { visibility: hidden; }
/* Off-screen copies of the two cards the turning leaf is painted from. */
.wd3d-page--measure {
    position: absolute;
    left: -300vw;
    top: 0;
    visibility: hidden;
    pointer-events: none;
}
.wd3d-page .wd-port-desc {
    font-size: calc(var(--wd3d-page-h, 600px) * 0.0225);
    line-height: 1.55;
    color: #4a4238;
    margin-bottom: calc(var(--wd3d-pad) * 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    max-height: calc(var(--wd3d-page-h, 600px) * 0.0225 * 1.55 * 5);
    overflow: hidden;
}
/* Which line of work the page is from, pencilled over the notes. */
.wd3d-page .wd-port-service {
    font-size: calc(var(--wd3d-page-h, 600px) * 0.0185);
    letter-spacing: 0.4px;
    color: #6b5a3c;
    margin-bottom: calc(var(--wd3d-pad) * 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wd3d-page .wd-port-service span { color: #8a7a5e; }
.wd3d-page .wd-port-caps { margin-bottom: calc(var(--wd3d-pad) * 0.6); gap: 5px; }
/* Chips and links shrink with the page like the rest of its ink, so a
   small book keeps the proportions of a large one and the notes are
   never squeezed. They stop growing at their size off the page. */
.wd3d-page .wd-port-cap {
    font-size: clamp(8px, calc(var(--wd3d-page-h, 600px) * 0.0165), 10.5px);
    padding: 0.286em 0.952em;
    background: rgba(70, 55, 30, 0.06);
    border-color: rgba(70, 55, 30, 0.16);
    color: #5c4a2e;
}
.wd3d-page .wd-port-caps > :nth-child(n+6) { display: none; }
.wd3d-page .wd-port-links { padding-top: calc(var(--wd3d-pad) * 0.4); }
.wd3d-page .wd-port-link { font-size: clamp(9.5px, calc(var(--wd3d-page-h, 600px) * 0.0205), 13px); color: #1a1612; }
.wd3d-page .wd-port-link i { font-size: 1em; }
.wd3d-page .wd-port-link--site { font-size: clamp(9px, calc(var(--wd3d-page-h, 600px) * 0.019), 12px); }
.wd3d-page .wd-port-link--site i { font-size: 0.92em; }

@media (prefers-reduced-motion: reduce) {
    .wd3d-stage { transition: none; }
}
