/* ==========================================================================
   Arcwave Pilates — Animations & Utility Styles (Pure PHP / Vanilla JS)
   ========================================================================== */

/* Font fallbacks and variables */
:root {
  --font-sans: 'Almarai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

body {
  font-family: var(--font-sans);
  background-color: #f6f4ed;
  color: #152f3e;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip; /* clip, not hidden: hidden would make this a scroll container and break scroll-driven animations */
}

/* Scroll reveal animations — matching Framer Motion ease [0.16, 1, 0.3, 1].
   Only hidden once JS is running (html.js), so content never stays invisible if scripts fail. */
.js .reveal-init {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-visible {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Hero word pull-up animation */
@keyframes wordPullUp {
  0% {
    opacity: 0;
    transform: translateY(28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.pull-up-word {
  display: inline-block;
  opacity: 0;
  animation: wordPullUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Safe area insets for mobile notched devices */
.safe-pt {
  padding-top: env(safe-area-inset-top, 0px);
}
.safe-pb {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Mobile drawer animation */
@keyframes slideDownDrawer {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.drawer-animate {
  animation: slideDownDrawer 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Toast styling */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 0.875rem 1.25rem;
  border-radius: 1rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid #d9ded5;
  background: #fffefa;
  color: #152f3e;
  animation: slideDownDrawer 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.toast-destructive {
  border-color: #b3261e;
  background: #fdf2f2;
  color: #b3261e;
}

/* FAQ accordion (faq.php) — not in the prebuilt Tailwind bundle */
.faq-item + .faq-item { border-top: 1px solid #d9ded5; }
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary .faq-icon { transition: transform 200ms ease; }
.faq-item[open] > summary .faq-icon { transform: rotate(45deg); }

/* Studio gallery (about.php) — tiles are 4:5; a landscape photo spans two
   tiles (≈3:2) so neither shape is cropped much. 2 columns on phones, 5 from
   tablet up; with 6 tall + 2 wide photos both fill completely. */
.studio-gallery-wrap { container-type: inline-size; }
.studio-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: 0.75rem;
  grid-auto-rows: calc((100cqw - 0.75rem) / 2 * 1.25);
}
.gallery-tile--wide { grid-column: span 2; }
.gallery-tile > div { height: 100%; }
@media (min-width: 768px) {
  .studio-gallery { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; grid-auto-rows: calc((100cqw - 4rem) / 5 * 1.25); }
}
/* Certification photo wall (certifications.php) — gap-free tiled grid.
   Rows are one landscape (3:2) tall; portraits span 2 rows, the feature photo
   2×2. With 1 feature + 3 portraits + 6 landscapes the grid fills completely
   at both 2 columns (phone/tablet) and 4 columns (desktop). */
.cert-photos-wrap { container-type: inline-size; }
.cert-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: 0.75rem;
  grid-auto-rows: calc((100cqw - 0.75rem) / 2 * 2 / 3);
}
.cert-tile--tall { grid-row: span 2; }
.cert-tile--feature { grid-column: span 2; grid-row: span 2; }
.cert-tile > div, .cert-tile img { height: 100%; }
@media (min-width: 1024px) {
  .cert-photos { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; grid-auto-rows: calc((100cqw - 3rem) / 4 * 2 / 3); }
}

/* ==========================================================================
   Motion system (2026-10) — transform/opacity/clip-path only, so it stays
   smooth on low-end phones and never shifts layout. Everything is disabled
   under prefers-reduced-motion (see the end of this block), and anything that
   hides content first is gated on html.js so it can never stay invisible.
   ========================================================================== */

:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

/* 1. Photo reveal: the frame opens up while the photo settles from a slight zoom */
.js .reveal-photo {
  clip-path: inset(7% 7% 7% 7% round 1.25rem);
  transition: clip-path 1.1s var(--ease-out-expo);
}
.js .reveal-photo > img, .js .reveal-photo > video {
  transition: transform 1.4s var(--ease-out-expo);
}
.js .reveal-photo:not(.is-in) > img, .js .reveal-photo:not(.is-in) > video {
  transform: scale(1.14);
}
.js .reveal-photo.is-in {
  clip-path: inset(0 0 0 0 round 0);
}

/* 2. Hero entrance: photo eases in with a slow zoom, then the copy rises */
@keyframes heroPhotoIn {
  from { opacity: 0; transform: scale(1.12); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes heroCopyIn {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero-photo {
  animation: heroPhotoIn 2.2s var(--ease-soft) both;
}
.hero-copy {
  animation: heroCopyIn 1s var(--ease-out-expo) 0.45s both;
}

/* 2b. Home hero (index.php): photo → wordmark → cut-out of the people, so the
   letters sit behind them. Phones see a squarer crop that keeps both people
   whole; from 640px the photo shows at its own 3:2 shape (nothing cropped);
   on desktop the stage is sized to fit the screen height. */
.hero-stage {
  container-type: inline-size;
  aspect-ratio: 1 / 1.12;
  --hero-x: 9%;
  --hero-y: 50%;
}
@media (min-width: 640px) {
  .hero-stage { aspect-ratio: 1.455; --hero-x: 50%; }   /* the trimmed photo's own shape */
}
/* Desktop: as large as the screen allows while the whole scene stays above the
   fold — a slightly wider 1.65 frame that only trims ceiling and floor (never the
   people), up to the full page width on big screens. */
@media (min-width: 1024px) {
  .hero-stage {
    aspect-ratio: 1.65;
    width: clamp(min(100%, 820px), calc((100svh - 8rem) * 1.65), min(100%, 1600px));
    --hero-y: 35%;
  }
}
.hero-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--hero-x) var(--hero-y);
  animation: heroPhotoIn 2.2s var(--ease-soft) both;
}
.hero-cut { z-index: 2; pointer-events: none; }
.hero-word {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 3.2%;
  margin: 0;
  text-align: center;
  color: var(--color-ink);
  line-height: 0.82;
}
.hero-word-inner { display: inline-block; text-align: left; }
.hero-word-main {
  display: block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 23cqw;
  letter-spacing: -0.06em;
  animation: heroWordRise 1.5s var(--ease-out-expo) 0.35s both;
}
.hero-word-sub {
  display: block;
  margin-top: 0.12em;
  padding-left: 0.35em;
  text-align: left;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 9cqw;
  letter-spacing: 0;
  color: var(--color-teal);
  animation: heroCopyIn 1s var(--ease-out-expo) 0.9s both;
}
@media (min-width: 640px) {
  .hero-word { top: 2.6%; }
  .hero-word-main { font-size: 17cqw; }
  /* under the end of the word, over the curtains (clear of both people) */
  .hero-word-sub { font-size: 5.6cqw; text-align: right; padding-left: 0; padding-right: 0.15em; }
}
.hero-ctas { animation: heroCopyIn 1s var(--ease-out-expo) 1.1s both; }
@media (min-width: 1024px) {
  .hero-word-main { font-size: 16cqw; }
  .hero-word-sub { font-size: 5.2cqw; }
}
@keyframes heroWordRise {
  from { opacity: 0; transform: translateY(45%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 3. Header on scroll (desktop): slimmer bar with a soft shadow.
   The bar is sticky (part of the page), so getting 28px shorter would pull the page up
   by 28px — near the top that flips it back to "not scrolled" and the bar flickers.
   margin-bottom keeps that space while it is slim, so the page never moves. */
.site-header {
  transition: box-shadow 0.35s ease, background-color 0.35s ease, margin-bottom 0.35s var(--ease-out-expo);
}
.site-header .site-header-inner,
.site-header .site-logo {
  transition: padding 0.35s var(--ease-out-expo), height 0.35s var(--ease-out-expo);
}
.site-header.is-scrolled {
  box-shadow: 0 10px 30px -18px rgba(21, 47, 62, 0.35);
  background-color: rgba(246, 244, 237, 0.94);
}
@media (min-width: 768px) {
  .site-header.is-scrolled {
    margin-bottom: 1.75rem; /* = padding (2 × 0.5rem) + logo (3.5rem → 2.75rem) it loses */
  }
  .site-header.is-scrolled .site-header-inner {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  .site-header.is-scrolled .site-logo {
    height: 2.75rem;
  }
}

/* 4. Number count-up keeps its width steady while counting */
.count-up {
  font-variant-numeric: tabular-nums;
}

/* 5. FAQ answers slide open (height animated in JS; this is the fade) */
.faq-item .faq-answer {
  overflow: hidden;
}
.faq-item[open] .faq-answer {
  animation: faqFade 0.35s ease both;
}
@keyframes faqFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 6. Buttons and cards: gentle lift on hover, press on tap */
:is(a, button)[class*="rounded-full"]:not(:disabled) {
  transition: transform 0.2s var(--ease-out-expo), box-shadow 0.2s ease,
              background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
@media (hover: hover) {
  :is(a, button)[class*="rounded-full"][class*="bg-teal"]:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -10px rgba(33, 102, 94, 0.55);
  }
  .lift-card {
    transition: transform 0.35s var(--ease-out-expo), box-shadow 0.35s ease, border-color 0.35s ease;
  }
  .lift-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px -24px rgba(21, 47, 62, 0.45);
  }
}
:is(a, button)[class*="rounded-full"]:not(:disabled):active {
  transform: scale(0.97);
}

/* 7. Light parallax on large photos (browsers with scroll-driven animations only) */
@supports (animation-timeline: view()) {
  /* overflow: clip (not hidden) so the page, not this frame, drives the view timeline */
  .parallax-photo {
    overflow: clip;
  }
  .parallax-photo > img {
    animation: parallaxDrift linear both;
    animation-timeline: view();
    animation-range: cover;
  }
  @keyframes parallaxDrift {
    from { transform: translateY(-5%) scale(1.12); }
    to   { transform: translateY(5%) scale(1.12); }
  }
  /* parallax replaces the reveal zoom on the same photo */
  .js .reveal-photo.parallax-photo:not(.is-in) > img { transform: none; }
}

/* 8. Page transitions: soft cross-fade between pages (supporting browsers only) */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
  animation-timing-function: ease;
}
.site-header {
  view-transition-name: site-header; /* header stays put while the page fades */
}

/* Reduced motion: no movement at all, content shown immediately */
@media (prefers-reduced-motion: reduce) {
  .js .reveal-init { opacity: 1; transform: none; transition: none; }
  .js .reveal-photo, .js .reveal-photo.is-in { clip-path: none; transition: none; }
  .js .reveal-photo > img, .js .reveal-photo:not(.is-in) > img,
  .js .reveal-photo > video, .js .reveal-photo:not(.is-in) > video { transform: none; transition: none; }
  .hero-photo, .hero-copy, .pull-up-word, .hero-layer, .hero-word-main, .hero-word-sub, .hero-ctas { animation: none; opacity: 1; transform: none; }
  .parallax-photo > img { animation: none !important; transform: none !important; }
  .lift-card:hover, :is(a, button)[class*="rounded-full"]:hover,
  :is(a, button)[class*="rounded-full"]:active { transform: none !important; }
  @view-transition { navigation: none; }
}

/* ==========================================================================
   9. Member experience (2026-10): sheets, day strip, floating tab bar
   ========================================================================== */

/* Sheet — bottom sheet on phones, centred dialog from 640px (assets/js/main.js → arcSheet) */
html.sheet-open { overflow: hidden; }
/* Mobile menu / modals: lock the page where it is (on <html> — see initMobileNav in main.js) */
html.nav-open, html.scroll-locked { overflow: hidden; }
html.nav-open .site-header { background-color: var(--color-paper); }
@media (max-width: 767px) {
  #mobile-nav-drawer {
    max-height: calc(100dvh - 69px - env(safe-area-inset-top));
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
}
dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: 92svh;
  padding: 0 0 env(safe-area-inset-bottom);
  border: 1px solid #d9ded5;
  border-bottom: 0;
  border-radius: 1.5rem 1.5rem 0 0;
  background: #fffefa;
  color: #152f3e;
  box-shadow: 0 -12px 40px -12px rgba(21, 47, 62, 0.3);
  overflow-y: auto;
  overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(21, 47, 62, 0.45); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: sheet-up 0.32s var(--ease-out-expo) both; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (min-width: 640px) {
  dialog.sheet {
    inset: 0;
    margin: auto;
    width: min(520px, calc(100vw - 2rem));
    height: fit-content;
    max-height: calc(100svh - 3rem);
    border-bottom: 1px solid #d9ded5;
    border-radius: 1.5rem;
    padding-bottom: 0;
  }
  dialog.sheet[open] { animation-name: sheet-pop; }
}
dialog.sheet.sheet-wide { width: min(760px, calc(100vw - 2rem)); }
@media (max-width: 639px) { dialog.sheet.sheet-wide { width: 100%; } }
.sheet-handle { width: 40px; height: 4px; margin: 10px auto 0; border-radius: 999px; background: #d9ded5; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.25rem 0.25rem; }
.sheet-title { font-size: 1.25rem; line-height: 1.3; font-weight: 500; padding-top: 0.5rem; }
.sheet-close {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; margin-right: -0.5rem; border-radius: 999px; color: #5c696b;
}
.sheet-close:hover { background: #ece9e0; color: #152f3e; }
.sheet-body { padding: 0.25rem 1.25rem 1rem; font-size: 0.875rem; line-height: 1.6; }
.sheet-actions {
  position: sticky; bottom: 0;
  display: flex; flex-direction: column-reverse; gap: 0.5rem;
  padding: 0.75rem 1.25rem 1.25rem;
  border-top: 1px solid #d9ded5;
  background: #fffefa;
}
.sheet-actions > * { min-height: 48px; width: 100%; }
@media (min-width: 640px) {
  .sheet-handle { display: none; }
  .sheet-head { padding-top: 1.25rem; }
  .sheet-actions { flex-direction: row; justify-content: flex-end; }
  .sheet-actions > * { min-height: 44px; width: auto; }
}
/* key/value rows inside sheets */
.sheet-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid #ece9e0; }
.sheet-row:last-child { border-bottom: 0; }
.sheet-row > :first-child { color: #5c696b; }
.sheet-row > :last-child { text-align: right; font-weight: 500; }

/* Horizontal scrollers (day strip, About photo strip) */
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Toasts sit at the top on phones so they never cover the bottom tab bar or sheets' buttons */
@media (max-width: 767px) {
  .toast-container { top: calc(env(safe-area-inset-top) + 76px); bottom: auto; left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }
}

/* Floating member tab bar (dashboard.php) */
.member-tabbar {
  position: fixed; z-index: 40;
  left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
  padding: 6px;
  border: 1px solid rgba(217, 222, 213, 0.9);
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px -12px rgba(21, 47, 62, 0.35);
}
.member-tabbar button {
  flex: 1 1 0; min-width: 0; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 999px;
  padding: 0 2px;
  font-size: 10px; font-weight: 600; letter-spacing: 0; white-space: nowrap; color: #5c696b;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.member-tabbar button[aria-current="page"] { background: #21665e; color: #fff; }
@media (min-width: 768px) { .member-tabbar { display: none; } }

@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open] { animation: none; }
  .member-tabbar button { transition: none; }
}

/* Floating WhatsApp chat button (includes/footer.php) */
.wa-float {
  position: fixed; z-index: 45;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 999px;
  background: #25d366; color: #fff;
  box-shadow: 0 10px 24px -8px rgba(18, 140, 74, 0.55), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s var(--ease-soft), box-shadow 0.2s ease;
}
.wa-float:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 28px -8px rgba(18, 140, 74, 0.6), 0 2px 6px rgba(0, 0, 0, 0.12); }
.wa-float:focus-visible { outline: 3px solid #21665e; outline-offset: 3px; }
/* Member dashboard on phones: sit above the floating tab bar */
@media (max-width: 767px) {
  body:has(.member-tabbar) .wa-float { bottom: calc(88px + env(safe-area-inset-bottom)); width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) { .wa-float, .wa-float:hover { transition: none; transform: none; } }

/* About: founder portrait (about.php #founder) */
.founder-portrait { position: relative; isolation: isolate; }
.founder-frame {
  position: absolute; inset: 0; z-index: -1;
  border-radius: 1.5rem;
  background: linear-gradient(140deg, rgba(220, 231, 181, 0.95), rgba(33, 102, 94, 0.22));
  opacity: 0;
  transform: translate(0, 0);
  transition: transform 1.3s var(--ease-out-expo) 0.45s, opacity 0.8s ease 0.45s;
}
.founder-arc {
  position: absolute; z-index: -1;
  top: -28px; left: -28px;
  width: 112px; height: 112px;
  color: var(--color-teal);
  opacity: 0;
  transition: opacity 1.2s ease 0.8s;
  animation: founderArcSpin 36s linear infinite;
}
.reveal-visible .founder-frame, html:not(.js) .founder-frame { opacity: 1; transform: translate(12px, 12px); }
.reveal-visible .founder-arc, html:not(.js) .founder-arc { opacity: 0.6; }
.founder-portrait:hover .founder-frame { transform: translate(18px, 18px); transition-delay: 0s; transition-duration: 0.6s; }
@media (min-width: 768px) {
  .founder-arc { top: -40px; left: -40px; width: 150px; height: 150px; }
  .reveal-visible .founder-frame, html:not(.js) .founder-frame { transform: translate(22px, 22px); }
  .founder-portrait:hover .founder-frame { transform: translate(30px, 30px); }
}
.reveal-visible .founder-float { animation: founderBreathe 7s ease-in-out 1.8s infinite; }
@keyframes founderArcSpin { to { transform: rotate(360deg); } }
@keyframes founderBreathe {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) {
  .founder-arc, .reveal-visible .founder-float { animation: none; }
  .founder-frame, .founder-arc { transition: none; }
}

/* Admin: the sidebar slides in on phones/tablets when the menu button is pressed.
   Kept outside Tailwind's layers on purpose: the -translate-x-full utility on the
   element would otherwise always win over a layered rule and keep the menu hidden. */
.admin-sidebar[data-open="true"] {
  translate: 0 0;
  box-shadow: 0 25px 50px -12px rgba(21, 47, 62, 0.35);
}
