/* ==========================================================================
   Ottawa Used Spares — shared stylesheet
   Palette: workshop charcoal + trade red on cool off-white.
   Light default (:root); dark override on [data-theme="dark"].
   ========================================================================== */

/* ---- Design tokens --------------------------------------------------- */
:root {
  /* Brand constants (theme-independent) */
  --charcoal: #1E2124;
  --charcoal-deep: #141619;
  --red: #D8352A;          /* CTA fills / rules / large display only */
  --red-hover: #C42E24;
  --red-text: #A6281F;     /* small red text on LIGHT ground only */
  --amber: #E8A33D;        /* very sparing: open dot / "since 2002" mark */

  /* --on-brand: text/icons sitting on charcoal (header/hero/footer/buttons).
     Stays near-white in BOTH themes. Never remapped. */
  --on-brand: #F3F4F5;

  /* Themed roles (light defaults) */
  --ground: #F3F4F5;       /* page background */
  --surface: #FFFFFF;      /* card / panel fill */
  --surface-2: #F3F4F5;    /* quiet inset band on a surface */
  --text: #1B1D1F;         /* body text */
  --text-muted: #5B6169;   /* secondary / meta */
  --line: #E1E3E5;         /* hairline borders */
  --link: #A6281F;         /* inline links on light */

  --header-bg: #1E2124;
  --footer-bg: #1E2124;
  --hero-bg: #1E2124;

  --surface-border: var(--line);
  --surface-shadow: 0 1px 3px rgba(20, 22, 25, 0.10), 0 4px 14px rgba(20, 22, 25, 0.06);

  /* Type */
  --font-head: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Metrics */
  --container: 1120px;
  --radius: 10px;
  --radius-sm: 6px;
  --space: 1rem;
}

[data-theme="dark"] {
  --ground: #141619;
  --surface: #31353B;      /* verified in-browser ~1.49:1 vs #141619 ground */
  --surface-2: #26292E;
  --text: #E9EAEB;
  --text-muted: #9AA0A6;
  --line: #434952;
  --link: #F0776B;         /* lifted red for small text on dark surface */

  --header-bg: #141619;
  --footer-bg: #141619;
  --hero-bg: #141619;

  --surface-border: #434952;
  --surface-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 20px rgba(0, 0, 0, 0.35);
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 0.5em;
  font-weight: 700;
}
h1 { font-size: clamp(1.8rem, 5vw, 2.75rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1rem; }

a { color: var(--link); }
a:hover { text-decoration: none; }

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

ul { margin: 0 0 1rem; padding-left: 1.2rem; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.eyebrow {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--red-text);
  margin: 0 0 0.5rem;
}
[data-theme="dark"] .eyebrow { color: var(--link); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  min-height: 48px;           /* large tap target */
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary {
  background: var(--red);
  color: #FFFFFF;             /* white on red (verified ~4.7:1) */
  border-color: var(--red);
}
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }

.btn-whatsapp {
  background: var(--red);
  color: #FFFFFF;
  border-color: var(--red);
}
.btn-whatsapp:hover { background: var(--red-hover); border-color: var(--red-hover); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn-outline:hover { border-color: var(--red); color: var(--red-text); }
[data-theme="dark"] .btn-outline { color: var(--text); border-color: var(--line); }
[data-theme="dark"] .btn-outline:hover { color: var(--link); border-color: var(--red); }

/* Buttons that sit on the charcoal header/hero */
.on-brand .btn-outline {
  color: var(--on-brand);
  border-color: rgba(243, 244, 245, 0.4);
}
.on-brand .btn-outline:hover {
  border-color: var(--on-brand);
  color: var(--on-brand);
}

.btn .icon { width: 20px; height: 20px; }

/* ---- Icon wrappers (recurring-bug guard #6) -------------------------- */
.icon {
  display: inline-flex;      /* fixed-size wrappers MUST be flex */
  align-items: center;
  justify-content: center;
  flex: none;
}
.icon svg { width: 100%; height: 100%; display: block; }

/* ---- Header ---------------------------------------------------------- */
.site-header {
  background: var(--header-bg);
  color: var(--on-brand);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--on-brand);
  margin-right: auto;
  min-width: 0;      /* last-resort: ellipsis rather than overflow the row */
  flex: 0 1 auto;
}
.brand-mark {
  width: 26px; height: 26px;
  background: var(--red);
  border-radius: 4px;
  flex: none;
}
.brand-word {
  font-family: var(--font-head);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  white-space: nowrap;
  color: var(--on-brand);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Primary nav */
.primary-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
}
.primary-nav a {
  color: var(--on-brand);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;        /* guard #3: no mid-phrase wrap */
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
}
.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
  border-bottom-color: var(--red);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
}

/* Header call link (icon + short label) */
.header-call {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--on-brand);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.header-call:hover { color: #FFFFFF; text-decoration: underline; }
.header-call .icon { width: 18px; height: 18px; }

.header-wa {
  padding: 0.55rem 0.95rem;
  min-height: 40px;
  font-size: 0.92rem;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: var(--on-brand);
  cursor: pointer;
  flex: none;
}
.theme-toggle:hover { border-color: rgba(255, 255, 255, 0.6); }
.theme-toggle .icon { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-flex; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline-flex; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Mobile nav toggle (hamburger) */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: var(--on-brand);
  cursor: pointer;
  flex: none;
}
.nav-toggle .icon { width: 22px; height: 22px; }

/* ---- Off-canvas nav breakpoint --------------------------------------
   Inline nav must genuinely fit above this width. Below it, collapse to
   an off-canvas panel. No overflow-x:hidden hacks anywhere. */
@media (max-width: 1080px) {
  .nav-toggle { display: inline-flex; }

  .primary-nav {
    position: fixed;
    inset: 64px 0 auto 0;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transform: translateY(-120%);
    transition: transform 0.22s ease;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  .primary-nav.open { transform: translateY(0); }
  .primary-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 1.25rem 1rem;
  }
  .primary-nav a {
    display: block;
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .primary-nav a:hover,
  .primary-nav a[aria-current="page"] {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    padding-left: 0.4rem;
  }
}

/* Very small screens: keep the header row within the viewport by making the
   persistent WhatsApp action icon-only and tightening the action gap.
   (The action still says "WhatsApp" via aria-label.) */
@media (max-width: 480px) {
  .header-row { gap: 0.5rem; }
  .header-actions { gap: 0.4rem; }
  .header-wa .wa-text { display: none; }
  .header-wa { padding: 0.55rem 0.7rem; }
  .brand-word { font-size: 0.95rem; }
}

/* ---- Hero ------------------------------------------------------------ */
.hero {
  background: var(--hero-bg);
  color: var(--on-brand);
  padding: 3rem 0 3.25rem;
  border-bottom: 3px solid var(--red);
}
.hero h1 { color: var(--on-brand); max-width: 20ch; }
.hero p { color: var(--on-brand); opacity: 0.92; max-width: 52ch; font-size: 1.1rem; }
.hero .eyebrow { color: #FFB3AC; }
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Open/closed status pill */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-brand);
  margin-top: 1.25rem;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}
.status.is-open .status-dot { background: #45C46A; }
.status.is-closed .status-dot { background: var(--amber); }

/* ---- Sections -------------------------------------------------------- */
.section { padding: 3rem 0; }
.section-tight { padding: 2rem 0; }
.section.alt { background: var(--surface-2); }
.section-head { max-width: 60ch; margin-bottom: 1.75rem; }
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }

/* Trust strip */
.trust-strip {
  background: var(--charcoal);
  color: var(--on-brand);
  padding: 1rem 0;
}
.trust-strip ul {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  justify-content: center;
  font-size: 0.92rem;
}
.trust-strip li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--on-brand);
}
.trust-strip .icon { width: 16px; height: 16px; color: var(--red); }

/* [TO CONFIRM] chip */
.chip-confirm {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6B4A0C;
  background: rgba(232, 163, 61, 0.12);
  border: 1px solid rgba(232, 163, 61, 0.5);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
  white-space: nowrap;
}
[data-theme="dark"] .chip-confirm {
  color: #E8A33D;
  background: rgba(232, 163, 61, 0.14);
  border-color: rgba(232, 163, 61, 0.45);
}

/* ---- Cards / grids --------------------------------------------------- */
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  box-shadow: var(--surface-shadow);
  padding: 1.5rem;
}
a.card { text-decoration: none; color: var(--text); display: block; }
a.card:hover { border-color: var(--red); }
.card h3 { margin-bottom: 0.35rem; }
.card p { color: var(--text-muted); margin-bottom: 0; }
.card .card-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: rgba(216, 53, 42, 0.10);
  color: var(--red);
  margin-bottom: 1rem;
}
[data-theme="dark"] .card .card-icon {
  background: rgba(216, 53, 42, 0.22);
  color: #F0776B;
}
.card-icon .icon { width: 24px; height: 24px; }
.card .card-more {
  display: inline-block;
  margin-top: 0.75rem;
  font-weight: 600;
  color: var(--red-text);
}
[data-theme="dark"] .card .card-more { color: var(--link); }

/* Steps */
.steps { counter-reset: step; }
.step { position: relative; padding-left: 3.25rem; }
.step .step-num {
  position: absolute; left: 0; top: 0;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  background: var(--red);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
}

/* Spec / definition list for parts by system */
.system-list { }
.system-list h3 { margin-top: 0; }
.system-list .card p { color: var(--text); }
.system-list .card p:last-child { margin-bottom: 0; }

/* Placeholder image block (no real photos exist) */
.img-placeholder {
  background:
    repeating-linear-gradient(
      135deg,
      var(--surface-2),
      var(--surface-2) 12px,
      var(--line) 12px,
      var(--line) 24px
    );
  border: 1px dashed var(--surface-border);
  border-radius: var(--radius);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.img-placeholder span { max-width: 32ch; }

/* ---- Contact / NAP --------------------------------------------------- */
.nap-block dt { font-weight: 600; color: var(--text-muted); margin-top: 0.75rem; }
.nap-block dd { margin: 0.15rem 0 0; }
.nap-block a { color: var(--link); font-weight: 600; }

.hours-table { width: 100%; border-collapse: collapse; }
.hours-table th, .hours-table td {
  text-align: left; padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.hours-table th { font-weight: 600; }
.hours-table td { text-align: right; font-variant-numeric: tabular-nums; }
.hours-table tr.today { background: rgba(216, 53, 42, 0.07); }
[data-theme="dark"] .hours-table tr.today { background: rgba(216, 53, 42, 0.15); }

.map-embed {
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--surface-shadow);
}
.map-embed iframe { width: 100%; height: 340px; border: 0; display: block; }

/* ---- Forms ----------------------------------------------------------- */
.form-field { margin-bottom: 1.1rem; }
.form-field label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.req { color: var(--red-text); }
[data-theme="dark"] .req { color: var(--link); }

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
  border-color: var(--red);
}
.form-field textarea { min-height: 120px; resize: vertical; }

.radio-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; margin: 0; }
.radio-row input { width: auto; }

.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }
.form-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ---- CTA band -------------------------------------------------------- */
.cta-band {
  background: var(--charcoal);
  color: var(--on-brand);
  padding: 2.5rem 0;
  text-align: center;
}
.cta-band h2 { color: var(--on-brand); }
.cta-band p { color: var(--on-brand); opacity: 0.9; }
.cta-band .hero-cta { justify-content: center; }

/* ---- Footer ---------------------------------------------------------- */
.site-footer {
  background: var(--footer-bg);
  color: var(--on-brand);
  padding: 2.5rem 0 1.5rem;
  border-top: 3px solid var(--red);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
}
.site-footer h4 {
  color: var(--on-brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.site-footer p, .site-footer li { color: var(--on-brand); opacity: 0.88; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.4rem; }

/* Guard #1: footer link colour stays near-white in BOTH themes */
.site-footer a { color: var(--on-brand); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
[data-theme="dark"] .site-footer a:not([class]) { color: var(--on-brand); }

.footer-brand .brand-word { color: var(--on-brand); }
.footer-legal {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.82rem;
  opacity: 0.75;
}
.footer-legal p { margin-bottom: 0.4rem; }

/* ---- Utility --------------------------------------------------------- */
.lead { font-size: 1.12rem; color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.anchor-offset { scroll-margin-top: 80px; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 720px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero { padding: 2.25rem 0 2.5rem; }
  .section { padding: 2.25rem 0; }
}

@media (min-width: 721px) and (max-width: 980px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
