/* ==========================================================================
   Heichel Plumbing, Inc.
   Layers keep specificity predictable: later layers win, regardless of
   selector weight, so component selectors can stay flat (one class).
   ========================================================================== */
@layer reset, base, layout, components, utilities;

/* ---------- Tokens ---------- */
:root {
  --blue: #1e71c5;
  --blue-dark: #134c85;
  --red: #db1b10;
  --red-on-dark: #ff6b5f; /* red that passes AA on --ink */
  --ink: #252525;
  --paper: #fff;
  --mist: #f4f4f4;

  --font-body: "Merriweather Sans", system-ui, sans-serif;
  --font-head: "Merriweather", Georgia, serif;

  --wrap: 60rem;          /* 960px content width, as before */
  --gutter: 2.5rem;
  --space: clamp(2.5rem, 6vw, 5rem);
  --radius: 10px;
  --pill: 999px;
  --ease: 0.25s ease;
  --header-h: 6.25rem;
}

/* ---------- Reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, h4, p, figure, blockquote, ul { margin: 0; }
  img, video, svg, iframe { display: block; max-width: 100%; }
  img, video { height: auto; }
  button { font: inherit; color: inherit; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important; /* reset-layer override, intentional */
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ---------- Base ---------- */
@layer base {
  html { scroll-padding-top: var(--header-h); }
  body {
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.6 var(--font-body);
    overflow-wrap: break-word;
  }
  h1, h2, h3 { font-family: var(--font-head); font-weight: 900; line-height: 1.3; }
  h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); }
  h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 1.875rem); }
  h3 { font-size: 1.375rem; }
  h1 + *, h2 + *, h3 + * { margin-top: 0.75rem; }
  p + p { margin-top: 1em; }
  a { color: var(--blue); }
  a:hover { color: var(--red); }
  :focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
}

/* ---------- Layout ---------- */
@layer layout {
  .wrap {
    width: min(100% - 2 * var(--gutter), var(--wrap));
    margin-inline: auto;
  }
  .section { padding-block: var(--space); }
  .split {
    display: grid;
    gap: 2.5rem;
    align-items: center;
  }
  @media (min-width: 48em) {
    .split { grid-template-columns: 1fr 1fr; }
  }
}

/* ---------- Components ---------- */
@layer components {

  /* Skip link */
  .skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    background: var(--ink);
    color: var(--paper);
    transform: translateY(-200%);
  }
  .skip-link:focus { transform: none; }

  /* ===== Header & nav (rebuilt from your heichel_nav) ===== */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--paper);
    box-shadow: 0 0 20px -10px #000;
  }
  .site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 1rem;
    width: min(100% - 2 * var(--gutter), 65rem);
    min-height: var(--header-h);
    margin-inline: auto;
    padding-block: 0.625rem;
  }
  .logo { flex: 0 1 18rem; }
  .logo img { width: 100%; max-height: 5rem; }

  .nav-list {
    display: flex;
    align-items: center;
    padding: 0;
    list-style: none;
  }
  .nav-item { position: relative; }

  .nav-link {
    display: block;
    padding: 1rem;
    border: 0;
    background: none;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--ease);
  }
  .nav-link[aria-current="page"],
  .nav-item:has(.sub-link[aria-current="page"]) > .nav-link {
    text-decoration: underline;
    text-underline-offset: 0.4em;
    text-decoration-thickness: 1px;
  }
  .nav-item:hover > .nav-link,
  .nav-item:focus-within > .nav-link { color: var(--blue); }

  /* Dropdown */
  .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 22rem;
    padding: 0 0 1rem;
    list-style: none;
    background: var(--paper);
    border-top: 5px solid var(--blue);
    box-shadow: 0 5px 25px -20px #000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ease), visibility 0s var(--ease);
  }
  .sub-menu::before { /* the little pointer */
    content: "";
    position: absolute;
    top: -15px;
    left: 2rem;
    border: 10px solid transparent;
    border-bottom-color: var(--blue);
    border-top: 0;
  }
  .nav-item:hover > .sub-menu,
  .sub-toggle[aria-expanded="true"] + .sub-menu {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--ease), visibility 0s;
  }
  .sub-link {
    display: block;
    white-space: nowrap;
    padding: 1rem 2rem;
    color: var(--ink);
    text-decoration: none;
    transition: background-color var(--ease), color var(--ease);
  }
  .sub-link:hover,
  .sub-link:focus-visible { background: var(--blue); color: var(--paper); }
  .sub-link[aria-current="page"] { font-weight: 700; }

  .sub-toggle::after { /* chevron: tells sighted users there is a menu */
    content: "";
    display: inline-block;
    width: 0.45em;
    height: 0.45em;
    margin-left: 0.5em;
    border-right: 2px solid;
    border-bottom: 2px solid;
    transform: translateY(-0.2em) rotate(45deg);
  }

  /* Careers pill */
  .nav-cta {
    display: block;
    margin-left: 1rem;
    padding: 0.5rem 2rem;
    border-radius: var(--pill);
    background: var(--blue);
    color: var(--paper);
    font-weight: 700;
    text-decoration: none;
    transition: background-color var(--ease);
  }
  .nav-cta:hover,
  .nav-cta:focus-visible { background: var(--red); color: var(--paper); }
  .nav-cta[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }

  /* Burger (hidden until mobile) */
  .nav-toggle { display: none; }

  /* Tablet: logo centred on top, nav centred below */
  @media (max-width: 60em) {
    .site-header__inner { justify-content: center; padding-block: 1.25rem 0.625rem; }
    .logo { flex-basis: 25rem; text-align: center; }
    .logo img { margin-inline: auto; }
    .site-nav { flex-basis: 100%; margin-top: 0.75rem; }
    .nav-list { justify-content: center; }
  }

  /* Mobile: burger + full-height menu (only when JS can toggle it) */
  @media (max-width: 48em), (max-width: 60em) and (max-height: 48em) and (orientation: landscape) {
    .site-header__inner { --gutter: 1.25rem; justify-content: space-between; padding-block: 0.625rem; }
    .logo { flex: 0 1 70%; }
    .logo img { max-height: 3.75rem; margin-inline: 0; }

    .js .nav-toggle {
      display: grid;
      place-items: center;
      width: 3.125rem;
      height: 3.125rem;
      padding: 0;
      border: 0;
      background: none;
      cursor: pointer;
    }
    .nav-toggle__bars,
    .nav-toggle__bars::before,
    .nav-toggle__bars::after {
      display: block;
      width: 2.5rem;
      height: 5px;
      background: var(--ink);
      transition: transform 0.15s cubic-bezier(0.5, 0, 1, 1), background-color 0s 0.15s;
    }
    .nav-toggle__bars { position: relative; }
    .nav-toggle__bars::before,
    .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
    .nav-toggle__bars::before { top: -10px; }
    .nav-toggle__bars::after { top: 10px; }
    .nav-toggle[aria-expanded="true"] .nav-toggle__bars { background-color: transparent; }
    .nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(10px) rotate(45deg); }
    .nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-10px) rotate(-45deg); }

    .js .site-nav { display: none; }
    .js .site-nav.is-open {
      display: block;
      max-height: calc(100dvh - 5rem);
      overflow-y: auto;
      padding-bottom: 10vh;
    }
    .site-nav { flex-basis: 100%; margin-top: 0; }
    .nav-list { flex-direction: column; align-items: stretch; margin-block: 1.25rem; }
    .nav-link { width: 100%; padding: 1.25rem 2%; text-align: left; }
    .nav-link[aria-current="page"] { font-weight: 700; text-decoration: none; }
    .nav-item:hover > .nav-link,
    .nav-item:focus-within > .nav-link { color: var(--ink); }

    /* Submenu shows expanded inline, as before; no toggle needed */
    .sub-toggle { cursor: default; }
    .sub-toggle::after { display: none; }
    .sub-menu {
      position: static;
      min-width: 0;
      padding: 0 0 0 1.25rem;
      border: 0;
      box-shadow: none;
      opacity: 1;
      visibility: visible;
    }
    .sub-menu::before { display: none; }
    .sub-link { padding: 1.25rem 2%; white-space: normal; }
    .sub-link:hover { background: none; color: var(--blue); }

    .nav-cta {
      max-width: 28rem;
      margin: 2.5rem auto 0;
      padding: 1rem;
      text-align: center;
    }
  }

  /* ===== Buttons ===== */
  .btn {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    border: 1px solid var(--mist);
    border-radius: var(--pill);
    background: var(--paper);
    color: var(--red);
    font-weight: 700;
    text-decoration: none;
    transition: background-color var(--ease), color var(--ease);
  }
  .btn:hover,
  .btn:focus-visible { background: var(--red); color: var(--paper); }

  /* ===== Wave edges (same shape as before) ===== */
  .wave-bottom,
  .wave-top { position: relative; }
  .wave-bottom::after,
  .wave-top::before {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: clamp(2.5rem, 8vw, 6.25rem);
    background: url("/img/wave.svg") center / 100% 100% no-repeat;
    pointer-events: none;
  }
  .wave-bottom::after { bottom: -1px; transform: rotate(180deg); }
  .wave-top::before { top: -1px; }

  /* ===== Hero ===== */
  .hero {
    display: grid;
    place-items: center;
    min-height: 70vh;
    padding-block: 6rem 8rem;
    overflow: hidden;
    background: var(--ink) url("/img/heichel-banner.jpg") center / cover;
    color: var(--paper);
    text-align: center;
    isolation: isolate;
  }
  .hero__video,
  .hero::before { position: absolute; inset: 0; z-index: -1; }
  .hero__video { width: 100%; height: 100%; object-fit: cover; }
  .hero::before { content: ""; z-index: 0; background: rgb(0 0 0 / 0.45); }
  .hero__content { position: relative; z-index: 1; }
  .hero__play {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 0.25rem 0.5rem;
    border: 0;
    background: none;
    color: var(--paper);
    font-size: 1.875rem;
    text-decoration: none;
    font-weight: 300;
    cursor: pointer;
    transition: opacity var(--ease);
  }
  .hero__play svg { width: 1.5em; height: 1.5em; fill: currentColor; }
  .hero__play:hover { opacity: 0.7; }
  .hero__pause {
    position: absolute;
    right: 1.25rem;
    bottom: clamp(3.5rem, 9vw, 7rem);
    z-index: 2;
    padding: 0.4rem 0.9rem;
    border: 1px solid rgb(255 255 255 / 0.7);
    border-radius: var(--pill);
    background: rgb(0 0 0 / 0.5);
    color: var(--paper);
    font-size: 0.875rem;
    cursor: pointer;
  }

  /* ===== Video dialog ===== */
  .video-dialog {
    width: min(92vw, 60rem);
    padding: 0;
    border: 0;
    background: #000;
    overflow: visible;
  }
  .video-dialog::backdrop { background: rgb(0 0 0 / 0.85); }
  .video-dialog iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }
  .video-dialog__close {
    position: absolute;
    top: -2.75rem;
    right: 0;
    padding: 0.25rem 0.5rem;
    border: 0;
    background: none;
    color: var(--paper);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
  }

  /* ===== Mission ===== */
  .mission { text-align: center; }
  .eyebrow {
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .mission h2 { max-width: 50rem; margin-inline: auto; font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); }

  /* ===== Blue band ===== */
  .band-blue {
    padding-top: calc(var(--space) + 3rem);
    background: var(--blue);
    color: var(--paper);
  }
  .band-blue p { font-size: 1.125rem; }
  .band-blue .btn { margin-top: 1.5rem; }
  .band-blue video { width: 100%; border-radius: var(--radius); }

  /* ===== Our Work ===== */
  .work {
    background: radial-gradient(at center bottom, var(--blue) 0%, var(--blue-dark) 100%);
    color: var(--paper);
  }
  .work > .wrap > h2 { margin-bottom: 2rem; text-align: center; }
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1.5rem;
    padding: 0;
    list-style: none;
  }
  .card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
  }
  .card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
  .card__body { padding: 1rem 1.25rem 1.25rem; }
  .card h3 { font-size: 1.125rem; }
  .card a { color: inherit; text-decoration: none; }
  .card a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
  .card:hover h3 { color: var(--blue); }
  .card:focus-within { outline: 3px solid var(--paper); outline-offset: 3px; }
  .card a:focus-visible { outline: none; }
  .card__meta { margin-top: 0.25rem; color: #595959; font-size: 0.9375rem; }

  /* ===== Contact band (site-wide) ===== */
  .contact-band { background: var(--ink); color: var(--paper); }
  .contact-band a { color: var(--paper); }
  .contact-band a:hover { color: var(--red-on-dark); }
  .contact-band :focus-visible { outline-color: var(--paper); }
  .contact-list { margin-top: 1.25rem; padding: 0; list-style: none; }
  .contact-list li + li { margin-top: 0.75rem; }
  .contact-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    text-decoration: none;
  }
  .contact-list a:hover { text-decoration: underline; }
  .icon { width: 1.75rem; height: 1.75rem; flex: none; fill: currentColor; }
  .social {
    display: flex;
    gap: 1.25rem;
    margin-top: 1.5rem;
    padding: 1.5rem 0 0;
    border-top: 1px solid #555;
    list-style: none;
  }
  .social .icon { width: 2rem; height: 2rem; }
  .map { width: 100%; height: 18.75rem; border: 0; border-radius: var(--radius); }

  /* ===== Inner pages ===== */
  .section--flush-top { padding-top: 0; }
  .section--mist { background: var(--mist); }
  .section-title { margin-bottom: 2rem; text-align: center; }

  .page-head {
    padding-block: var(--space) 2.5rem;
    text-align: center;
  }
  .page-head__meta { color: #595959; }
  .seal { margin: 0 auto 1.5rem; }

  .page-hero { /* service banners: photo, dark overlay, wave edge */
    display: grid;
    place-items: center;
    min-height: 40vh;
    padding-block: 5rem 7rem;
    background: linear-gradient(rgb(0 0 0 / 0.5), rgb(0 0 0 / 0.5)), var(--bg, none) center / cover, var(--ink);
    color: var(--paper);
    text-align: center;
  }

  .prose { max-width: 46rem; }
  .prose > * + * { margin-top: 1rem; }
  .prose > h2,
  .prose > h3 { margin-top: 2.5rem; }
  .prose ul { padding-left: 1.25rem; }
  .prose li + li { margin-top: 0.4rem; }
  .prose blockquote {
    padding: 0.25rem 0 0.25rem 1.5rem;
    border-left: 5px solid var(--blue);
    font-size: 1.25rem;
    font-style: italic;
  }

  .full-bleed { width: 100%; max-height: 32rem; object-fit: cover; }
  .figure { width: 100%; border-radius: var(--radius); }

  .link-list { padding: 0; list-style: none; }
  .link-list a {
    display: block;
    padding: 1rem 0;
    border-bottom: 1px solid #ddd;
    font-size: 1.125rem;
    font-weight: 700;
    text-decoration: none;
  }
  .link-list a:hover { text-decoration: underline; }

  /* Team */
  .team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 2.5rem 2rem;
    padding: 0;
    list-style: none;
  }
  .person img {
    width: 100%;
    max-width: 14rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
  }
  .person h3 { font-size: 1.25rem; }
  .person__role { margin: 0.25rem 0 0.75rem; color: var(--blue); font-weight: 700; }

  /* Contact page */
  .split--top { align-items: start; }
  .contact-card + .contact-card { margin-top: 2rem; }
  .contact-card h2 { font-size: 1.375rem; }
  .contact-line {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 1.125rem;
  }

  /* Careers */
  .btn--blue { border-color: var(--blue); background: var(--blue); color: var(--paper); }
  .embed-video { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius); }
  .jobs-frame { width: 100%; height: 50rem; border: 0; background: var(--paper); }
  .jobs-link { margin-top: 1rem; text-align: center; }

  /* ===== Footer ===== */
  .site-footer {
    padding-block: 1.25rem;
    border-top: 1px solid #dbdbdb;
    background: var(--mist);
    font-size: 0.875rem;
    text-align: center;
  }
}

/* ---------- Utilities ---------- */
@layer utilities {
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
