/* ============================================================
   Liberty Fence LLC — design system
   Palette from the brand's royal-blue job-site sign.
   Display: Big Shoulders. Body: Public Sans.
   Signature motif: star-rail (thin rail line broken by a star).
   ============================================================ */

:root {
  /* color */
  --ink: #101b2d;
  --navy: #16305b;
  --royal: #2557a7;
  --red: #b3282d;
  --paper: #f5f3ed;
  --white: #ffffff;
  --steel: #93a5bf;
  --line: rgba(16, 27, 45, 0.14);
  --line-light: rgba(245, 243, 237, 0.18);

  /* type */
  --display: "Big Shoulders", "Arial Narrow", sans-serif;
  --body: "Public Sans", Georgia, sans-serif;

  /* scale */
  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2.5rem;
  --s5: 4rem;
  --s6: 6rem;
  --measure: 62ch;
  --wrap: 1160px;

  /* misc */
  --radius: 6px;
  --shadow: 0 10px 30px rgba(16, 27, 45, 0.16);
  --speed: 240ms;
  --ease: cubic-bezier(0.33, 1, 0.68, 1);
  --header-h: 72px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--royal); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--royal);
  outline-offset: 2px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin: 0 0 var(--s2);
  text-wrap: balance;
}
h1 { font-size: clamp(2.9rem, 7.5vw, 5.4rem); }
h2 { font-size: clamp(2.1rem, 4.4vw, 3.4rem); }
h3 { font-size: clamp(1.35rem, 2.4vw, 1.8rem); letter-spacing: 0.02em; }
p { margin: 0 0 var(--s2); max-width: var(--measure); }

.wrap { width: min(var(--wrap), 100% - 2.5rem); margin-inline: auto; }

section { padding-block: clamp(3.5rem, 8vw, 6rem); }

/* ---------- signature: star-rail ---------- */
.star-rail {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: var(--s3);
}
.star-rail::before,
.star-rail::after {
  content: "";
  height: 3px;
  background: currentColor;
  opacity: 0.35;
}
.star-rail::before { width: 3.2rem; }
.star-rail::after { flex: 0 0 3.2rem; }
.star-rail svg { flex: none; width: 18px; height: 18px; fill: var(--red); }
.star-rail .eyebrow {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
}
.on-dark .star-rail svg { fill: #e0574f; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0.75rem 1.6rem 0.85rem;
  cursor: pointer;
  transition: transform var(--speed) var(--ease), background var(--speed) var(--ease),
    color var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn-red { background: var(--red); color: var(--white); }
.btn-red:hover { background: #99181d; }
.btn-ghost { background: transparent; color: var(--white); border-color: var(--white); }
.btn-ghost:hover { background: var(--white); color: var(--navy); }
.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { background: var(--royal); }

/* ---------- header (hide on scroll) ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  height: var(--header-h);
  /* NOTE: no backdrop-filter here. It would create a containing block,
     trapping the fixed fullscreen mobile nav inside the header bar. */
  background: rgba(16, 27, 45, 0.97);
  color: var(--paper);
  transition: transform 260ms ease-out;
}
.site-header.header-hidden { transform: translateY(-100%); }
.site-header .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.65rem;
  letter-spacing: 0.05em;
  color: var(--paper);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
}
.brand svg { width: 17px; height: 17px; fill: var(--red); }
.brand span { color: var(--steel); font-weight: 500; }

.main-nav { display: flex; align-items: center; gap: 1.6rem; }
.main-nav a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.08rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--paper);
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 3px solid transparent;
  transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.main-nav a:hover { color: var(--white); border-color: var(--red); }
.main-nav a[aria-current="page"] { border-color: var(--red); }
.nav-phone { display: inline-flex; align-items: center; gap: 0.45rem; }
.nav-phone svg { width: 15px; height: 15px; fill: currentColor; }

.menu-btn {
  display: none;
  background: none;
  border: 2px solid var(--line-light);
  border-radius: var(--radius);
  color: var(--paper);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: min(92vh, 860px);
  display: flex;
  align-items: flex-end;
  color: var(--white);
  isolation: isolate;
  padding-block: 0;
}
.hero-img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  /* WCAG AA scrim: darkest where headline + trust facts sit */
  background: linear-gradient(
    to top,
    rgba(16, 27, 45, 0.92) 0%,
    rgba(16, 27, 45, 0.62) 38%,
    rgba(16, 27, 45, 0.28) 68%,
    rgba(16, 27, 45, 0.55) 100%
  );
}
.hero .wrap { padding-block: calc(var(--header-h) + 3rem) 3.2rem; }
.hero h1 {
  margin-bottom: var(--s2);
  text-shadow: 0 2px 14px rgba(16, 27, 45, 0.55);
}
.hero h1 em {
  font-style: normal;
  color: #f0b6b3;
}
.hero .lede {
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  max-width: 46ch;
  text-shadow: 0 1px 8px rgba(16, 27, 45, 0.6);
  margin-bottom: var(--s3);
}
.hero-ctas { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }
.trust-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2.2rem;
  border-top: 1px solid var(--line-light);
  padding-top: var(--s2);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 1px 6px rgba(16, 27, 45, 0.7);
}
.trust-bar li { list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.trust-bar svg { width: 13px; height: 13px; fill: var(--red); }
.trust-bar { margin: 0; padding-left: 0; }

/* ---------- services grid ---------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s3);
}
.service-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--navy);
  color: var(--white);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: 4 / 3;
  isolation: isolate;
  box-shadow: var(--shadow);
}
.service-card img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 480ms var(--ease);
}
.service-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, rgba(16, 27, 45, 0.88) 8%, rgba(16, 27, 45, 0.15) 55%);
  transition: background var(--speed) var(--ease);
}
.service-card:hover img { transform: scale(1.045); }
.service-card:hover .card-title { border-color: var(--red); }
.card-body { padding: var(--s3); }
.card-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 3px solid transparent;
  display: inline-block;
  transition: border-color var(--speed) var(--ease);
}
.card-sub { font-size: 0.95rem; color: #d8dfeb; margin: 0.35rem 0 0; max-width: none; }

/* ---------- split sections ---------- */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.split.flip > .split-media { order: 2; }
.split-media img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  object-fit: cover;
}
.fact-list { list-style: none; padding: 0; margin: 0 0 var(--s3); }
.fact-list li {
  padding: 0.55rem 0 0.55rem 1.7rem;
  position: relative;
  border-bottom: 1px solid var(--line);
}
.fact-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05rem;
  width: 10px;
  height: 10px;
  background: var(--red);
  clip-path: polygon(50% 0, 63% 35%, 100% 38%, 71% 60%, 82% 100%, 50% 76%, 18% 100%, 29% 60%, 0 38%, 37% 35%);
}
.on-dark .fact-list li { border-color: var(--line-light); }

/* ---------- dark bands ---------- */
.on-dark { background: var(--navy); color: var(--paper); }
.on-dark p { color: #dbe2ee; }
.band-ink { background: var(--ink); }

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s3);
  text-align: center;
}
.stat b {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 5vw, 4rem);
  line-height: 1;
  color: var(--white);
}
.stat span {
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--steel);
}

/* ---------- before / after ---------- */
.ba-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.ba-item { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ba-item img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }
.ba-tag {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--white);
  background: rgba(16, 27, 45, 0.85);
  padding: 0.3rem 0.8rem;
  border-left: 3px solid var(--red);
  border-radius: 3px;
}
.ba-tag.after { background: var(--red); border-color: var(--white); }

/* ---------- reviews band ---------- */
.ratings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.rating-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 4px solid var(--royal);
  border-radius: var(--radius);
  padding: var(--s3);
}
.rating-card .score {
  font-family: var(--display);
  font-weight: 800;
  font-size: 3rem;
  line-height: 1;
  color: var(--navy);
}
.rating-card .stars { color: var(--red); letter-spacing: 0.12em; font-size: 1.15rem; }
.rating-card p { font-size: 0.98rem; margin: 0.5rem 0 0; }

/* ---------- service area ---------- */
.area-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; padding: 0; margin: 0 0 var(--s2); list-style: none; }
.area-chips li {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 0.35rem 0.95rem;
}

/* ---------- CTA band ---------- */
.cta-band { text-align: center; }
.cta-band h2 { color: var(--white); }
.cta-band .phone-big {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  color: var(--white);
  text-decoration: none;
  display: inline-block;
  border-bottom: 4px solid var(--red);
  margin-bottom: var(--s3);
}

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
form.estimate { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
}
.field textarea { min-height: 130px; resize: vertical; }
.field .err {
  color: var(--red);
  font-size: 0.85rem;
  min-height: 1.1em;
}
.field input[aria-invalid="true"],
.field select[aria-invalid="true"] { border-color: var(--red); }
.contact-panel {
  background: var(--navy);
  color: var(--paper);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: var(--shadow);
}
.contact-panel h3 { color: var(--white); }
.contact-panel a { color: var(--white); }
.contact-panel dl { margin: 0; }
.contact-panel dt {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--steel);
  margin-top: var(--s2);
}
.contact-panel dd { margin: 0.15rem 0 0; }

/* ---------- projects gallery ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: var(--s3); }
.filter-bar button {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 1.05rem;
  cursor: pointer;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.filter-bar button[aria-pressed="true"] {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}
.gallery button {
  padding: 0;
  border: 0;
  background: var(--navy);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 1;
  box-shadow: 0 4px 14px rgba(16, 27, 45, 0.12);
}
.gallery button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 420ms var(--ease), opacity 420ms var(--ease);
}
.gallery button:hover img { transform: scale(1.05); opacity: 0.92; }
.gallery button.hide { display: none; }

/* ---------- lightbox / modal / toast ---------- */
.lightbox,
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 27, 45, 0.9);
  padding: 1.2rem;
}
.lightbox.open, .modal.open { display: flex; }
.lightbox figure { margin: 0; max-width: min(1100px, 100%); }
.lightbox img {
  max-height: 78vh;
  width: auto;
  max-width: 100%;
  margin-inline: auto;
  border-radius: var(--radius);
}
.lightbox figcaption { color: var(--paper); text-align: center; padding-top: 0.8rem; }
.lb-btn {
  position: absolute;
  background: rgba(245, 243, 237, 0.12);
  border: 1px solid var(--line-light);
  color: var(--white);
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  cursor: pointer;
  transition: background var(--speed) var(--ease);
}
.lb-btn:hover { background: rgba(245, 243, 237, 0.28); }
.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%); }

.modal-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  padding: var(--s4);
  box-shadow: var(--shadow);
  text-align: center;
}
.modal-card h3 { color: var(--navy); }
.modal-actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; margin-top: var(--s3); }

.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.8rem 1.4rem;
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 95;
  transition: transform 320ms var(--ease);
  max-width: min(92vw, 480px);
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- footer ---------- */
.site-footer {
  background: var(--ink);
  color: var(--steel);
  padding-block: var(--s5) var(--s4);
  font-size: 0.95rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: var(--s4);
  margin-bottom: var(--s4);
}
.site-footer h3 { color: var(--paper); font-size: 1.2rem; }
.site-footer a { color: var(--paper); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.footer-legal {
  border-top: 1px solid var(--line-light);
  padding-top: var(--s2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  justify-content: space-between;
}

/* ---------- scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 600ms var(--ease), transform 600ms var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- anchors under fixed header ---------- */
[id] { scroll-margin-top: calc(var(--header-h) + 1rem); }

/* ---------- page hero (interior) ---------- */
.page-hero {
  background: var(--navy);
  color: var(--paper);
  padding-block: calc(var(--header-h) + 3.5rem) 3.5rem;
}
.page-hero p { color: #d5ddea; }

/* ============================================================
   Breakpoints: 640 / 1024 / 1440
   ============================================================ */
@media (max-width: 1024px) {
  .services-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  .split.flip > .split-media { order: 0; }
}

@media (max-width: 640px) {
  :root { --header-h: 62px; }
  .menu-btn { display: inline-block; }
  .main-nav {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: var(--ink);
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    transform: translateX(100%);
    transition: transform 300ms var(--ease);
    z-index: 70;
  }
  .main-nav.open { transform: none; }
  .main-nav a { font-size: 1.6rem; }
  .nav-close {
    position: absolute;
    top: 1.1rem;
    right: 1.25rem;
    background: none;
    border: 2px solid var(--line-light);
    border-radius: var(--radius);
    color: var(--paper);
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
  }
  .hero::after {
    /* heavier mobile scrim per standard: 0.6 to 0.9 */
    background: linear-gradient(
      to top,
      rgba(16, 27, 45, 0.94) 0%,
      rgba(16, 27, 45, 0.72) 42%,
      rgba(16, 27, 45, 0.5) 70%,
      rgba(16, 27, 45, 0.72) 100%
    );
  }
  .services-grid,
  .gallery,
  .ba-pair,
  .ratings { grid-template-columns: 1fr; }
  form.estimate { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: var(--s3) var(--s2); }
  .footer-grid { grid-template-columns: 1fr; }
  .trust-bar { gap: 0.5rem 1.4rem; font-size: 0.95rem; }
}

@media (min-width: 641px) { .nav-close { display: none; } }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-header { transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn, .service-card img, .gallery button img, .toast { transition: none; }
}
