/* ==========================================================================
   RJR Roofing — main stylesheet
   Mobile-first: base styles target 390px, scaled up with min-width queries.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens — the only place colour values may appear
   -------------------------------------------------------------------------- */
:root {
  --ink:          #263340;  /* Primary text, headings */
  --ink-soft:     #52616E;  /* Secondary/body-support text */
  --paper:        #E7EBEC;  /* Page background — cool pale blue-grey */
  --paper-panel:  #FFFFFF;  /* Card/panel background */
  --paper-line:   #CBD3D6;  /* Hairline borders, dividers */
  --accent:       #9A3B2E;  /* CTAs, key accents — brick red */
  --accent-ink:   #FBF1EC;  /* Text on top of --accent */
  --slate:        #5A6874;  /* Muted labels, meta text — 5.7:1 on --paper-panel, 4.7:1 on --paper (AA) */

  /* Dark chrome (header, hero, reviews, footer) — permanently dark by design,
     so these are fixed and deliberately NOT redefined in the dark-mode block */
  --slate-dark:   #37424C;  /* Header/footer/hero/reviews background */
  --white:        #FFFFFF;  /* Primary text on the dark chrome */
  --chrome-soft:  #C7CBCD;  /* Muted/secondary text on the dark chrome */
  --chrome-panel: #434D57;  /* Card background on the dark chrome (review cards) */
  --accent-on-chrome: #EE9C8C;  /* Accents on the dark chrome — 4.8:1 on --slate-dark (AA) */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:          #E6EAEC;
    --ink-soft:     #B9C3C9;
    --paper:        #1C2328;
    --paper-panel:  #242C32;
    --paper-line:   #39434A;
    --accent:       #D9715E;
    --accent-ink:   #1C2328;
    --slate:        #96A3AB;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'PT Sans', sans-serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  line-height: 1.12;
}

p,
ul,
ol,
figure {
  margin: 0;
}

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

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

/* Visible keyboard focus on every interactive element */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* --accent is only 1.5:1 on the dark chrome — switch the ring there */
body > header :focus-visible,
.hero :focus-visible,
.review-strip :focus-visible,
.lightbox :focus-visible,
body > footer :focus-visible {
  outline-color: var(--accent-on-chrome);
}

/* ...and invisible on the --accent closing panel */
.closing :focus-visible {
  outline-color: var(--accent-ink);
}

/* --------------------------------------------------------------------------
   Safe-area insets (viewport-fit=cover)
   Padding lives on the topmost element (the demo banner) and the footer,
   NOT on :root — putting it on :root as well doubles the gap (the bug found
   on the TradesFront build).
   -------------------------------------------------------------------------- */
.demo-banner {
  padding-top: env(safe-area-inset-top, 0px);
}

/* Footer's own 32px bottom padding is added on top of the inset here, so the
   two don't override each other */
body > footer {
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --------------------------------------------------------------------------
   Shared components
   -------------------------------------------------------------------------- */
/* Small uppercase label above a headline */
.kicker {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Flat, sharp-cornered buttons — no shadow, no hover-lift */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: 2px solid transparent;
  border-radius: 3px;
  font-family: 'PT Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Ghost button for use on the dark chrome */
.btn-ghost {
  background: transparent;
  border-color: var(--white);
  color: var(--white);
}

.btn-ghost:hover {
  background: var(--white);
  color: var(--slate-dark);
}

/* --------------------------------------------------------------------------
   Demo banner — TradesFront's notice, deliberately plain and not in RJR's
   brand styling (no slate chrome, no accent colour)
   -------------------------------------------------------------------------- */
.demo-banner {
  background: var(--paper);
  border-bottom: 1px solid var(--paper-line);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.demo-banner p {
  padding-top: 7px;
  padding-bottom: 7px;
  text-align: center;
}

.demo-banner a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.demo-banner a:hover {
  text-decoration-thickness: 2px;
}

/* --------------------------------------------------------------------------
   Header / navigation (not sticky)
   -------------------------------------------------------------------------- */
header {
  background: var(--slate-dark);
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* phone drops to its own line below ~360px rather than overflowing */
  justify-content: space-between;
  gap: 8px 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 23px;
  letter-spacing: 0.01em;
  color: var(--white);
  text-decoration: none;
}

.logo span {
  color: var(--accent-on-chrome);
}

.logo-mark {
  flex: none;
  width: 32px;
  height: 32px;
  color: var(--accent-on-chrome);
}

/* Hidden on mobile — the phone number stays visible instead */
.nav-links {
  display: none;
  align-items: center;
  gap: 30px;
}

.nav-links a {
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--accent-on-chrome);
}

/* Always visible, every breakpoint — the header's primary action, so it's
   larger and accent-coloured to read apart from the white nav links */
.nav-phone {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-on-chrome);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.nav-phone:hover {
  color: var(--white);
}

.nav-phone-icon {
  flex: none;
  width: 18px;
  height: 18px;
}

@media (min-width: 720px) {
  .nav-links {
    display: flex;
  }

  .nav-phone {
    gap: 7px;
    font-size: 17px;
  }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  background: var(--slate-dark);
  color: var(--white);
  padding: 56px 0 72px;
}

.hero-inner {
  max-width: 680px;
}

.hero .kicker {
  color: var(--accent-on-chrome);
  font-size: 14px;
}

.hero h1 {
  margin-top: 14px;
  color: var(--white);
  font-size: clamp(32px, 6vw, 50px);
}

.hero-lead {
  max-width: 48ch;
  margin-top: 18px;
  color: var(--chrome-soft);
  font-size: 18px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 30px;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 34px;
  padding: 0;
  list-style: none;
  color: var(--chrome-soft);
  font-weight: 700;
  font-size: 14px;
}

.trust-strip li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.trust-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-on-chrome);
}

/* Laptop/desktop only: centre the hero so it doesn't sit left-heavy with an
   empty right half. Mobile and tablet keep the left-aligned layout. */
@media (min-width: 1024px) {
  .hero-inner {
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
  }

  .hero-lead {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-cta,
  .trust-strip {
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Content sections
   -------------------------------------------------------------------------- */
section {
  padding: 64px 0;
}

.section-head {
  max-width: 60ch;
  margin-bottom: 36px;
}

.section-head h2 {
  margin-top: 10px;
  font-size: clamp(26px, 3.6vw, 34px);
}

.section-head p:not(.kicker) {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 17px;
}

/* Hairline divider between adjacent light sections */
.rule {
  border-top: 1px solid var(--paper-line);
}

/* Section heading sitting on the dark chrome (e.g. Reviews strip) */
.section-head--on-chrome h2 {
  color: var(--white);
}

.section-head--on-chrome .kicker {
  color: var(--accent-on-chrome);
}

.section-head--on-chrome p:not(.kicker) {
  color: var(--chrome-soft);
}

/* --------------------------------------------------------------------------
   Services
   -------------------------------------------------------------------------- */
.services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.service-card {
  padding: 28px 24px;
  background: var(--paper-panel);
  border: 1px solid var(--paper-line);
  border-top: 4px solid var(--accent);
  border-radius: 4px;
}

.service-card h3 {
  font-size: 20px;
}

.service-card p {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 15.5px;
}

@media (min-width: 760px) {
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Gallery
   Mobile: swipeable scroll-snap carousel, one photo at a time.
   640px+: static 3-column grid. Both flex to any number of tiles —
   add or remove a .gallery-tile in the HTML and nothing else changes.
   -------------------------------------------------------------------------- */
.gallery-section {
  background: var(--paper-panel);
}

.gallery-grid {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; /* room for any scrollbar */
}

.gallery-tile {
  flex: 0 0 82%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  scroll-snap-align: start;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  background: var(--paper); /* shows while a lazy-loaded photo arrives */
}

/* Each photo is a button that opens the lightbox */
.gallery-open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* Inset ring — the tile's overflow: hidden would clip an outside one */
.gallery-open:focus-visible {
  outline-offset: -3px;
}

/* Photos are cropped to the tile's fixed 4:3 ratio */
.gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
}

.gallery-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--paper-line);
}

.gallery-dots span.active {
  background: var(--accent);
}

@media (min-width: 640px) {
  .gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .gallery-tile {
    flex: initial;
  }

  .gallery-dots {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Gallery lightbox (native <dialog>)
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: color-mix(in srgb, var(--slate-dark) 90%, transparent);
  cursor: zoom-out;
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox::backdrop {
  background: transparent;
}

/* Never overflows the viewport; vertical room left for the close button */
.lightbox-img {
  width: auto;
  height: auto;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 128px);
  max-height: calc(100dvh - 128px);
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--white);
  cursor: pointer;
}

.lightbox-close:hover {
  color: var(--accent-on-chrome);
}

.lightbox-close svg {
  width: 26px;
  height: 26px;
}

/* Stop the page scrolling behind the open lightbox */
html:has(.lightbox[open]) {
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] {
    animation: lightbox-fade 160ms ease-out;
  }

  .lightbox[open] .lightbox-img {
    animation: lightbox-zoom 160ms ease-out;
  }
}

@keyframes lightbox-fade {
  from { opacity: 0; }
}

@keyframes lightbox-zoom {
  from { transform: scale(0.96); }
}

/* --------------------------------------------------------------------------
   Why us
   -------------------------------------------------------------------------- */
.why-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 0;
  list-style: none;
}

.why-item {
  display: flex;
  gap: 16px;
}

/* Decorative — the <ol> already conveys the numbering to assistive tech */
.why-num {
  flex: none;
  width: 44px;
  color: var(--accent);
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 30px;
}

.why-item h3 {
  font-size: 18px;
}

.why-item p {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 15px;
}

@media (min-width: 760px) {
  .why-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Reviews (dark chrome strip)
   -------------------------------------------------------------------------- */
.review-strip {
  background: var(--slate-dark);
  color: var(--white);
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.review-card {
  padding: 22px;
  background: var(--chrome-panel);
  border-radius: 4px;
}

.review-card blockquote {
  margin: 0;
}

.review-stars {
  color: var(--accent-on-chrome);
  font-size: 14px;
  letter-spacing: 2px;
}

.review-card p {
  margin-top: 12px;
  color: var(--white);
  font-size: 15px;
}

.review-card .who {
  margin-top: 14px;
  color: var(--chrome-soft);
  font-weight: 700;
  font-size: 13px;
}

@media (min-width: 760px) {
  .review-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Contact
   -------------------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

.contact-card {
  margin: 0;
  padding: 28px;
  background: var(--paper-panel);
  border: 1px solid var(--paper-line);
  border-radius: 4px;
}

.contact-row {
  padding: 14px 0;
  border-top: 1px solid var(--paper-line);
}

.contact-row:first-child {
  padding-top: 0;
  border-top: none;
}

.contact-row .label {
  color: var(--slate);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.contact-row .val {
  margin: 2px 0 0;
  font-weight: 700;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.contact-row .val a {
  color: var(--ink);
  text-decoration: none;
}

.contact-row .val a:hover {
  color: var(--accent);
}

/* Google Maps embed — fills the 4:3 box; corners clipped by overflow */
.map-box {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  background: var(--paper-panel); /* shows while the lazy-loaded map arrives */
}

.map-box iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (min-width: 860px) {
  .contact-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* --------------------------------------------------------------------------
   Closing CTA
   -------------------------------------------------------------------------- */
.closing {
  padding: 44px 36px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  text-align: center;
}

.closing h2 {
  color: var(--accent-ink);
  font-size: clamp(24px, 3.6vw, 32px);
}

.closing p {
  margin-top: 10px;
  color: var(--accent-ink);
}

.closing-cta {
  margin-top: 22px;
}

.closing .btn-ghost {
  border-color: var(--accent-ink);
  color: var(--accent-ink);
}

.closing .btn-ghost:hover {
  background: var(--accent-ink);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Footer (bottom padding + safe-area inset is set in the safe-area block above)
   -------------------------------------------------------------------------- */
footer {
  padding-top: 32px;
  background: var(--slate-dark);
  color: var(--chrome-soft);
  font-size: 14px;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
}

.footer-grid a {
  color: var(--chrome-soft);
  font-weight: 700;
  text-decoration: none;
}

.footer-grid a:hover {
  color: var(--accent-on-chrome);
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
