/* ==========================================================================
   layout.css — page scaffolding: container, header/nav/drawer, footer,
   sticky mobile CTA bar, section rhythm, water-line divider.
   (POOL-SITE-BUILD-PLAN §3, §4.5). Depends on tokens.css.
   ========================================================================== */

/* --- Containers -------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: var(--container-narrow); }

/* --- Section rhythm ---------------------------------------------------- */
.section { padding-block: var(--s16); }
@media (min-width: 768px) { .section { padding-block: var(--s24); } }
.section--tight { padding-block: var(--s12); }

/* ==========================================================================
   Signature element: the water-line (§4.5)
   A hairline in --shallow with a slow, low-amplitude sine drift — still water.
   20s loop, barely perceptible. Static under prefers-reduced-motion.
   ========================================================================== */
/* The wave is a single 120px SVG tile repeated infinitely across the width
   (mask-repeat: repeat-x) — so the line is genuinely never-ending at any
   viewport size. Color comes from --shallow via the mask (no hard-coded hex);
   the tile drifts left by exactly one tile-width per loop, so it seams
   perfectly and appears to flow forever. The tile holds two full periods and
   starts/ends at the same phase, which is what makes the repeat invisible. */
.waterline {
  display: block;
  width: 100%;
  height: 12px;
  background-color: var(--shallow);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='120'%20height='12'%20viewBox='0%200%20120%2012'%20fill='none'%20stroke='white'%20stroke-width='1.5'%3E%3Cpath%20d='M0%206%20Q15%202%2030%206%20T60%206%20T90%206%20T120%206'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='120'%20height='12'%20viewBox='0%200%20120%2012'%20fill='none'%20stroke='white'%20stroke-width='1.5'%3E%3Cpath%20d='M0%206%20Q15%202%2030%206%20T60%206%20T90%206%20T120%206'/%3E%3C/svg%3E");
  -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
  -webkit-mask-position: 0 center; mask-position: 0 center;
  -webkit-mask-size: 120px 100%; mask-size: 120px 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .waterline { animation: waterline-drift var(--waterline-loop) linear infinite; }
}
/* one full tile-width of travel = seamless loop */
@keyframes waterline-drift {
  from { -webkit-mask-position: 0 center;      mask-position: 0 center; }
  to   { -webkit-mask-position: -120px center; mask-position: -120px center; }
}

/* ==========================================================================
   Header + primary nav (§3)
   Desktop: Services ▾ | Plans | Service Areas | Gallery | About | [Quote][Call]
   Mobile:  logo · tap-to-call icon · hamburger  (drawer holds the rest)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--paper);            /* solid white, fully opaque */
  /* No straight border — the header's bottom edge IS the wave (::before/::after). */
}
/* Signature wave edge (§4.5): the navbar's own bottom ripples into water.
   Two synced layers on one 240px path (one broad wave/tile, drifting a tile
   per loop → seamless): ::before = white fill (navbar body dipping into the
   wave, opaque so no photo bleeds) carrying a whisper of drop-shadow for soft
   depth; ::after = a THIN --deep stroke so the edge stays visible on every
   background, including white (a shadow alone vanishes on white). Static under
   prefers-reduced-motion. */
.site-header::before,
.site-header::after {
  content: "";
  position: absolute;
  top: 100%; left: 0; right: 0;
  height: 14px;
  pointer-events: none;
  -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
  -webkit-mask-position: 0 top; mask-position: 0 top;
  -webkit-mask-size: 240px 100%; mask-size: 240px 100%;
}
.site-header::before {
  background: var(--paper);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='240'%20height='14'%20viewBox='0%200%20240%2014'%3E%3Cpath%20fill='white'%20d='M0%207%20Q60%2013%20120%207%20T240%207%20L240%200%20L0%200%20Z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='240'%20height='14'%20viewBox='0%200%20240%2014'%3E%3Cpath%20fill='white'%20d='M0%207%20Q60%2013%20120%207%20T240%207%20L240%200%20L0%200%20Z'/%3E%3C/svg%3E");
  filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--deep) 28%, transparent));
}
/* thin deep line tracing the wavy edge — visible on white too */
.site-header::after {
  background: var(--deep);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='240'%20height='14'%20viewBox='0%200%20240%2014'%3E%3Cpath%20fill='none'%20stroke='white'%20stroke-width='1'%20d='M0%207%20Q60%2013%20120%207%20T240%207'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='240'%20height='14'%20viewBox='0%200%20240%2014'%3E%3Cpath%20fill='none'%20stroke='white'%20stroke-width='1'%20d='M0%207%20Q60%2013%20120%207%20T240%207'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: no-preference) {
  .site-header::before,
  .site-header::after { animation: navbar-wave-drift var(--waterline-loop) linear infinite; }
}
/* one full 240px tile of travel = seamless loop */
@keyframes navbar-wave-drift {
  from { -webkit-mask-position: 0 top;      mask-position: 0 top; }
  to   { -webkit-mask-position: -240px top; mask-position: -240px top; }
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 64px;
  padding-block: var(--s2);
}

.brand { display: inline-flex; align-items: center; gap: var(--s3); flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand__mark { height: 40px; width: auto; }  /* logo art is ~1.18:1 — keep its aspect, don't square it */
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--deep);
  line-height: 1.05;
  letter-spacing: -.01em;
}
/* The wordmark stays visible at every width. On the narrowest screens there
   isn't room for it on one line beside the tap-to-call + hamburger, so it
   wraps to two ("Providence" / "Pool Care" — the nbsp keeps the last two
   together) at a slightly smaller size rather than disappearing. */
@media (max-width: 479px) {
  /* .brand is flex:0 0 auto by default — it must be allowed to shrink here, or
     the wordmark keeps its one-line width and pushes the header off-screen. */
  .brand { flex: 0 1 auto; min-width: 0; }
  .brand__name { font-size: 1rem; min-width: 0; }
}

/* Primary nav (desktop) — hidden until ≥1024px, replaced by the mobile drawer */
.nav { display: none; margin-left: auto; }
.nav__list { display: flex; align-items: center; gap: var(--s2); list-style: none; padding: 0; margin: 0; }
.nav__list li { margin: 0; }  /* cancel base.css `li + li` top-margin leaking in and misaligning items */
.nav__link {
  display: inline-flex; align-items: center; gap: var(--s1);
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  color: var(--deep);
  font-weight: 500;
  border-radius: var(--radius-md);
  position: relative;
}
.nav__link:hover { text-decoration: none; background: color-mix(in srgb, var(--shallow) 35%, transparent); }
/* Active nav item uses the water-line as its underline (§4.5) */
.nav__link[aria-current="page"]::after {
  content: ""; position: absolute; left: var(--s3); right: var(--s3); bottom: 4px;
  height: 2px; border-radius: var(--radius-pill);
  background: var(--shallow);
}

/* Services dropdown — the only dropdown. Two labeled sections (Services +
   Service Areas), no nested submenus, no mega-menu (§3). */
.nav__dropdown { position: relative; }
.nav__panel {
  position: absolute; top: 100%; left: 0;
  /* The header's wave edge (::after) is also an absolutely-positioned,
     z-index:auto box in the same stacking context, and pseudo-::after paints
     after the content — so without this the wave's stroke draws across the
     open panel. Any positive z-index lifts the panel clear of both wave layers. */
  z-index: 1;
  display: none;
  grid-template-columns: 1fr; gap: var(--s4);
  min-width: 240px;
  padding: var(--s4);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: var(--s2) 0 0;
}
/* Open on keyboard focus, or when nav.js marks it open. Hover open/close is
   driven by nav.js with a short close delay (hover-intent), so moving from the
   button down into the menu — across the gap — never flickers it shut. */
.nav__dropdown:focus-within .nav__panel,
.nav__panel[data-open="true"] { display: grid; }
.nav__group ul { list-style: none; padding: 0; margin: 0; }
.nav__group li + li { margin-top: 0; }
.nav__group h3 {
  font-family: var(--font-body);
  font-size: var(--t-micro); text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-muted); font-weight: 700;
  padding: var(--s2) var(--s3) var(--s1); margin: 0;
}
.nav__panel a { display: block; padding: var(--s2) var(--s3); border-radius: var(--radius-md); color: var(--deep); font-weight: 500; }
.nav__panel a:hover { text-decoration: none; background: var(--sand); }
.nav__all { color: var(--water); }

/* Header action cluster — one CTA + a quiet phone link (not a 2nd button) */
.header-actions { display: none; align-items: center; gap: var(--s6); flex: 0 0 auto; }
.header-phone { display: inline-flex; align-items: center; gap: var(--s2); color: var(--deep); font-weight: 600; white-space: nowrap; }
.header-phone svg { width: 18px; height: 18px; color: var(--water); }
.header-phone:hover { text-decoration: none; color: var(--water); }

/* Mobile-only header controls */
.header-mobile { display: inline-flex; align-items: center; gap: var(--s1); margin-left: auto; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--paper); color: var(--deep); cursor: pointer;
}
.icon-btn:hover { background: var(--sand); }
.icon-btn svg { width: 22px; height: 22px; }

/* Desktop / mobile visibility swap */
@media (min-width: 1024px) {
  .nav, .header-actions { display: flex; }
  .header-mobile { display: none; }
}

/* ==========================================================================
   Mobile drawer (§3) — Get a Quote is the first item, full-width
   ========================================================================== */
.drawer {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  visibility: hidden;
}
.drawer[data-open="true"] { visibility: visible; }
.drawer__scrim {
  position: absolute; inset: 0;
  background: rgba(11, 61, 79, .45);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.drawer[data-open="true"] .drawer__scrim { opacity: 1; }
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(88vw, 360px);
  padding: var(--s6) var(--s4) calc(var(--s6) + env(safe-area-inset-bottom));
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s2);
}
.drawer[data-open="true"] .drawer__panel { transform: translateX(0); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); }
.drawer__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s1); }
.drawer__list li { margin: 0; }  /* cancel base.css `li + li` top-margin — it made the first item in each list sit tighter than the rest */
.drawer__list a {
  display: block; padding: var(--s3); min-height: var(--tap);
  color: var(--deep); font-weight: 500; border-radius: var(--radius-md);
}
.drawer__list a:hover { text-decoration: none; background: var(--sand); }
.drawer__sub { padding-left: var(--s4); }
.drawer__sub a { font-weight: 400; color: var(--ink-muted); }

/* ==========================================================================
   Sticky mobile action bar (§3) — highest-leverage conversion element.
   Appears after 400px scroll (JS toggles .is-visible). Safe-area aware.
   ========================================================================== */
.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky-cta);
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2);
  padding: var(--s2) var(--s3);
  padding-bottom: calc(var(--s2) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  transform: translateY(110%);
  transition: transform var(--dur) var(--ease);
}
.sticky-cta.is-visible { transform: translateY(0); }
.sticky-cta .btn { width: 100%; }
@media (min-width: 1024px) { .sticky-cta { display: none; } }

/* ==========================================================================
   Footer (§5.1 #12) — NAP block, hours, service + city links, socials, legal
   ========================================================================== */
.site-footer {
  background: var(--deep);
  color: color-mix(in srgb, var(--on-deep) 82%, transparent);
  padding-block: var(--s16) var(--s8);
  margin-bottom: 72px; /* clearance so sticky-cta never covers footer on mobile */
}
@media (min-width: 1024px) { .site-footer { margin-bottom: 0; } }
.site-footer a { color: color-mix(in srgb, var(--on-deep) 82%, transparent); }
.site-footer a:hover { color: var(--on-deep); }
.footer-grid {
  display: grid; gap: var(--s8);
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
@media (min-width: 1024px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.footer-col h3 { color: var(--on-deep); font-size: var(--t-small); text-transform: uppercase; letter-spacing: .06em; margin-bottom: var(--s3); }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-top: var(--s2); }
.footer-nap { font-style: normal; line-height: var(--lh-body); }
.footer-areas { margin: 0; line-height: var(--lh-body); }
.footer-areas__cta { margin-top: var(--s3); }
.footer-areas__cta a { color: var(--shallow); font-weight: 600; }
.footer-brand__mark { height: 44px; width: auto; margin-bottom: var(--s3); }
.footer-legal {
  display: flex; flex-wrap: wrap; gap: var(--s4);
  margin-top: var(--s12); padding-top: var(--s6);
  border-top: 1px solid color-mix(in srgb, var(--on-deep) 18%, transparent);
  font-size: var(--t-small);
}
.footer-legal__spacer { margin-left: auto; }

/* Build credit — the studio that made the site. Small, but legible enough to
   read as a signature rather than fine print. Specificity beats `.site-footer a`. */
.site-footer .footer-credit {
  display: inline-flex; align-items: center; gap: var(--s2);
  margin-top: var(--s6);
  font-size: var(--t-micro);
  color: color-mix(in srgb, var(--on-deep) 72%, transparent);
}
.site-footer .footer-credit:hover { color: var(--on-deep); text-decoration: none; }
/* The mark is a dark charcoal badge — on the deep-teal footer it needs a light
   disc behind it to read at all. */
.footer-credit__mark {
  width: 28px; height: 28px; flex: 0 0 auto;
  background: var(--on-deep); border-radius: 50%; padding: 3px;
}
.footer-credit strong { font-weight: 600; }
/* AgileRocket wordmark — one word, "Agile" gray + "Rocket" orange, matching the
   email footer (server/templates.mjs). Same deep-teal background there, so the
   gray is a LIGHT one — a mid gray disappears on it.
   These are AgileRocket's brand colours, deliberately NOT the --sun token:
   --sun is reserved for Providence CTAs (accent discipline), and a partner's
   wordmark must not shift if that token is ever retuned. */
.ar-wordmark__agile  { color: #B7BEC2; }
.ar-wordmark__rocket { color: #E8873A; }
