/*
  GYANEXIS motion layer
  ---------------------------------------------------------------------------
  One small set of timings and a handful of reusable effects, loaded on every
  page after the page's own styles. It only adds feedback and entrances; it
  never changes layout, and nothing here is needed for a page to work.

  Rules of the layer:
    - only opacity, transform, scale and translate are animated;
    - an entrance always ends at "no transform", so nothing stays shifted;
    - content is hidden for an entrance only by script-added classes, so with
      scripts off, or if a script fails, everything is simply visible;
    - prefers-reduced-motion switches all of it off (see the end of the file).
*/

:root {
  --gx-motion-fast: 140ms;      /* press, hover, focus */
  --gx-motion-normal: 200ms;    /* dropdowns, toasts, small reveals */
  --gx-motion-modal: 220ms;     /* dialogs */
  --gx-motion-page: 220ms;      /* page entry */
  --gx-motion-exit: 150ms;      /* anything leaving */
  --gx-motion-section: 320ms;   /* sections and screens */
  --gx-ease-out: cubic-bezier(.2, .7, .25, 1);
  --gx-ease-in: cubic-bezier(.4, 0, 1, 1);
  --gx-ease-standard: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- pages ---------- */
/* Entry runs from the first paint (this stylesheet is in the head), so there
   is no moment where content shows, hides and shows again. Opacity only: a
   transform on <body> would re-anchor fixed bars and popups. */
@keyframes gx-page-in { from { opacity: 0; } }
@keyframes gx-fade-in { from { opacity: 0; } }
@keyframes gx-rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes gx-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

body {
  animation: gx-page-in var(--gx-motion-page) var(--gx-ease-out) both;
}

/* Set by script the moment an internal link is followed. */
html.gx-leaving body {
  opacity: 0;
  transition: opacity var(--gx-motion-exit) var(--gx-ease-in);
}

/* ---------- press feedback ---------- */
/* "scale" is its own property, so it adds to whatever transform a control
   already uses for its position or hover lift instead of replacing it. */
:where(button, [role="button"], input[type="submit"], input[type="button"], summary,
  a[class*="btn"], a[class*="button"], .gx-button, .rs-act, .qp-opt, .qp-pop__go, .qp-exit, .tq-go, .tr-act, .gx-search__chip) {
  transition: scale var(--gx-motion-fast) var(--gx-ease-out);
}

:where(button, [role="button"], input[type="submit"], input[type="button"],
  a[class*="btn"], a[class*="button"], .gx-button, .rs-act, .qp-opt, .qp-pop__go, .qp-exit, .tq-go, .tr-act, .gx-search__chip):active:not(:disabled, [aria-disabled="true"]) {
  scale: .975;
}

/* Cards that are links: a lighter press, mainly for touch where there is no hover. */
:where(a[class*="card"], a[class*="tile"], .gx-bottom-nav a, .pf-quick__item):active {
  scale: .985;
}

:where(button, [role="button"]):disabled,
:where(button, [role="button"])[aria-busy="true"] {
  transform: none;
}

/* ---------- ripple ---------- */
/* Added by script to main action buttons only. The wave is clipped to the
   button and removes itself when its animation ends. */
.gx-ripple-host {
  overflow: hidden;
  isolation: isolate;
}

.gx-ripple-host--anchor {
  position: relative;
}

.gx-ripple {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: .22;
  transform: scale(0);
  pointer-events: none;
  animation: gx-ripple 520ms var(--gx-ease-out) forwards;
}

@keyframes gx-ripple {
  to { transform: scale(1); opacity: 0; }
}

/* ---------- navigation ---------- */
/* Mobile bottom bar and header links answer a tap at once. */
.gx-bottom-nav a,
.gx-home-nav a,
.sq-link {
  transition: color var(--gx-motion-fast) var(--gx-ease-out), scale var(--gx-motion-fast) var(--gx-ease-out);
}

.gx-bottom-nav a:active {
  scale: .94;
}

.gx-bottom-nav a.is-active lucide-icon,
.gx-bottom-nav a[aria-current="page"] lucide-icon {
  animation: gx-nav-settle var(--gx-motion-section) var(--gx-ease-out) both;
}

@keyframes gx-nav-settle {
  from { transform: translateY(3px) scale(.9); }
  to { transform: none; }
}

/* ---------- dropdowns ---------- */
/* These open by having "hidden" removed, so the entrance plays on appearance. */
.prequiz-language-options:not([hidden]),
.gx-support-bell-panel.is-open,
.gx-support-bell-panel.show,
.gx-support-bell-dropdown.show,
.gx-mobile-menu.is-open {
  animation: gx-pop-in var(--gx-motion-normal) var(--gx-ease-out) both;
  transform-origin: top center;
}

/* ---------- dialogs ---------- */
/* The dialog box already has an entrance; the dimmed backdrop used to snap in. */
.modal.active,
.modal.show,
.popup-modal.show-popup,
.forgot-modal.show-forgot,
.modal-overlay.active,
.pdf-language-modal.is-open,
.confirm-modal.show,
.howto-modal.show,
.pf-modal.active {
  animation: gx-fade-in var(--gx-motion-modal) var(--gx-ease-out) both;
}

/* ---------- sections and screens ---------- */
/* A same-page section that was jumped to (script adds the class briefly). */
.gx-section-arrive {
  animation: gx-section-arrive var(--gx-motion-section) var(--gx-ease-out) both;
}

@keyframes gx-section-arrive {
  from { opacity: .55; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Quiz and test-series screens swap in place; the incoming one eases in. */
.screen.active {
  animation: gx-rise-in var(--gx-motion-section) var(--gx-ease-out) both;
}

/* Below-the-fold blocks: script marks them, then reveals each one once as it
   scrolls into view. Nothing above the fold is ever hidden. */
.gx-reveal {
  opacity: 0;
  transform: translateY(14px);
}

.gx-reveal.is-revealed {
  opacity: 1;
  transform: none;
  transition: opacity var(--gx-motion-section) var(--gx-ease-out), transform var(--gx-motion-section) var(--gx-ease-out);
}

/* ---------- ambient motion ---------- */
/* Decorative loops stop while their section is off screen. */
.gx-motion-paused,
.gx-motion-paused * {
  animation-play-state: paused !important;
}

/* ---------- forms and messages ---------- */
:where(input, select, textarea) {
  transition: border-color var(--gx-motion-fast) var(--gx-ease-out), box-shadow var(--gx-motion-fast) var(--gx-ease-out), background-color var(--gx-motion-fast) var(--gx-ease-out);
}

.gx-field-error {
  animation: gx-fade-in var(--gx-motion-normal) var(--gx-ease-out) both;
}

.gx-toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--gx-motion-exit) var(--gx-ease-in), transform var(--gx-motion-exit) var(--gx-ease-in);
}

@media (max-width: 760px) {
  .gx-toast-region {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- quiz ---------- */
/* Presentation only. Nothing here delays an answer, the timer or the next
   question: the buttons are clickable from their first frame. */
body#quiz-page .qp-opt {
  animation: gx-option-in 180ms var(--gx-ease-out) both;
}

body#quiz-page .qp-opt:nth-child(2) { animation-delay: 30ms; }
body#quiz-page .qp-opt:nth-child(3) { animation-delay: 60ms; }
body#quiz-page .qp-opt:nth-child(4) { animation-delay: 90ms; }

@keyframes gx-option-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

body#quiz-page .gx-question-swap {
  animation: gx-fade-in 180ms var(--gx-ease-out) both;
}

body#quiz-page .qp-opt.correct {
  animation: gx-answer-right 320ms var(--gx-ease-out) both;
}

body#quiz-page .qp-opt.incorrect {
  animation: gx-answer-wrong 260ms var(--gx-ease-standard) both;
}

@keyframes gx-answer-right {
  0% { transform: scale(1); }
  45% { transform: scale(1.02); }
  100% { transform: none; }
}

@keyframes gx-answer-wrong {
  0%, 100% { transform: none; }
  25% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
}

/* Result figures arrive in a short sequence; the coin gives one small pulse. */
#results-screen.active .rs-figure {
  animation: gx-rise-in var(--gx-motion-section) var(--gx-ease-out) both;
}

#results-screen.active .rs-figure:nth-child(2) { animation-delay: 40ms; }
#results-screen.active .rs-figure:nth-child(3) { animation-delay: 80ms; }
#results-screen.active .rs-figure:nth-child(4) { animation-delay: 120ms; }
#results-screen.active .rs-figure:nth-child(5) { animation-delay: 160ms; }
#results-screen.active .rs-figure:nth-child(6) { animation-delay: 200ms; }

#results-screen.active .rs-figure__art,
#results-screen.active .rs-xp-mark {
  animation: gx-reward-pulse 520ms var(--gx-ease-out) 320ms both;
}

@keyframes gx-reward-pulse {
  0% { transform: scale(.8); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* ---------- cards ---------- */
/* Cards already lift on hover. The home Explore cards jumped 6px and grew;
   they are brought down to the same restrained lift used elsewhere. */
body#home .gx-explore-grid .gx-explore-action-card:hover {
  transform: translateY(-4px);
}

body#home .gx-explore-grid .gx-explore-action-card:hover img {
  transform: scale(1.04);
}

/* On touch screens a hover state sticks after a tap, leaving the card raised.
   There the lift is dropped and the press feedback above is used instead. */
@media (hover: none) {
  body#home .gx-explore-grid .gx-explore-action-card:hover,
  body#home .gx-explore-grid .gx-explore-action-card:hover img {
    transform: none;
  }
}

/* ---------- touch screens: no sticky lift ---------- */
/* On a touch screen a hover state stays on the last thing tapped, so a card or
   button that lifts on hover stays lifted. These are the hover rules in the
   older stylesheets that only lift or grow an element; on devices without a
   real pointer the lift is dropped and the press feedback above is used. */
@media (hover: none) {
  body:not(#home):not(#quiz-page) .btn:hover,
  body:not(#home):not(#quiz-page) .action-btn:hover,
  body:not(#home):not(#quiz-page) .submit-btn:hover,
  body:not(#home):not(#quiz-page) .login-btn:hover,
  body:not(#home):not(#quiz-page) .modal-close-btn:hover,
  body:not(#home):not(#quiz-page) .back-btn:hover,
  body:not(#home):not(#quiz-page) .back-button a:hover,
  body:not(#home):not(#quiz-page) .contact-button:hover,
  body:not(#home):not(#quiz-page) #save-cookies:hover,
  body:not(#home):not(#quiz-page) .home-btn:hover,
  body:not(#home):not(#quiz-page) .popup-btn:hover,
  body:not(#home):not(#quiz-page) .forgot-btn.primary:hover,
  body:not(#home):not(#quiz-page) .card:hover,
  body:not(#home):not(#quiz-page) .course:hover,
  body:not(#home):not(#quiz-page) .section:hover,
  body:not(#home):not(#quiz-page) .panel:hover,
  body:not(#home):not(#quiz-page) .reward-card:hover,
  body:not(#home):not(#quiz-page) .claimed-rewards:hover,
  body:not(#home):not(#quiz-page) .rules:hover,
  body:not(#home):not(#quiz-page) .glass-panel:hover,
  body:not(#home):not(#quiz-page) .contact-form:hover,
  body:not(#home):not(#quiz-page) .contact-info:hover,
  body:not(#home):not(#quiz-page) .hero-card:hover,
  body:not(#home):not(#quiz-page) .follow-card:hover,
  body:not(#home):not(#quiz-page) .stat-card:hover,
  body#home .edu-banner-btn:hover,
  body#home .hero-secondary-btn:hover,
  body#home .sq-login-btn:hover,
  body#home .sq-register-btn:hover,
  body#home .sq-profile-btn:hover,
  body:has(.auth-shell) .action-btn:hover,
  body:has(.auth-shell) .forgot-btn.primary:hover,
  body:has(.auth-shell) .popup-btn:hover,
  body#home .study-card-new:hover,
  body :where(button:not(.navbar-toggler):not(.close-btn):hover, .btn:hover, .primary-btn:hover, .secondary-btn:hover, .action-btn:hover, .submit-btn:hover, .home-btn:hover),
  body :where(.sq-link:hover),
  body :where(.card:hover, .course:hover, .panel:hover, .team-card:hover, .reward-card:hover, .support-card:hover, .note-card:hover, .pdf-card:hover),
  .gx-ui-card--interactive:hover,
  body#notes-page .card-grid > *:hover,
  body#pyqs-page .card-grid > *:hover,
  body.testseries-body :where(.series-card, .test-card):hover,
  body#categories-page .category-hub-list .gx-category-card:hover,
  a.cx-reach-item:hover,
  .cx-social-link:hover,
  .submit-btn:hover,
  .db-btn-primary:hover,
  .db-stat-strip-card:hover,
  .gx-directory__grid a:hover,
  .gx-social-link:hover,
  .primary-action:not(:disabled):hover,
  .secondary-action:not(:disabled):hover,
  .text-action:not(:disabled):hover,
  #games-page .arcade-primary-button:hover,
  #games-page :is(.btn-play, .btn-how):hover,
  .filter-tag:hover,
  .card-3d:hover .card-image-area img,
  .card-footer .btn-how:hover,
  .btn-play:hover,
  .btn-action:hover,
  .btn-confirm.btn-yes:hover,
  .btn-confirm.btn-no:hover,
  .header-back-btn:hover,
  .header-btn:hover,
  .btn-start-session:hover,
  .btn-keep-playing:hover,
  .btn-quit-game:hover,
  .btn-play-again:hover,
  .gx-auth-modal-btn:hover,
  html body#home #latestUpdates .gx-updates__btn:hover,
  html body#home #home-footer .gx-home-footer__highlights a:hover,
  html body#home #home-footer .gx-home-footer__top:hover,
  .gx-button:hover,
  .gx-category-card:hover,
  .gx-explore-grid a:hover,
  body#home .gx-explore-grid .gx-explore-action-card:hover,
  .gx-home-footer__socials a:hover,
  body#home .gx-home-footer__highlights a:hover lucide-icon,
  body#home .gx-home-footer__follow a:hover,
  body#home .gx-rating__stars label:hover img,
  .logout-card:hover,
  .pdf-card:hover,
  .note-card:hover,
  .btn-view:hover,
  .note-btn-view:hover,
  .btn-download:hover,
  .note-btn-download:hover,
  :where(.btn, .action-btn, .submit-btn, .login-btn, .confirm-btn, .popup-btn, .home-btn, .contact-button, .forgot-btn.primary):hover:not(:disabled),
  body#quiz-page .option-btn:hover:not(:disabled),
  #results-screen .rs-act:hover,
  .setup-card-action:hover,
  .result-card:hover,
  .option-btn:hover:not(:disabled),
  .btn:hover,
  .language-card:hover,
  .prequiz-start-button:hover,
  .quiz-sound-toggle:hover,
  .action-btn:hover,
  button[type="submit"]:hover,
  body .sq-header .sq-profile-btn:hover,
  .course-card:hover,
  .btn-lang:hover,
  .sq-link:hover,
  .sq-login-btn:hover,
  .sq-register-btn:hover,
  .sq-profile-btn:hover,
  .edu-banner-btn:hover,
  .home-search-result-card:hover,
  .category-item:hover,
  .category-item:hover img,
  .edu-card-inner:hover,
  .edu-nav-buttons button:hover,
  #submit-btn:hover,
  .hero-secondary-btn:hover,
  .study-card:hover,
  .test-series-card:hover,
  .event-card:hover,
  .event-link:hover,
  .support-primary-btn:hover,
  .support-secondary-btn:hover,
  .support-ticket-row-clickable:hover,
  body.support-thread-page .support-user-panel #supportReplySubmit:hover:not(:disabled),
  .utility-pill:hover,
  .filter-btn:hover,
  .start-btn:hover,
  .primary-btn:hover,
  .back-home-btn:hover,
  body.testseries-body .test-card:hover,
  body.testseries-body .start-btn:hover,
  body.testseries-body .primary-btn:hover,
  body.testseries-body .back-home-btn:hover,
  #searchButton:hover,
  .filter-actions button:hover,
  .section-heading button:hover,
  .video-card:hover,
  .video-card:hover .card-thumb img,
  .video-card:hover .thumb-overlay span {
    transform: none;
  }

  body#home .hero-secondary-btn:hover,
  body .category-card:hover,
  body .subject-card:hover,
  body .study-card:hover,
  body .hero-mini-card:hover,
  .sq-auth .sq-login-btn:hover,
  .sq-auth .sq-register-btn:hover,
  body .sq-login-btn:hover,
  body .sq-register-btn:hover,
  body .sq-profile-btn:hover,
  body#study-material-page .course-card:hover,
  body[data-reward-guard] .reward-card-new:hover,
  body#home .explore-card:hover,
  body#home #home-footer .gx-home-footer__highlights a:hover lucide-icon,
  body#home #home-footer .gx-home-footer__follow a:hover,
  #categories-section .neo-card:hover,
  body#categories-page .neo-card:hover,
  .card.neo-card:hover,
  body.testseries-body .simple-series-grid .test-card:hover {
    transform: none !important;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  body,
  .screen.active,
  .gx-section-arrive,
  .gx-field-error,
  body#quiz-page .qp-opt,
  body#quiz-page .qp-opt.correct,
  body#quiz-page .qp-opt.incorrect,
  body#quiz-page .gx-question-swap,
  #results-screen.active .rs-figure,
  #results-screen.active .rs-figure__art,
  #results-screen.active .rs-xp-mark,
  .gx-bottom-nav a lucide-icon {
    animation: none !important;
  }

  .gx-reveal,
  .gx-reveal.is-revealed {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  html.gx-leaving body {
    opacity: 1;
    transition: none;
  }

  .gx-ripple {
    display: none;
  }

  :where(button, [role="button"], a[class*="btn"], a[class*="button"], a[class*="card"], .gx-button, .rs-act, .qp-opt, .qp-pop__go, .qp-exit, .tq-go, .tr-act):active {
    scale: none;
  }
}
