/* ==========================================================================
   brjoub.com — the home page
   ========================================================================== */

/* --- Hero ------------------------------------------------------------------- */
.hero { position: relative; padding: 100px 0 84px; overflow: hidden; }
.hero::before {
    /* Faint dot paper under the copy. */
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(70, 52, 24, 0.13) 1.1px, transparent 1.3px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(120% 80% at 20% 30%, #000 30%, transparent 75%);
    mask-image: radial-gradient(120% 80% at 20% 30%, #000 30%, transparent 75%);
    pointer-events: none;
}
.hero-grid { position: relative; display: grid; gap: 44px; align-items: center; }
.hero-kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 0.86rem; font-weight: 700; color: var(--ink-2); }
.hero-kicker .prompt { color: var(--forest); }
.hero-kicker .typed { color: var(--ink); }
.caret { display: inline-block; width: 9px; height: 1.15em; background: var(--honey); border-radius: 1px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.hero-title { font-size: clamp(2.55rem, 7.4vw, 4.85rem); line-height: 1.02; letter-spacing: -0.03em; font-weight: 700; margin-bottom: 22px; max-width: 13ch; }
.hero-title .mark::before { height: 0.38em; bottom: 0.08em; }
.hero-lede { max-width: 52ch; font-size: 1.08rem; line-height: 1.65; color: var(--ink-2); margin-bottom: 26px; }
.hero-lede strong { color: var(--ink); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 26px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.hero-links a { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; font-size: 0.9rem; font-weight: 600; color: var(--ink-2); }
.hero-links a:hover { color: var(--forest); }
.hero-links a:hover svg { transform: rotate(-10deg) scale(1.12); }
.hero-links svg { transition: transform 0.35s var(--ease-paper); }

/* --- The shadow box ------------------------------------------------------------ */
.shadowbox { position: relative; width: min(100%, 540px); margin: 0 auto; }
.shadowbox > .strata { border-radius: 10px; }
.shadowbox::before {
    /* The frame: dark felt, a cream mat inside it. */
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: 20px;
    background: var(--forest-deep) url("assets/images/paper/grain-light.webp") 0 0 / 240px;
    box-shadow: var(--sh-3), inset 0 0 0 2px rgba(255, 255, 255, 0.05);
}
.shadowbox::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 14px;
    background: var(--card);
    z-index: 0;
}
.strata {
    position: relative;
    z-index: 1;
    aspect-ratio: 600 / 640;
    overflow: hidden;
    isolation: isolate;
    background: linear-gradient(180deg, #F3E5C8 0%, #F8EEDB 46%, #F6E6C6 100%);
}
.strata::after {
    /* Depth of the box: the frame's shadow falling inward over every layer. */
    content: '';
    position: absolute;
    inset: 0;
    z-index: 20;
    border-radius: inherit;
    box-shadow: inset 0 10px 18px -6px rgba(40, 25, 5, 0.38), inset 0 0 0 1px rgba(40, 25, 5, 0.12);
    pointer-events: none;
}
.sky { position: absolute; inset: 0; }
.sky::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(70, 52, 24, 0.12) 1px, transparent 1.2px);
    background-size: 18px 18px;
}
.sky-sun { position: absolute; right: 7%; top: 5%; width: 17%; translate: calc(var(--px, 0) * 0.6px) calc(var(--sy, 0) * 0.2px); animation: sunIn 1.6s var(--ease-out) 0.2s both; }
.sky-cloud { position: absolute; translate: calc(var(--px, 0) * 1px) 0; }
.sky-cloud.c1 { left: 4%; top: 15%; width: 30%; animation: cloudIn 1.4s var(--ease-out) 0.5s both, drift 18s ease-in-out 2s infinite alternate; }
.sky-cloud.c2 { right: 3%; top: 31%; width: 19%; animation: cloudIn 1.4s var(--ease-out) 0.7s both, drift 14s ease-in-out 2s infinite alternate-reverse; }
@keyframes sunIn { from { opacity: 0; transform: translateY(40%) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes cloudIn { from { opacity: 0; transform: translateX(-20%); } to { opacity: 1; transform: none; } }
@keyframes drift { from { transform: translateX(-6%); } to { transform: translateX(8%); } }

/* The app, rising behind the layers like a sunrise. */
.rise-phone {
    position: absolute;
    left: 35.5%;
    top: 7%;
    width: 29%;
    translate: calc(var(--px, 0) * 1.4px) calc(var(--sy, 0) * 0.6px);
    animation: phoneRise 1.6s var(--ease-out) 0.85s both;
}
.rise-phone .paper-phone { animation: float 6s ease-in-out 2.5s infinite alternate; }
@keyframes phoneRise { from { transform: translateY(85%) rotate(7deg); } to { transform: rotate(-3deg); } }
@keyframes float { from { transform: translateY(0); } to { transform: translateY(-3.5%); } }

/* The paper plane. */
.plane-track { position: absolute; inset: 0; animation: planeX 17s linear 2.6s infinite both; }
.plane-bob { position: absolute; left: 0; top: 17%; animation: planeY 3.2s ease-in-out infinite alternate; }
.plane { width: clamp(28px, 7.5%, 46px); height: auto; filter: drop-shadow(0 5px 4px rgba(40, 25, 5, 0.25)); }
@keyframes planeX { from { transform: translateX(-12%); } to { transform: translateX(112%); } }
@keyframes planeY { from { transform: translateY(0) rotate(4deg); } to { transform: translateY(60%) rotate(-6deg); } }

/* The strata. Front layers rise first, so the stack builds from the metal up. */
.layer { position: absolute; inset: 0; animation: layerRise 1.15s var(--ease-paper) calc(0.1s + var(--i) * 0.12s) both; }
.layer svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 -3px 4px rgba(40, 25, 5, 0.26));
    translate: calc(var(--px, 0) * var(--z) * 1px) calc(var(--sy, 0) * var(--z) * -1px);
    animation: sway calc(6s + var(--z) * 1.4s) ease-in-out 1.8s infinite alternate;
    will-change: transform;
}
@keyframes layerRise { from { transform: translateY(58%); } to { transform: none; } }
@keyframes sway { from { transform: translateX(-0.7%); } to { transform: translateX(0.7%); } }

/* Paper tags pinned to each layer, dropped in once their layer arrives. */
.tags { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.tag {
    position: absolute;
    right: 3%;
    padding: 0.28em 0.7em 0.3em 1.45em;
    font-family: var(--f-mono);
    font-size: clamp(9px, 2.1vw, 12px);
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
    background: var(--card);
    border-radius: 3px 5px 5px 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 4px 8px -3px rgba(40, 25, 5, 0.4);
    transform-origin: 12% 50%;
    transform: rotate(var(--r, -3deg));
    animation: tagDrop 1.1s var(--ease-paper) var(--t) both;
    translate: calc(var(--px, 0) * 4px) 0;
}
.tag::before {
    content: '';
    position: absolute;
    left: 0.5em;
    top: 50%;
    width: 0.48em;
    height: 0.48em;
    margin-top: -0.24em;
    border-radius: 50%;
    background: var(--paper-2);
    box-shadow: inset 0 1px 1px rgba(60, 40, 10, 0.45);
}
@keyframes tagDrop {
    0% { opacity: 0; transform: translateY(-14px) rotate(-22deg); }
    45% { opacity: 1; transform: rotate(8deg); }
    70% { transform: rotate(-6deg); }
    100% { transform: rotate(var(--r, -3deg)); }
}
.t-apps { right: auto; left: 67%; top: 11%; --r: 4deg; background: var(--honey-2); }
.t-cloud { top: 49.5%; --r: -2deg; }
.t-cpp { top: 57.8%; --r: 3deg; }
.t-kernel { top: 66.2%; --r: -4deg; }
.t-riscv { top: 74.6%; --r: 2deg; }
.t-verify { top: 83%; --r: -3deg; }
.t-gates { top: 91.3%; --r: 2deg; color: var(--paper); background: #24395A; }
.t-gates::before { background: var(--navy-deep); }

.shadowbox figcaption {
    position: absolute;
    right: -6px;
    bottom: -52px;
    font-size: 1.35rem;
    color: var(--ink-3);
    transform: rotate(-3deg);
}
.shadowbox figcaption::before { content: '↖ '; color: var(--honey); }

@media (min-width: 960px) {
    .hero { padding: 96px 0 96px; }
    .hero-grid { grid-template-columns: 1.02fr 0.98fr; min-height: min(calc(100vh - 64px), 820px); gap: 56px; }
    .shadowbox { margin-right: 14px; }
}
@media (max-width: 959px) {
    .hero-copy { max-width: 640px; }
    .shadowbox { margin-top: 4px; width: min(100% - 28px, 460px); }
}

/* --- The stack ------------------------------------------------------------------ */
.stack { position: relative; padding: 0 0 104px; background: var(--paper-2) url("assets/images/paper/grain.webp") 0 0 / 320px; }
.stack > .container { padding-top: 84px; }
.layers { position: relative; display: grid; gap: 22px; padding-left: 42px; max-width: 1040px; margin: 0 auto; }
.bus { position: absolute; left: 13px; top: 10px; bottom: 10px; width: 4px; border-radius: 2px; background: repeating-linear-gradient(to bottom, var(--line-2) 0 9px, transparent 9px 17px); }
.bus-fill { position: absolute; inset: 0; border-radius: 2px; background: var(--honey); transform-origin: 50% 0; transform: scaleY(var(--p, 0)); }
.bus-spark {
    position: absolute;
    left: 50%;
    top: calc(var(--p, 0) * 100%);
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #FFE7A8;
    box-shadow: 0 0 0 4px rgba(217, 164, 58, 0.35), 0 0 18px 4px rgba(217, 164, 58, 0.7);
    opacity: var(--spark, 0);
    transition: opacity 0.3s ease;
}
.layer-card {
    position: relative;
    padding: 22px 22px 20px 22px;
    background: var(--card);
    border-radius: 4px 6px 6px 4px;
    box-shadow: var(--sh-2);
    transition: transform 0.45s var(--ease-out), box-shadow 0.45s ease;
}
.layer-card::before {
    /* The coloured edge: a strip of the layer's felt. */
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    border-radius: 4px 0 0 4px;
    background: var(--c);
}
@media (hover: hover) {
    .layer-card:hover { transform: translateY(-4px) rotate(-0.4deg); box-shadow: var(--sh-3); }
    .layer-card:hover .lc-icon { transform: rotate(-6deg) scale(1.06); }
}
.node {
    position: absolute;
    left: -37px;
    top: 30px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--card);
    box-shadow: 0 0 0 3px var(--line-2);
    transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.5s var(--ease-paper);
}
.layer-card.in .node { background: var(--honey); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--honey); transform: scale(1.15); transition-delay: 0.35s; }
.lc-icon {
    float: right;
    width: 56px;
    height: 56px;
    margin: -4px -4px 8px 14px;
    padding: 6px;
    border-radius: 12px;
    background: var(--c) url("assets/images/paper/grain-light.webp") 0 0 / 200px;
    box-shadow: 0 3px 0 var(--c2), 0 8px 14px -8px rgba(40, 25, 5, 0.5);
    transform: rotate(4deg);
    transition: transform 0.5s var(--ease-paper);
}
.lc-icon svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1.5px 1px rgba(0, 0, 0, 0.22)); }
.lc-num { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.layer-card h3 { font-size: 1.45rem; margin-bottom: 8px; }
.layer-card p:not(.lc-num) { font-size: 0.97rem; line-height: 1.6; color: var(--ink-2); }
.lc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; clear: both; }
.lc-link { display: inline-flex; gap: 6px; margin-top: 14px; font-family: var(--f-mono); font-size: 0.78rem; font-weight: 700; color: var(--forest-2); border-bottom: 2px solid var(--honey-2); padding-bottom: 1px; }
.lc-link:hover { border-color: var(--honey); }

@media (min-width: 900px) {
    .layers { padding-left: 0; gap: 0; }
    .bus { left: calc(50% - 2px); }
    .layer-card { width: calc(50% - 54px); }
    .layer-card + .layer-card { margin-top: -54px; }
    .layer-card:nth-child(even) { justify-self: start; }
    .layer-card:nth-child(odd) { justify-self: end; }
    .layer-card:nth-child(even) .node { left: auto; right: -62px; }
    .layer-card:nth-child(odd) .node { left: -62px; }
    .layer-card:nth-child(odd)::before { left: auto; right: 0; border-radius: 0 4px 4px 0; }
}

/* --- Numbers -------------------------------------------------------------------- */
.numbers { padding: 64px 0 24px; }
.numbers-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 34px 18px; max-width: 980px; }
.num { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.flip { display: inline-flex; gap: 5px; perspective: 400px; }
.flip .tile {
    position: relative;
    display: inline-grid;
    place-items: center;
    min-width: 0.78em;
    height: 1.22em;
    padding: 0 0.08em;
    font-family: var(--f-display);
    font-size: clamp(2.6rem, 8vw, 3.6rem);
    font-weight: 700;
    line-height: 1;
    color: var(--paper);
    background: var(--forest-2) url("assets/images/paper/grain-light.webp") 0 0 / 200px;
    border-radius: 8px;
    box-shadow: 0 3px 0 var(--forest-deep), 0 12px 18px -10px rgba(22, 56, 41, 0.6);
    transform-origin: 50% 50%;
}
.flip .tile::after {
    /* The split of a split-flap tile. */
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: rgba(0, 0, 0, 0.28);
}
.flip .tile.dot { min-width: 0.36em; background: none; box-shadow: none; color: var(--forest-2); }
.flip .tile.dot::after { display: none; }
.flip .tile.flap { animation: flap 0.11s ease-in-out; }
@keyframes flap { 50% { transform: rotateX(-80deg); } }
.num-label { max-width: 18ch; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); line-height: 1.35; }
@media (min-width: 760px) { .numbers-row { grid-template-columns: repeat(4, 1fr); } }

/* --- How I build: index cards -------------------------------------------------------- */
.craft { padding: 72px 0 110px; }
.cards { display: grid; gap: 30px 22px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); max-width: 1080px; margin: 0 auto; }
.index-card {
    position: relative;
    padding: 30px 22px 20px;
    min-height: 168px;
    border-radius: 2px;
    background: #FFFEF9;
    box-shadow: var(--sh-2);
    transform: rotate(var(--tilt));
    transition: transform 0.45s var(--ease-paper), box-shadow 0.45s ease;
}
.js .index-card.pop.in { transform: rotate(var(--tilt)); }
@media (hover: hover) {
    .index-card:hover, .js .index-card.pop.in:hover { transform: rotate(0deg) translateY(-6px) scale(1.02); box-shadow: var(--sh-3); }
}
.index-card h3 { font-size: 1.28rem; line-height: 1.15; margin: 0 -22px 10px; padding: 0 22px 10px; border-bottom: 2px solid rgba(217, 110, 90, 0.55); }
.index-card p { font-family: var(--f-hand); font-size: 1.42rem; line-height: 27px; color: #2E4467; background: repeating-linear-gradient(transparent 0 26px, rgba(105, 150, 185, 0.3) 26px 27px); }
.pin {
    position: absolute;
    top: -9px;
    left: 50%;
    width: 22px;
    height: 22px;
    margin-left: -11px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #F6C978 0 18%, var(--honey) 40%, #A8731B 100%);
    box-shadow: 0 5px 6px -2px rgba(40, 25, 5, 0.45);
}
.index-card:nth-child(2) .pin { background: radial-gradient(circle at 35% 30%, #8FD0AE 0 18%, var(--forest) 40%, var(--forest-deep) 100%); }
.index-card:nth-child(3) .pin { background: radial-gradient(circle at 35% 30%, #F2A98A 0 18%, var(--rust) 40%, #7C3A1C 100%); }
.index-card:nth-child(4) .pin { background: radial-gradient(circle at 35% 30%, #9FB6D8 0 18%, var(--navy) 40%, var(--navy-deep) 100%); }

/* --- The apps --------------------------------------------------------------------- */
.apps { position: relative; padding: 0 0 110px; background: var(--paper-2) url("assets/images/paper/grain.webp") 0 0 / 320px; }
.apps > .container { padding-top: 84px; }
.app-card { position: relative; max-width: 1120px; margin: 0 auto; background: var(--card); border-radius: 6px 10px 10px 10px; box-shadow: var(--sh-3); }
.folder-tab {
    position: absolute;
    left: 18px;
    bottom: calc(100% - 2px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--paper);
    background: var(--forest-2) url("assets/images/paper/grain-light.webp") 0 0 / 200px;
    border-radius: 9px 9px 0 0;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #9BE3B4; box-shadow: 0 0 0 0 rgba(155, 227, 180, 0.7); animation: live 2s ease-out infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(155, 227, 180, 0); } 100% { box-shadow: 0 0 0 0 rgba(155, 227, 180, 0); } }
.offshelf-card { margin-top: 58px; }
.app-body { display: grid; }
.app-copy { padding: 26px 22px 28px; }
.app-id { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.app-icon-wrap { position: relative; flex-shrink: 0; }
.app-icon-wrap .tape { width: 54px; height: 18px; top: -8px; left: 50%; margin-left: -27px; transform: rotate(-6deg); }
.app-icon { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), 0 12px 22px -10px rgba(22, 56, 41, 0.6); transform: rotate(-3deg); }
.app-name { font-size: 2.1rem; line-height: 1; }
.app-sub { margin-top: 4px; font-weight: 600; color: var(--ink-2); }
.stars { margin-top: 6px; font-size: 0.86rem; color: var(--ink-2); }
.stars span { color: var(--honey); letter-spacing: 1px; }
.stars strong { color: var(--ink); }
.app-pitch { font-size: 1.06rem; line-height: 1.6; color: var(--ink-2); max-width: 52ch; }
.app-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0 16px; }
.app-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 22px; }
.app-actions .stores { flex: 1 1 360px; }
.explore svg { transition: transform 0.35s var(--ease-out); }
.explore:hover svg { transform: translateX(4px); }

/* The visual: three paper phones fanned over a pile of felt books. */
.app-visual {
    position: relative;
    order: -1;
    display: block;
    height: 330px;
    margin: 18px 14px 0;
    border-radius: 6px;
    background:
        radial-gradient(70% 60% at 50% 110%, rgba(217, 164, 58, 0.35), transparent 70%),
        linear-gradient(180deg, #EEF1E4, #E4E9D6);
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transform-style: preserve-3d;
    transition: transform 0.5s var(--ease-out);
    overflow: hidden;
}
.app-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(36, 86, 63, 0.14) 1px, transparent 1.2px);
    background-size: 18px 18px;
}
.prop { position: absolute; z-index: 5; bottom: -8px; filter: drop-shadow(0 10px 10px rgba(40, 25, 5, 0.3)); transform: translateZ(70px); transition: transform 1s var(--ease-paper) 0.4s; }
.prop-books { left: -2%; width: 27%; max-width: 150px; }
.prop-cup { right: 1%; width: 17%; max-width: 96px; }
.js .app-card:not(.in) .prop { transform: translateY(70%); }
.fan { position: absolute; left: 50%; bottom: -70px; width: 0; height: 100%; transform: translateZ(40px); }
.fan .paper-phone { position: absolute; bottom: 0; width: 136px; margin-left: -68px; transition: transform 1.1s var(--ease-paper); }
.fan-c { z-index: 3; }
.fan-l { transform: translateX(-62%) rotate(-11deg); transform-origin: 50% 100%; }
.fan-r { transform: translateX(62%) rotate(11deg); transform-origin: 50% 100%; }
.js .app-card:not(.in) .fan-l, .js .app-card:not(.in) .fan-r { transform: translateY(20%) rotate(0deg); }
.app-card.in .fan-l { transition-delay: 0.55s; }
.app-card.in .fan-r { transition-delay: 0.65s; }
@media (hover: hover) {
    .app-visual:hover .fan-l { transform: translateX(-74%) rotate(-15deg) translateY(-4px); }
    .app-visual:hover .fan-r { transform: translateX(74%) rotate(15deg) translateY(-4px); }
    .app-visual:hover .fan-c { transform: translateY(-10px); }
}
.note-tag {
    position: absolute;
    left: 14px;
    top: 14px;
    z-index: 5;
    padding: 6px 12px 4px;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--ink);
    background: var(--honey-pale);
    box-shadow: var(--sh-1);
    transform: rotate(-4deg);
}

@media (min-width: 900px) {
    .app-body { grid-template-columns: 1fr 1fr; align-items: stretch; }
    .app-copy { padding: 44px 40px 40px 44px; }
    .app-visual { order: 0; height: auto; min-height: 480px; margin: 16px 16px 16px 0; }
    .fan .paper-phone { width: 178px; margin-left: -89px; }
    .fan { bottom: -92px; }
}

/* --- OffShelf, cut open ------------------------------------------------------------------
   The phone lies on the desk, seen from above, and its four layers lift apart.
   --gap is the space between sheets; it opens on reveal and breathes while on screen.
   The view is orthographic, so the tags beside it are placed by the same rotation:
   a sheet's near corner sits 0.986 × --sw right of the centre and 0.278 × --sw down,
   and each step of --gap up the stack lifts it by sin 56° = 0.829 × --gap. */
@property --gap { syntax: '<length>'; inherits: true; initial-value: 60px; }
.cutaway { --sw: 108px; --gap-open: 74px; display: grid; gap: 8px; max-width: 1120px; margin: 88px auto 0; align-items: center; }
.cut-figure { --sx: -30px; position: relative; height: 380px; --gap: var(--gap-open); }
.cut-scene {
    position: absolute;
    left: calc(50% + var(--sx));
    top: 50%;
    width: var(--sw);
    height: calc(var(--sw) * 2.175);
    margin: calc(var(--sw) * -1.0875) 0 0 calc(var(--sw) * -0.5);
    transform: rotateX(56deg) rotateZ(-38deg);
    transform-style: preserve-3d;
}
.js .cutaway:not(.in) .cut-figure { --gap: 6px; }
.cutaway.in .cut-figure { animation: cutOpen 1.7s var(--ease-paper) 0.2s both; }
.cutaway.in.live .cut-figure { animation: cutOpen 1.7s var(--ease-paper) 0.2s both, cutBreathe 4.6s ease-in-out 1.9s infinite alternate; }
@keyframes cutOpen { from { --gap: 6px; } to { --gap: var(--gap-open); } }
@keyframes cutBreathe { from { --gap: var(--gap-open); } to { --gap: calc(var(--gap-open) + 9px); } }

.cut-sheet {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform: translateZ(calc((var(--k) - 1.5) * var(--gap)));
    transition: translate 0.6s var(--ease-paper);
}
/* The sheet shown lifts a little; every sheet above it lifts more, opening the stack there. */
.cut-sheet.on { translate: 0 0 calc(var(--gap) * 0.12); }
.cut-sheet.above { translate: 0 0 calc(var(--gap) * 0.6); }
.s-ai::before {
    /* The stack's shadow on the desk. */
    content: '';
    position: absolute;
    inset: -7% -9% -9% -5%;
    background: radial-gradient(closest-side, rgba(28, 16, 2, 0.3), rgba(28, 16, 2, 0.12) 62%, transparent);
    transform: translate3d(5%, 3%, -16px);
    pointer-events: none;
}
.cut-face {
    position: absolute;
    inset: 0;
    border-radius: 16% / 7.4%;
    background: var(--face) url("assets/images/paper/grain-light.webp") 0 0 / 160px;
    transform-style: preserve-3d;
}
.cut-face::before {
    /* Card-stock thickness: a darker copy just beneath. */
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--edge);
    transform: translateZ(-4px);
}
.cut-face::after {
    /* The sheet above keeps some light off this one, most where the stack is shut. */
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(90% 70% at 42% 40%, rgba(20, 12, 0, 0.13), transparent 75%);
    pointer-events: none;
}
.s-app .cut-face::after { display: none; }
.cut-face svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.s-app .cut-face { padding: 6.5%; }
.s-app img { position: relative; width: 100%; height: 100%; object-fit: cover; border-radius: 12% / 5.6%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.s-app { --face: var(--card); --edge: #D2B98F; }
.s-native { --face: var(--honey); --edge: #A8731B; }
.s-cloud { --face: var(--navy); --edge: var(--navy-deep); }
.s-ai { --face: var(--forest-deep); --edge: #0B1F16; }

/* Each tag sits beside its sheet's near corner and rises with it. */
.cut-tags { position: absolute; inset: 0; pointer-events: none; }
.cut-tag {
    position: absolute;
    left: calc(50% + var(--sx) + var(--sw) * 0.986 + 14px);
    top: calc(50% + var(--sw) * 0.278 - 0.829 * (var(--k) - 1.5) * var(--gap));
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 3px;
    white-space: nowrap;
    font-family: var(--f-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--card);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 6px 10px -5px rgba(40, 25, 5, 0.45);
    transform: translateY(-50%);
    transition: background 0.35s ease, color 0.35s ease, translate 0.6s var(--ease-paper);
}
.cut-tag.on { translate: 0 calc(var(--gap) * -0.0995); }
.cut-tag.above { translate: 0 calc(var(--gap) * -0.497); }
.cut-tag::before {
    /* The leader back to the corner. */
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    width: 14px;
    border-top: 1.5px dashed var(--ink-3);
}
.cut-tag b { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: var(--paper); background: var(--forest-2); font-size: 0.68rem; }
.cut-tag i { display: none; font-style: normal; padding-right: 4px; }
.cut-tag.on { background: var(--honey-2); }
.cut-tag.on b { background: var(--ink); }

.cut-head { position: relative; }
.cut-title { font-size: clamp(1.9rem, 5vw, 2.8rem); margin: 14px 0 8px; }
.cut-sub { color: var(--ink-2); font-size: 1.04rem; margin-bottom: 18px; }
.cut-legend { display: grid; gap: 4px; counter-reset: none; }
.cut-legend li {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 12px;
    padding: 12px 14px 12px 10px;
    border-radius: 6px;
    cursor: default;
    transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.5s var(--ease-paper);
}
.cut-legend li.on { background: var(--card); box-shadow: var(--sh-2); transform: translateX(6px) rotate(-0.4deg); }
.cl-num {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-top: 1px;
    border-radius: 50%;
    font-family: var(--f-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--paper);
    background: var(--forest-2);
    transition: background 0.35s ease, transform 0.5s var(--ease-paper);
}
.cut-legend li.on .cl-num { background: var(--honey); color: var(--ink); transform: scale(1.1) rotate(-8deg); }
.cut-legend h4 { font-size: 1.12rem; margin-bottom: 2px; }
.cut-legend p { font-size: 0.94rem; line-height: 1.55; color: var(--ink-2); }
.js .cutaway:not(.in) .cut-legend li { opacity: 0; transform: translateY(14px); }
.cutaway.in .cut-legend li { transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.7s var(--ease-paper), opacity 0.6s ease; }
.cutaway.in .cut-legend li:nth-child(2) { transition-delay: 0s, 0s, 0.1s, 0.1s; }
.cutaway.in .cut-legend li:nth-child(3) { transition-delay: 0s, 0s, 0.2s, 0.2s; }
.cutaway.in .cut-legend li:nth-child(4) { transition-delay: 0s, 0s, 0.3s, 0.3s; }
.cutaway.in.settled .cut-legend li { transition-delay: 0s; }

@media (min-width: 560px) {
    .cutaway { --sw: 128px; --gap-open: 88px; }
    .cut-figure { --sx: -60px; height: 450px; }
    .cut-tag { font-size: 0.76rem; }
    .cut-tag i { display: inline; }
}
@media (min-width: 900px) {
    .cutaway { --sw: 170px; --gap-open: 114px; grid-template-columns: 1.1fr 0.9fr; grid-template-rows: auto auto; column-gap: 36px; row-gap: 0; margin-top: 104px; }
    .cut-figure { --sx: -56px; height: 610px; grid-column: 1; grid-row: 1 / span 2; }
    .cut-head, .cut-legend { grid-column: 2; padding-right: 12px; }
    .cut-head { align-self: end; }
    .cut-legend { align-self: start; }
}
@media (hover: hover) {
    .cut-legend li { cursor: pointer; }
}

/* --- Contact: the envelope ---------------------------------------------------------------- */
.contact { padding: 110px 0 120px; }
.contact-grid { position: relative; }
.mailbox { display: none; }
@media (min-width: 1000px) {
    .mailbox { display: block; position: absolute; right: 4%; bottom: 20px; width: 120px; filter: drop-shadow(0 14px 12px rgba(40, 25, 5, 0.28)); transform-origin: 50% 100%; }
    .contact.in .mailbox, .envelope.in ~ .mailbox { animation: wobble 1.4s var(--ease-paper) 1.2s both; }
}
@keyframes wobble { 0% { transform: rotate(0); } 30% { transform: rotate(-5deg); } 60% { transform: rotate(3deg); } 100% { transform: rotate(0); } }
.envelope { position: relative; max-width: 660px; margin: 0 auto; padding: 0 28px 142px; overflow: hidden; }
.env-back, .env-front, .env-flap { position: absolute; left: 10px; right: 10px; }
.env-back { bottom: 24px; height: 250px; border-radius: 10px; background: var(--kraft-deep) url("assets/images/paper/grain.webp") 0 0 / 260px; box-shadow: var(--sh-3); }
.env-front {
    bottom: 24px;
    height: 190px;
    z-index: 3;
    border-radius: 0 0 10px 10px;
    background: var(--kraft) url("assets/images/paper/grain.webp") 0 0 / 260px;
    clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
    filter: drop-shadow(0 -2px 3px rgba(40, 25, 5, 0.2));
}
.env-flap {
    height: 140px;
    z-index: 4;
    transform-origin: 50% 0;
    background: #CDAE7E url("assets/images/paper/grain.webp") 0 0 / 260px;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transition: transform 0.8s var(--ease-out), z-index 0s 0.4s;
}
.env-flap::after {
    /* The wax seal. */
    content: 'B';
    position: absolute;
    left: 50%;
    bottom: 6px;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-family: var(--f-display);
    font-weight: 750;
    font-size: 1.15rem;
    color: #F6D9CB;
    background: radial-gradient(circle at 38% 32%, #C8664A, #8E3C25);
    box-shadow: 0 3px 5px rgba(40, 10, 0, 0.4);
}
.env-flap { top: calc(100% - 274px); }
.envelope.in .env-flap { transform: rotateX(180deg); z-index: 0; }
.letter {
    position: relative;
    z-index: 2;
    padding: 34px 26px 96px;
    background:
        repeating-linear-gradient(transparent 0 31px, rgba(105, 150, 185, 0.22) 31px 32px) 0 72px / 100% calc(100% - 72px) no-repeat,
        #FFFEF9;
    border-radius: 3px;
    box-shadow: var(--sh-2);
    transition: transform 1.2s var(--ease-paper) 0.45s;
}
.js .envelope:not(.in) .letter { transform: translateY(calc(100% - 60px)); }
.letter-to { font-size: 1.6rem; color: var(--ink-3); line-height: 1; }
.letter h2 { font-size: clamp(2.3rem, 7vw, 3.4rem); margin: 6px 0 12px; }
.letter p:not(.hand) { color: var(--ink-2); font-size: 1.04rem; max-width: 44ch; }
.letter-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 14px; }
.letter-sign { font-size: 1.8rem; color: var(--forest-2); text-align: right; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
    .layer svg, .sky-cloud, .rise-phone .paper-phone, .plane-track, .plane-bob, .cut-scene { animation: none !important; }
    .cut-sheet, .cut-tag, .cut-legend li { transition: none !important; }
    .plane-track { display: none; }
    .js .envelope .letter { transform: none; }
}

@media (max-width: 899px) {
    .apps { padding-bottom: 64px; }
    .contact { padding: 64px 0 72px; }
}
