/* ============================================================
   RenovationCalcPH — style.css
   Mobile-first · Light/Dark · Zero framework dependencies
   ============================================================ */

/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root,
[data-theme='light'] {
  /* Surfaces — warm construction-site cement palette */
  --color-bg: #f6f5f1;
  --color-surface: #f9f8f5;
  --color-surface-2: #fafaf7;
  --color-surface-offset: #f0ede8;
  --color-surface-offset-2: #e9e6e1;
  --color-surface-dynamic: #e3e0da;
  --color-divider: #d8d5cf;
  --color-border: #ccc9c2;

  /* Text */
  --color-text: #25221a;
  --color-text-muted: #7a7870;
  --color-text-faint: #b8b6b0;
  --color-text-inverse: #f9f8f4;

  /* Primary — deep terracotta-teal (PH flag inspired) */
  --color-primary: #006e6e;
  --color-primary-hover: #005555;
  --color-primary-active: #003d3d;
  --color-primary-highlight: #c8dede;

  /* Accent — warm golden-yellow for CTAs */
  --color-accent: #c97a00;
  --color-accent-hover: #a85f00;
  --color-accent-highlight: #fdecc8;

  /* Status */
  --color-success: #3c7a1e;
  --color-warning: #a35200;
  --color-error: #b02a2a;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows */
  --shadow-sm: 0 1px 3px oklch(0.2 0.02 80 / 0.07);
  --shadow-md: 0 4px 14px oklch(0.2 0.02 80 / 0.09);
  --shadow-lg: 0 12px 36px oklch(0.2 0.02 80 / 0.13);

  /* Layout */
  --content-narrow: 680px;
  --content-default: 960px;
  --content-wide: 1200px;

  /* Type scale — fluid */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.82rem + 0.3vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.65vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.3rem + 2.2vw, 3.25rem);

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Fonts */
  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body: 'General Sans', 'Helvetica Neue', sans-serif;
}

/* ── DARK MODE ──────────────────────────────────────────────── */
[data-theme='dark'] {
  --color-bg: #161510;
  --color-surface: #1b1a15;
  --color-surface-2: #201f19;
  --color-surface-offset: #1e1d18;
  --color-surface-offset-2: #23221c;
  --color-surface-dynamic: #2c2b25;
  --color-divider: #2a2923;
  --color-border: #38372f;
  --color-text: #cccac4;
  --color-text-muted: #7a7870;
  --color-text-faint: #524f48;
  --color-text-inverse: #1f1e18;
  --color-primary: #3fa8a8;
  --color-primary-hover: #2d8e8e;
  --color-primary-active: #1a6f6f;
  --color-primary-highlight: #1f3636;
  --color-accent: #e89c38;
  --color-accent-hover: #d07f18;
  --color-accent-highlight: #3d2e10;
  --color-success: #68aa3e;
  --color-warning: #cc7a22;
  --color-error: #dd5555;
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.22);
  --shadow-md: 0 4px 14px oklch(0 0 0 / 0.32);
  --shadow-lg: 0 12px 36px oklch(0 0 0 / 0.42);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #161510;
    --color-surface: #1b1a15;
    --color-surface-2: #201f19;
    --color-surface-offset: #1e1d18;
    --color-surface-offset-2: #23221c;
    --color-surface-dynamic: #2c2b25;
    --color-divider: #2a2923;
    --color-border: #38372f;
    --color-text: #cccac4;
    --color-text-muted: #7a7870;
    --color-text-faint: #524f48;
    --color-text-inverse: #1f1e18;
    --color-primary: #3fa8a8;
    --color-primary-hover: #2d8e8e;
    --color-primary-active: #1a6f6f;
    --color-primary-highlight: #1f3636;
    --color-accent: #e89c38;
    --color-accent-hover: #d07f18;
    --color-accent-highlight: #3d2e10;
    --color-success: #68aa3e;
    --color-warning: #cc7a22;
    --color-error: #dd5555;
  }
}

/* ── 2. BASE RESET ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.65;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color 200ms ease, color 200ms ease;
}

img, picture, svg { display: block; max-width: 100%; height: auto; }
ul[role='list'], ol[role='list'] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; font-family: var(--font-display); }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }
a { color: var(--color-primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--color-primary-hover); }

::selection {
  background: color-mix(in oklab, var(--color-primary) 22%, transparent);
  color: var(--color-text);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

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

/* ── 3. LAYOUT UTILITIES ────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

@media (min-width: 768px) {
  .container { padding-inline: var(--space-8); }
}

.container--narrow { max-width: var(--content-narrow); }

.section {
  padding-block: clamp(var(--space-12), 7vw, var(--space-20));
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-10);
}

.section-header h2 {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.section-sub {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 58ch;
  margin-inline: auto;
}

/* ── 4. BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid transparent;
  min-height: 48px;
  padding-inline: var(--space-5);
  font-size: var(--text-sm);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.btn-accent {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-accent:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
}

.btn-lg { min-height: 52px; font-size: var(--text-base); padding-inline: var(--space-8); }
.btn-sm { min-height: 40px; font-size: var(--text-xs); padding-inline: var(--space-4); }
.btn-full { width: 100%; }

/* ── 5. CONSENT BANNER ──────────────────────────────────────── */
.consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

.consent-banner.visible {
  transform: translateY(0);
}

.consent-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5);
  max-width: var(--content-wide);
  margin-inline: auto;
}

@media (min-width: 640px) {
  .consent-inner {
    flex-direction: row;
    align-items: center;
    padding: var(--space-4) var(--space-8);
  }
}

.consent-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  flex: 1;
  max-width: none;
}

.consent-text a {
  color: var(--color-primary);
}

.consent-actions {
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ── 6. HEADER ──────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: color-mix(in oklab, var(--color-bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 64px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.logo-icon .logo-bg { color: var(--color-primary); }

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-base);
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-ph {
  color: var(--color-primary);
}

.logo:hover { opacity: 0.85; }

/* Nav */
.site-nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

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

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  margin-left: auto;
  transition: color var(--transition), background var(--transition);
}

@media (min-width: 768px) {
  .theme-toggle { margin-left: 0; }
}

.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

/* Mobile nav toggle */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }
}

/* Mobile nav open state */
.site-nav.nav-open {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4);
  gap: var(--space-2);
  z-index: 898;
}

.nav-open .nav-link {
  display: block;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
}

/* ── 7. HERO ────────────────────────────────────────────────── */
.hero {
  padding-block: clamp(var(--space-12), 8vw, var(--space-20));
  background: linear-gradient(
    165deg,
    var(--color-surface) 0%,
    var(--color-bg) 50%,
    var(--color-surface-offset) 100%
  );
  border-bottom: 1px solid var(--color-divider);
}

.hero-inner {
  text-align: center;
}

.hero-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border: 1px solid color-mix(in oklab, var(--color-primary) 25%, transparent);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: var(--space-5);
}

.hero h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: var(--space-5);
  line-height: 1.1;
}

.hero-accent {
  color: var(--color-primary);
}

.br-mobile { display: none; }
@media (max-width: 600px) { .br-mobile { display: block; } }

.hero-sub {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 58ch;
  margin-inline: auto;
  margin-bottom: var(--space-8);
}

.hero-cta-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-10);
}

@media (min-width: 480px) {
  .hero-cta-group {
    flex-direction: row;
    justify-content: center;
  }
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--color-border);
}

/* ── 8. AD PLACEHOLDERS ─────────────────────────────────────── */
.ad-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: var(--space-5);
  background: var(--color-surface-offset);
  border-block: 1px solid var(--color-divider);
  width: 100%;
  box-sizing: border-box;
}

.ad-leaderboard .ad-placeholder {
  width: min(728px, 100%);
  height: 90px;
}

.ad-rectangle .ad-placeholder {
  width: min(336px, 100%);  /* IAB medium rectangle, never overflows */
  height: 250px;
  margin: 0 auto;           /* belt-and-suspenders centering */
}

.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-dynamic);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── 9. CALCULATOR ──────────────────────────────────────────── */
.section-calculator { background: var(--color-surface); }

.calculator-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 900px) {
  .calculator-layout {
    grid-template-columns: 1fr 380px;
    gap: var(--space-10);
  }
}

/* Form */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-select,
.form-input {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-text);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a7870' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-primary) 18%, transparent);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* Range slider */
.form-range {
  width: 100%;
  height: 6px;
  min-height: unset;
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
  border: none;
  padding: 0;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--color-primary);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
}

.form-range::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--color-primary);
  border-radius: 50%;
  border: none;
  box-shadow: var(--shadow-sm);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}

/* Finish options */
.finish-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.finish-option {
  cursor: pointer;
}

.finish-option input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.finish-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  min-height: 64px;
  justify-content: center;
}

.finish-label strong {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-display);
  line-height: 1.1;
}

.finish-label small {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.finish-option input:checked + .finish-label {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-primary) 20%, transparent);
}

.finish-option:hover .finish-label {
  border-color: var(--color-primary);
}

.calc-inputs { display: flex; flex-direction: column; gap: var(--space-6); }

/* Calculator Output */
.calc-output-sticky {
  position: sticky;
  top: calc(64px + var(--space-4));
}

.calc-output {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-3);
}

.output-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.output-city {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.output-range {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.output-low,
.output-high {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.output-dash {
  font-size: var(--text-lg);
  color: var(--color-text-faint);
}

.output-type {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.output-breakdown {
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.breakdown-row span:last-child {
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
}

.breakdown-contingency {
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
  color: var(--color-warning);
}

.breakdown-contingency span:last-child {
  color: var(--color-warning);
}

.output-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
  max-width: none;
}

/* ── 10. COST TABLES ──────────────────────────────────────── */
.section-tables { background: var(--color-bg); }

/* Tab nav */
.tab-nav {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-8);
  border-bottom: 2px solid var(--color-divider);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--color-text-muted);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), box-shadow var(--transition);
  position: relative;
  min-height: 44px;
  white-space: nowrap;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background var(--transition);
}

.tab-btn:hover { color: var(--color-text); background: var(--color-surface-offset); }

.tab-btn.active {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

.tab-btn.active::after { background: var(--color-primary); }

.tab-panel { animation: fadeIn 180ms ease; }
.tab-panel[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.tab-panel h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.tab-panel > p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-8);
  -webkit-overflow-scrolling: touch;
}

.cost-table {
  width: 100%;
  font-size: var(--text-sm);
}

.cost-table thead {
  background: var(--color-surface-offset);
}

.cost-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  white-space: nowrap;
  border-bottom: 2px solid var(--color-border);
}

.cost-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}

.cost-table td strong {
  font-weight: 600;
  color: var(--color-text);
}

.cost-table tbody tr:last-child td { border-bottom: none; }

.cost-table tbody tr {
  background: var(--color-surface);
  transition: background var(--transition);
}

.cost-table tbody tr:nth-child(even) {
  background: var(--color-surface-2);
}

.cost-table tbody tr:hover {
  background: var(--color-primary-highlight);
}

/* Responsive table — card view on mobile */
@media (max-width: 640px) {
  .cost-table thead { display: none; }
  .cost-table tbody tr {
    display: block;
    margin-bottom: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
  }
  .cost-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-divider);
    gap: var(--space-4);
  }
  .cost-table td:last-child { border-bottom: none; }
  .cost-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  .table-wrapper { border: none; }
}

/* Breakdown cards */
.cost-breakdown-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 600px) { .cost-breakdown-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .cost-breakdown-cards { grid-template-columns: repeat(3, 1fr); } }

.breakdown-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.breakdown-card h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-text);
  font-family: var(--font-display);
}

.breakdown-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.breakdown-card li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding-left: var(--space-4);
  position: relative;
  max-width: none;
}

.breakdown-card li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--text-xs);
  top: 2px;
}

/* ── 11. CITIES ─────────────────────────────────────────────── */
.section-cities { background: var(--color-surface-offset); }

.city-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 600px) { .city-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .city-grid { grid-template-columns: repeat(4, 1fr); } }

.city-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.city-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.city-card--featured {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}

@media (min-width: 960px) {
  .city-card--featured { grid-column: span 2; }
}

.city-card-inner { padding: var(--space-5); }

.city-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.city-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.city-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.city-badge--high { background: var(--color-accent-highlight); color: var(--color-accent); }
.city-badge--low { background: color-mix(in oklab, var(--color-success) 15%, transparent); color: var(--color-success); }

.city-costs {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.city-cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.city-cost-row span { color: var(--color-text-muted); }
.city-cost-row strong { font-weight: 700; color: var(--color-text); text-align: right; }

.city-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  max-width: none;
}

/* ── 12. TIPS ────────────────────────────────────────────────── */
.section-tips { background: var(--color-bg); }

.tips-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 600px) { .tips-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .tips-grid { grid-template-columns: repeat(3, 1fr); } }

.tip-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: box-shadow var(--transition), transform var(--transition);
}

.tip-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tip-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-highlight);
  border-radius: var(--radius-lg);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

.tip-card h3 {
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.tip-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ── 13. FAQ ─────────────────────────────────────────────────── */
.section-faq { background: var(--color-surface-offset); }

.faq-list { display: flex; flex-direction: column; gap: var(--space-2); }

.faq-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  text-align: left;
  padding: var(--space-5);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
  min-height: 60px;
}

.faq-question:hover { background: var(--color-surface-offset); }
.faq-question[aria-expanded='true'] { background: var(--color-primary-highlight); color: var(--color-primary); }

.faq-chevron {
  flex-shrink: 0;
  transition: transform var(--transition);
}

.faq-question[aria-expanded='true'] .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-divider);
}

.faq-answer p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-4);
  max-width: none;
}

.faq-answer ul,
.faq-answer ol {
  padding-left: var(--space-5);
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.faq-answer li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: none;
}

/* ── 14. FOOTER ──────────────────────────────────────────────── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  padding-block: var(--space-12);
}

@media (min-width: 768px) {
  .footer-inner { grid-template-columns: 1fr auto; gap: var(--space-12); }
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  max-width: 32ch;
}

.footer-nav {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.footer-nav-col h4 {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.footer-nav-col ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }

.footer-nav-col a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-nav-col a:hover { color: var(--color-primary); }

.footer-bottom {
  border-top: 1px solid var(--color-divider);
  padding-block: var(--space-5);
}

.footer-bottom p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  max-width: none;
}

/* ── 15. FONT FALLBACK IMPROVEMENT ──────────────────────────── */
:root {
  --font-display: 'Cabinet Grotesk', system-ui, 'Helvetica Neue', sans-serif;
  --font-body: 'General Sans', system-ui, 'Helvetica Neue', sans-serif;
}

/* ── 16. FRESHNESS TAG ───────────────────────────────────────── */
.freshness-tag {
  display: inline-block;
  background: var(--color-accent-highlight);
  color: var(--color-accent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 10px;
  letter-spacing: 0.02em;
}

/* ── 17. OUTPUT CHART (bar) ──────────────────────────────────── */
.output-chart {
  margin: var(--space-4) 0 var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.chart-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}
.chart-label {
  width: 110px;
  flex-shrink: 0;
  color: var(--color-text-muted);
}
.chart-bar-wrap {
  flex: 1;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
}
.chart-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 400ms cubic-bezier(0.16,1,0.3,1);
}
.chart-bar--mat  { background: var(--color-primary); }
.chart-bar--lab  { background: var(--color-accent); }
.chart-bar--misc { background: var(--color-text-faint); }
.chart-pct {
  width: 32px;
  text-align: right;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* ── 18. OUTPUT ACTIONS ──────────────────────────────────────── */
.output-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* ── 19. LOAN CALCULATOR ─────────────────────────────────────── */
.section-loan { background: var(--color-surface); }
.loan-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
  margin-top: var(--space-8);
}
@media (max-width: 680px) { .loan-layout { grid-template-columns: 1fr; } }
.loan-tips-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
}
@media (max-width: 680px) { .loan-tips-row { grid-template-columns: 1fr; } }

/* ── 20. TYPHOON SECTION ─────────────────────────────────────── */
.section-typhoon { background: var(--color-surface-offset); }
.typhoon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
}
@media (max-width: 900px) { .typhoon-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .typhoon-grid { grid-template-columns: 1fr; } }

.typhoon-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.typhoon-card--cta {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.typhoon-card--cta h3,
.typhoon-card--cta p { color: var(--color-text-inverse); }

.typhoon-icon { color: var(--color-primary); }
.typhoon-card--cta .typhoon-icon { color: var(--color-text-inverse); }

.typhoon-card h3 {
  font-size: var(--text-base);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.typhoon-cost-badge {
  display: inline-block;
  background: var(--color-accent-highlight);
  color: var(--color-accent);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 12px;
  width: fit-content;
}
.typhoon-cost-badge--large {
  font-size: var(--text-sm);
  padding: 5px 16px;
}
.typhoon-card--cta .typhoon-cost-badge {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.typhoon-card ul {
  margin: 0;
  padding-left: var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.typhoon-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin: 0;
  border-left: 3px solid var(--color-primary);
}

/* ── 21. CONTRACTOR CHECKLIST ────────────────────────────────── */
.section-checklist { background: var(--color-surface-2); }
.checklist-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-top: var(--space-8);
}
.checklist-print-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-offset);
  border-bottom: 1px solid var(--color-divider);
  flex-wrap: wrap;
}
.checklist-note {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}
.checklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: checklist;
}
.checklist-item {
  border-bottom: 1px solid var(--color-divider);
  transition: background var(--transition);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item:has(.checklist-check:checked) {
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
}
.checklist-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  cursor: pointer;
}
.checklist-check {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.checklist-label span {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.6;
}
.checklist-item:has(.checklist-check:checked) .checklist-label span {
  text-decoration: line-through;
  color: var(--color-text-muted);
}
.checklist-progress {
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-offset);
  border-top: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.checklist-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--color-surface-offset-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}
#checklist-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 300ms ease;
}
#checklist-progress-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── 22. SEO LANDING PAGE COMPONENTS ────────────────────────── */
.hero--compact { padding-block: var(--space-12) var(--space-10); }
.hero--compact h1 { font-size: var(--text-xl); }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.breadcrumb a { color: var(--color-text-muted); text-decoration: underline; }
.breadcrumb a:hover { color: var(--color-primary); }

/* ── 23. 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;
}

/* ── 24. CLS FIX — AD CONTAINER MIN-HEIGHTS ─────────────────── */
/* Reserve layout space before ads lazy-load — prevents CLS      */
.ad-leaderboard {
  min-height: 90px;
  max-height: 100px;
}
.ad-rectangle {
  min-height: 250px;
}
@media (max-width: 600px) {
  .ad-leaderboard { min-height: 50px; max-height: 60px; }
  .ad-rectangle   { min-height: 250px; }
}

/* ── 25. TABLE SCROLL CUE ────────────────────────────────────── */
/* Signals horizontal scroll to one-handed thumb navigators       */
.table-wrapper {
  position: relative;
}
.table-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 100%;
  background: linear-gradient(to left, var(--color-surface) 0%, transparent 100%);
  pointer-events: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  /* Only show when content overflows — JS or container query not needed:
     the gradient is invisible when table fits, visible when clipped */
}
/* Once fully scrolled right, hide the cue */
.table-wrapper:has(> .cost-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── 26. PRINT ───────────────────────────────────────────────── */
@media print {
  .site-header,
  .consent-banner,
  .ad-container,
  .hero-cta-group,
  .theme-toggle,
  .nav-toggle { display: none !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .cost-table { font-size: 10pt; }
}

/* ── 26. @MEDIA PRINT — MAIN PAGE QUOTATION VIEW ────────────── */
/* Strips web chrome so the calculator output prints as a clean   */
/* Renovation Quotation Sheet — shareable via Messenger/PDF       */
@media print {
  /* Hide everything except the estimate output */
  .site-header,
  .site-footer,
  .ad-container,
  .consent-banner,
  .hero,
  .section-tables,
  .section-cities,
  .section-tips,
  .section-typhoon,
  .section-checklist,
  .section-faq,
  .section-loan,
  .calc-inputs,
  .output-actions,
  .output-chart,
  .nav-toggle,
  .theme-toggle { display: none !important; }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
    font-family: 'Helvetica Neue', Arial, sans-serif;
  }

  /* Make the output panel fill the page */
  .section-calculator { padding: 0 !important; }
  .calculator-layout  { display: block !important; }

  .calc-output-sticky {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .calc-output {
    box-shadow: none !important;
    border: 1px solid #dcdcdc !important;
    border-radius: 8px !important;
    padding: 24px !important;
    page-break-inside: avoid;
  }

  /* Print branding footer */
  .calc-output::after {
    content: "Generated via RenovationCalcPH.com  ·  Share with your contractor  ·  renovationcalcph.com";
    display: block;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid #e0ddd8;
    font-size: 9pt;
    color: #999;
    text-align: center;
  }
}
