/* ==========================================================================
   Bisa Lulus — Redesign Public & Auth Styles + Modern Native Animations
   Location: /assets/css/landing-redesign.css
   ========================================================================== */

/* ---------- Cross-Document & Group View Transitions (Top-level) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

::view-transition {
  pointer-events: none;
}

/* Disable full-page root snapshot during in-page package filter morph */
:root.vt-filtering {
  view-transition-name: none;
}

.pkg-card {
  view-transition-class: pkg-card;
}

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) {
    animation: vt-fade-out 0.22s ease-in both;
  }

  ::view-transition-new(root) {
    animation: vt-fade-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  ::view-transition-group(.pkg-card) {
    animation-duration: 0.38s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }

  ::view-transition-new(.pkg-card):only-child {
    animation: vt-card-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  ::view-transition-old(.pkg-card):only-child {
    animation: vt-card-out 0.22s ease-in both;
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

@keyframes vt-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes vt-fade-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

@keyframes vt-card-in {
  from {
    opacity: 0;
    scale: 0.95;
    translate: 0 10px;
  }
}

@keyframes vt-card-out {
  to {
    opacity: 0;
    scale: 0.95;
  }
}

/* ---------- Public & Auth Shell Helpers ---------- */
.public-shell section[id] {
  scroll-margin-top: 104px;
}

.public-shell :focus-visible,
.auth-shell :focus-visible {
  outline: 3px solid #FBBF24;
  outline-offset: 3px;
  border-radius: 10px;
}

.auth-shell input:focus-visible,
.auth-shell select:focus-visible {
  outline: none;
}

.auth-shell .seg input:focus-visible + span {
  outline: 3px solid #FBBF24;
  outline-offset: 2px;
}

iconify-icon {
  display: inline-block;
  flex: none;
}

.hero-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 30%, transparent 80%);
  mask-image: radial-gradient(70% 60% at 50% 30%, #000 30%, transparent 80%);
}

.grid-bg {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(80% 70% at 30% 20%, #000 30%, transparent 85%);
  mask-image: radial-gradient(80% 70% at 30% 20%, #000 30%, transparent 85%);
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 6px;
  height: 2px;
  border-radius: 2px;
  background: #FBBF24;
  transform: scaleX(0);
  transform-origin: center;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

.nav-link[aria-current="true"] {
  color: #fff;
}

.nav-link[aria-current="true"]::after {
  transform: scaleX(1);
  opacity: 1;
}

.m-link[aria-current="true"] {
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- Auth Reset-Password Checklist ---------- */
.req[data-ok="true"] .dot {
  background: #16A34A;
  border-color: #16A34A;
}

.req[data-ok="true"] .dot::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}

.req[data-ok="true"] {
  color: #166534;
}

/* ---------- Native Accordion (<details>::details-content) ---------- */
details.accordion-item summary::-webkit-details-marker {
  display: none;
}

details.accordion-item[open] .chev {
  transform: rotate(180deg);
}

details.accordion-item::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

details.accordion-item:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  details.accordion-item::details-content {
    transition-property: block-size, content-visibility, display;
    transition-duration: 0.3s;
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    transition-behavior: allow-discrete;
  }
}

/* ---------- Discrete Entry / Exit (@starting-style + allow-discrete) ---------- */
.discrete-panel {
  opacity: 1;
  translate: 0 0;
  transition-property: display, opacity, translate;
  transition-duration: 0.24s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;
}

@starting-style {
  .discrete-panel {
    opacity: 0;
    translate: 0 -8px;
  }
}

.discrete-panel:where([hidden], [data-closing]) {
  opacity: 0;
  translate: 0 -8px;
}

.discrete-panel[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .discrete-panel {
    translate: none;
    transition-duration: 0.08s;
  }

  @starting-style {
    .discrete-panel {
      translate: none;
    }
  }

  .discrete-panel:where([hidden], [data-closing]) {
    translate: none;
  }
}

/* ---------- Carousel Containment, Markers & Scroll-Driven Slide Effects ---------- */
#testiList {
  overscroll-behavior-x: contain;
  touch-action: manipulation;
}

#tPrev,
#tNext {
  touch-action: manipulation;
}

/* Carousel dot markers: >=24x24px accessible hit target, active state uses shape + color */
.testi-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.testi-marker-pill {
  position: relative;
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background-color: #CBD5E1;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s ease;
}

.testi-marker:hover .testi-marker-pill {
  background-color: #94A3B8;
}

.testi-marker[aria-current="true"] .testi-marker-pill {
  width: 28px;
  background-color: #BFDBFE;
}

.testi-marker[aria-current="true"] .testi-marker-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background-color: #1E40AF;
  transform-origin: left center;
  transform: scaleX(1);
}

#testiCarousel[data-autoplay="running"] .testi-marker[aria-current="true"] .testi-marker-pill::after {
  animation: testi-pill-progress var(--testi-delay, 5000ms) linear forwards;
}

#testiCarousel[data-autoplay="paused"] .testi-marker[aria-current="true"] .testi-marker-pill::after {
  animation-play-state: paused;
}

@keyframes testi-pill-progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  html.public-html {
    scroll-behavior: smooth;
  }

  #testiList {
    scroll-behavior: smooth;
  }

  /* Continuous horizontal scroll-driven card enter/exit animation (compositor-only) */
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes testi-slide-flow {
      0% {
        transform: scale(0.92) translateY(10px);
        opacity: 0.45;
      }
      18% {
        transform: scale(1) translateY(0);
        opacity: 1;
      }
      82% {
        transform: scale(1) translateY(0);
        opacity: 1;
      }
      100% {
        transform: scale(0.92) translateY(10px);
        opacity: 0.45;
      }
    }

    #testiList > .testi-slide {
      animation: testi-slide-flow auto linear both;
      animation-timeline: view(inline);
    }
  }
}

/* ---------- CSS Scroll-Driven Animations ---------- */
.scroll-progress {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    @keyframes scroll-progress-grow {
      from {
        transform: scaleX(0);
      }
      to {
        transform: scaleX(1);
      }
    }

    .scroll-progress {
      display: block;
      position: fixed;
      inset-inline: 0;
      top: 0;
      z-index: 60;
      height: 3px;
      background: linear-gradient(90deg, #FBBF24 0%, #FCD34D 60%, #60A5FA 100%);
      transform-origin: 0 50%;
      pointer-events: none;
      animation: scroll-progress-grow auto linear both;
      animation-timeline: scroll(block root);
    }
  }

  /* Hero subtle scroll parallax */
  @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
    @keyframes hero-drift-up {
      from {
        translate: 0 0;
      }
      to {
        translate: 0 -28px;
      }
    }

    @keyframes hero-drift-down {
      from {
        translate: 0 0;
      }
      to {
        translate: 0 22px;
      }
    }

    .hero-parallax-up {
      animation: hero-drift-up auto linear both;
      animation-timeline: scroll(block root);
      animation-range: 0px 680px;
    }

    .hero-parallax-down {
      animation: hero-drift-down auto linear both;
      animation-timeline: scroll(block root);
      animation-range: 0px 680px;
    }
  }

  /* Native Scroll-Driven Reveal via view() — fill-mode: backwards keeps hover transforms free after entry */
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes reveal-enter {
      from {
        opacity: 0;
        transform: translateY(20px) scale(0.985);
      }
      to {
        opacity: 1;
        transform: none;
      }
    }

    .reveal {
      animation: reveal-enter auto linear backwards;
      animation-timeline: view(block);
      animation-range: entry 0% entry 28%;
    }
  }

  /* Fallback reveal for browsers without view() + animation-range */
  @supports not ((animation-timeline: view()) and (animation-range: entry)) {
    .js-reveal-ready .reveal {
      opacity: 0;
      transform: translateY(18px);
      transition:
        opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .js-reveal-ready .reveal.in {
      opacity: 1;
      transform: none;
    }
  }
}
