/* ==========================================================================
   Motion layer
   Everything that moves lives here so it can be tuned (or removed) in one place.
   Rules: transform/opacity/clip-path only, ease-out for entrances,
   ease-in-out for on-screen morphs, linear only for ambient loops,
   hover gated to fine pointers, nothing moves under reduced motion.
   ========================================================================== */

:root {
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --dur-press: 150ms;
  --dur-hover: 200ms;
  --dur-ui: 280ms;
  --dur-reveal: 800ms;
  --stagger: 70ms;
}

/* The headline is split into lines so each can be choreographed; the layout
   is identical to the previous <br> version. */
.hero h1 .line { display: block; }

@media (prefers-reduced-motion: no-preference) {

  /* ---------- Hero: load choreography ------------------------------------ */

  .hero-copy > .overline,
  .hero h1 .line,
  .hero-description,
  .hero-copy > .actions,
  .hero-features > div {
    animation: rise var(--dur-reveal) var(--ease-out) both;
  }

  .hero-copy > .overline { animation-delay: 80ms; }
  .hero h1 .line { animation-name: rise-blur; animation-duration: 1000ms; }
  .hero h1 .line:nth-child(1) { animation-delay: 160ms; }
  .hero h1 .line:nth-child(2) { animation-delay: 240ms; }
  .hero h1 .line:nth-child(3) { animation-delay: 330ms; }
  .hero-description { animation-delay: 480ms; }
  .hero-copy > .actions { animation-delay: 560ms; }

  .hero-features > div { animation-duration: 700ms; }
  .hero-features > div:nth-child(1) { animation-delay: 720ms; }
  .hero-features > div:nth-child(2) { animation-delay: 780ms; }
  .hero-features > div:nth-child(3) { animation-delay: 830ms; }
  .hero-features > div:nth-child(4) { animation-delay: 870ms; }

  /* The rule under the features draws itself in from the left. */
  .hero-features { position: relative; border-top-color: transparent; }
  .hero-features::before,
  .art-caption::before {
    content: "";
    position: absolute;
    inset: -1px 0 auto;
    height: 1px;
    background: #423d50;
    transform-origin: left;
    animation: draw-line 1200ms var(--ease-in-out) 500ms both;
  }
  .art-caption { position: relative; border-top-color: transparent; }
  .art-caption::before { animation-delay: 700ms; }

  /* Art arrives slightly later than the copy, out of a soft focus. */
  .art-stage > .art-frame { animation: art-in 1400ms var(--ease-out) 250ms both; }
  .art-stage::before { animation: fade 1600ms var(--ease-out) 150ms both; }
  .registration::before { animation: corner-tl 900ms var(--ease-out) 600ms both; }
  .registration::after { animation: corner-br 900ms var(--ease-out) 600ms both; }
  .art-caption > * { animation: fade 700ms var(--ease-out) 900ms both; }

  /* Ambient: the module breathes, the signal mark transmits. */
  #modulo img { animation: float 7s ease-in-out 1.6s infinite alternate; }
  .signal-mark { animation: signal 1.4s linear infinite; }

  /* Pointer parallax target (driven by motion.js through `translate`). */
  .art-stage > .art-frame,
  .art-stage .registration { transition: translate 600ms var(--ease-out); }

  /* View switch Módulo/Rack: crossfade masked by a small blur. */
  .art-stage[data-switched] .art-frame:not([hidden]) {
    animation: change-view-soft 420ms var(--ease-out) both;
  }

  /* ---------- Scroll reveals ------------------------------------------- */
  /* Only hidden once motion.js confirms it can reveal them again. */

  html.motion-ready [data-reveal] {
    transition:
      opacity var(--dur-reveal) var(--ease-out),
      translate var(--dur-reveal) var(--ease-out),
      filter var(--dur-reveal) var(--ease-out);
    transition-delay: calc(var(--i, 0) * var(--stagger));
  }
  html.motion-ready [data-reveal]:not(.is-revealed) {
    opacity: 0;
    translate: 0 1.25rem;
  }
  html.motion-ready [data-reveal="title"]:not(.is-revealed) {
    translate: 0 .4em;
    filter: blur(4px);
  }
  html.motion-ready [data-reveal="fade"]:not(.is-revealed) { translate: none; }

  /* About photo: wipe up from the bottom while the image settles. */
  html.motion-ready .about-photo[data-reveal] { transition: clip-path 1100ms var(--ease-in-out); }
  html.motion-ready .about-photo[data-reveal]:not(.is-revealed) {
    opacity: 1;
    translate: none;
    clip-path: inset(100% 0 0 0);
  }
  .about-photo { clip-path: inset(0); }
  .about-photo img { scale: 1; transition: scale 1600ms var(--ease-out); }
  html.motion-ready .about-photo:not(.is-revealed) img { scale: 1.14; }

  /* ---------- Plans --------------------------------------------------------- */

  /* Cards enter one after another when switching cPanel ↔ VPS. */
  .plan-category.is-entering .plan {
    animation: rise 460ms var(--ease-out) both;
  }
  .plan-category.is-entering .plan:nth-child(2) { animation-delay: 55ms; }
  .plan-category.is-entering .plan:nth-child(3) { animation-delay: 100ms; }
  .plan-category.is-entering .plan-note { animation: fade 460ms var(--ease-out) 160ms both; }

  /* ---------- Domains ----------------------------------------------------- */

  .domain-orbit { animation: orbit 160s linear infinite; }
  .domain-orbit span:nth-child(3) { animation: orbit 90s linear infinite reverse; }
  .domain-input { transition: border-color var(--dur-hover) ease, background-color var(--dur-hover) ease; }
  .domain-error:not(:empty) { animation: shake 360ms var(--ease-out); }

  /* ---------- FAQ: height animation where the platform supports it ------ */

  @supports selector(::details-content) {
    .faq-list { interpolate-size: allow-keywords; }
    .faq-list details::details-content {
      block-size: 0;
      overflow: clip;
      transition:
        block-size 320ms var(--ease-drawer),
        content-visibility 320ms allow-discrete;
    }
    .faq-list details[open]::details-content { block-size: auto; }
  }
  .faq-list details p { transition: opacity 320ms ease, translate 320ms var(--ease-out); }
  .faq-list details:not([open]) p { opacity: 0; translate: 0 -.35rem; }
  .plus { transition: background-color var(--dur-hover) ease, border-color var(--dur-hover) ease, color var(--dur-hover) ease, rotate var(--dur-ui) var(--ease-out); }
  .faq-list details[open] .plus { rotate: 180deg; }
  .plus::after { transition: transform var(--dur-ui) var(--ease-out); }

  /* ---------- Interaction feedback ---------------------------------------- */

  .button, .menu-toggle {
    transition:
      transform var(--dur-press) var(--ease-out),
      background-color var(--dur-hover) ease,
      border-color var(--dur-hover) ease,
      color var(--dur-hover) ease;
  }
  .button:active, .menu-toggle:active { transform: scale(.97); }
  .site-nav a:not(.button), .footer-grid nav a, .section-link, .domain-links a,
  .contact-phone, .faq-list summary, .plans .category, .art-views button {
    transition: color var(--dur-hover) ease, text-decoration-color var(--dur-hover) ease;
  }
  .faq-list summary .plus { transition-property: background-color, border-color, color, rotate; }
}

/* Hover-only motion: never on touch, never under reduced motion. */
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {

  .plans .plan {
    isolation: isolate;
    transition: translate 360ms var(--ease-out);
  }
  .plans .plan::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 24px 48px -24px #2a2350, 0 2px 6px -2px #2a235022;
    opacity: 0;
    transition: opacity 360ms var(--ease-out);
    pointer-events: none;
  }
  .plans .plan:hover { translate: 0 -4px; }
  .plans .plan:hover::after { opacity: .45; }
  .plans .plan-featured:hover::after { opacity: .8; }

  /* The chassis icon "racks up": each tier separates slightly. */
  .plan-stack i { transition: translate 360ms var(--ease-out); }
  .plans .plan:hover .plan-stack i:nth-child(2) { translate: 0 -3px; }
  .plans .plan:hover .plan-stack i:nth-child(3) { translate: 0 -6px; }

  .section-link, .domain-links a, .contact-phone { text-underline-offset: .32em; transition-property: color, text-decoration-color, text-underline-offset; }
  .section-link:hover, .domain-links a:hover, .contact-phone:hover { text-underline-offset: .45em; }

  .footer-company img { transition: opacity var(--dur-hover) ease; }
  .footer-company:hover img { opacity: .8; }
}

/* ---------- Scroll-driven parallax (off the main thread) ------------------ */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .about-photo img {
      height: 112%;
      animation: parallax linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
    .contact-inner h2 em {
      display: inline-block;
      animation: drift-in linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 45%;
    }
  }
}

/* ---------- Keyframes ------------------------------------------------------ */

@keyframes rise { from { opacity: 0; translate: 0 1rem; } }
@keyframes rise-blur { from { opacity: 0; translate: 0 .35em; filter: blur(5px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes draw-line { from { transform: scaleX(0); } }
@keyframes art-in { from { opacity: 0; scale: .96; filter: blur(6px); } }
@keyframes corner-tl { from { opacity: 0; translate: .6rem .6rem; } }
@keyframes corner-br { from { opacity: 0; translate: -.6rem -.6rem; } }
@keyframes float { to { translate: 0 -8px; } }
@keyframes signal { to { background-position: 10px 0; } }
@keyframes change-view-soft { from { opacity: 0; scale: .985; filter: blur(4px); } }
@keyframes orbit { to { rotate: 1turn; } }
@keyframes shake { 25% { translate: -4px 0; } 50% { translate: 3px 0; } 75% { translate: -2px 0; } }
@keyframes parallax { from { translate: 0 -10%; } to { translate: 0 0; } }
@keyframes drift-in { from { translate: -.35em 0; opacity: .4; } }

@media (prefers-reduced-motion: no-preference) {
  @starting-style {
    .faq-list details[open] p { opacity: 0; translate: 0 -.35rem; }
  }
}
