/* ============================================
   glass.css — Translucent "liquid glass" surfaces

   backdrop-filter is limited to three components:
   the header, the mobile nav panel, and the contact form.
   Every other surface uses a semi-transparent fill.
   ============================================ */

/* 1. GLASS HEADER */
.site-header {
  background: transparent;
  /* TRAP — a `backdrop-filter` HERE would make this element a "backdrop root",
     and per Filter Effects L2 no DOM ancestor of a backdrop root contributes to
     its backdrop image. The mobile nav panel is a DESCENDANT of this header, so
     with the filter on this element the panel's own backdrop-filter was inert:
     blur(2px), blur(8px), blur(16px), blur(40px) and none all produced
     identical pixels, and the only symptom was "the dropdown is not blurred".
     Chromium and Safari both refuse the nesting (Gecko allows it), so it failed
     differently by browser. The header's frost therefore lives on ::below
     instead, which is a sibling of .header-inner rather than an ancestor of the
     panel. Do NOT move it back onto .site-header, and do not add a fourth
     backdrop-filter surface inside this header. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  transform: translateZ(0);
  border-radius: var(--radius-md);
  margin: var(--space-xs);
  width: calc(100% - 16px);
  transition: background-color var(--duration-medium) ease, box-shadow var(--duration-medium) ease;
}
/* `z-index: -1` is safe because `transform: translateZ(0)` above already makes
   .site-header a stacking context, which pins this pseudo-element inside it —
   it cannot escape and paint behind the page. Without that transform this would
   need `isolation: isolate` instead. The header's own background is painted
   first, so the ::before's backdrop is (page + uniform fill); blurring a
   uniform fill changes nothing, so this is visually identical to filtering
   .site-header directly. */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: -1;
}
.site-header.is-scrolled {
  background: var(--glass-band);
  box-shadow: var(--glass-inset-highlight), 0 1px 0 var(--header-border);
}

/* 2. GLASS NAVIGATION */
.primary-nav > a:not(.nav-cta) {
  position: relative;
  padding: var(--space-xs) 14px;
  border-radius: var(--radius-pill);
  transition: color var(--duration-fast), background var(--duration-fast), box-shadow var(--duration-fast);
}
.primary-nav > a:not(.nav-cta):hover {
  background: var(--glass-bg);
  box-shadow: var(--glass-inset-highlight);
}

/* Mobile nav — glass dropdown panel */
@media (max-width: 840px) {
  /* No override of the header's filter is needed here any more: it lives on
     `.site-header::before`, which is not an ancestor of this panel, so the panel
     is free to be its own backdrop root. If you ever reintroduce
     `backdrop-filter` on `.site-header` itself, this panel goes inert again with
     no visible error — see the trap note above. */

  .js .primary-nav {
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-inset-highlight), var(--glass-shadow);
    /* The fill is ~1.06:1 against the page, so the border is what actually
       defines this panel's shape. --border-strong is the 3:1 control-boundary
       token and a dropdown is a control surface. */
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    /* Was `0 var(--space-xs)`. The panel hangs inside a header that is itself
       inset by 8px, so that margin made it 8px narrower than the bar above it —
       two misaligned rounded cards stacked on each other. Full-bleed now. */
    margin: 0;
    /* A thumb landing on the panel was scrolling the page behind it, so a tap
       landed somewhere else. One declaration, no JS, no layout shift. */
    overscroll-behavior: contain;
  }

  /* Desktop pill styling leaking into the dropdown: border-radius: 999px above
     plus responsive.css's bottom border draws a full-width shallow arc, so each
     38px-tall row renders as its own outlined pill inside a menu. Also has to
     restate the padding — `.primary-nav > a:not(.nav-cta)` above is the SAME
     (0,2,1) specificity and loads later, so it silently beat responsive.css's
     `14px 5px` and left every nav link 38.3px tall, under the 44px thumb
     target. One rule, two overrides of an earlier file. */
  .js .primary-nav > a:not(.nav-cta) {
    padding: 15px 14px;
    border-radius: 0;
  }
}

/* 2b. THE FIELD UNDER THE MATERIAL — a translucent panel over a flat page has
   nothing to bend. Without this wash the pale cards read as white rectangles
   with faint borders however much blur is spent on them; with it, the colour
   shifts faintly through the surfaces as the page moves. */
body {
  background-image: var(--page-wash);
  background-attachment: fixed;
}

/* 3. SERVICE CARDS — translucent fill only (no backdrop-filter) */
.service-card {
  background: var(--glass-tint-frost);
  border: 1px solid var(--glass-edge-line);
  box-shadow: var(--glass-inset-highlight), inset 0 -1px 0 var(--glass-thickness), var(--glass-shadow);
  /* `translate` and `scale` are here because effects.css moves the card with
     them on hover: a `transform` in that transition would not be reached while
     the entrance animation's filled end state outranks it. */
  transition: background var(--duration-fast) ease, box-shadow var(--duration-fast) ease, translate var(--duration-medium) var(--ease-premium), scale var(--duration-medium) var(--ease-premium);
}
.service-card:hover {
  background: var(--glass-bg-hover);
  box-shadow: var(--glass-inset-highlight), inset 0 -1px 0 var(--glass-thickness), var(--glass-shadow-raise);
}

/* 4. GLASS CONTACT FORM */
.contact-form {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur-medium);
  -webkit-backdrop-filter: var(--glass-blur-medium);
  box-shadow: var(--glass-inset-highlight), var(--glass-shadow);
  transform: translateZ(0);
}

/* Form inputs inherit the form's blur */
.contact-form input:not([type="checkbox"]):not([type="radio"]),
.contact-form textarea {
  background: var(--glass-bg);
  box-shadow: var(--glass-inset-highlight);
  transition: background var(--duration-fast), box-shadow var(--duration-fast);
}
.contact-form input:not([type="checkbox"]):not([type="radio"]):focus,
.contact-form textarea:focus {
  background: var(--glass-bg-hover);
  /* The focus indicator is the outline and nothing else: the 1px inner halo
     that used to be here doubled the ring at a second radius and offset. The
     inset highlight is the material's own top hairline, present at rest. */
  box-shadow: var(--glass-inset-highlight);
}

/* 5. BUTTONS */
.button-red,
.nav-cta {
  background: linear-gradient(180deg, var(--red-bright) 0%, var(--red) 50%, var(--red-dark) 100%);
  box-shadow: var(--glass-inset-highlight), 0 4px 16px var(--glass-red-glow);
  transition: background var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}
.button-red:hover,
.nav-cta:hover {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  box-shadow: var(--glass-inset-highlight), 0 6px 20px var(--glass-red-glow-hover);
}
.button-outline {
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}
.button-outline:hover {
  background: var(--glass-bg);
  box-shadow: var(--glass-inset-highlight);
}

/* 6. THEME TOGGLE — translucent fill only */
[data-theme-toggle] {
  background: var(--glass-bg);
  border-color: var(--glass-edge-line);
  box-shadow: var(--glass-inset-highlight), var(--glass-shadow);
  transition: border-color var(--duration-fast), background-color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}
[data-theme-toggle]:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-text);
  box-shadow: var(--glass-inset-highlight), var(--glass-shadow-hover);
}
[data-theme-toggle] .theme-toggle__icon {
  filter: drop-shadow(0 0 6px var(--accent-text));
}

/* 7. FOOTER — translucent fill only */
.site-footer {
  background: var(--glass-bg);
}
.footer-bottom {
  box-shadow: var(--glass-inset-highlight);
}

/* 8. DEPTH & LAYERING — top-edge highlight for glass panels */
.service-card::before,
.contact-form::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-edge-line), transparent);
  pointer-events: none;
}

/* 9. PERFORMANCE — solid fallbacks when backdrop-filter is unsupported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  /* `.is-scrolled` has to be in this selector list. `.site-header` alone is
     (0,1,0) and lost to `.site-header.is-scrolled` at (0,2,0) regardless of
     source order, so the moment a visitor scrolled the header went back to
     50%-opaque with no blur and page text showed through it. */
  .site-header,
  .site-header.is-scrolled {
    background: var(--glass-bg-strong-solid);
  }
  @media (max-width: 840px) {
    .js .primary-nav {
      background: var(--glass-bg-strong-solid);
    }
  }
  .contact-form {
    background: var(--glass-bg-solid);
  }
  .contact-form input:not([type="checkbox"]):not([type="radio"]),
  .contact-form textarea {
    background: var(--glass-bg-solid);
  }
  .contact-form input:not([type="checkbox"]):not([type="radio"]):focus,
  .contact-form textarea:focus {
    background: var(--glass-bg-strong-solid);
  }
}
