:root {
  color-scheme: light;
  --sand: #f4efe6;
  --sand-2: #ebe3d5;
  --stone: #d9cfbd;
  --sage: #8fa58a;
  --sage-deep: #5d7259;
  --moss: #3d4c3a;
  --ink: #2b2f29;
  --muted: #6b6e63;
  --white: #fbf9f4;
  --radius: 18px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  --ease: cubic-bezier(.22,.7,.2,1);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--sand); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.08; margin: 0 0 .5em; color: var(--moss); }
h1 { font-size: clamp(3rem, 7vw, 5.6rem); letter-spacing: -0.01em; }
h1 em, h2 em { font-style: italic; color: var(--sage-deep); }
h2 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); }
h3 { font-size: 1.8rem; }
p { margin: 0 0 1em; }
.wrap { width: min(1180px, 100% - 3rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; background: var(--moss); color: var(--white); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }
:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 3px; }

.eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: .74rem; font-weight: 500; color: var(--sage-deep); margin-bottom: 1.1rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244,239,230,.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .3s, box-shadow .3s;
}
.site-header.scrolled { border-color: var(--stone); box-shadow: 0 6px 24px -18px rgba(61,76,58,.4); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { font-family: var(--serif); font-size: 1.55rem; font-weight: 600; text-decoration: none; color: var(--moss); display: flex; align-items: center; gap: .6rem; margin: 0; }
.brand-mark { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; background: var(--sage); transform: rotate(-45deg); }
.site-nav { display: flex; align-items: center; gap: 2rem; }
.site-nav a { text-decoration: none; font-size: .95rem; color: var(--ink); position: relative; }
.site-nav a:not(.nav-cta)::after { content: ""; position: absolute; left: 0; bottom: -4px; height: 1px; width: 100%; background: var(--sage-deep); transform: scaleX(0); transform-origin: right; transition: transform .4s var(--ease); }
.site-nav a:hover::after, .site-nav a.active::after { transform: scaleX(1); transform-origin: left; }
.nav-cta { padding: .55rem 1.2rem; border: 1px solid var(--sage-deep); border-radius: 99px; color: var(--sage-deep) !important; transition: background .3s, color .3s; }
.nav-cta:hover { background: var(--sage-deep); color: var(--white) !important; }
.menu-toggle { display: none; background: none; border: 0; width: 44px; height: 44px; cursor: pointer; position: relative; }
.menu-toggle span { position: absolute; left: 11px; right: 11px; height: 1.5px; background: var(--moss); transition: transform .35s var(--ease), top .35s var(--ease); }
.menu-toggle span:first-child { top: 18px; }
.menu-toggle span:last-child { top: 25px; }
.menu-toggle[aria-expanded="true"] span:first-child { top: 21.5px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:last-child { top: 21.5px; transform: rotate(-45deg); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .95rem 1.7rem; border-radius: 99px; font: 500 .95rem var(--sans); text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: transform .35s var(--ease), background .3s, color .3s, box-shadow .35s; }
.btn-primary { background: var(--moss); color: var(--white); }
.btn-primary:hover { background: var(--sage-deep); transform: translateY(-2px); box-shadow: 0 12px 24px -14px rgba(61,76,58,.7); }
.btn-ghost { border-color: var(--stone); color: var(--moss); }
.btn-ghost:hover { background: var(--sand-2); transform: translateY(-2px); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .65; cursor: progress; transform: none; }

/* Hero */
.hero { position: relative; padding: clamp(3rem, 7vw, 6rem) 0 clamp(4rem, 8vw, 7rem); overflow: hidden; }
.hero::before { content: ""; position: absolute; width: 640px; height: 640px; right: -180px; top: -160px; border-radius: 50%; background: radial-gradient(circle, rgba(143,165,138,.28), transparent 65%); pointer-events: none; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 33rem; margin: 1.2rem 0 2.2rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .9rem; }
.hero-visual { position: relative; padding-bottom: 3rem; }
.hero-img { margin: 0; overflow: hidden; background: var(--sand-2); }
.hero-img img { width: 100%; height: 100%; object-fit: cover; }
.hero-img-main { border-radius: 200px 200px var(--radius) var(--radius); aspect-ratio: 4/5; width: 82%; margin-left: auto; animation: rise 1.4s var(--ease) both .2s; }
.hero-img-main img { animation: slowzoom 18s ease-out both; }
.hero-img-small { position: absolute; left: 0; bottom: 0; width: 40%; aspect-ratio: 4/5; border-radius: var(--radius); border: 6px solid var(--sand); animation: rise 1.4s var(--ease) both .55s, float 7s ease-in-out infinite 2s; }
.hero-caption { position: absolute; right: 0; bottom: 0; margin: 0; font-family: var(--serif); font-style: italic; color: var(--muted); }
.scroll-cue { position: absolute; left: 50%; bottom: 1.5rem; width: 24px; height: 38px; border: 1.5px solid var(--sage); border-radius: 14px; transform: translateX(-50%); }
.scroll-cue span { position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 2px; background: var(--sage-deep); animation: cue 2s ease-in-out infinite; }

.fade-up { opacity: 0; animation: fadeUp 1s var(--ease) forwards; animation-delay: var(--d, 0s); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(40px); clip-path: inset(30% 0 0 0); } to { opacity: 1; transform: none; clip-path: inset(0); } }
@keyframes slowzoom { from { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes cue { 0% { opacity: 0; transform: translateY(0); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }

/* Sections */
.section { padding: clamp(4.5rem, 9vw, 8rem) 0; }
.section-head { text-align: center; max-width: 40rem; margin: 0 auto 3rem; }
.section-intro { color: var(--muted); }
.reveal { opacity: 0; transform: translateY(32px); transition: opacity 1s var(--ease), transform 1s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }

/* Gallery */
.work { background: var(--white); }
.filters { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-bottom: 2.5rem; }
.filter { font: 500 .9rem var(--sans); padding: .55rem 1.2rem; border-radius: 99px; border: 1px solid var(--stone); background: transparent; color: var(--ink); cursor: pointer; transition: background .3s, color .3s, border-color .3s; }
.filter:hover { border-color: var(--sage); }
.filter.is-active { background: var(--sage-deep); border-color: var(--sage-deep); color: var(--white); }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 260px; grid-auto-flow: dense; gap: 1rem; }
.tile { border-radius: var(--radius); overflow: hidden; background: var(--sand-2); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.tile.tall { grid-row: span 2; }
.tile.wide { grid-column: span 2; }
.tile.hide { display: none; }
.tile.pop { animation: pop .6s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.tile-btn { all: unset; display: block; width: 100%; height: 100%; position: relative; cursor: zoom-in; }
.tile-btn:focus-visible { outline: 3px solid var(--sage-deep); outline-offset: -3px; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease), filter .6s; }
.tile-btn:hover img, .tile-btn:focus-visible img { transform: scale(1.06); }
.tile-meta { position: absolute; inset: auto 0 0 0; padding: 2.5rem 1.2rem 1rem; display: flex; justify-content: space-between; align-items: end; color: var(--white); background: linear-gradient(transparent, rgba(43,47,41,.65)); font-family: var(--serif); font-size: 1.35rem; opacity: 0; transform: translateY(10px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.tile-meta small { font-family: var(--sans); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }
.tile-btn:hover .tile-meta, .tile-btn:focus-visible .tile-meta { opacity: 1; transform: none; }
.gallery-empty { text-align: center; color: var(--muted); padding: 3rem 0; }

/* About */
.about-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(2rem, 6vw, 5.5rem); align-items: center; }
.about-img { margin: 0; border-radius: var(--radius) 160px var(--radius) var(--radius); overflow: hidden; aspect-ratio: 4/5; background: var(--sand-2); }
.about-img img { width: 100%; height: 100%; object-fit: cover; }
.about-copy p { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 2.5rem 0 0; padding-top: 2rem; border-top: 1px solid var(--stone); }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: .82rem; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--serif); font-size: 2.8rem; color: var(--moss); line-height: 1.1; }

/* Services */
.services { background: var(--sand-2); }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.card { position: relative; background: var(--white); padding: 2.4rem 2rem; border-radius: var(--radius); border: 1px solid transparent; transition: transform .5s var(--ease), box-shadow .5s var(--ease), opacity 1s var(--ease); }
.card:hover { transform: translateY(-6px); box-shadow: 0 24px 40px -28px rgba(61,76,58,.5); }
.card p { color: var(--muted); }
.card .price { font-family: var(--serif); font-size: 1.3rem; font-style: italic; color: var(--sage-deep); }
.card ul { list-style: none; padding: 1.2rem 0 0; margin: 1.2rem 0 0; border-top: 1px solid var(--sand-2); }
.card li { padding: .35rem 0 .35rem 1.6rem; position: relative; font-size: .95rem; }
.card li::before { content: ""; position: absolute; left: 0; top: .85rem; width: 8px; height: 8px; border-radius: 50% 50% 50% 0; background: var(--sage); transform: rotate(-45deg); }
.card-featured { background: var(--moss); }
.card-featured h3, .card-featured li { color: var(--white); }
.card-featured p { color: #c9d3c3; }
.card-featured .price { color: #c6d6bf; }
.card-featured ul { border-color: rgba(255,255,255,.15); }
.badge { position: absolute; top: 1.4rem; right: 1.4rem; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; background: var(--sage); color: var(--moss); padding: .3rem .7rem; border-radius: 99px; }

/* Quotes */
.quote-slider { max-width: 46rem; margin: 0 auto; text-align: center; }
.quote-track { display: grid; }
.quote { grid-area: 1 / 1; margin: 0; opacity: 0; transform: translateY(12px); transition: opacity .8s var(--ease), transform .8s var(--ease); visibility: hidden; }
.quote.is-active { opacity: 1; transform: none; visibility: visible; }
.quote p { font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.35; color: var(--moss); font-style: italic; }
.quote footer { font-size: .9rem; color: var(--muted); }
.quote-dots { display: flex; justify-content: center; gap: .6rem; margin-top: 2rem; }
.quote-dots button { width: 10px; height: 10px; padding: 0; border-radius: 99px; border: 0; background: var(--stone); cursor: pointer; transition: width .4s var(--ease), background .3s; }
.quote-dots button[aria-current="true"] { width: 28px; background: var(--sage-deep); }

/* Contact */
.contact { background: var(--white); }
.contact-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.contact-copy p { color: var(--muted); }
.contact-list { list-style: none; padding: 0; margin: 2rem 0 0; }
.contact-list li { display: flex; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--sand-2); }
.contact-list span { width: 6.5rem; flex-shrink: 0; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--sage-deep); padding-top: .15rem; }
.contact-list a { text-decoration: none; border-bottom: 1px solid var(--stone); }
.contact-list a:hover { border-color: var(--sage-deep); }
.contact-form { background: var(--sand); padding: clamp(1.5rem, 4vw, 2.5rem); border-radius: var(--radius); }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .4rem; color: var(--moss); }
.field input, .field select, .field textarea { width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--white); border: 1px solid var(--stone); border-radius: 12px; padding: .8rem 1rem; transition: border-color .3s, box-shadow .3s; appearance: none; }
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--sage-deep) 50%), linear-gradient(135deg, var(--sage-deep) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 4px rgba(143,165,138,.25); }
.field.invalid input, .field.invalid textarea { border-color: #b4664e; }
.error { color: #9c5440; font-size: .82rem; margin: .35rem 0 0; min-height: 0; }
.form-status { margin: 1rem 0 0; font-size: .95rem; text-align: center; color: var(--sage-deep); }

/* Footer */
.site-footer { background: var(--moss); color: #c9d3c3; padding: 2.5rem 0; font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.footer-inner p { margin: 0; }
.site-footer .brand { color: var(--white); }
.to-top { text-decoration: none; }
.to-top:hover { color: var(--white); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(30,34,29,.94); display: flex; align-items: center; justify-content: center; padding: 2rem 4.5rem; opacity: 0; transition: opacity .4s var(--ease); }
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-height: calc(100vh - 8rem); max-width: 100%; width: auto; border-radius: 10px; transform: scale(.97); transition: transform .5s var(--ease), opacity .3s; background: #2b2f29; }
.lightbox.open img { transform: none; }
.lightbox img.loading { opacity: .3; }
.lightbox figcaption { color: #d9e0d4; font-family: var(--serif); font-style: italic; font-size: 1.25rem; margin-top: 1rem; }
.lb-close, .lb-nav { position: absolute; background: rgba(255,255,255,.08); color: var(--white); border: 0; border-radius: 50%; width: 48px; height: 48px; font-size: 1.8rem; line-height: 1; cursor: pointer; transition: background .3s; }
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-close { top: 1.2rem; right: 1.2rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }

/* Responsive */
@media (max-width: 960px) {
  .gallery { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 220px; }
  .cards { grid-template-columns: 1fr; max-width: 32rem; margin: 0 auto; }
}
@media (max-width: 820px) {
  .menu-toggle { display: block; z-index: 2; }
  .site-nav { position: fixed; inset: 72px 0 auto 0; flex-direction: column; align-items: flex-start; gap: 0; padding: 1rem 1.5rem 2rem; background: var(--sand); border-bottom: 1px solid var(--stone); transform: translateY(-12px); opacity: 0; visibility: hidden; transition: opacity .35s var(--ease), transform .35s var(--ease), visibility .35s; }
  .site-nav.open { transform: none; opacity: 1; visibility: visible; }
  .site-nav a { font-family: var(--serif); font-size: 1.6rem; padding: .5rem 0; width: 100%; }
  .site-nav a::after { display: none; }
  .nav-cta { margin-top: 1rem; text-align: center; font-family: var(--sans) !important; font-size: 1rem !important; padding: .8rem !important; }
  .hero-grid, .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .hero-visual { max-width: 460px; margin: 0 auto; width: 100%; }
  .scroll-cue { display: none; }
  .about-img { max-width: 440px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { width: min(1180px, 100% - 2.5rem); }
  .gallery { grid-template-columns: 1fr 1fr; grid-auto-rows: 170px; gap: .6rem; }
  .tile.wide { grid-column: span 2; }
  .tile-meta { opacity: 1; transform: none; font-size: 1.05rem; padding: 2rem .8rem .7rem; }
  .tile-meta small { display: none; }
  .stats dd { font-size: 2.1rem; }
  .hero-actions .btn { flex: 1 1 auto; }
  .lightbox { padding: 4rem .75rem; }
  .lb-nav { top: auto; bottom: 1rem; transform: none; }
  .lb-prev { left: calc(50% - 60px); }
  .lb-next { right: calc(50% - 60px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal, .fade-up { opacity: 1; transform: none; }
}
@END
@@WRITE app.js
document.addEventListener("DOMContentLoaded", function () {
  var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  document.getElementById("year").textContent = new Date().getFullYear();

  /* Header shadow + mobile menu */
  var header = document.querySelector(".site-header");
  var toggle = document.querySelector(".menu-toggle");
  var nav = document.getElementById("site-nav");
  function onScroll() { header.classList.toggle("scrolled", window.scrollY > 10); }
  window.addEventListener("scroll", onScroll, { passive: true });
  onScroll();

  function setMenu(open) {
    nav.classList.toggle("open", open);
    toggle.setAttribute("aria-expanded", String(open));
    toggle.setAttribute("aria-label", open ? "Close menu" : "Open menu");
  }
  toggle.addEventListener("click", function () { setMenu(!nav.classList.contains("open")); });
  nav.querySelectorAll("a").forEach(function (a) { a.addEventListener("click", function () { setMenu(false); }); });

  /* Active nav link */
  var navLinks = Array.prototype.slice.call(nav.querySelectorAll("a[href^='#']"));
  if ("IntersectionObserver" in window) {
    var secObs = new IntersectionObserver(function (entries) {
      entries.forEach(function (e) {
        if (e.isIntersecting) {
          navLinks.forEach(function (l) { l.classList.toggle("active", l.getAttribute("href") === "#" + e.target.id); });
        }
      });
    }, { rootMargin: "-45% 0px -50% 0px" });
    document.querySelectorAll("main section[id]").forEach(function (s) { secObs.observe(s); });
  }

  /* Scroll reveal + count-up */
  var reveals = document.querySelectorAll(".reveal");
  function countUp(el) {
    var target = parseInt(el.getAttribute("data-count"), 10);
    if (reduceMotion) { el.textContent = target; return; }
    var start = null;
    function step(ts) {
      if (!start) start = ts;
      var p = Math.min((ts - start) / 1600, 1);
      el.textContent = Math.round(target * (1 - Math.pow(1 - p, 3)));
      if (p < 1) requestAnimationFrame(step);
    }
    requestAnimationFrame(step);
  }
  if ("IntersectionObserver" in window && !reduceMotion) {
    var obs = new IntersectionObserver(function (entries) {
      entries.forEach(function (e) {
        if (e.isIntersecting) {
          e.target.classList.add("in");
          e.target.querySelectorAll("[data-count]").forEach(countUp);
          obs.unobserve(e.target);
        }
      });
    }, { threshold: 0.12, rootMargin: "0px 0px -40px 0px" });
    reveals.forEach(function (el) { obs.observe(el); });
  } else {
    reveals.forEach(function (el) { el.classList.add("in"); });
  }

  /* Gallery filter */
  var tiles = Array.prototype.slice.call(document.querySelectorAll(".tile"));
  var filters = document.querySelectorAll(".filter");
  var empty = document.getElementById("gallery-empty");
  filters.forEach(function (btn) {
    btn.addEventListener("click", function () {
      var f = btn.getAttribute("data-filter");
      filters.forEach(function (b) {
        var on = b === btn;
        b.classList.toggle("is-active", on);
        b.setAttribute("aria-pressed", String(on));
      });
      var shown = 0;
      tiles.forEach(function (t, i) {
        var match = f === "all" || t.getAttribute("data-cat") === f;
        t.classList.toggle("hide", !match);
        t.classList.remove("pop");
        if (match) {
          shown++;
          void t.offsetWidth;
          t.style.animationDelay = (shown * 0.05) + "s";
          t.classList.add("pop");
        }
      });
      empty.hidden = shown > 0;
    });
  });

  /* Lightbox */
  var lb = document.getElementById("lightbox");
  var lbImg = document.getElementById("lb-img");
  var lbCap = document.getElementById("lb-cap");
  var current = 0, lastFocus = null;
  function visibleTiles() { return tiles.filter(function (t) { return !t.classList.contains("hide"); }); }
  function show(i) {
    var list = visibleTiles();
    if (!list.length) return;
    current = (i + list.length) % list.length;
    var btn = list[current].querySelector(".tile-btn");
    var thumb = btn.querySelector("img");
    lbImg.classList.add("loading");
    lbImg.onload = function () { lbImg.classList.remove("loading"); };
    lbImg.onerror = function () { lbImg.classList.remove("loading"); lbImg.src = thumb.src; };
    lbImg.src = btn.getAttribute("data-full");
    lbImg.alt = thumb.alt;
    lbCap.textContent = btn.getAttribute("data-caption");
  }
  function openLb(i) {
    lastFocus = document.activeElement;
    show(i);
    lb.hidden = false;
    document.body.classList.add("no-scroll");
    requestAnimationFrame(function () { lb.classList.add("open"); });
    lb.querySelector(".lb-close").focus();
  }
  function closeLb() {
    lb.classList.remove("open");
    document.body.classList.remove("no-scroll");
    setTimeout(function () { lb.hidden = true; }, reduceMotion ? 0 : 350);
    if (lastFocus) lastFocus.focus();
  }
  tiles.forEach(function (t) {
    t.querySelector(".tile-btn").addEventListener("click", function () { openLb(visibleTiles().indexOf(t)); });
  });
  lb.querySelector(".lb-close").addEventListener("click", closeLb);
  lb.querySelector(".lb-prev").addEventListener("click", function () { show(current - 1); });
  lb.querySelector(".lb-next").addEventListener("click", function () { show(current + 1); });
  lb.addEventListener("click", function (e) { if (e.target === lb) closeLb(); });
  document.addEventListener("keydown", function (e) {
    if (e.key === "Escape" && nav.classList.contains("open")) setMenu(false);
    if (lb.hidden) return;
    if (e.key === "Escape") closeLb();
    else if (e.key === "ArrowRight") show(current + 1);
    else if (e.key === "ArrowLeft") show(current - 1);
    else if (e.key === "Tab") {
      var f = lb.querySelectorAll("button");
      var first = f[0], last = f[f.length - 1];
      if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
      else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
    }
  });
  var touchX = null;
  lb.addEventListener("touchstart", function (e) { touchX = e.touches[0].clientX; }, { passive: true });
  lb.addEventListener("touchend", function (e) {
    if (touchX === null) return;
    var dx = e.changedTouches[0].clientX - touchX;
    if (Math.abs(dx) > 50) show(current + (dx < 0 ? 1 : -1));
    touchX = null;
  });

  /* Testimonials */
  var quotes = document.querySelectorAll(".quote");
  var dots = document.querySelectorAll(".quote-dots button");
  var qi = 0, timer = null;
  function setQuote(i) {
    qi = (i + quotes.length) % quotes.length;
    quotes.forEach(function (q, n) { q.classList.toggle("is-active", n === qi); });
    dots.forEach(function (d, n) { if (n === qi) d.setAttribute("aria-current", "true"); else d.removeAttribute("aria-current"); });
  }
  function startAuto() { if (!reduceMotion) { clearInterval(timer); timer = setInterval(function () { setQuote(qi + 1); }, 6500); } }
  dots.forEach(function (d, n) { d.addEventListener("click", function () { setQuote(n); startAuto(); }); });
  var slider = document.querySelector(".quote-slider");
  slider.addEventListener("mouseenter", function () { clearInterval(timer); });
  slider.addEventListener("mouseleave", startAuto);
  startAuto();

  /* Contact form */
  var form = document.getElementById("contact-form");
  var status = document.getElementById("form-status");
  function validate(input) {
    var field = input.closest(".field");
    var err = field.querySelector(".error");
    var msg = "";
    var v = input.value.trim();
    if (!v) msg = "Please fill this in.";
    else if (input.type === "email" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)) msg = "That email doesn't look quite right.";
    else if (input.minLength > 0 && v.length < input.minLength) msg = "A few more words would help (10+ characters).";
    field.classList.toggle("invalid", !!msg);
    input.setAttribute("aria-invalid", msg ? "true" : "false");
    if (err) err.textContent = msg;
    return !msg;
  }
  var required = form.querySelectorAll("[required]");
  required.forEach(function (input) {
    input.addEventListener("blur", function () { if (input.value) validate(input); });
    input.addEventListener("input", function () { if (input.closest(".field").classList.contains("invalid")) validate(input); });
  });
  form.addEventListener("submit", function (e) {
    e.preventDefault();
    var ok = true, firstBad = null;
    required.forEach(function (input) { if (!validate(input)) { ok = false; firstBad = firstBad || input; } });
    if (!ok) { status.textContent = ""; firstBad.focus(); return; }
    var btn = form.querySelector("button[type=submit]");
    btn.disabled = true;
    btn.textContent = "Sending…";
    status.textContent = "";
    setTimeout(function () {
      var name = form.name.value.trim().split(" ")[0];
      form.reset();
      btn.disabled = false;
      btn.textContent = "Send enquiry";
      status.textContent = "Thank you, " + name + " — your note is on its way. I'll be in touch within two working days.";
    }, 1100);
  });
});