/* =========================================================================
   Fortezza Construction Group — motion & interaction layer
   -------------------------------------------------------------------------
   Loaded after fortezza-ui.css. Pairs with fortezza-animations.js, which
   adds .fortezza-reveal + .is-inview. Respects prefers-reduced-motion.
   ========================================================================= */

:root {
  --fortezza-motion-duration: 0.85s;
  --fortezza-motion-duration-slow: 1.15s;
  --fortezza-motion-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fortezza-motion-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fortezza-stagger-step: 0.09s;
}

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

/* -------------------------------------------------------------------------
   Reveal primitives — hidden until .is-inview (JS) or no-motion bypass
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  html.fortezza-animations-active .fortezza-reveal {
    opacity: 0;
    transition:
      opacity var(--fortezza-motion-duration) var(--fortezza-motion-ease-out),
      transform var(--fortezza-motion-duration) var(--fortezza-motion-ease-out),
      filter var(--fortezza-motion-duration) var(--fortezza-motion-ease-out);
    will-change: opacity, transform;
  }

  html.fortezza-animations-active .fortezza-reveal.is-inview {
    opacity: 1;
    transform: none !important;
    filter: none !important;
    transition-delay: var(--fortezza-reveal-delay, 0s);
  }

  .fortezza-reveal--up {
    transform: translateY(36px);
  }
  .fortezza-reveal--down {
    transform: translateY(-28px);
  }
  .fortezza-reveal--left {
    transform: translateX(-48px);
  }
  .fortezza-reveal--right {
    transform: translateX(48px);
  }
  .fortezza-reveal--scale {
    transform: scale(0.94);
  }
  .fortezza-reveal--fade {
    transform: none;
  }

  /* Stagger children inside a revealed container */
  .fortezza-stagger > .fortezza-reveal-child {
    opacity: 0;
    transform: translateY(22px);
    transition:
      opacity 0.65s var(--fortezza-motion-ease-out),
      transform 0.65s var(--fortezza-motion-ease-out);
  }
  .fortezza-stagger.is-inview > .fortezza-reveal-child {
    opacity: 1;
    transform: none;
  }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(1) { transition-delay: calc(var(--fortezza-stagger-step) * 1); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(2) { transition-delay: calc(var(--fortezza-stagger-step) * 2); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(3) { transition-delay: calc(var(--fortezza-stagger-step) * 3); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(4) { transition-delay: calc(var(--fortezza-stagger-step) * 4); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(5) { transition-delay: calc(var(--fortezza-stagger-step) * 5); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(6) { transition-delay: calc(var(--fortezza-stagger-step) * 6); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(7) { transition-delay: calc(var(--fortezza-stagger-step) * 7); }
  .fortezza-stagger.is-inview > .fortezza-reveal-child:nth-child(8) { transition-delay: calc(var(--fortezza-stagger-step) * 8); }

  /* Animated gold rule on section headings */
  .fortezza-reveal-line.is-inview .sqs-html-content > h1::before,
  .fortezza-reveal-line.is-inview .sqs-html-content > h2:first-child::before,
  .fortezza-reveal-line.is-inview h1::before {
    animation: fortezza-line-grow 0.95s var(--fortezza-motion-ease-out) forwards;
  }
}

@keyframes fortezza-line-grow {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 46px;
    opacity: 1;
  }
}

/* No-motion / bypass — everything visible immediately */
html.fortezza-no-motion .fortezza-reveal,
html.fortezza-no-motion .fortezza-reveal-child,
html:not(.fortezza-animations-active) .fortezza-reveal,
html:not(.fortezza-animations-active) .fortezza-reveal-child {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  transition: none !important;
}

/* -------------------------------------------------------------------------
   Hero — slow Ken Burns + text cascade
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .page-section.has-background:has(.fortezza-hero-bg) .fortezza-hero-bg img {
    animation: fortezza-ken-burns 24s ease-in-out infinite alternate;
  }

  .fortezza-hero-cascade.is-inview .sqs-html-content > * {
    animation: fortezza-hero-fade-up 0.9s var(--fortezza-motion-ease-out) both;
  }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(1) { animation-delay: 0.12s; }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(2) { animation-delay: 0.22s; }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(3) { animation-delay: 0.32s; }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(4) { animation-delay: 0.42s; }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(5) { animation-delay: 0.52s; }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(6) { animation-delay: 0.62s; }
  .fortezza-hero-cascade.is-inview .sqs-html-content > *:nth-child(7) { animation-delay: 0.72s; }
}

@keyframes fortezza-ken-burns {
  from { transform: scale(1.03); }
  to   { transform: scale(1.09); }
}

@keyframes fortezza-hero-fade-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------------------------------------------------
   Header — subtle shrink on scroll
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  #header {
    transition:
      box-shadow 0.35s var(--fortezza-motion-ease),
      transform 0.35s var(--fortezza-motion-ease);
  }
  html.fortezza-header-scrolled #header .header-title-logo img {
    transition: max-height 0.35s var(--fortezza-motion-ease);
    max-height: clamp(48px, 7vw, 72px) !important;
  }
  html.fortezza-header-scrolled #header .header-dropshadow {
    box-shadow: 0 10px 28px rgba(28, 24, 18, 0.1) !important;
  }
}

/* -------------------------------------------------------------------------
   Contact page — glass panel, image depth, field micro-interactions
   ------------------------------------------------------------------------- */

#collection-67c7c3445e03545e66104f9e #block-82f1772e7ffa0981729e .sqs-image-content {
  transform-style: preserve-3d;
  transition:
    box-shadow 0.45s var(--fortezza-motion-ease),
    transform 0.45s var(--fortezza-motion-ease);
}
#collection-67c7c3445e03545e66104f9e #block-82f1772e7ffa0981729e.is-inview .sqs-image-content {
  box-shadow:
    0 28px 64px rgba(28, 24, 18, 0.16),
    0 8px 20px rgba(28, 24, 18, 0.08);
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  #collection-67c7c3445e03545e66104f9e #block-82f1772e7ffa0981729e.fortezza-tilt-ready .sqs-image-content {
    transition: transform 0.12s ease-out, box-shadow 0.45s var(--fortezza-motion-ease);
  }
}

/* Glass inquiry card — opaque panels (ui.css already sets white; avoid shimmer bleed-through) */
#collection-67c7c3445e03545e66104f9e #block-c06a2271b9870d1e6955 .sqs-html-content,
#collection-67c7c3445e03545e66104f9e #block-6cd003ccf7f1bc72e7ae .form-wrapper {
  background: var(--fortezza-white) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Contact form fields — never hide before scroll-reveal */
#fortezza-contact-form .fortezza-reveal-child,
#fortezza-contact-form .form-wrapper.fortezza-stagger > .fortezza-reveal-child {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

/* Form field focus lift */
@media (prefers-reduced-motion: no-preference) {
  .fortezza-contact-form .field {
    transition: transform 0.25s var(--fortezza-motion-ease);
  }
  .fortezza-contact-form .field:focus-within {
    transform: translateY(-2px);
  }
  .fortezza-contact-form .field:focus-within .caption {
    color: hsla(38, 28%, 42%, 1);
    transition: color 0.2s var(--fortezza-motion-ease);
  }
  .fortezza-contact-form .field-element {
    transition:
      border-color 0.2s ease,
      box-shadow 0.3s var(--fortezza-motion-ease),
      background 0.2s ease,
      transform 0.25s var(--fortezza-motion-ease);
  }
  .fortezza-contact-form .field:focus-within .field-element {
    box-shadow: 0 10px 28px rgba(28, 24, 18, 0.08);
    transform: translateY(-1px);
  }
}

/* Submit — shimmer sweep on hover */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .fortezza-contact-form button[type="submit"],
  .sqs-block-button-element--primary {
    position: relative;
    overflow: hidden;
    isolation: isolate;
  }
  .fortezza-contact-form button[type="submit"]::after,
  .sqs-block-button-element--primary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      105deg,
      transparent 42%,
      hsla(0, 0%, 100%, 0.22) 50%,
      transparent 58%
    );
    transform: translateX(-120%);
    transition: transform 0.55s var(--fortezza-motion-ease);
    pointer-events: none;
  }
  .fortezza-contact-form button[type="submit"]:hover:not(:disabled)::after,
  .sqs-block-button-element--primary:hover::after {
    transform: translateX(120%);
  }
}

/* -------------------------------------------------------------------------
   Blog, gallery, cards — hover polish
   ------------------------------------------------------------------------- */

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .blog-side-by-side .blog-item {
    transition:
      transform 0.4s var(--fortezza-motion-ease),
      box-shadow 0.4s var(--fortezza-motion-ease),
      border-color 0.3s ease;
  }
  .blog-side-by-side .blog-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(28, 24, 18, 0.12);
    border-color: hsla(38, 28%, 52%, 0.35);
  }

  .gallery-masonry-item,
  .gallery-grid-item {
    transition:
      transform 0.4s var(--fortezza-motion-ease),
      box-shadow 0.4s var(--fortezza-motion-ease);
  }
}

/* Section ambient shimmer on contact gradient band */
@media (prefers-reduced-motion: no-preference) {
  #collection-67c7c3445e03545e66104f9e
    [data-section-id="67c7c3445e03545e66104fb4"]::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      118deg,
      transparent 30%,
      hsla(0, 0%, 100%, 0.35) 48%,
      transparent 66%
    );
    opacity: 0;
    pointer-events: none;
    animation: fortezza-section-shimmer 9s ease-in-out infinite;
  }
}

@keyframes fortezza-section-shimmer {
  0%, 72% { opacity: 0; transform: translateX(-30%); }
  82%     { opacity: 0.55; }
  100%    { opacity: 0; transform: translateX(30%); }
}

/* Link underline draw */
@media (prefers-reduced-motion: no-preference) {
  .header-nav-item > a::after {
    transition:
      left 0.28s var(--fortezza-motion-ease),
      right 0.28s var(--fortezza-motion-ease),
      opacity 0.2s ease;
  }
}

/* -------------------------------------------------------------------------
   Scroll progress · back-to-top · hero scroll cue · lightbox crossfade
   ------------------------------------------------------------------------- */

/* Reading-progress bar — a slim gold line fixed to the very top edge that
   fills as the page is scrolled. Pure transform (scaleX), so it is cheap and
   GPU-composited. Sits below the lightbox (z 99999), which fully covers it. */
.fortezza-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 99990;
  pointer-events: none;
  background: transparent;
}
.fortezza-progress__bar {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(
    90deg,
    hsla(38, 30%, 50%, 0.95),
    hsla(42, 48%, 64%, 1)
  );
  box-shadow: 0 0 10px hsla(38, 42%, 50%, 0.45);
}
@media (prefers-reduced-motion: no-preference) {
  .fortezza-progress__bar {
    transition: transform 0.1s linear;
  }
}

/* Back-to-top — appears past the fold; charcoal pill that warms to gold on
   hover. Safe-area aware for notched phones. */
.fortezza-totop {
  position: fixed;
  right: clamp(0.85rem, 3vw, 1.75rem);
  bottom: clamp(0.85rem, 3vw, 1.75rem);
  bottom: calc(clamp(0.85rem, 3vw, 1.75rem) + env(safe-area-inset-bottom, 0px));
  z-index: 9000;
  width: 46px;
  height: 46px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fortezza-white, #fff);
  background: hsla(0, 6%, 16%, 0.9);
  border: 1px solid hsla(38, 26%, 62%, 0.45);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.9);
  box-shadow: 0 10px 26px rgba(28, 24, 18, 0.26);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition:
    opacity 0.35s var(--fortezza-motion-ease-out),
    transform 0.35s var(--fortezza-motion-ease-out),
    visibility 0.35s linear,
    background 0.25s ease,
    border-color 0.25s ease;
}
.fortezza-totop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.fortezza-totop svg {
  width: 19px;
  height: 19px;
  display: block;
}
.fortezza-totop:focus-visible {
  outline: 2px solid var(--fortezza-gold, hsl(38, 28%, 52%));
  outline-offset: 3px;
}
@media (hover: hover) {
  .fortezza-totop:hover {
    background: var(--fortezza-gold, hsl(38, 28%, 52%));
    border-color: var(--fortezza-gold, hsl(38, 28%, 52%));
    color: #fff;
    transform: translateY(-3px) scale(1.05);
  }
}
@media (prefers-reduced-motion: reduce) {
  .fortezza-totop {
    transition: opacity 0.2s linear, visibility 0.2s linear;
    transform: none;
  }
  .fortezza-totop.is-visible,
  .fortezza-totop:hover {
    transform: none;
  }
}

/* Homepage hero scroll cue — sits over the lower hero photo (above its dark
   scrim for contrast), gently bobs, and fades out on first scroll. */
.fortezza-scrollcue {
  position: absolute;
  left: 50%;
  bottom: clamp(0.9rem, 2.6vw, 1.7rem);
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: hsla(0, 0%, 100%, 0.94);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s var(--fortezza-motion-ease-out);
}
.fortezza-scrollcue.is-ready {
  opacity: 1;
}
.fortezza-scrollcue.is-hidden {
  opacity: 0;
}
.fortezza-scrollcue__label {
  font-family: "Marcellus", Georgia, serif;
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}
.fortezza-scrollcue__chev {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5));
}
@media (prefers-reduced-motion: no-preference) {
  .fortezza-scrollcue__chev {
    animation: fortezza-cue-bob 1.9s var(--fortezza-motion-ease-out) infinite;
  }
}
@keyframes fortezza-cue-bob {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50%      { transform: translateY(6px); opacity: 1; }
}

/* Lightbox — crossfade between photos (paired with the token-guarded swap in
   fortezza-animations.js). */
@media (prefers-reduced-motion: no-preference) {
  .fortezza-lightbox__img {
    transition: opacity 0.22s var(--fortezza-motion-ease-out);
  }
}

/* Respect reduced motion — kill decorative loops */
@media (prefers-reduced-motion: reduce) {
  .page-section.has-background:has(.fortezza-hero-bg) .fortezza-hero-bg img,
  #collection-67c7c3445e03545e66104f9e
    [data-section-id="67c7c3445e03545e66104fb4"]::after,
  .fortezza-scrollcue__chev {
    animation: none !important;
  }
}
