/* Stidham's Lounge — motion: page-load entrance, hero sequence, intro exit,
   scroll reveals, reduced motion.
   Only opacity, translate, scale and mask position are animated (no layout properties).
   Entrances use `backwards` fill so each element returns to its own styles afterwards,
   which keeps hover transforms (buttons, cards) working once the animation ends.
   Loaded on every page. The homepage hero sequence is shared with the other
   pages' heroes (photo hero, inner-page banner).
   JS counterpart: js/home.js (hero sequence, intro), js/animations.js (reveals). */

:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --reveal-dur: 750ms;
}

@keyframes m-fade      { from { opacity: 0; } }
@keyframes m-fade-up   { from { opacity: 0; translate: 0 var(--rise, 18px); } }
@keyframes m-fade-down { from { opacity: 0; translate: 0 -10px; } }
@keyframes m-grow-x    { from { scale: 0 1; } }
@keyframes m-underline { from { transform: scaleX(0); } }
@keyframes m-settle    { from { scale: 1.06; } }
@keyframes m-lights-up { from { opacity: .15; } }
@keyframes m-hero-zoom { from { scale: 1.03; } to { scale: 1.08; } }

/* =========================================================
   PAGE LOAD (pure CSS: plays even if JavaScript fails)
   ========================================================= */

/* Hero photo: the lights come up, then a slow push-in. */
.hero-media img {
  animation:
    m-lights-up 1.8s var(--ease-out) backwards,
    m-hero-zoom 14s ease-out forwards;
}

/* Header */
.brand              { animation: m-fade-down .8s var(--ease-out) .1s backwards; }
.nav-list,
.nav-toggle         { animation: m-fade-down .8s var(--ease-out) .25s backwards; }
.nav-cta            { animation: m-fade-down .8s var(--ease-out) .35s backwards; }
.nav-list a[aria-current="page"]::after {
  transform-origin: left;
  animation: m-underline .8s var(--ease-out) .8s backwards;
}

/* Hero copy, in sequence.
   The other pages' heroes share the homepage sequence, on the same rules:
     photo hero (components.css; Services, Menu, Events, Contact)
       eyebrow, title         as the homepage's
       script line            handwritten, with its amber glint, as "Your Place."
       lede                   the location label's entrance and light sweep
       index                  the Explore button's entrance
     inner-page banner (components.css; About): no script line, so its lede
     takes the location label's part straight after the title (--loc-start below).
   Each script line and lede carries its own words in data-text for the glint
   and sweep copies, as on the homepage. */
.photo-hero-media img {
  animation:
    m-lights-up 1.8s var(--ease-out) backwards,
    m-hero-zoom 14s ease-out forwards;
}
.hero-eyebrow,
.photo-hero .eyebrow,
.page-hero .eyebrow { animation: m-fade-up .7s var(--ease-out) .25s backwards; --rise: 10px; }
.hero-title-main,
.photo-hero-title-main,
.page-title         { animation: m-fade-up .9s var(--ease-out) .4s backwards; --rise: 26px; }

.hero-title-script,
.photo-hero-title-script {
  animation: m-handwrite 1.6s linear .7s backwards;
}
@keyframes m-handwrite {
  0% {
    -webkit-mask-image: linear-gradient(105deg, #000 47%, transparent 53%);
            mask-image: linear-gradient(105deg, #000 47%, transparent 53%);
    -webkit-mask-size: 200% 100%;  mask-size: 200% 100%;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: 106% 0;  mask-position: 106% 0;
    animation-timing-function: cubic-bezier(.45, .05, .55, .95);
  }
  42%  { -webkit-mask-position: 55% 0;  mask-position: 55% 0;  animation-timing-function: linear; }
  50%  { -webkit-mask-position: 53% 0;  mask-position: 53% 0;  animation-timing-function: cubic-bezier(.4, .05, .5, 1); }
  88%  { -webkit-mask-position: 11% 0;  mask-position: 11% 0;  animation-timing-function: linear; }
  92%  { -webkit-mask-position: 10% 0;  mask-position: 10% 0;  animation-timing-function: cubic-bezier(.3, .6, .4, 1); }
  100% {
    -webkit-mask-image: linear-gradient(105deg, #000 47%, transparent 53%);
            mask-image: linear-gradient(105deg, #000 47%, transparent 53%);
    -webkit-mask-size: 200% 100%;  mask-size: 200% 100%;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: -8% 0;   mask-position: -8% 0;
  }
}
/* Fresh ink catching the lamplight: a warm amber copy of the words shows only in a
   band just behind the pen (the parent's mask hides everything ahead of it), then
   cools away. Same stops as m-handwrite so the two stay locked together. */
.hero-title-script::after,
.photo-hero-title-script::after {
  content: attr(data-text);
  content: attr(data-text) / "";   /* hidden from screen readers where supported */
  position: absolute;
  inset: 0;
  padding: inherit;
  color: #e6c486;
  text-shadow: none;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  -webkit-mask-image: linear-gradient(105deg, transparent 37%, #000 46%, #000 49%, transparent 53%);
          mask-image: linear-gradient(105deg, transparent 37%, #000 46%, #000 49%, transparent 53%);
  -webkit-mask-size: 200% 100%;  mask-size: 200% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  animation: m-ink-glint 1.6s linear .7s backwards;
}
@keyframes m-ink-glint {
  0%   { opacity: .6; -webkit-mask-position: 106% 0; mask-position: 106% 0; animation-timing-function: cubic-bezier(.45, .05, .55, .95); }
  42%  { -webkit-mask-position: 55% 0;  mask-position: 55% 0;  animation-timing-function: linear; }
  50%  { -webkit-mask-position: 53% 0;  mask-position: 53% 0;  animation-timing-function: cubic-bezier(.4, .05, .5, 1); }
  85%  { opacity: .6; }
  88%  { -webkit-mask-position: 11% 0;  mask-position: 11% 0;  animation-timing-function: linear; }
  92%  { -webkit-mask-position: 10% 0;  mask-position: 10% 0;  animation-timing-function: cubic-bezier(.3, .6, .4, 1); }
  100% { opacity: 0; -webkit-mask-position: -8% 0; mask-position: -8% 0; }
}

/* Location label + CTA follow only once "Your Place." is fully written.
   --loc-start is when they begin. With js/home.js running (html.motion), the
   label is held hidden until it sees both animations above actually finish and
   adds .is-written to the hero; the label then starts 200ms later.
   Without it, the fallback start is m-handwrite's .7s delay + 1.6s run + .2s. */
:root { --loc-start: 2.5s; }
.motion .hero.is-written { --loc-start: .2s; }

.hero-location,
.photo-hero-lede,
.page-lede          { animation: m-fade-up .9s var(--ease-out) var(--loc-start) backwards; --rise: 14px; }
/* Inner-page banner: nothing is written, so the lede follows the title. */
.page-hero { --loc-start: .7s; }
.hero-location-label .icon { animation: m-fade-down .7s var(--ease-out) calc(var(--loc-start) + .1s) backwards; }
.hero-location-label::before,
.hero-location-label::after { animation: m-grow-x 1.1s var(--ease-out) calc(var(--loc-start) + .1s) backwards; }

.motion .hero:not(.is-written) .hero-location { opacity: 0; }
.motion .hero:not(.is-written) .hero-location,
.motion .hero:not(.is-written) .hero-location *,
.motion .hero:not(.is-written) .hero-location *::before,
.motion .hero:not(.is-written) .hero-location *::after,
.motion .hero:not(.is-written) .hero-cta { animation: none; }
.motion .hero:not(.is-written) .hero-cta { opacity: 0; }

/* Signature: a band of warm lamplight passes once over the location label, like a
   light sweeping a vintage sign. An ivory copy of the words sits exactly on top of
   the olive text; a moving mask shows only a soft band of it. The real text below
   never changes, so it stays readable throughout. Resting state: copy invisible. */
.hero-location-text,
.photo-hero-lede,
.page-lede { position: relative; }
.hero-location-text::after,
.photo-hero-lede::after,
.page-lede::after {
  content: attr(data-text);
  content: attr(data-text) / "";   /* hidden from screen readers where supported */
  position: absolute;
  inset: 0;
  color: #f6eedc;
  text-shadow: 0 0 14px rgba(217, 163, 91, .35);   /* faint amber warmth, not a glow */
  pointer-events: none;
  user-select: none;
  opacity: 0;
  -webkit-mask-image: linear-gradient(100deg, transparent 36%, #000 50%, transparent 64%);
          mask-image: linear-gradient(100deg, transparent 36%, #000 50%, transparent 64%);
  -webkit-mask-size: 300% 100%;
          mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  animation: m-light-sweep 1.15s cubic-bezier(.45, .05, .25, 1) calc(var(--loc-start) + .15s) backwards;
}
@keyframes m-light-sweep {
  0%   { opacity: 1; -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  80%  { opacity: 1; }
  100% { opacity: 0; -webkit-mask-position: 0 0; mask-position: 0 0; }
}

.hero-cta,
.photo-hero-index  { animation: m-fade-up .8s var(--ease-out) calc(var(--loc-start) + .3s) backwards; --rise: 14px; }

/* =========================================================
   INTRO EXIT (js/home.js)
   The copy lifts away first, then the whole layer fades as the photo eases
   forward, revealing the site underneath. home.js marks the intro closed once this
   has finished (1.25s). Reopening (Home link) runs the same transitions in reverse.
   ========================================================= */
html[data-intro] .hero        { transition: opacity .6s var(--ease-out); }
html[data-intro] .hero-media  { transition: scale 1.2s var(--ease-out); }
html[data-intro] .hero-content { transition: opacity .7s var(--ease-out), translate .9s var(--ease-out); }
html[data-intro="leaving"] .hero { opacity: 0; transition: opacity 1s var(--ease-out) .25s; }
html[data-intro="leaving"] .hero-media,
html[data-intro="closed"] .hero-media { scale: 1.04; }
html[data-intro="leaving"] .hero-content,
html[data-intro="closed"] .hero-content { opacity: 0; translate: 0 -40px; }

/* =========================================================
   SCROLL REVEALS (js/animations.js)
   Hidden states only apply under html.motion, which js/boot.js sets (and removes
   again if js/animations.js never starts).
     data-reveal           the element itself fades up (="fade": opacity only)
     data-reveal-children  its children fade up in turn, --stagger apart
   Optional per-element: --delay, --stagger, --rise.
   ========================================================= */
.motion [data-reveal]:not(.is-revealed),
.motion [data-reveal-children]:not(.is-revealed) > * { opacity: 0; }

.motion [data-reveal].is-revealed,
.motion [data-reveal-children].is-revealed > * {
  animation: m-fade-up var(--reveal-dur) var(--ease-out) backwards;
  animation-delay: calc(var(--delay, 0ms) + var(--hero-wait, 0ms) + var(--i, 0) * var(--stagger, 120ms));
}
.motion [data-reveal="fade"].is-revealed { animation-name: m-fade; animation-duration: 1.1s; }

/* Per-section timing: the food copy and events follow the food photo. */
.food-copy   { --delay: 150ms; --stagger: 100ms; }
.events-head { --delay: 150ms; }
.event-list  { --delay: 300ms; --stagger: 110ms; }
/* Services and Events: the cards follow the heading. Closing band: line by line. */
.experience-grid, .gig-grid, .whats-on-grid { --delay: 120ms; }
.contact-list { --delay: 120ms; --stagger: 100ms; }
#message { --delay: 150ms; }
.cta-band-inner  { --stagger: 100ms; }
/* Menu page: the photo follows its heading. */
.menu-board { --delay: 120ms; }

/* Food photo settles into frame as it fades in. */
.motion .food-photo.is-revealed img { animation: m-settle 1.6s var(--ease-out) backwards; }

/* Events divider draws out from the heading. */
.events-head::after { transform-origin: left; }
.motion .events-head.is-revealed::after { animation: m-grow-x 1s var(--ease-out) .25s backwards; }

/* =========================================================
   REDUCED MOTION
   No smooth scrolling, transitions, movement or zoom. "Your Place." and the
   location label show at once; the rest of the hero keeps a short plain fade.
   Scroll reveals and the .is-written gate are off entirely (html.motion is never set).
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0s !important; }

  .hero-media img,
  .photo-hero-media img,
  .nav-list a[aria-current="page"]::after,
  .hero-title-script,
  .photo-hero-title-script,
  .photo-hero-lede,
  .photo-hero-index,
  .page-lede,
  .hero-location,
  .hero-location-label .icon,
  .hero-location-label::before,
  .hero-location-label::after { animation: none; }
  .hero-location-text::after,
  .hero-title-script::after,
  .photo-hero-title-script::after,
  .photo-hero-lede::after,
  .page-lede::after { display: none; }

  .brand, .nav-list, .nav-toggle, .nav-cta,
  .hero-eyebrow, .hero-title-main, .hero-cta,
  .page-hero .eyebrow, .page-title,
  .photo-hero .eyebrow, .photo-hero-title-main {
    animation-name: m-fade;
    animation-duration: .4s;
  }
}
