/* ============================================================
   /src/css/global.css — RoofSheetCalc Global Styles
   Mobile-first. Base = 375px. Scale up via media queries.
   Breakpoints: 600px | 768px | 1024px
   ============================================================ */

/* ============================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Brand colours */
  --color-primary:      #E85D26;
  --color-primary-dark: #c94e1f;

  /* Text */
  --color-text:       #1a1a1a;
  --color-text-light: #666;

  /* Backgrounds */
  --color-bg:     #fff;
  --color-bg-alt: #f8f8f8;

  /* Borders */
  --color-border: #e0e0e0;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
}


/* ============================================================
   2. CSS RESET
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul,
ol {
  padding-left: 1.5rem;
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  line-height: 1.25;
}

p {
  margin-top: 0;
}

a {
  color: var(--color-primary);
}


/* ============================================================
   3. BASE TYPOGRAPHY & BODY
   ============================================================ */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-text-size-adjust: 100%;
}


/* ============================================================
   4. ACCESSIBILITY — SKIP TO CONTENT
   ============================================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Screen-reader only utility */
.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;
}


/* ============================================================
   5. LAYOUT — CONTAINER
   ============================================================ */
.container {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}


/* ============================================================
   6. HEADER — MOBILE FIRST
   Sticky header. Hamburger visible on mobile.
   Nav hidden on mobile, shown on desktop (768px+).
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Logo */
.site-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-logo:hover {
  color: var(--color-primary-dark);
}

/* Hamburger button */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
}

.hamburger span:nth-child(1) { margin-bottom: 5px; }
.hamburger span:nth-child(2) { margin-bottom: 5px; }

/* Animate hamburger to X when nav is open */
.site-header.nav-open .hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-header.nav-open .hamburger span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.site-header.nav-open .hamburger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Nav — hidden on mobile by default */
.site-nav {
  display: none;
}

/* Nav open state on mobile — full-width dropdown */
.site-header.nav-open .site-nav {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0.5rem 1rem 1rem;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-bg);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  box-shadow: var(--shadow-md);
  z-index: 99;
}

.site-nav a {
  display: block;
  padding: 0.65rem 0;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--color-border);
  min-height: 44px;
  line-height: 44px;
}

.site-nav a:last-child {
  border-bottom: none;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-primary);
}

.site-nav a.active {
  font-weight: 700;
}

.site-nav a:focus-visible,
.hamburger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}


/* ============================================================
   7. FOOTER
   FIX: Rewritten to match footer.html class names exactly.
   Uses: .footer-brand, .footer-nav, .footer-nav-group,
         .footer-nav-heading, .footer-bottom, .footer-copy,
         .footer-disclaimer, .footer-tagline, .footer-site-name
   Dark background. 1 column mobile → 3 column desktop (768px).
   ============================================================ */
.site-footer {
  background-color: #1a1a1a;
  color: #fff;
  padding: 2.5rem 1rem 1.5rem;
  margin-top: 0;
}

.footer-inner {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Brand block — site name + tagline */
.footer-brand {
  margin-bottom: 2rem;
}

.footer-site-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.25rem;
}

.footer-tagline {
  font-size: 0.875rem;
  color: #aaa;
  margin: 0;
}

/* Nav — wraps all 3 nav groups in a row on desktop */
.footer-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Individual nav group: heading + links stacked */
.footer-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.footer-nav-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
  margin: 0 0 0.5rem;
}

.footer-nav-group a {
  display: block;
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.2rem 0;
  transition: color 0.15s ease;
}

.footer-nav-group a:hover {
  color: var(--color-primary);
}

/* Bottom bar — disclaimer + copyright */
.footer-bottom {
  border-top: 1px solid #333;
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-disclaimer {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.5;
  margin: 0;
}

.footer-copy {
  font-size: 0.85rem;
  color: #888;
  margin: 0;
}


/* ============================================================
   8. BREADCRUMB
   ============================================================ */
.breadcrumb {
  padding: 0.6rem 0;
  margin-bottom: 1rem;
}

.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.breadcrumb li {
  font-size: 0.85rem;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
}

.breadcrumb li + li::before {
  content: "›";
  margin: 0 0.4rem;
  color: var(--color-border);
}

.breadcrumb a {
  color: var(--color-text-light);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--color-text);
  font-weight: 500;
}


/* ============================================================
   9. HERO SECTION
   ============================================================ */
.hero {
  background-color: var(--color-bg-alt);
  padding: 2.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

.hero h1 {
  font-size: 1.75rem;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.hero-sub {
  font-size: 1rem;
  color: var(--color-text-light);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.5rem;
}

/* FIX: Hero CTA buttons row — flex with gap and wrap */
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}


/* ============================================================
   10. TOOL CARDS GRID
   1 col (default) → 2 col (600px) → 4 col (1024px)
   ============================================================ */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem 0;
}

/* Homepage uses .tool-cards — alias to same grid */
.tool-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem 0;
}

.tool-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background-color: var(--color-bg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.tool-card-icon {
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  line-height: 1;
}

.tool-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.tool-card-desc {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-bottom: 1rem;
  flex: 1;
}

/* .tool-card-link used in homepage HTML (not .tool-card-cta) */
.tool-card-link,
.tool-card-cta {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: auto;
}

.tool-card:hover .tool-card-link,
.tool-card:hover .tool-card-cta {
  text-decoration: underline;
}


/* ============================================================
   11. BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  min-height: 44px;
  font-weight: 600;
  font-size: 1rem;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.1s ease;
  line-height: 1.2;
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
  color: #fff;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  color: var(--color-primary);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-primary);
  min-height: 44px;
  font-weight: 600;
  font-size: 1rem;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  line-height: 1.2;
}

.btn-secondary:hover {
  background-color: var(--color-primary);
  color: #fff;
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-large {
  padding: 0.9rem 2rem;
  font-size: 1.1rem;
}


/* ============================================================
   12. AD SLOTS
   ============================================================ */
.ad-slot {
  background-color: var(--color-bg-alt);
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
}

.ad-slot-header {
  min-height: 90px;
}

.ad-label {
  font-size: 0.7rem;
  text-align: center;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}


/* ============================================================
   13. TABLES
   ============================================================ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-sm);
}

.data-table {
  border-collapse: collapse;
  min-width: 500px;
  width: 100%;
  font-size: 0.9rem;
}

.data-table th {
  background-color: var(--color-bg-alt);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.data-table td,
.data-table th {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
}

.data-table tbody tr:nth-child(even) {
  background-color: var(--color-bg-alt);
}

.data-table td:not(:first-child) {
  text-align: right;
}


/* ============================================================
   14. FEATURE GRID — "Why Use RoofSheetCalc?"
   FIX: Added .features-grid (HTML uses this name, not .feature-grid).
        Added card styling to .feature-item.
        Both class names supported for backward compat.
   1 col mobile → 3 col (768px)
   ============================================================ */
.features-grid,
.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1rem 0;
}

.feature-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.25rem;
  transition: box-shadow 0.2s ease;
}

.feature-item:hover {
  box-shadow: var(--shadow-md);
}

.feature-icon {
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.feature-item h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.feature-item p {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin: 0;
  line-height: 1.6;
}


/* ============================================================
   15. HOMEPAGE SECTIONS — shared layout helpers
   ============================================================ */
.tools-section,
.features-section,
.articles-teaser,
.brands-teaser,
.cta-banner {
  padding: 1.5rem 0;
}

.tools-section,
.features-section {
  border-bottom: 1px solid var(--color-border);
}

.tools-section h2,
.features-section h2,
.articles-teaser h2,
.brands-teaser h2,
.cta-banner h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.section-sub {
  font-size: 0.95rem;
  color: var(--color-text-light);
  margin-bottom: 0.75rem;
}

/* FIX: Section header row — heading + "View All" link on same row */
.section-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.section-header-row h2 {
  margin-bottom: 0;
}

.view-all-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
}

.view-all-link:hover {
  text-decoration: underline;
}


/* ============================================================
   16. ARTICLE CARDS — "Latest Guides" on homepage
   FIX: Added from scratch — was completely missing from CSS.
   1 col mobile → 3 col (1024px)
   ============================================================ */
.article-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 0.75rem 0 0;
}

.article-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.article-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Article type badge pill */
.article-tag {
  display: inline-block;
  background-color: #fff3ee;
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  border: 1px solid #fcd5c2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}

.article-card-title a {
  color: var(--color-text);
  text-decoration: none;
}

.article-card-title a:hover {
  color: var(--color-primary);
}

.article-card-desc {
  font-size: 0.875rem;
  color: var(--color-text-light);
  line-height: 1.6;
  margin: 0;
  flex: 1;
}


/* ============================================================
   17. BRAND DIRECTORY TEASER — homepage brand badges
   FIX: Added from scratch — was completely missing from CSS.
   ============================================================ */
.brand-logos-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.brand-logo-item {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.brand-name-badge {
  display: inline-block;
  background-color: var(--color-bg);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.brand-logo-item:hover .brand-name-badge {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background-color: #fff3ee;
  box-shadow: var(--shadow-sm);
}

.brands-cta {
  margin-top: 0.5rem;
}


/* ============================================================
   18. CTA BANNER
   ============================================================ */
.cta-banner {
  background-color: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.cta-banner p {
  color: var(--color-text-light);
  margin-bottom: 1.5rem;
  font-size: 1rem;
}


/* ============================================================
   19. UTILITY CLASSES
   ============================================================ */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-light);
}

.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }
.mb-3  { margin-bottom: 1.5rem; }
.mb-4  { margin-bottom: 2rem; }

.section {
  padding: 2.5rem 0;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-text);
}


/* ============================================================
   20. MAIN CONTENT WRAPPER
   ============================================================ */
main {
  min-height: 60vh;
  padding-bottom: 0;
}


/* ============================================================
   21. PRINT STYLES
   ============================================================ */
@media print {
  .site-header,
  .site-footer,
  .ad-slot,
  .ad-slot-header,
  .breadcrumb,
  .hamburger,
  .btn-primary,
  .btn-secondary,
  .site-nav {
    display: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  main {
    padding: 0;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }
}


/* ============================================================
   22. MEDIA QUERIES — 600px
   ============================================================ */
@media (min-width: 600px) {
  .tools-grid,
  .tool-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .article-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h1 {
    font-size: 2rem;
  }

  .footer-nav {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ============================================================
   23. MEDIA QUERIES — 768px (DESKTOP)
   ============================================================ */
@media (min-width: 768px) {
  /* Show nav inline, hide hamburger */
  .site-nav {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    position: static;
    width: auto;
    padding: 0;
    border-top: none;
    box-shadow: none;
    background: transparent;
  }

  .hamburger {
    display: none;
  }

  .site-nav a {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    border-bottom: none;
    min-height: auto;
    line-height: 1.4;
    border-radius: var(--radius-sm);
  }

  .site-nav a:hover {
    background-color: var(--color-bg-alt);
  }

  /* Footer bottom row — disclaimer left, copyright right */
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
  }

  .footer-disclaimer {
    max-width: 60%;
  }

  /* Feature grid 3 columns */
  .features-grid,
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Hero larger H1 */
  .hero h1 {
    font-size: 2.5rem;
  }

  .hero {
    padding: 2rem 1rem;
  }

  /* Footer brand + nav side by side */
  .footer-inner {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    align-items: start;
  }

  /* Footer bottom spans full width */
  .footer-bottom {
    grid-column: 1 / -1;
  }
}


/* ============================================================
   24. MEDIA QUERIES — 1024px
   ============================================================ */
@media (min-width: 1024px) {
  .tools-grid,
  .tool-cards {
    grid-template-columns: repeat(4, 1fr);
  }

  .article-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}