/*
 * Site-wide styles, loaded by skeleton.html.
 * Page-specific rules are scoped with the page class set on <body> (page-home, page-contact, page-listing, page-listings, page-sold).
 */

/* ---------- Base ---------- */

body {
  background-color: #F5F4F0;
  margin: 0;
  overflow-x: hidden;
  font-family: "Urbanist", sans-serif;
  font-optical-sizing: auto;
  scroll-behavior: smooth;
}

.heading-font {
  font-optical-sizing: auto;
  font-family: "Marcellus", serif;
}

/* ---------- Shared animations ---------- */

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(24px);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Scroll reveal: the js-reveal class is added to <html> by each page's inline script */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(32px);
  transition:
    opacity 1s cubic-bezier(.22, 1, .36, 1),
    transform 1s cubic-bezier(.22, 1, .36, 1);
  transition-delay: var(--reveal-delay, 0s);
}

.js-reveal .reveal.is-visible {
  opacity: 1;
  transform: none;
}

.js-reveal .reveal.reveal-left {
  transform: translateX(-48px);
}

.js-reveal .reveal.reveal-left.is-visible {
  transform: none;
}

/* ---------- Home page ---------- */

.listing .photo {
  transform: scale(1);
  transition-duration: .15s;
  transition-property: transform;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
}

.listing:hover .photo {
  transform: scale(1.05);
}

@keyframes hero-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes hero-settle {
  from { letter-spacing: .3em; }
  to { letter-spacing: .1em; }
}

.page-home .hero-line path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: hero-draw 1.8s cubic-bezier(.65, 0, .35, 1) .2s forwards;
}

.page-home .hero-title {
  opacity: 0;
  animation:
    hero-rise 1.2s cubic-bezier(.22, 1, .36, 1) .9s forwards,
    hero-settle 1.6s cubic-bezier(.22, 1, .36, 1) .9s both;
}

.page-home .hero-subtitle {
  opacity: 0;
  animation: hero-rise 1.2s cubic-bezier(.22, 1, .36, 1) 1.4s forwards;
}

/* ---------- Contact page ---------- */

@keyframes hero-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.page-contact .hero-title,
.page-sold .hero-title,
.page-listings .hero-title {
  opacity: 0;
  animation: hero-rise 1.2s cubic-bezier(.22, 1, .36, 1) .2s forwards;
}

.page-contact .hero-rule,
.page-sold .hero-rule,
.page-listings .hero-rule {
  transform: scaleX(0);
  animation: hero-grow 1s cubic-bezier(.65, 0, .35, 1) .6s forwards;
}

.page-contact .hero-subtitle,
.page-sold .hero-subtitle,
.page-listings .hero-subtitle {
  opacity: 0;
  animation: hero-rise 1.2s cubic-bezier(.22, 1, .36, 1) .8s forwards;
}

/* Contact form card: stretches to the photo's height, and the message box takes the spare room */
.contact-card #contact-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.contact-card #contact-form > form {
  flex: 1;
}

.contact-card #contact-form > form > div:has(textarea) {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.contact-card textarea {
  flex: 1 0 auto;
  min-height: 10rem;
}

/* Side by side with the photo: start the message box small so the photo sets the height, then let it grow */
@media (min-width: 64rem) {
  .contact-card textarea {
    flex-basis: 0;
    height: auto;
    min-height: 8rem;
  }
}

/* Contact success state, swapped in by htmx after a successful submit */
@keyframes success-pop {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes success-draw {
  to { stroke-dashoffset: 0; }
}

.success-badge {
  opacity: 0;
  animation: success-pop .6s cubic-bezier(.22, 1, .36, 1) forwards;
}

.success-check {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: success-draw .5s cubic-bezier(.65, 0, .35, 1) .45s forwards;
}

.success-text,
.success-actions {
  opacity: 0;
  animation: hero-rise 1s cubic-bezier(.22, 1, .36, 1) .6s forwards;
}

.success-actions {
  animation-delay: .8s;
}

/* ---------- Listing page ---------- */

.gallery-photo {
  transition: transform .15s cubic-bezier(.4, 0, .2, 1);
}

.gallery-photo:hover {
  transform: scale(1.03);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .page-home .hero-line path,
  .page-home .hero-title,
  .page-home .hero-subtitle {
    animation: none;
    opacity: 1;
    stroke-dashoffset: 0;
  }

  .page-contact .hero-title,
  .page-contact .hero-rule,
  .page-contact .hero-subtitle,
  .page-sold .hero-title,
  .page-sold .hero-rule,
  .page-sold .hero-subtitle,
  .page-listings .hero-title,
  .page-listings .hero-rule,
  .page-listings .hero-subtitle {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .success-badge,
  .success-text,
  .success-actions {
    animation: none;
    opacity: 1;
  }

  .success-check {
    animation: none;
    stroke-dashoffset: 0;
  }

  .js-reveal .reveal,
  .js-reveal .reveal.reveal-left {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
