/* =============================================================
   Ben's Gunsmithing — Site Stylesheet (clean-room rewrite)
   "The Working Shop": flat surfaces, sharp corners, earth tones.
   Tokens map 1:1 to DESIGN.md. Shared chrome lives here; per-page
   styles get their own files in later sessions.
   ============================================================= */

/* -------------------------------------------------------------
   1. Design tokens  (DESIGN.md → CSS custom properties)
   ------------------------------------------------------------- */
:root {
  /* --- Color: earth palette pulled from the logo --- */
  --brown-dark: #4A2C0F;     /* Mountain Brown Deep — hero/footer/admin field   */
  --brown: #5B3A1A;          /* Mountain Brown — headings, secondary stroke      */
  --brown-light: #7A5230;
  --green-dark: #3A5520;     /* Workshop Olive Deep — pressed/hover of primary   */
  --green: #4A6B2A;          /* Workshop Olive — THE action color (verb only)    */
  --green-light: #5E8236;
  --cream: #F5F0E8;          /* Cream Paper — default page background             */
  --cream-dark: #E8E0D2;     /* Cream Edge — borders, dividers, inactive strokes */
  --tan: #C4A87A;            /* Trail Tan — warm accents                         */
  --tan-light: #D4C4A0;      /* Trail Tan Light — subtitles on dark fields       */
  --white: #FFFFFF;          /* Sheet White — cards, form fields                 */
  --charcoal: #2D2D2D;       /* Workbench Charcoal — body text (never #000)      */
  --charcoal-light: #4A4A4A; /* secondary body text                              */
  --gray: #777777;           /* tertiary metadata only                           */
  --gray-light: #CCCCCC;
  --red-error: #9B2C2C;      /* the only red — errors only                       */
  --copper-parts: #B87333;   /* "Awaiting Parts" kanban status only              */

  /* --- Typography --- */
  --font-display: 'Bitter', Georgia, 'Times New Roman', serif;  /* headings, nav, labels */
  --font-body: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif; /* running prose         */

  --fs-display: clamp(2.25rem, 5vw, 3rem); /* hero headline            */
  --fs-headline: 2.625rem;                 /* 42px — section openers   */
  --fs-title: 1.625rem;                    /* 26px — card/sub heads    */
  --fs-body: 1.125rem;                     /* 18px — body floor        */
  --fs-small: 1rem;                        /* 16px — smallest allowed  */
  --lh-heading: 1.2;
  --lh-body: 1.65;
  --tracking-label: 0.05em;

  /* --- Corner radius: sharp. 2px default, 4px max. --- */
  --r-none: 0px;
  --r-sm: 2px;
  --r-md: 4px;

  /* --- Spacing scale --- */
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-2xl: 48px;
  --s-3xl: 64px;
  --s-section: 80px;

  /* --- Layout --- */
  --container-max: 1100px; /* public content column */
  --measure: 70ch;         /* prose line-length cap */

  /* --- Motion (honored only where allowed; killed by reduced-motion) --- */
  --transition: 150ms ease;

  /* --- Mobile sticky CTA bar height (reserved as body padding) --- */
  --mobile-cta-h: 60px;
}

/* -------------------------------------------------------------
   2. Reset & base
   ------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--charcoal);
  background-color: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a { color: var(--green); }

button { font: inherit; cursor: pointer; }

/* Body text: capped measure inside prose contexts only. */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--s-md); }

/* -------------------------------------------------------------
   3. Typography helpers
   ------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-heading);
  color: var(--brown-dark);
}

h1 { font-size: var(--fs-headline); }
h2 { font-size: var(--fs-title); }

.display { font-size: var(--fs-display); }

.label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}

.text-small { font-size: var(--fs-small); }

/* Visually-hidden, screen-reader-only (skip-link has its own styles) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------
   4. Layout primitives
   ------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--s-lg);
}

main { flex: 1 0 auto; }

/* Section rhythm — 80px vertical beat; separation comes from a color step
   (cream → white → cream), never a horizontal rule. */
.section { padding-block: var(--s-section); }
.section--alt { background-color: var(--white); }

/* Section opener: left-aligned headline + optional one-line lede. */
.section-head { margin-bottom: var(--s-2xl); }
.section-head__lead {
  margin-top: var(--s-sm);
  max-width: 60ch;
  color: var(--charcoal-light);
}

/* -------------------------------------------------------------
   Interior page header  (shared by service / policies / contact)
   Mountain Brown Deep field, shop photo bleeding from the right,
   title anchored LEFT over the solid-brown side for legibility.
   The photo is set per page via an inline `background-image`
   (image-set) on the element; brown-dark is the fallback field.
   ------------------------------------------------------------- */
.page-header {
  position: relative;
  background-color: var(--brown-dark);
  background-size: cover;
  background-position: center right;
  background-repeat: no-repeat;
  overflow: hidden;
}
/* Scrim: opaque on the left (holds the title), fading to a darkened
   reveal on the right so the photo reads without washing the text. */
.page-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(74, 44, 15, 0.96) 0%,
    rgba(74, 44, 15, 0.92) 42%,
    rgba(74, 44, 15, 0.58) 100%
  );
}
.page-header__inner {
  position: relative; /* above the scrim */
  padding-block: var(--s-2xl);
}
.page-header__title { color: var(--cream); }
.page-header__subtitle {
  margin-top: var(--s-sm);
  max-width: 42ch;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-title);
  line-height: var(--lh-heading);
  color: var(--tan-light);
}

/* Skip link — visible only on keyboard focus */
.skip-link {
  position: absolute;
  left: var(--s-md);
  top: -100px;
  z-index: 1000;
  background: var(--green);
  color: var(--white);
  padding: var(--s-sm) var(--s-md);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus { top: var(--s-md); }

/* -------------------------------------------------------------
   5. Buttons  (flat, sharp, color-swap on hover — no lift)
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-small);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  text-decoration: none;
  padding: 12px 32px;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.btn--primary { background-color: var(--green); color: var(--white); }
.btn--primary:hover { background-color: var(--green-dark); color: var(--white); }

.btn--secondary {
  background-color: var(--cream);
  color: var(--brown);
  border-color: var(--brown);
}
.btn--secondary:hover { background-color: var(--brown); color: var(--white); }

/* On dark photographic fields (hero scrim, brown-deep bands) */
.btn--hero {
  background-color: var(--brown-dark);
  color: var(--cream);
  border-color: var(--cream);
}
.btn--hero:hover { background-color: var(--cream); color: var(--brown-dark); }

.btn--lg { padding: 16px 48px; font-size: var(--fs-body); }

/* -------------------------------------------------------------
   6. Focus-visible — action-color outline, 3px offset
   ------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}
/* On dark fields, a cream ring reads better than olive */
.on-dark :focus-visible { outline-color: var(--cream); }

/* -------------------------------------------------------------
   7. Site header  (sticky, cream, brown top border)
   The one functional shadow in the system lives here.
   ------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--cream);
  border-top: 4px solid var(--brown);
  border-bottom: 1px solid var(--cream-dark);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* functional: content slides under */
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-md);
  min-height: 64px;
}

.site-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--brown-dark);
  text-decoration: none;
  white-space: nowrap;
}
.site-wordmark:hover { color: var(--green); }

/* -------------------------------------------------------------
   8. Primary navigation
   ------------------------------------------------------------- */
.main-nav { display: flex; align-items: center; }

.main-nav__list {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.main-nav__link {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--brown-dark);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border-bottom: 2px solid transparent; /* reserved so active state is layout-stable */
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}
.main-nav__link:hover {
  background-color: var(--cream-dark);
  color: var(--green);
}
/* Active page: olive text + olive underline on a cream-edge highlight */
.main-nav__link[aria-current="page"] {
  background-color: var(--cream-dark);
  color: var(--green);
  border-bottom-color: var(--green);
}

/* Hamburger toggle — hidden on desktop */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 2px solid var(--brown);
  border-radius: var(--r-sm);
  position: relative;
}
.nav-toggle__bar,
.nav-toggle__bar::before,
.nav-toggle__bar::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 22px;
  height: 2px;
  background: var(--brown-dark);
  transform: translateX(-50%);
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle__bar { top: 50%; margin-top: -1px; }
.nav-toggle__bar::before { top: -7px; }
.nav-toggle__bar::after { top: 7px; }
/* Open state → X */
.nav-toggle[aria-expanded="true"] .nav-toggle__bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar::before { top: 0; transform: translateX(-50%) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar::after { top: 0; transform: translateX(-50%) rotate(-45deg); }

/* -------------------------------------------------------------
   9. Mobile navigation  (≤768px)
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  .nav-toggle { display: block; }

  .main-nav__list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background-color: var(--white);
    border-bottom: 3px solid var(--brown);
    padding: var(--s-xs) 0;
  }
  .main-nav__list--open { display: flex; }

  .main-nav__link {
    border-radius: 0;
    border-bottom: 1px solid var(--cream-dark);
    padding: 14px var(--s-lg);
  }
  .main-nav__link:last-child { border-bottom: 0; }
  .main-nav__link[aria-current="page"] { border-bottom-color: var(--cream-dark); }

  .main-nav { position: static; }
  .site-header__inner { position: relative; }
}

/* -------------------------------------------------------------
   10. CTA banner  (olive field, once per page, before footer)
   ------------------------------------------------------------- */
.cta-banner { background-color: var(--green); color: var(--white); }
.cta-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-lg);
  padding-block: var(--s-2xl);
}
.cta-banner__heading {
  color: var(--white);
  font-size: var(--fs-title);
  margin: 0;
}
/* nowrap keeps the number whole — it otherwise breaks after a hyphen on narrow phones */
.cta-banner__phone { color: var(--white); text-decoration: none; white-space: nowrap; }
.cta-banner__phone:hover { text-decoration: underline; }
/* White button with olive text, per spec */
.cta-banner .btn--secondary {
  background-color: var(--white);
  color: var(--green);
  border-color: var(--white);
}
.cta-banner .btn--secondary:hover { background-color: var(--green-dark); color: var(--white); border-color: var(--white); }

/* -------------------------------------------------------------
   11. Footer  (brown-deep field over footer-bg photo)
   ------------------------------------------------------------- */
.site-footer {
  background-color: var(--brown-dark);
  /* jpg first as the universal fallback; image-set serves the lighter webp where supported. */
  background-image: linear-gradient(rgba(74, 44, 15, 0.86), rgba(74, 44, 15, 0.92)), url('/images/footer-bg.jpg');
  background-image: linear-gradient(rgba(74, 44, 15, 0.86), rgba(74, 44, 15, 0.92)),
    image-set(url('/images/footer-bg.webp') type('image/webp'), url('/images/footer-bg.jpg') type('image/jpeg'));
  background-size: cover;
  background-position: center;
  color: var(--cream);
  padding-block: var(--s-3xl) var(--s-xl);
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--s-2xl);
}

.footer-brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cream);
}
.footer-brand__line {
  font-size: var(--fs-small);
  color: var(--tan-light);
  margin-top: var(--s-xs);
}

.footer-col__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--tan);
  margin-bottom: var(--s-sm);
}
.footer-col__list { list-style: none; }
.footer-col__list li + li { margin-top: var(--s-xs); }
.footer-col__list a {
  color: var(--cream);
  text-decoration: none;
  font-size: var(--fs-small);
}
.footer-col__list a:hover { color: var(--tan-light); text-decoration: underline; }

.footer-bottom {
  border-top: 1px solid rgba(245, 240, 232, 0.18);
  margin-top: var(--s-2xl);
  padding-top: var(--s-md);
}
.footer-bottom p {
  font-size: var(--fs-small);
  color: var(--tan-light);
}

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--s-xl); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------
   12. Mobile sticky CTA bar  (public pages, ≤768px)
   Phone number is the primary conversion path on mobile.
   ------------------------------------------------------------- */
.mobile-cta {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  border-top: 2px solid var(--brown-dark);
}
.mobile-cta__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--mobile-cta-h);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-body);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  text-decoration: none;
  color: var(--white);
}
.mobile-cta__btn--call { background-color: var(--green); }
.mobile-cta__btn--text { background-color: var(--brown-dark); }

@media (max-width: 768px) {
  .mobile-cta { display: flex; }
  /* keep fixed bar from covering footer content */
  body.has-mobile-cta { padding-bottom: var(--mobile-cta-h); }
}

/* -------------------------------------------------------------
   13. Reduced motion — kill all transitions/animation
   ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------
   14. Print — drop fixed chrome
   ------------------------------------------------------------- */
@media print {
  .mobile-cta,
  .site-header { position: static; box-shadow: none; }
  .mobile-cta { display: none; }
}
