/* ==========================================================
   PAGE ANIMATIONS
   Paste at the very bottom of styles.css (it must come last).
   Uses the individual `translate` / `scale` / `rotate` properties
   so nothing fights your existing `transform` hovers and loops.
   ========================================================== */

:root {
    --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
    --ease-io:  cubic-bezier(0.76, 0, 0.24, 1);
}

/* Hold every animation until animations.js says the curtain has
   lifted. Without JS (no .js class) animations simply play on load. */
html.js:not(.is-ready) * {
    animation-play-state: paused !important;
}

/* ---------- Keyframes ---------- */
@keyframes rise    { from { opacity: 0; translate: 0 1.4rem; } }
@keyframes riseBig { from { opacity: 0; translate: 0 0.3em; } }
@keyframes fade    { from { opacity: 0; } }
@keyframes pop     { from { opacity: 0; scale: 0.88; translate: 0 0.8rem; } }
@keyframes spinIn  { from { opacity: 0; rotate: -90deg; } }
@keyframes tileIn  { from { opacity: 0; scale: 0.2; translate: 0 1.5px; } }
@keyframes panelIn {
    from { clip-path: inset(100% 0 0 0 round var(--r)); }
    to   { clip-path: inset(0 0 0 0 round var(--r)); }
}

/* ---------- Shared entrance (staggered with --base and --i) ---------- */
.tagline, .nav-item, .contact-btn,
.panel-title, .panel-tagline, .panel-text, .price-btn,
.contact-title, .contact-tagline, .inquiry-title, .inquiry-tagline,
.field, .submit-btn {
    animation: rise 0.7s var(--ease-out) backwards;
    animation-delay: calc(var(--base, 0s) + min(var(--i, 0), 8) * 0.07s);
}

/* ---------- Home ---------- */
/* Logo: the nine tiles drop in on a diagonal, wordmark follows */
.logo-wrapper .grid-tile {
    animation: tileIn 0.55s var(--ease-out) backwards;
    animation-delay: calc(0.1s + var(--k, 0) * 0.05s);
}
.logo-wrapper .grid-tile:nth-child(1) { --k: 4; }
.logo-wrapper .grid-tile:nth-child(2) { --k: 3; }
.logo-wrapper .grid-tile:nth-child(3) { --k: 2; }
.logo-wrapper .grid-tile:nth-child(4) { --k: 3; }
.logo-wrapper .grid-tile:nth-child(5) { --k: 2; }
.logo-wrapper .grid-tile:nth-child(6) { --k: 1; }
.logo-wrapper .grid-tile:nth-child(7) { --k: 2; }
.logo-wrapper .grid-tile:nth-child(8) { --k: 1; }
.logo-wrapper .grid-tile:nth-child(9) { --k: 0; }

#grid-text {
    animation: fade 0.7s var(--ease-out) 0.5s backwards;
}

.tagline     { --base: 0.3s; }
.nav-item    { --base: 0.5s; }
.contact-btn { --base: 0.7s; }

.nav-item:nth-child(2) { --i: 1; }
.nav-item:nth-child(3) { --i: 2; }

/* Scroll arrow: fade in, then carry on floating (keeps your float loop) */
.scroll-arrow {
    animation-name: fade, float;
    animation-duration: 0.7s, 2.4s;
    animation-timing-function: var(--ease-out), ease-in-out;
    animation-delay: 0.9s, 1.6s;
    animation-iteration-count: 1, infinite;
    animation-fill-mode: backwards, none;
}

/* ---------- Launch / Revamp / Custom ---------- */
/* The blue panel rises from the bottom edge, then its content settles in */
.panel {
    --r: clamp(1rem, 2vw, 1.75rem);
    animation: panelIn 0.8s var(--ease-io) backwards;
}

.panel-title {
    --base: 0.35s;
    animation-name: riseBig;
    animation-duration: 0.9s;
}
.panel-tagline { --base: 0.5s; }
.panel-text    { --base: 0.65s; }
.price-btn     { --base: 0.75s; animation-name: pop; }
.panel .nav-item { --base: 0.85s; }

/* ---------- Contact / Inquiry ---------- */
.contact-title, .inquiry-title {
    --base: 0.1s;
    animation-name: riseBig;
    animation-duration: 0.9s;
}
.contact-tagline, .inquiry-tagline { --base: 0.2s; }
.field      { --base: 0.35s; }   /* --i is set per field by animations.js */
.submit-btn { --base: 0.4s; }

.close-btn {
    animation: spinIn 0.7s var(--ease-out) 0.5s backwards;
}

/* ---------- Scroll reveals (classes added by animations.js) ---------- */
.reveal {
    opacity: 0;
    translate: 0 2.5rem;
    transition: opacity 0.9s var(--ease-out), translate 0.9s var(--ease-out);
    transition-delay: calc(var(--rd, 0) * 0.1s);
}
.reveal.is-visible {
    opacity: 1;
    translate: 0 0;
}

/* Work images settle inward as their tile appears */
.work-item.reveal img {
    scale: 1.15;
    transition: scale 1.6s var(--ease-out);
    transition-delay: calc(var(--rd, 0) * 0.1s);
}
.work-item.reveal.is-visible img {
    scale: 1;
}

/* ---------- Page transition: quick fade out ---------- */
body { transition: opacity 0.2s ease; }
html.is-leaving body { opacity: 0; }

/* ---------- Reduced motion: everything just appears ---------- */
@media (prefers-reduced-motion: reduce) {
    .tagline, .nav-item, .contact-btn, .panel, .panel-title, .panel-tagline,
    .panel-text, .price-btn, .contact-title, .contact-tagline, .inquiry-title,
    .inquiry-tagline, .field, .submit-btn, .close-btn, #grid-text,
    .scroll-arrow, .logo-wrapper .grid-tile {
        animation: none !important;
    }
    .reveal, .work-item.reveal img {
        opacity: 1;
        translate: none;
        scale: none;
        transition: none;
    }
    html.is-leaving body { opacity: 1; }
}