/* ==========================================================================
   Dominio motion system
   One vocabulary shared by all five pages: long, decelerating eases
   (expo-out), short staggers, and transform/opacity/clip-path only.

   Every hidden "before" state is scoped under html.motion, which
   motion.js adds in <head> only when the visitor has not asked for
   reduced motion. With JS off or reduced motion on, nothing is ever
   hidden and the page renders statically.
   ========================================================================== */

:root {
  --motion-ease: var(--ease-out-expo);
  --motion-reveal: 650ms;
  --motion-stagger: 45ms;
  --motion-hover: 350ms;
}

/* Anchor jumps (services.html#bathrooms) land below the sticky header. */
html { scroll-padding-top: calc(var(--header-h) + var(--space-sm)); }

/* Cross-page fade on supporting browsers; the header holds still while the
   page content dissolves underneath it. */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 240ms;
  animation-timing-function: var(--ease-out-quart);
}

/* --------------------------------------------------------------------------
   Logo — signature star. Plays once per browsing session (first page
   only), then rests. Hover turns the star exactly one point (72°), so it
   settles back into the identical silhouette.
   -------------------------------------------------------------------------- */
.brand-mark--live { overflow: visible; }
.brand-mark--live .mark-disc,
.brand-mark--live .mark-ring,
.brand-mark--live .mark-star {
  transform-box: fill-box;
  transform-origin: center;
}
/* Ring starts its stroke at 12 o'clock so the intro draws clockwise from top. */
.brand-mark--live .mark-ring {
  transform: rotate(-90deg);
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}
.brand-mark--live .mark-star {
  transition: transform 600ms var(--motion-ease);
}
.brand:hover .mark-star,
.brand:focus-visible .mark-star { transform: rotate(72deg); }
.brand .brand-name { transition: color var(--duration-normal) var(--ease-out-quart); }
.brand:hover .brand-name { color: var(--color-navy-700); }

/* `backwards` (not `both`) so once the intro ends the element falls back to
   its static style, and hover transforms are not overridden. */
.motion.logo-intro .site-header .mark-disc {
  animation: mark-disc-in 500ms var(--motion-ease) backwards;
}
.motion.logo-intro .site-header .mark-ring {
  animation: mark-ring-draw 700ms cubic-bezier(0.65, 0, 0.35, 1) 60ms backwards;
}
.motion.logo-intro .site-header .mark-star {
  animation: mark-star-in 850ms var(--motion-ease) 100ms backwards;
}
.motion.logo-intro .site-header .brand-name {
  animation: rise-x 500ms var(--motion-ease) 180ms backwards;
}
.motion.logo-intro .site-header .brand-tag {
  animation: rise-x 500ms var(--motion-ease) 240ms backwards;
}

@keyframes mark-disc-in {
  from { opacity: 0; transform: scale(0.55); }
}
@keyframes mark-ring-draw {
  from { stroke-dashoffset: 100; }
}
/* -144° is two star points, so the turn ends on the exact resting pose. */
@keyframes mark-star-in {
  from { opacity: 0; transform: rotate(-144deg) scale(0.2); }
}
@keyframes rise-x {
  from { opacity: 0; transform: translateX(-10px); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

/* --------------------------------------------------------------------------
   Buttons — a fill sweeps in from the left, the arrow nudges forward,
   and a press compresses slightly. Phone buttons get no arrow; external
   links get a diagonal one.
   -------------------------------------------------------------------------- */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition: transform var(--motion-hover) var(--motion-ease),
              color 250ms var(--ease-out-quart),
              border-color 250ms var(--ease-out-quart),
              box-shadow var(--motion-hover) var(--motion-ease);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--btn-fill, transparent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 400ms var(--motion-ease);
}
.btn:hover::before,
.btn:focus-visible::before { transform: scaleX(1); transform-origin: left; }
.btn:hover { transform: translateY(-2px); }
.btn-primary:hover { box-shadow: 0 16px 32px -12px rgba(194, 65, 12, 0.6); }
.btn:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 120ms;
}

.btn:not([href^="tel:"])::after {
  content: "";
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--motion-hover) var(--motion-ease);
}
.btn:not([href^="tel:"]):hover::after { transform: translateX(4px); }
.btn[target="_blank"]::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 11 11 5M6 5h5v5'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 11 11 5M6 5h5v5'/%3E%3C/svg%3E");
}
.btn[target="_blank"]:hover::after { transform: translate(3px, -3px); }

/* --------------------------------------------------------------------------
   Homepage hero — the photo settles in from dark, then badges, kicker,
   headline (word by word, rising out of a mask), lede, and CTAs follow in
   sequence. motion.js adds the scroll parallax.
   -------------------------------------------------------------------------- */
.hero-media { will-change: transform; }

/* The stage (photo + light glows + blueprint lines) settles as one unit;
   polish.css then hands it to the slow Ken Burns zoom. */
.motion .hero-stage {
  animation: hero-settle 1400ms var(--motion-ease) backwards;
}
/* Opacity resolves in the first 30% (~400ms) so the photo is never dim for
   long; the gentle scale settle carries on underneath. */
@keyframes hero-settle {
  from { opacity: 0; transform: scale(1.08); }
  30% { opacity: 1; }
}

.motion .hero-badges li { animation: rise 450ms var(--motion-ease) backwards; }
.motion .hero-badges li:nth-child(1) { animation-delay: 40ms; }
.motion .hero-badges li:nth-child(2) { animation-delay: 80ms; }
.motion .hero-badges li:nth-child(3) { animation-delay: 120ms; }
.motion .hero .hero-kicker { animation: rise 450ms var(--motion-ease) 80ms backwards; }
.motion .hero-lede { animation: rise 500ms var(--motion-ease) 250ms backwards; }
.motion .hero-actions .btn { animation: rise 500ms var(--motion-ease) backwards; }
.motion .hero-actions .btn:nth-child(1) { animation-delay: 300ms; }
.motion .hero-actions .btn:nth-child(2) { animation-delay: 340ms; }

/* Headline words. Until motion.js has split them, keep the text hidden so
   it never flashes unsplit; the failsafe shows it if the script fails. */
.motion .hero-title-text:not(.is-split) {
  opacity: 0;
  animation: failsafe-show 0s 1200ms forwards;
}
.hero-title-text .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* Room for descenders inside the clipping mask. */
  padding-bottom: 0.1em;
  margin-bottom: -0.1em;
}
.hero-title-text .w > span { display: inline-block; }
.motion .hero-title-text .w > span {
  animation: word-up 650ms var(--motion-ease) backwards;
  animation-delay: calc(120ms + var(--w, 0) * 30ms);
}
@keyframes word-up {
  from { transform: translateY(105%); }
}
@keyframes failsafe-show {
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   Inner-page heroes — copy rises in sequence while the photography wipes
   up out of a mask, frame by frame. Parallax drift is added by motion.js.
   -------------------------------------------------------------------------- */
.motion .page-hero-copy > * { animation: rise 500ms var(--motion-ease) backwards; }
.motion .page-hero-copy > :nth-child(1) { animation-delay: 0ms; }
.motion .page-hero-copy > :nth-child(2) { animation-delay: 40ms; }
.motion .page-hero-copy > :nth-child(3) { animation-delay: 80ms; }
.motion .page-hero-copy > :nth-child(4) { animation-delay: 130ms; }
.motion .page-hero-copy > :nth-child(5) { animation-delay: 180ms; }
.motion .page-hero-copy > :nth-child(6) { animation-delay: 220ms; }

.motion .hero-frame.page-hero-media,
.motion .page-hero-media .hero-frame {
  animation: frame-reveal 850ms var(--motion-ease) 80ms backwards;
}
.motion .page-hero-media .hero-frame:nth-child(2) { animation-delay: 150ms; }
.motion .page-hero-media .hero-frame:nth-child(3) { animation-delay: 220ms; }
.motion .page-hero-media img {
  animation: photo-settle 1200ms var(--motion-ease) 80ms backwards;
}
@keyframes frame-reveal {
  from { clip-path: inset(100% 0 0 0 round var(--radius-lg)); transform: translateY(16px); }
  to { clip-path: inset(0 0 0 0 round var(--radius-lg)); transform: none; }
}
@keyframes photo-settle {
  from { transform: scale(1.08); }
}
[data-parallax] { will-change: transform; }

/* --------------------------------------------------------------------------
   Scroll reveals. motion.js tags the meaningful pieces inside each
   [data-reveal] group as .rv (with a stagger index --i) and photos as
   .rv-media, then adds .is-in when the group scrolls into view.
   -------------------------------------------------------------------------- */
/* Hold groups hidden until motion.js has tagged them (prevents a flash of
   content that then disappears); failsafe reveals them if JS fails. */
.motion [data-reveal]:not(.rv-ready) {
  opacity: 0;
  animation: failsafe-show 0s 1500ms forwards;
}

.motion .rv {
  transition: opacity 450ms var(--ease-out-quart),
              transform var(--motion-reveal) var(--motion-ease);
  transition-delay: calc(var(--i, 0) * var(--motion-stagger));
}
.motion .rv:not(.is-in) {
  opacity: 0;
  transform: translateY(16px);
}

/* Photos wipe upward out of a mask while the image itself settles from a
   slight zoom — a gentler, more architectural feel than a plain fade. */
.motion .rv-media {
  transition: clip-path 800ms var(--motion-ease),
              transform 800ms var(--motion-ease);
  transition-delay: calc(var(--i, 0) * var(--motion-stagger));
}
.motion .rv-media:not(.is-in) {
  opacity: 1;
  clip-path: inset(100% 0 0 0 round var(--radius-lg));
  transform: translateY(18px);
}
.motion .rv-media.is-in { clip-path: inset(0 0 0 0 round var(--radius-lg)); }
.motion .rv-media img {
  transition: transform 1000ms var(--motion-ease);
  transition-delay: calc(var(--i, 0) * var(--motion-stagger));
}
.motion .rv-media:not(.is-in) img { transform: scale(1.08); }

/* --------------------------------------------------------------------------
   Photographs — slow, weighted zoom on hover everywhere.
   -------------------------------------------------------------------------- */
.split-media img,
.project-card img,
.ba-item img {
  transition: transform 900ms var(--motion-ease);
}
.split-media:hover img { transform: scale(1.04); }
.ba-item:hover img { transform: scale(1.04); }

.project-card {
  transition: transform var(--motion-hover) var(--motion-ease),
              box-shadow var(--motion-hover) var(--motion-ease);
}
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.project-card:hover img { transform: scale(1.07); }

/* --------------------------------------------------------------------------
   Service cards — accent rule draws across the top, the icon lifts, and a
   faint warm light follows the pointer (position set by motion.js).
   -------------------------------------------------------------------------- */
.service-card {
  overflow: hidden;
  transition: transform var(--motion-hover) var(--motion-ease),
              box-shadow var(--motion-hover) var(--motion-ease),
              border-color var(--motion-hover) var(--motion-ease);
}
.service-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 450ms var(--motion-ease);
}
.service-card:hover::before,
.service-card:focus-visible::before { transform: scaleX(1); transform-origin: left; }
.service-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 0%), rgba(239, 108, 26, 0.09), transparent 70%);
  opacity: 0;
  transition: opacity 300ms var(--ease-out-quart);
}
.service-card:hover::after { opacity: 1; }
.service-card .service-icon { transition: transform var(--motion-hover) var(--motion-ease); }
.service-card:hover .service-icon { transform: translateY(-3px); }

/* Painting division panel: the warm glow tracks the pointer. */
.division-panel::before {
  background: radial-gradient(circle at var(--mx, 15%) var(--my, 20%), rgba(239, 108, 26, 0.25), transparent 55%);
}

/* --------------------------------------------------------------------------
   Mobile menu — links cascade in when the panel opens; the page behind
   stops scrolling while it is open.
   -------------------------------------------------------------------------- */
@media (max-width: 1120px) {
  .nav-open { overflow: hidden; }
  .main-nav .nav-links li,
  .main-nav .header-actions {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 200ms var(--ease-out-quart),
                transform 200ms var(--ease-out-quart);
  }
  .nav-open .main-nav .nav-links li,
  .nav-open .main-nav .header-actions {
    opacity: 1;
    transform: none;
    transition: opacity 300ms var(--ease-out-quart),
                transform 450ms var(--motion-ease);
  }
  .nav-open .main-nav .nav-links li:nth-child(1) { transition-delay: 30ms; }
  .nav-open .main-nav .nav-links li:nth-child(2) { transition-delay: 60ms; }
  .nav-open .main-nav .nav-links li:nth-child(3) { transition-delay: 90ms; }
  .nav-open .main-nav .nav-links li:nth-child(4) { transition-delay: 120ms; }
  .nav-open .main-nav .header-actions { transition-delay: 160ms; }
}

/* Reduced motion: the global rule in global.css already flattens every
   transition/animation; these keep transformed resting states static. */
@media (prefers-reduced-motion: reduce) {
  .hero-media { will-change: auto; }
  .brand:hover .mark-star,
  .brand:focus-visible .mark-star { transform: none; }
  @view-transition { navigation: none; }
}
