/* Alimayu Studio — 3D layer. Pairs with studio3d.js and studio3d-scenes.js. */

/* ---------- 1. Hero depth ---------- */
.s3d [data-depth] { perspective: 1100px; }
.s3d [data-depth] .a-arch {
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(calc(1 + var(--push, 0) * .07));
  transform-style: preserve-3d; will-change: transform;
}
.s3d [data-depth]::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: -26px; height: 36px; z-index: -1;
  background: radial-gradient(closest-side, rgba(20, 24, 48, .38), transparent);
  translate: calc(var(--ry, 0deg) / 1deg * -2px) 0; filter: blur(4px);
}
.a-window canvas.dust { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; mix-blend-mode: screen; }
.a-window .pw-sheen { z-index: 3; }

/* ---------- 2. Screens that lay flat ---------- */
.s3d .folio[data-screen-in] {
  transform: perspective(1500px) rotateX(calc((1 - var(--flat, 0)) * 24deg)) rotateY(calc((1 - var(--flat, 0)) * -10deg)) scale(calc(.84 + var(--flat, 0) * .16));
  transform-origin: 50% 80%; will-change: transform;
  box-shadow: 0 calc(20px + var(--flat, 0) * 30px) calc(40px + var(--flat, 0) * 50px) -40px rgba(0,0,0,.8), 0 0 0 1px rgba(176,141,87,.6) inset;
}
.s3d-still .folio[data-screen-in] { transform: none; }
.folio-screen .reel-sound, .folio-screen .reel-end { position: absolute; z-index: 4; opacity: 0; pointer-events: none; transition: opacity .4s; }
.folio-screen .reel-sound {
  right: 14px; bottom: 58px; display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px;
  font: 600 15px var(--sans); color: var(--night); background: var(--gold); border: 0; cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,.6);
}
.folio-screen .reel-sound svg { width: 18px; height: 18px; }
[data-reel].previewing .reel-sound { opacity: 1; pointer-events: auto; }
.folio-screen .reel-end {
  inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; padding: 20px;
  background: radial-gradient(80% 80% at 50% 45%, rgba(30,35,70,.86), rgba(17,20,42,.96));
}
.reel-end p { font-family: var(--serif); font-style: italic; font-size: clamp(22px, 2.6vw, 32px); color: var(--cream); margin: 0; line-height: 1.2; }
.reel-end .reel-replay { background: none; border: 0; color: var(--gold-soft); font: 600 15px var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
[data-reel].ended .reel-end { opacity: 1; pointer-events: auto; }

/* ---------- 5. Tilt cards (Ways to work together) ---------- */
.s3d [data-tilt] { transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2,1.2,.3,1), box-shadow .35s, opacity .8s ease; }
.s3d [data-tilt]:is(.in, :not(.reveal)) { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px)); }
.s3d [data-tilt]:is(.in, :not(.reveal)):hover { --lift: -10px; }
.s3d [data-tilt].tilting { transition: transform .12s linear, box-shadow .35s; }
.s3d [data-tilt] .env-window, .s3d [data-tilt] h3, .s3d [data-tilt] .sc-img { transform: translateZ(28px); }
.s3d [data-tilt] .env-go, .s3d [data-tilt] .sc-go { transform: translateZ(18px); }
.s3d [data-tilt]::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--gx, 50%) var(--gy, 50%), rgba(255,244,222,.55), transparent 45%);
  mix-blend-mode: soft-light;
}
.s3d [data-tilt]:hover::after, .s3d [data-tilt].tilting::after { opacity: 1; }
@media (hover: none) { .s3d [data-tilt]::after { opacity: .7; } }

/* ---------- 9. Ballot ready planner ---------- */
.s3d [data-planner] { perspective: 1000px; transform-style: preserve-3d; }
.s3d [data-planner] .pp { backface-visibility: hidden; transition: transform .5s cubic-bezier(.2,1.1,.3,1); }
.s3d [data-planner] .p1 { transform-origin: 0 50%; transform: rotate(-3deg) rotateY(calc(var(--open, 0) * -150deg - var(--peek, 0deg))) translateZ(3px); }
.s3d [data-planner] .p2 { transform-origin: 0 50%; transform: rotate(calc(4deg - var(--open, 0) * 4deg)) translateX(calc(var(--open, 0) * 30px)) rotateY(calc(var(--open, 0) * -18deg)); }
.s3d [data-planner] .p3 { transform-origin: 0 50%; transform: rotate(calc(9deg - var(--open, 0) * 6deg)) translateX(calc(var(--open, 0) * 70px)) rotateY(calc(var(--open, 0) * -6deg)); }
.s3d [data-planner].peek { --peek: 24deg; }
.s3d [data-planner]::after {
  content: ""; position: absolute; left: 0; top: 0; width: 170px; height: 100%; max-height: 240px; z-index: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.28), transparent 30%); opacity: calc(var(--open, 0) * 1.4);
}
.s3d-still [data-planner] .p1 { transform: rotate(-3deg) rotateY(-70deg); }

/* ---------- 3. The changing stage ---------- */
.stage3d { position: relative; }
.stage-wrap { display: grid; grid-template-columns: 1.35fr .65fr; gap: clamp(20px, 3vw, 48px); align-items: start; }
.stage-sticky { position: sticky; top: 11vh; height: 78vh; min-height: 420px; }
.stage-sticky canvas { width: 100%; height: 100%; display: block; }
.stage-sticky::after { content: ""; position: absolute; inset: auto 0 0; height: 18%; background: linear-gradient(transparent, var(--navy)); pointer-events: none; }
.stage-panels { padding: 10vh 0 6vh; }
.stage-panel {
  min-height: 72vh; display: flex; flex-direction: column; justify-content: center;
  opacity: .32; transition: opacity .5s, transform .5s; transform: translateX(14px);
}
.stage-panel.is-on { opacity: 1; transform: none; }
.stage-panel .room-num { font: 600 13px var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold-soft); }
.stage-panel h3 { font-family: var(--serif); font-size: clamp(34px, 3.6vw, 48px); color: #fff; margin: 6px 0 12px; line-height: 1.02; }
.stage-panel ul { list-style: none; margin: 0 0 18px; padding: 0; }
.stage-panel li { padding: 10px 0; border-top: 1px solid rgba(231,219,197,.18); color: var(--cream); font-size: 16px; }
.stage-panel li span { color: rgba(231,219,197,.6); }
.stage-panel .btn { align-self: flex-start; margin-top: 8px; }
.stage-sticky .scene-poster { position: absolute; inset: 0; display: none; }
.stage3d.scene-off .stage-wrap { grid-template-columns: 1fr; }
.stage3d.scene-off .stage-sticky { display: none; }
.stage3d.scene-off .stage-panels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 36px; padding: 0; }
.stage3d.scene-off .stage-panel { min-height: 0; opacity: 1; transform: none; }
@media (max-width: 900px) {
  .stage-wrap { grid-template-columns: 1fr; }
  .stage-sticky { top: 64px; height: 44vh; min-height: 260px; z-index: 0; margin: 0 calc(var(--gutter) * -1); }
  .stage-panels { position: relative; z-index: 1; padding: 0; margin-top: -8vh; }
  .stage-panel { min-height: 62vh; justify-content: flex-end; padding-bottom: 6vh; opacity: 1; transform: none; }
  .stage-panel > * { position: relative; }
  .stage-panel { background: linear-gradient(180deg, transparent 0, rgba(30,35,70,.0) 10%, rgba(30,35,70,.92) 42%); padding-top: 18vh; }
  .stage3d.scene-off .stage-panels { grid-template-columns: 1fr; margin: 0; }
  .stage3d.scene-off .stage-panel { background: none; padding: 0; }
}

/* ---------- 4. Topic panel beside the deck (deck in craft.css) ---------- */
.const-panel { background: rgba(17,20,42,.55); border: 1px solid rgba(205,176,131,.35); padding: clamp(22px, 2.6vw, 34px); }
.const-panel .cp-kicker { font: 600 12px var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold-soft); margin: 0 0 8px; }
.const-panel .cp-title { font-family: var(--serif); font-size: clamp(28px, 2.8vw, 38px); line-height: 1.05; color: #fff; margin: 0 0 12px; }
.const-panel .cp-hook { font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--cream) !important; margin: 0 0 12px; }
.const-panel .cp-best { font-size: 15px; margin: 0 0 20px; }
.const-panel .btn { width: 100%; justify-content: center; }
.const-panel .cp-more { display: inline-block; margin-top: 14px; color: var(--gold-soft); font-weight: 600; font-size: 15px; }
.const-panel .cp-more[href="#"] { display: none; }
.const-panel.flash { animation: cpflash .6s ease; }
@keyframes cpflash { from { box-shadow: 0 0 0 1px var(--gold), 0 0 40px -6px rgba(205,176,131,.6); } to { box-shadow: none; } }

/* ---------- 6. Boardroom ---------- */
.board3d-stage { position: relative; aspect-ratio: 16 / 8.2; min-height: 320px; margin-top: 10px; }
.board3d-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board3d-stage [data-seat] {
  position: absolute; left: 0; top: 0; opacity: 0; transition: opacity .6s; pointer-events: none;
  background: #FBF7EF; color: var(--navy); border-top: 2px solid var(--gold); padding: 7px 11px 8px; max-width: 190px;
  font: 600 12px/1.25 var(--sans); box-shadow: 0 14px 24px -14px rgba(20,24,48,.7); text-decoration: none;
}
.board3d-stage [data-seat] b { display: block; font: 600 17px/1.05 var(--serif); color: var(--navy); }
.board3d-stage [data-seat] small { color: var(--teal); letter-spacing: .12em; text-transform: uppercase; font-size: 10px; }
.board3d.seated .board3d-stage [data-seat] { opacity: 1; pointer-events: auto; }
.board3d-count { font-family: var(--serif); font-size: clamp(20px, 2vw, 26px); color: var(--navy); margin: 0; }
.board3d-count b { font-size: 1.6em; color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }
.board3d-legend { display: none; list-style: none; padding: 0; margin: 18px 0 0; columns: 2; column-gap: 24px; }
.board3d-legend li { break-inside: avoid; padding: 8px 0; border-top: 1px solid var(--rule); font-size: 15px; color: #4A4F63; }
.board3d-legend b { color: var(--navy); }
.board3d.scene-off .board3d-stage { display: none; }
.board3d.scene-off .board3d-legend { display: block; }
@media (max-width: 760px) {
  .board3d-stage { aspect-ratio: 1 / .8; min-height: 0; }
  .board3d-stage [data-seat] { display: none; }
  .board3d-legend { display: block; columns: 1; }
}

/* ---------- 10. Gold monogram ---------- */
.monogram3d { position: relative; width: clamp(130px, 16vw, 190px); aspect-ratio: 1; margin: 0 auto 6px; }
.monogram3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.monogram3d::before {
  content: ""; position: absolute; inset: 14%; background: url(../alimayu-seal.png) center / contain no-repeat;
  opacity: 0; transition: opacity .4s;
}
.monogram3d.scene-off::before { opacity: 1; }
.monogram3d.left { margin-left: 0; }

/* ---------- 7. Bookshelf (ready for the book list) ---------- */
.shelf3d { position: relative; display: flex; align-items: flex-end; gap: 6px; padding: 26px 18px 0; perspective: 1200px; min-height: 340px; }
.shelf3d::after { content: ""; position: absolute; left: 0; right: 0; bottom: -18px; height: 18px; background: linear-gradient(#6b4f2c, #3f2d18); box-shadow: 0 18px 30px -12px rgba(0,0,0,.55); }
.book3d { position: relative; width: 46px; height: var(--h, 280px); transform-style: preserve-3d; cursor: pointer; transition: transform .7s cubic-bezier(.2,1,.3,1), width .7s cubic-bezier(.2,1,.3,1); outline-offset: 6px; }
.book3d .spine { position: absolute; inset: 0; background: var(--c, var(--navy)); color: var(--cream); display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; transform: rotate(180deg); font: 600 15px var(--serif); padding: 12px 0; box-shadow: inset 4px 0 8px rgba(255,255,255,.12), inset -6px 0 10px rgba(0,0,0,.35); }
.book3d .face { position: absolute; left: 0; top: 0; width: 200px; height: 100%; backface-visibility: hidden; transform: rotateY(90deg) translateZ(23px) translateX(100px); transform-origin: 0 50%; background: #FBF7EF; padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 40px -20px rgba(0,0,0,.6); }
.book3d .face img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }
.book3d .face p { font-size: 14px; color: #4A4F63; margin: 0; }
.book3d:hover { transform: translateY(-14px); }
.book3d.pulled { width: 220px; transform: translateY(-20px) translateZ(60px); z-index: 2; }
.book3d.pulled .spine { opacity: 0; transition: opacity .3s; }
.book3d.pulled .face { transform: none; }

/* Placement */
.envelopes + .monogram3d { margin-top: clamp(48px, 6vw, 72px); }
.monogram3d + .signoff { margin-top: 8px; }
.form-card .monogram3d { width: 120px; margin-bottom: 0; }

/* With motion turned off, keep the portrait centered in its arch (the push animation normally centers it). */
@media (prefers-reduced-motion: reduce) { .pw-photo { transform: translateX(-50%); } }


/* ---------- Studio Notes issue: a 3D annual that turns toward the cursor and opens on scroll ---------- */
.issue3d { --open: 0; position: relative; width: min(300px, 78vw); aspect-ratio: 3 / 4; margin: 0 auto; perspective: 1400px; }
.issue3d .issue-body { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(calc(var(--ry, 0deg) - 18deg)) rotateZ(-2deg); transition: transform .6s cubic-bezier(.2,1.2,.3,1); }
.issue3d.tilting .issue-body { transition: transform .12s linear; }
.issue3d .issue-page, .issue3d .issue-cover { position: absolute; inset: 0; }
.issue3d .issue-page { background: #FBF7EF; background-image: var(--fiber); transform: translateZ(-14px); box-shadow: 0 40px 60px -30px rgba(20,24,48,.7); padding: 28px 26px; display: flex; flex-direction: column; gap: 10px; }
.issue3d .issue-page b { font: 600 12px var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--teal); }
.issue3d .issue-page i { display: block; height: 7px; border-radius: 4px; background: rgba(30,35,70,.12); }
.issue3d .issue-page i.s { width: 62%; } .issue3d .issue-page i.g { background: rgba(176,141,87,.35); width: 40%; }
.issue3d .issue-page .frame { flex: 1; margin-top: 8px; background: radial-gradient(circle at 50% 40%, var(--teal), var(--teal-deep)); position: relative; overflow: hidden; }
.issue3d .issue-page .frame::after { content: "\25B6"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--cream); font-size: 26px; opacity: .85; }
.issue3d .issue-edge { position: absolute; top: 2%; bottom: 2%; right: -1px; width: 14px; transform-origin: 0 50%; transform: rotateY(90deg); background: repeating-linear-gradient(90deg, #efe6d5 0 1px, #d9ccb4 1px 2px); }
.issue3d .issue-cover {
  transform-origin: 0 50%; transform: rotateY(calc(var(--open) * -128deg)); transition: transform .5s cubic-bezier(.2,1.1,.3,1);
  background: radial-gradient(120% 90% at 30% 20%, #2A3060, var(--navy) 55%, #141830); color: var(--cream);
  padding: 30px 26px; display: flex; flex-direction: column; justify-content: space-between; backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(205,176,131,.5), inset 12px 0 18px -10px rgba(0,0,0,.6);
}
.issue3d .issue-cover .ic-top { font: 600 11px var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--gold-soft); }
.issue3d .issue-cover h3 { font-family: var(--serif); font-weight: 500; font-size: 46px; line-height: .95; color: #fff; margin: 0; }
.issue3d .issue-cover h3 em { display: block; color: var(--gold-soft); font-size: .62em; margin-top: 8px; }
.issue3d .issue-cover img { width: 70px; align-self: flex-end; filter: drop-shadow(0 6px 8px rgba(0,0,0,.5)); }
.issue3d .issue-cover::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(400px circle at var(--gx, 30%) var(--gy, 20%), rgba(255,240,210,.22), transparent 45%); }
.s3d-still .issue3d { --open: .25; }
@media (max-width: 900px) { .issue3d { width: min(240px, 64vw); margin-bottom: 10px; } }

/* ---------- Rise: items lift out of the page in sequence ---------- */
.s3d [data-rise] { perspective: 1200px; }
.s3d [data-rise] > * { opacity: 0; transform: rotateX(28deg) translateY(46px) translateZ(-60px); transform-origin: 50% 100%; transition: opacity .7s ease var(--rise-d, 0s), transform .9s cubic-bezier(.2,1.1,.3,1) var(--rise-d, 0s); }
.s3d [data-rise].risen > * { opacity: 1; transform: none; }
.s3d [data-rise].risen > [data-tilt] { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px)); }
.s3d [data-rise].risen > [data-tilt].tilting { transition: transform .12s linear, box-shadow .35s; }
.s3d-still [data-rise] > * { opacity: 1; transform: none; }
[data-follow] { will-change: transform; filter: drop-shadow(0 18px 22px rgba(20,15,10,.35)); }
.js .p-hero .stamp-solo[data-follow] { animation-fill-mode: backwards; }
