/* ==========================================================================
   SoffitPro — "Glass Rail" header (desktop + mobile)
   Self-contained, scoped under .grail so it never touches the rest of the site.
   Replaces the old .site-header / .nav / .mobile-nav.
   ========================================================================== */
.grail {
  --g-bg-deep: #070B14;
  --g-surface: #0B1220;
  --g-glass:   rgba(13,20,34,.86);
  --g-glass-2: rgba(13,20,34,.95);
  --g-border:  rgba(255,255,255,.09);
  --g-text:    #E8EDF5;
  --g-text-mid:#C3CDDD;
  --g-text-dim:#8B99B0;
  --g-blue:    #2563EB;
  --g-blue-dark:#1D4ED8;
  --g-blue-soft:#7DA9F5;
  --g-gold:    #C89B3C;
  --g-gold-soft:#E4C179;

  position: sticky;
  top: 0;
  z-index: 100;
  font-family: var(--font, "Plus Jakarta Sans", system-ui, sans-serif);
}
.grail *, .grail *::before, .grail *::after { box-sizing: border-box; }

/* ---------- The floating rail ---------- */
.grail__rail {
  position: relative;
  margin: 0;
  width: 100%;
  height: 72px;
  border-radius: 0;
  background: var(--g-glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: none;
  border-bottom: 1px solid var(--g-border);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  transition: height .25s ease, background .25s ease;
}
.grail.is-scrolled .grail__rail {
  height: 62px;
  background: var(--g-glass-2);
}

/* ---------- Brand ---------- */
.grail__brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; flex: none; }
.grail__logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(145deg,#2563EB,#0F2C6B);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.02em;
  box-shadow: 0 6px 16px rgba(37,99,235,.4);
}
.grail__word { color: var(--g-text); font-weight: 800; font-size: 20px; letter-spacing: -.02em; white-space: nowrap; }
.grail__dot { color: var(--g-gold); }

/* ---------- Nav pill ---------- */
.grail__nav {
  display: flex; align-items: center; gap: 2px;
  margin-left: 8px;
  padding: 5px;
  border-radius: 13px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}
.grail__navlink {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 15px; border-radius: 9px;
  font-size: 14px; font-weight: 600; line-height: 1;
  color: var(--g-text-mid); text-decoration: none;
  background: none; border: none; cursor: pointer; white-space: nowrap;
  font-family: inherit;
  transition: background .16s ease, color .16s ease;
}
.grail__navlink:hover { background: rgba(255,255,255,.07); color: var(--g-text); }
.grail__navlink.is-active,
.grail__navlink[aria-current="page"] {
  background: var(--g-blue-dark); color: #fff;
  box-shadow: 0 4px 14px rgba(29,78,216,.45);
}
.grail__caret { width: 14px; height: 14px; transition: transform .18s ease; }
.grail__navlink[aria-expanded="true"] .grail__caret { transform: rotate(180deg); }

/* ---------- Right actions ---------- */
.grail__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.grail__phone {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--g-text-mid); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}
.grail__phone:hover { background: rgba(255,255,255,.06); color: var(--g-text); }
.grail__phone svg { width: 16px; height: 16px; }

.grail__phone-ico {
  display: none;               /* shown when collapsed */
  width: 44px; height: 44px; border-radius: 12px;
  align-items: center; justify-content: center;
  color: var(--g-text-mid);
  border: 1px solid var(--g-border); background: rgba(255,255,255,.03);
  text-decoration: none;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.grail__phone-ico:hover { background: rgba(255,255,255,.07); color: var(--g-text); border-color: rgba(255,255,255,.18); }
.grail__phone-ico svg { width: 18px; height: 18px; }

.grail__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px;
  font-family: inherit; font-weight: 700; font-size: 14px; line-height: 1.05; text-decoration: none;
  cursor: pointer; white-space: nowrap; border: 1px solid transparent;
  transition: background .16s ease, box-shadow .2s ease, transform .14s ease, border-color .16s ease;
}
.grail__btn svg { width: 15px; height: 15px; flex: none; }
.grail__btn--gold { color: var(--g-gold-soft); border-color: rgba(200,155,60,.5); background: rgba(200,155,60,.06); }
.grail__btn--gold:hover { background: rgba(200,155,60,.14); border-color: rgba(200,155,60,.8); }
.grail__btn--blue { color: #fff; background: var(--g-blue); box-shadow: 0 8px 22px rgba(37,99,235,.4); }
.grail__btn--blue:hover { background: #3B82F6; }

/* ---------- Hamburger (mobile) ---------- */
.grail__burger {
  display: none;               /* shown on mobile */
  width: 44px; height: 44px; border-radius: 12px;
  align-items: center; justify-content: center; gap: 4px; flex-direction: column;
  background: var(--g-blue); border: none; cursor: pointer;
}
.grail__burger span { width: 16px; height: 2px; border-radius: 2px; background: #fff; }

/* ---------- Mega-menu (Services) ---------- */
.grail__mega {
  position: absolute;
  left: 24px; right: 24px; top: 76px;
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0,0,0,.5);
  padding: 22px;
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.grail.is-scrolled .grail__mega { top: 66px; }
.grail__mega.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.grail__mega[hidden] { display: none; }

.grail__mega-grid { display: grid; grid-template-columns: 1fr 300px; gap: 22px; }
.grail__mega-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--g-text-dim); margin-bottom: 16px;
}
.grail__mega-items { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px 14px; }
.grail__mega-item {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 12px; border-radius: 12px; text-decoration: none;
  transition: background .16s ease;
}
.grail__mega-item:hover { background: rgba(37,99,235,.13); }
.grail__mega-ico {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: rgba(37,99,235,.18); border: 1px solid rgba(125,169,245,.3);
  color: var(--g-blue-soft);
}
.grail__mega-ico svg { width: 17px; height: 17px; }
.grail__mega-item--gold .grail__mega-ico { background: rgba(200,155,60,.16); border-color: rgba(200,155,60,.4); color: var(--g-gold-soft); }
.grail__mega-title { display: block; color: var(--g-text); font-weight: 700; font-size: 14px; }
.grail__mega-desc  { display: block; color: var(--g-text-dim); font-size: 12.5px; margin-top: 3px; line-height: 1.4; }

.grail__mega-card {
  border-radius: 16px; padding: 22px;
  background: linear-gradient(160deg, rgba(37,99,235,.22), rgba(200,155,60,.1));
  border: 1px solid var(--g-border);
  display: flex; flex-direction: column;
}
.grail__mega-cardkick { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--g-gold-soft); }
.grail__mega-cardtitle { color: var(--g-text); font-weight: 800; font-size: 21px; line-height: 1.15; letter-spacing: -.02em; margin: 10px 0 0; }
.grail__mega-cardtext { color: var(--g-text-mid); font-size: 13.5px; line-height: 1.5; margin: 10px 0 18px; }
.grail__mega-cardbtn {
  margin-top: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 12px;
  background: #fff; color: #0B1220; font-weight: 700; font-size: 14px; text-decoration: none;
  transition: background .16s ease;
}
.grail__mega-cardbtn:hover { background: #EEF2FF; }
.grail__mega-cardbtn svg { width: 15px; height: 15px; }

/* ---------- Mobile drawer ---------- */
.grail__backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4,7,14,.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .26s ease;
}
.grail__backdrop.is-open { opacity: 1; pointer-events: auto; }

.grail__drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95;
  width: min(340px, 88vw);
  background: var(--g-surface);
  border-left: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column;
  transform: translateX(24px); opacity: 0; pointer-events: none;
  transition: transform .26s cubic-bezier(.22,1,.36,1), opacity .26s ease;
}
.grail__drawer.is-open { transform: translateX(0); opacity: 1; pointer-events: auto; }

.grail__drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.grail__drawer-label { font-size: 11px; font-weight: 700; letter-spacing: .18em; color: #6C7C96; }
.grail__drawer-close {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.05); border: 1px solid var(--g-border); color: var(--g-text-mid); cursor: pointer;
}
.grail__drawer-close svg { width: 20px; height: 20px; }

.grail__drawer-nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.grail__m-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 14px; border-radius: 13px;
  color: var(--g-text); font-weight: 600; font-size: 17px; text-decoration: none;
  background: none; border: none; width: 100%; cursor: pointer; font-family: inherit; text-align: left;
}
.grail__m-link:hover { background: rgba(255,255,255,.05); }
.grail__m-link.is-active,
.grail__m-link[aria-current="page"] { background: rgba(37,99,235,.16); color: #fff; }
.grail__m-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--g-blue-soft); }
.grail__m-login { color: var(--g-text-mid); font-size: 15px; }

.grail__m-plus { font-size: 20px; color: var(--g-text-dim); font-weight: 400; line-height: 1; }
.grail__m-accbtn[aria-expanded="true"] .grail__m-plus { color: var(--g-blue-soft); }
.grail__m-sub {
  display: flex; flex-direction: column;
  margin: 2px 0 6px 14px; padding-left: 12px;
  border-left: 2px solid rgba(37,99,235,.5);
}
.grail__m-sub[hidden] { display: none; }
.grail__m-sub a { padding: 11px 6px; color: #9FADC4; font-size: 15px; text-decoration: none; }
.grail__m-sub a:hover { color: var(--g-text); }

.grail__drawer-foot {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--g-border);
  display: flex; flex-direction: column; gap: 10px;
}
.grail__btn--full { width: 100%; height: 52px; padding: 0 18px; font-size: 15px; }
.grail__drawer-phone {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 44px; color: var(--g-text-mid); font-weight: 700; font-size: 15px; text-decoration: none;
}
.grail__drawer-phone svg { width: 17px; height: 17px; }

/* ---------- Cascade-in for drawer items ---------- */
.grail__drawer.is-open .grail__drawer-nav > * { animation: grailFadeUp .32s both; }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(1){ animation-delay:.03s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(2){ animation-delay:.07s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(3){ animation-delay:.11s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(4){ animation-delay:.15s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(5){ animation-delay:.19s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(6){ animation-delay:.23s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(7){ animation-delay:.27s }
.grail__drawer.is-open .grail__drawer-nav > *:nth-child(8){ animation-delay:.31s }
@keyframes grailFadeUp { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }

/* ==========================================================================
   Responsive collapse — viewport @media (spec thresholds are viewport px).
   ≤1200 phone→icon · ≤1040 hide Instant Estimate · ≤900 → mobile hamburger.
   ========================================================================== */
@media (max-width: 1200px) {
  .grail__phone { display: none; }
  .grail__phone-ico { display: inline-flex; }
}
@media (max-width: 1040px) {
  .grail__actions .grail__btn--gold { display: none; }
}
@media (max-width: 900px) {
  .grail__rail { margin: 0; height: 60px; border-radius: 0; gap: 10px; padding: 0 14px; }
  .grail__nav { display: none; }
  .grail__actions .grail__btn--blue { display: none; }
  .grail__word { font-size: 18px; }
  .grail__phone-ico { display: inline-flex; }   /* outlined phone stays */
  .grail__burger { display: inline-flex; }
  .grail__mega { display: none !important; }     /* mega never on mobile */
}
@media (min-width: 901px) {
  .grail__drawer, .grail__backdrop { display: none; }   /* drawer is mobile-only */
}

/* Desktop hides the icon-phone until the collapse breakpoints turn it on */
@media (min-width: 1201px) { .grail__phone-ico { display: none; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .grail__rail, .grail__mega, .grail__drawer, .grail__backdrop { transition: none; }
  .grail__drawer.is-open .grail__drawer-nav > * { animation: none; }
}
