/* ── Page Transition Overlay ── */

/* Hide scrollbar during transitions to prevent layout shift */
html.transitioning,
html.transition-arriving {
    overflow: hidden;
}

/* On mobile, skip overflow:hidden during entering phase —
   applying it triggers the browser address bar to reappear,
   which shrinks the viewport and causes the icon to jump up */
@media (max-width: 768px) {
    html.transitioning {
        overflow: visible;
    }
}

.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

.page-transition .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    clip-path: inset(0 100% 0 0); /* hidden */
}

.page-transition .overlay-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    opacity: 0;
}

.page-transition .overlay-text {
    font-family: 'Old Standard TT', serif;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    opacity: 0;
    letter-spacing: 2px;
}

/* ── Phase 1: entering — clip reveals overlay from left to right ── */
.page-transition.entering .overlay {
    animation: clipIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.page-transition.entering .overlay-text {
    animation: textFadeIn 0.3s 0.3s ease forwards;
}
.page-transition.entering .overlay-icon {
    animation: iconFadeIn 0.3s 0.3s ease forwards;
}

/* ── Arriving: cover page instantly before JS loads ── */
.transition-arriving .page-transition .overlay {
    clip-path: inset(0 0 0 0);
}
.transition-arriving .page-transition .overlay-text,
.transition-arriving .page-transition .overlay-icon {
    opacity: 1;
}

/* ── Phase 2: leaving — clip removes overlay from left to right ── */
.page-transition.leaving .overlay {
    clip-path: inset(0 0 0 0);
    animation: clipOut 0.5s 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.page-transition.leaving .overlay-text {
    opacity: 1;
}

/* ── Keyframes ── */
@keyframes clipIn {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0 0 0); }
}
@keyframes clipOut {
    from { clip-path: inset(0 0 0 0); }
    to   { clip-path: inset(0 0 0 100%); }
}
@keyframes textFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes iconFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
