/* The cabinet faces and the lettering share the same image coordinate space. */
:root[data-title-study="cathedral"] #boot-loader {
    padding: 0; overflow: hidden; background: linear-gradient(#25191138, #21150e52);
}
:root[data-title-study="cathedral"] #boot-loader .boot-content {
    position: absolute; left: 50%; top: 67%; translate: -50% -50%; margin: 0; padding: 0;
    width: min(180px, 23svh, 60vw); text-align: center;
}
:root[data-title-study="cathedral"] #boot-loader .boot-wordmark { display: none; }
:root[data-title-study="cathedral"] #boot-loader .boot-progress {
    margin: 0; width: 100%; height: 3px; border: 0; background: #27190e;
}
:root[data-title-study="cathedral"] #boot-loader .boot-status {
    margin: 6px 0 0; color: #fff2cf; font: 500 13px/1.3 'Lora', Georgia, serif;
    text-shadow: 0 1px 3px #160e09, 0 0 5px #201006;
}
body:has(#boot-loader:not([hidden])) .portal-camera :is(.door-invitation, .portal-credit) { visibility: hidden; }
:root[data-title-study="cathedral"] body #screen-menu {
    width: 100%; max-width: none; height: 100svh; height: 100dvh; min-height: 0;
    margin: 0; padding: 0; overflow: hidden; background: #221b17;
}
:root[data-title-study="cathedral"] body #screen-menu::before,
:root[data-title-study="cathedral"] body #screen-menu::after { display: none; }
.cathedral-entrance {
    position: relative; isolation: isolate; container-type: size;
    width: 100%; height: 100%; overflow: hidden; background: #221b17;
}
.chapel-view, .portal-camera, .portal-doors { position: absolute; inset: 0; }
.chapel-view { transform-origin: 50% 52%; }
.portal-camera { transform-origin: 50% 53%; }
.portal-plane, .chapel-plane {
    position: absolute; left: 50%; top: 50%; translate: -50% -50%;
    width: 150cqh; aspect-ratio: 3 / 2;
}
.cathedral-entrance img {
    display: block; max-width: none; pointer-events: none; user-select: none;
    -webkit-user-drag: none;
}
.portal-stone, .chapel-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.aisle-surround { position: absolute; inset: -50%; }
.aisle-surround img { width: 100%; height: 100%; }
.aisle-paving {
    position: absolute; top: calc(100% - .5px); left: -50%; width: 200%; height: 50%;
    background: var(--aisle) center bottom / 100% 400% no-repeat;
    transform-origin: 50% 0; pointer-events: none;
}
.portal-steps {
    position: absolute; top: 81.73828125%; left: 0; width: 100%; bottom: 0;
    background: url('assets/cathedral/portal.webp') center bottom / 100% 547.594% no-repeat;
    transform-origin: 50% 0; pointer-events: none;
    mask-image: linear-gradient(90deg, transparent, black 18% 82%, transparent);
}
.portal-steps::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(100deg, #ffc37e55 38%, #fff0b7 49%, #a8e1d3ac 58%, #c99a6a55 70%);
    mix-blend-mode: screen; opacity: 0;
}
.threshold-dust { position: absolute; inset: 0; pointer-events: none; }
.threshold-dust i {
    position: absolute; width: clamp(2px,.38cqh,4px); aspect-ratio: 1; border-radius: 50%;
    opacity: 0; background: #fff1c8; box-shadow: 0 0 .55cqh #ffe0aa;
}
.threshold-dust i:nth-child(1) { left: 43%; top: 60%; --delay: 0ms; }
.threshold-dust i:nth-child(2) { left: 56%; top: 49%; --delay: 120ms; }
.threshold-dust i:nth-child(3) { left: 47%; top: 41%; --delay: 250ms; }
.threshold-dust i:nth-child(4) { left: 63%; top: 66%; --delay: 80ms; }
.threshold-dust i:nth-child(5) { left: 34%; top: 54%; --delay: 180ms; }
.threshold-dust i:nth-child(6) { left: 52%; top: 58%; --delay: 320ms; }
.portal-doors { perspective: 92cqh; perspective-origin: 50% 53%; }
.portal-leaf {
    position: absolute; top: 15.52734375%; height: 66.6015625%; transform-style:preserve-3d;
    --timber-depth:2.65cqh;
}
.portal-leaf img {position:absolute;inset:0;width:100%;height:100%;}
.portal-leaf .leaf-interior {transform:translateZ(calc(0px - var(--timber-depth)));filter:brightness(.5);}
.portal-leaf::before,.portal-leaf::after,.leaf-head {
    content:'';position:absolute;pointer-events:none;
    background:linear-gradient(90deg,#382316aa,#93643ab3 13%,#5a3821a6 74%,#2a1b13cc),
        url('assets/gallery/materials/oak.webp') center/auto 34cqh;
    box-shadow:inset 0 0 0 .09cqh #412a1a;
}
.portal-leaf::before,.portal-leaf::after {width:var(--timber-depth);bottom:.5%;transform-origin:left center;transform:rotateY(90deg);}
.leaf-left::before {left:1%;top:42.5%;} .leaf-left::after {left:100%;top:.5%;}
.leaf-right::before {left:0;top:.5%;} .leaf-right::after {left:98%;top:42.5%;}
.leaf-head {height:var(--timber-depth);transform-origin:0 0;}
.leaf-stile {
    --projection:1.35cqh;position:absolute;top:1.8%;bottom:1%;width:6%;
    transform:translateZ(var(--projection));transform-style:preserve-3d;
    background:linear-gradient(90deg,#3d2316b8,#9d7043a1 20%,#58402aaa 51%,#815531b8 83%,#342118c9),
        url('assets/gallery/materials/oak.webp') center/auto 40cqh;
}
.leaf-left .leaf-stile {right:0;} .leaf-right .leaf-stile {left:0;}
.leaf-stile::before,.leaf-stile::after {
    content:'';position:absolute;top:0;height:100%;width:var(--projection);
    transform-origin:left;transform:rotateY(90deg);
    background:linear-gradient(90deg,#b08755aa,#684527bb 38%,#382619cc),
        url('assets/gallery/materials/oak.webp') center/auto 40cqh;
}
.leaf-stile::before {left:0;} .leaf-stile::after {left:100%;}
.cathedral-entrance[data-phase="outside"] .leaf-stile {visibility:hidden;}
.cathedral-entrance[data-phase="opening"] .leaf-stile {animation:catch-stile-light 280ms ease-out both;}
@keyframes catch-stile-light {from {opacity:0;} to {opacity:1;}}
.leaf-left { left: 36.328125%; width: 13.671875%; transform-origin: left center; }
.leaf-right { left: 50%; width: 13.3463542%; transform-origin: right center; }

/* Expand only the outer aisles on wide screens. The round window, door and
   interactive surfaces retain their proportions as the viewport changes. */
@media (min-aspect-ratio: 3/2) {
    .portal-camera::before, .portal-camera::after, .chapel-view::before, .chapel-view::after {
        content: ''; position: absolute; z-index: 1; top: 0; bottom: 0;
        width: calc((100% - 75cqh) / 2 + .5px); pointer-events: none;
        background-size: 400% 100%; background-repeat: no-repeat;
    }
    .portal-camera { --wings: url('assets/cathedral/portal.webp'); }
    .chapel-view { --wings: url('assets/cathedral/chapel.webp'); }
    .portal-camera::before, .chapel-view::before { left: 0; background-image: var(--wings); background-position: left; }
    .portal-camera::after, .chapel-view::after { right: 0; background-image: var(--wings); background-position: right; }
}

:root[data-theme] #screen-menu .portal-title {
    position: absolute; z-index: 2; left: 50%; top: 39%; translate: -50% -50%;
    margin: 0; padding: 0; color: #fff0cb; background: none; pointer-events: none;
    text-align: center; font: 600 clamp(30px, 7.1cqh, 90px)/1 'Cinzel', Georgia, serif;
    text-shadow: 0 1px 0 #24140e, 0 2px 3px #180d07, 0 0 12px #23160c;
    text-transform: uppercase; letter-spacing: .045em;
}
.portal-title span { display: block; }
.portal-title span:first-child {
    font-weight: 700;
    background: linear-gradient(#fff1cd, #dfc282 52%, #a88b52 54%, #eddaac);
    background-clip: text; color: transparent; text-shadow: none;
    filter: drop-shadow(0 2px 0 #3b3120) drop-shadow(0 3px 1px #17110c);
}
@media (forced-colors: active) {
    .portal-title span:first-child { color: CanvasText; filter: none; }
}
.portal-title span + span {
    margin-top: .38em; padding-left: .22em; font-size: .265em; letter-spacing: .22em;
}
:root[data-theme] #screen-menu .cathedral-entrance button {
    position: absolute; margin: 0; padding: 0; min-width: 0; max-width: none;
    border: 0; border-radius: 0; background: transparent; box-shadow: none;
    cursor: pointer; color: #fff0cb; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
:root[data-theme] #screen-menu #enter-cathedral {
    z-index: 3; left: 36.5%; top: 16%; width: 27%; height: 66%; min-height: 0;
    clip-path: polygon(49.7% 0%, 70% 8%, 86% 18%, 97% 32%, 100% 44%,
        100% 100%, 0 100%, 0 44%, 3% 32%, 14% 18%, 30% 8%);
    transform: none; outline: none;
}
.door-invitation {
    position: absolute; left: 50%; top: 78%; translate: -50% -50%;
    white-space: nowrap;
    color: #fff2cf; text-shadow: 0 1px 2px #160e09, 0 0 5px #201006;
    font: 600 clamp(12px, 1.95cqh, 21px)/1.3 'Cinzel', Georgia, serif; letter-spacing: .07em;
}
#enter-cathedral::after { content: none; }
#enter-cathedral:focus-visible .door-invitation { text-decoration: underline; text-underline-offset: .3em; }
.portal-doors { transition: filter 160ms ease; }
@media (hover: hover) {
    .cathedral-entrance[data-phase="outside"] .portal-plane:has(#enter-cathedral:hover) .portal-doors {
        filter: brightness(1.24);
    }
}
:root[data-theme] #screen-menu .portal-credit {
    position: absolute; z-index: 3; bottom: max(1cqh, env(safe-area-inset-bottom)); left: 50%;
    translate: -50% 0; display: grid; place-items: center; min-height: 44px;
    margin: 0; padding: 0 1em; color: #ffefcc; font: 500 13px/1.25 'Lora', Georgia, serif;
    text-decoration: underline; text-underline-offset: .22em; text-shadow: 0 1px 3px #100c09, 0 0 4px #100c09;
}
.portal-plane::after {
    content: ''; position: absolute; inset: 84% 0 0; pointer-events: none;
    background: linear-gradient(transparent, #1a120d9e);
}
.chapel-plane {
    --aisle: url('assets/cathedral/aisle.webp');
    --plate-x: 49.87%; --plate-width: 24.1%; --plate-height: 8.4%;
    --play-bottom: 68.85%; --gallery-top: 71.78%;
}
:root[data-theme] #screen-menu .chapel-plaque {
    left: var(--plate-x); translate: -50% 0; width: var(--plate-width);
    height: max(44px, var(--plate-height)); min-height: 0;
    font: 600 clamp(18px, 3.65cqh, 44px)/1 'Cinzel', Georgia, serif;
    letter-spacing: .05em; transform: none; outline: none;
    text-shadow: 0 1px 0 #312418, 0 2px 3px #17201b;
}
#title-play { bottom: calc(100% - var(--play-bottom)); }
#title-gallery { top: var(--gallery-top); }
.chapel-plaque span {
    display: grid; place-items: center; position: absolute; left: 0; width: 100%;
    height: 8.4cqh; border-radius: 4px;
    transition: color 150ms, background-color 150ms, box-shadow 150ms;
}
#title-play span { bottom: 0; }
#title-gallery span { top: 0; }
@media (hover: hover) {
    .chapel-plaque:hover span {
        color: #fff8dd; background: #edcc7620;
        box-shadow: inset 0 0 0 2px #e4c17fc4, inset 0 0 14px #deb46c32;
    }
}
.chapel-plaque:focus-visible span {
    color: #fffbe7; outline: 3px solid #ffde8d; outline-offset: 2px; background: #ebc37024;
}
.chapel-plaque:active span { color: white; background: #13251f80; box-shadow: inset 0 2px 8px #100e0ddd; }
@media (max-aspect-ratio: 4/5) {
    .chapel-plane {
        --aisle: url('assets/cathedral/aisle-portrait.webp');
        width: max(100cqw, 67.69784cqh); aspect-ratio: 941 / 1390;
        --plate-x: 49.85%; --plate-width: 40.9%; --plate-height: 6.05%;
        --play-bottom: 72.59%; --gallery-top: 74.46%;
    }
    .chapel-plaque span { height: max(8.94cqw, 6.05cqh); }
    :root[data-theme] #screen-menu .chapel-plaque { font-size: clamp(18px, 3.2cqh, 39px); }
}

/* The opaque closed doors cover the nave. Prepare its starting view during
   boot so the first tap can move the hinges and reveal the paving together. */
.cathedral-entrance[data-phase="outside"] .chapel-view {
    transform: translateY(-4cqh) scale(.5); opacity: .68;
}
.cathedral-entrance:not([data-phase="inside"]) :is(.chapel-view, .portal-camera, .portal-leaf) {
    will-change: transform;
}
.cathedral-entrance[data-phase="opening"] .portal-camera { animation: enter-portal 1480ms both; }
.cathedral-entrance[data-phase="opening"] .leaf-left { animation: swing-left 1030ms cubic-bezier(.27,.05,.24,1) both; }
.cathedral-entrance[data-phase="opening"] .leaf-right { animation: swing-right 1020ms 45ms cubic-bezier(.27,.05,.24,1) both; }
.cathedral-entrance[data-phase="opening"] .chapel-view { animation: approach-window 1480ms both; }
.cathedral-entrance[data-phase="opening"] .portal-steps { animation: climb-steps 1480ms ease-in both; }
.cathedral-entrance[data-phase="opening"] .portal-steps::after { animation: spill-on-steps 1040ms ease-out both; }
.cathedral-entrance[data-phase="opening"] .aisle-paving { animation: cross-paving 1480ms ease-in-out both; }
.cathedral-entrance[data-phase="opening"] .threshold-dust i { animation: dust-in-light 850ms calc(360ms + var(--delay)) ease-out both; }
.cathedral-entrance[data-phase="opening"] .chapel-view::before,
.cathedral-entrance[data-phase="opening"] .chapel-view::after { animation: settle-aisles 1480ms both; }
#screen-menu .cathedral-entrance[data-phase="opening"] :is(.portal-title, .door-invitation, .portal-credit) { animation: fade-inscription 155ms both; }
.cathedral-entrance[data-phase="inside"] .portal-camera { display: none; }
.cathedral-entrance[data-phase="inside"] :is(.aisle-surround, .aisle-paving, .threshold-dust) { display: none; }
@keyframes swing-left { to { transform: rotateY(86deg); } }
@keyframes swing-right { to { transform: rotateY(-85deg); } }
.cathedral-entrance[data-phase="opening"] .portal-leaf img:first-child {animation:door-face-shade 1030ms ease-out both;}
@keyframes door-face-shade {to {filter:brightness(.48);}}
@keyframes enter-portal {
    0% { transform: translateY(0) scale(1); animation-timing-function: ease-in; }
    35% { transform: translateY(3.5cqh) scale(1.13); animation-timing-function: cubic-bezier(.48,.05,.74,.55); }
    86% { transform: translateY(20cqh) scale(4.7); opacity: 1; }
    100% { transform: translateY(25cqh) scale(6.1); opacity: 0; }
}
@keyframes approach-window {
    0% { transform: translateY(-4cqh) scale(.5); opacity: .68; animation-timing-function: ease-in; }
    35% { transform: translateY(-2.4cqh) scale(.54); opacity: .82; animation-timing-function: cubic-bezier(.26,.07,.18,1); }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
/* Keep the top tread fixed to the hinge feet while the nearer nosings pass
   under the eye. The flat aisle continues several slab courses past the sill. */
@keyframes climb-steps {
    from { transform: perspective(70cqh) rotateX(0) scaleY(1); }
    to { transform: perspective(70cqh) rotateX(34deg) scaleY(2.05); }
}
@keyframes cross-paving {
    from { transform: perspective(100cqh) rotateX(0) scaleY(1); }
    to { transform: perspective(100cqh) rotateX(28deg) scaleY(1.55); }
}
@keyframes spill-on-steps {
    0%, 7% { opacity: 0; clip-path: polygon(49.8% 0, 50.2% 0, 50.7% 100%, 49.3% 100%); }
    28% { opacity: .5; clip-path: polygon(49% 0, 51% 0, 55% 100%, 45% 100%); }
    72%, 100% { opacity: .36; clip-path: polygon(40% 0, 60% 0, 70% 100%, 30% 100%); }
}
@keyframes dust-in-light {
    0% { opacity: 0; transform: translate(0, 1cqh) scale(.6); }
    35% { opacity: .78; }
    100% { opacity: 0; transform: translate(1.4cqh, -3.6cqh) scale(1.2); }
}
@keyframes settle-aisles { 0%, 70% { opacity: 0; } 100% { opacity: 1; } }
@keyframes fade-inscription { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .cathedral-entrance *, .cathedral-entrance *::before, .cathedral-entrance *::after {
        animation: none !important; transition: none !important;
    }
}
