/* ==========================================================================
   Helio Urban Development - Base Styles
   Foundation styles, variables, reset, layout, and utilities

   TABLE OF CONTENTS:
   1. CSS Custom Properties (Variables)
   2. Reset & Base Styles
   3. Typography
   4. Layout (Container, Grid, Sections)
   5. Utilities
   5.5. Mobile Foundation
   5.6. Global Focus Indicators
   6. Reduced Motion & Print Overrides
   ========================================================================== */

/* ==========================================================================
   1. CSS Custom Properties (Variables)
   ========================================================================== */

:root {
  /* Gold - Primary accent */
  --gold: #d8a035; /* Primary gold accent */
  --gold-900: #8b6a1f; /* Dark gold for text on white */
  --gold-600: #c4912f;
  --gold-500: #d8a035; /* Primary */
  --gold-400: #e5b84d;
  --gold-200: #f5d89f; /* Light gold */
  --gold-100: #fdf6e3;

  /* Charcoal - Text and dark sections */
  --charcoal-900: #111111;
  --charcoal-800: #1a1a1a;
  --charcoal-750: #242424;
  --charcoal-700: #2d2d2d;
  --charcoal-600: #404040;

  /* Neutrals - Backgrounds and borders */
  --white: #ffffff;
  --warm-white: #fafaf9;
  --gray-50: #fafaf9; /* Surface elevation */
  --gray-100: #f5f5f4;
  --gray-200: #e7e5e4;
  --gray-300: #d6d3d1;
  --gray-400: #a8a29e;
  --gray-500: #78716c;
  --gray-600: #57534e;
  --gray-700: #44403c;

  /* Surface Elevation System */
  --surface-0: #ffffff;
  --surface-1: #fafaf9;
  --surface-2: #f5f5f4;
  --surface-3: #e7e5e4;

  /* Feedback */
  --success: #16a34a;
  --success-light: #dcfce7;
  --error: #dc2626;
  --error-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;

  /* Links */
  --link: #d8a035;
  --link-hover: #c4912f;
  --link-visited: #a67c2e;

  /* Typography */
  --font-display: "Outfit", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Monaco, "Courier New", monospace;

  /* Type Scale */
  --text-display-xl: clamp(3rem, 6vw, 4.5rem);
  --text-display-lg: clamp(2.25rem, 4vw, 3rem);
  --text-display-md: clamp(1.75rem, 3vw, 2.25rem);
  --text-3xl: 1.875rem;
  --text-2xl: 1.5rem;
  --text-xl: 1.25rem;
  --text-lg: 1.125rem;
  --text-base: 1rem;
  --text-sm: 0.875rem;
  --text-xs: 0.75rem;

  /* Line Heights */
  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.6;
  --leading-relaxed: 1.65;

  /* Letter Spacing */
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.05em;
  --tracking-wider: 0.1em;

  /* Spacing (8px base with half-steps) */
  --space-px: 1px;
  --space-0-5: 0.125rem; /* 2px */
  --space-1: 0.25rem; /* 4px */
  --space-1-5: 0.375rem; /* 6px */
  --space-2: 0.5rem; /* 8px */
  --space-2-5: 0.625rem; /* 10px */
  --space-3: 0.75rem; /* 12px */
  --space-3-5: 0.875rem; /* 14px */
  --space-4: 1rem; /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem; /* 24px */
  --space-7: 1.75rem; /* 28px */
  --space-8: 2rem; /* 32px */
  --space-9: 2.25rem; /* 36px */
  --space-10: 2.5rem; /* 40px */
  --space-12: 3rem; /* 48px */
  --space-14: 3.5rem; /* 56px */
  --space-16: 4rem; /* 64px */
  --space-18: 4.5rem; /* 72px */
  --space-20: 5rem; /* 80px */
  --space-22: 5.5rem; /* 88px */
  --space-24: 6rem; /* 96px */
  --space-32: 8rem; /* 128px */

  /* Breakpoints (canonical - use these consistently)
     Mobile-first: always use min-width
     sm: Large phones landscape, small tablets
     md: Tablets portrait
     lg: Tablets landscape, small desktops
     xl: Desktops
  */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  /* Container Widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1440px;

  /* Touch Targets (WCAG 2.1 AA) */
  --touch-target-min: 44px;
  --touch-target-comfortable: 48px;
  --touch-spacing-min: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl:
    0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-gold: 0 4px 14px 0 rgb(216 160 53 / 0.3);
  --shadow-gold-lg: 0 8px 24px 0 rgb(216 160 53 / 0.4);
  --shadow-elevated:
    0 1px 2px rgb(0 0 0 / 0.04), 0 4px 8px rgb(0 0 0 / 0.04),
    0 12px 24px rgb(0 0 0 / 0.06);
  --shadow-focus: 0 0 0 3px rgb(216 160 53 / 0.15);
  --shadow-focus-error: 0 0 0 3px rgb(220 38 38 / 0.15);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Z-Index */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;

  /* Animation */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-expo-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 700ms;
}

/* ==========================================================================
   2. Reset & Base Styles
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--charcoal-900);
  background-color: var(--warm-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

/* ==========================================================================
   3. Typography
   ========================================================================== */

.text-hero {
  font-family: var(--font-display);
  font-size: var(--text-display-xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--charcoal-900);
}

.text-section {
  font-family: var(--font-display);
  font-size: var(--text-display-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--charcoal-900);
}

.text-subsection {
  font-family: var(--font-display);
  font-size: var(--text-display-md);
  font-weight: 500;
  line-height: var(--leading-snug);
  color: var(--charcoal-900);
}

.text-lead {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: var(--leading-normal);
  color: var(--gray-600);
}

.text-body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-normal);
  color: var(--charcoal-900);
}

.text-stat {
  font-family: var(--font-mono);
  font-size: var(--text-display-lg);
  font-weight: 500;
  line-height: 1;
  color: var(--gold-500);
}

.text-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--gray-500);
}

.text-button {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
}

/* ==========================================================================
   4. Layout (Container, Grid, Sections)
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

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

.container--wide {
  max-width: var(--container-2xl);
}

/* Sections */
.section {
  padding-top: var(--space-10);
  padding-bottom: var(--space-10);
}

@media (min-width: 768px) {
  .section {
    padding-top: var(--space-18);
    padding-bottom: var(--space-18);
  }
}

@media (min-width: 1024px) {
  .section {
    padding-top: var(--space-22);
    padding-bottom: var(--space-22);
  }
}

.section--sm {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
}

@media (min-width: 768px) {
  .section--sm {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
  }
}

.section--gray {
  background-color: var(--gray-100);
}

.section--dark {
  background-color: var(--charcoal-800);
  color: var(--white);
}

.section--dark h2,
.section--dark h3 {
  color: var(--white);
}

.section--dark p {
  color: var(--gray-300);
}

.section__header {
  text-align: center;
  margin-bottom: var(--space-6);
}

@media (min-width: 768px) {
  .section__header {
    margin-bottom: var(--space-10);
  }
}

.section__title {
  margin-bottom: var(--space-4);
}

.section__subtitle {
  max-width: min(60ch, 100%);
  margin-left: auto;
  margin-right: auto;
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-5);
}

.grid--2 {
  grid-template-columns: 1fr;
}

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

.grid--3 {
  grid-template-columns: 1fr;
}

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

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

.grid--4 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 479px) {
  .grid--4 {
    grid-template-columns: 1fr;
  }
}

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

/* ==========================================================================
   5. Utilities
   ========================================================================== */

/* Text alignment */
.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

/* Display */
.hidden {
  display: none;
}
.block {
  display: block;
}
.flex {
  display: flex;
}
.inline-flex {
  display: inline-flex;
}
.grid {
  display: grid;
}

/* Flex utilities */
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.flex-col {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.gap-2 {
  gap: var(--space-2);
}
.gap-4 {
  gap: var(--space-4);
}
.gap-6 {
  gap: var(--space-6);
}
.gap-8 {
  gap: var(--space-8);
}

/* Margin utilities */
.mt-0 {
  margin-top: 0;
}
.mt-4 {
  margin-top: var(--space-4);
}
.mt-6 {
  margin-top: var(--space-6);
}
.mt-8 {
  margin-top: var(--space-8);
}
.mt-12 {
  margin-top: var(--space-12);
}
.mb-0 {
  margin-bottom: 0;
}
.mb-4 {
  margin-bottom: var(--space-4);
}
.mb-6 {
  margin-bottom: var(--space-6);
}
.mb-8 {
  margin-bottom: var(--space-8);
}
.mb-12 {
  margin-bottom: var(--space-12);
}
.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

/* Padding utilities */
.p-4 {
  padding: var(--space-4);
}
.p-6 {
  padding: var(--space-6);
}
.p-8 {
  padding: var(--space-8);
}
.py-4 {
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}
.py-8 {
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}
.px-4 {
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* Width */
.w-full {
  width: 100%;
}
.max-w-prose {
  max-width: 65ch;
}
.max-w-md {
  max-width: var(--container-md);
}
.max-w-lg {
  max-width: var(--container-lg);
}

/* Responsive visibility */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}
@media (min-width: 768px) {
  .hide-desktop {
    display: none !important;
  }
}

/* ==========================================================================
   5.5. Mobile Foundation
   Canonical breakpoints, touch targets, and mobile-first utilities
   ========================================================================== */

/*
 * BREAKPOINT REFERENCE (mobile-first, use min-width):
 * ------------------------------------------------
 * Default    : 0 - 639px   (phones portrait)
 * sm         : 640px+      (phones landscape, small tablets)
 * md         : 768px+      (tablets portrait)
 * lg         : 1024px+     (tablets landscape, desktops)
 * xl         : 1280px+     (large desktops)
 *
 * USAGE:
 * @media (min-width: 640px)  { } // sm and up
 * @media (min-width: 768px)  { } // md and up
 * @media (min-width: 1024px) { } // lg and up
 * @media (min-width: 1280px) { } // xl and up
 */

/* Touch Target Base Styles
   Ensure all interactive elements meet minimum touch target size */
.touch-target {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
}

.touch-target-comfortable {
  min-width: var(--touch-target-comfortable);
  min-height: var(--touch-target-comfortable);
}

/* Mobile-specific button sizing */
@media (max-width: 767px) {
  button,
  [role="button"],
  .btn,
  input[type="button"],
  input[type="submit"] {
    min-height: var(--touch-target-comfortable);
  }

  /* Ensure adequate spacing between touch targets */
  .touch-row {
    gap: var(--touch-spacing-min);
  }
}

/* Mobile Stack Utilities
   Force single-column layout on mobile */
.mobile-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .mobile-stack {
    flex-direction: row;
  }
}

/* Mobile Full Width
   Make element full width on mobile, auto on desktop */
.mobile-full {
  width: 100%;
}

@media (min-width: 768px) {
  .mobile-full {
    width: auto;
  }
}

/* Mobile Center
   Center content on mobile only */
@media (max-width: 767px) {
  .mobile-center {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Mobile Padding Adjustments
   Reduce padding on mobile for more content space */
.mobile-compact {
  padding: var(--space-3);
}

@media (min-width: 768px) {
  .mobile-compact {
    padding: var(--space-6);
  }
}

/* Safe Area Insets (for notched devices) */
@supports (padding: env(safe-area-inset-bottom)) {
  .safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .safe-top {
    padding-top: env(safe-area-inset-top);
  }

  .safe-horizontal {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Responsive Text Alignment */
@media (max-width: 767px) {
  .md\:text-left {
    text-align: center;
  }
}
@media (min-width: 768px) {
  .md\:text-left {
    text-align: left;
  }
}

/* Responsive Spacing (mobile-reduced) */
.responsive-gap {
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .responsive-gap {
    gap: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .responsive-gap {
    gap: var(--space-8);
  }
}

/* Prevent Horizontal Overflow */
.overflow-safe {
  max-width: 100%;
  overflow-x: hidden;
}

/* Mobile-Optimized Form Inputs */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="url"],
  textarea,
  select {
    width: 100%;
    min-height: var(--touch-target-comfortable);
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* Responsive Hide/Show Utilities (extended) */
.show-sm {
  display: none;
}
.show-md {
  display: none;
}
.show-lg {
  display: none;
}

@media (min-width: 640px) {
  .hide-sm {
    display: none !important;
  }
  .show-sm {
    display: block;
  }
  .show-sm-flex {
    display: flex;
  }
  .show-sm-inline {
    display: inline;
  }
}

@media (min-width: 768px) {
  .hide-md {
    display: none !important;
  }
  .show-md {
    display: block;
  }
  .show-md-flex {
    display: flex;
  }
  .show-md-inline {
    display: inline;
  }
}

@media (min-width: 1024px) {
  .hide-lg {
    display: none !important;
  }
  .show-lg {
    display: block;
  }
  .show-lg-flex {
    display: flex;
  }
  .show-lg-inline {
    display: inline;
  }
}

/* Screen reader only */
.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.6. Global Focus Indicators
   ========================================================================== */

/* Enhanced focus styles for all interactive elements */
:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

/* Links get underline on focus */
a:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--gold-500);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Hide focus ring on mouse/touch interactions, keep for keyboard */
*:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   5.7. Skip Link (Accessibility)
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 12px 24px;
  background: var(--gold-500);
  color: var(--charcoal-900);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

/* ==========================================================================
   6. Reduced Motion & Print Overrides
   ========================================================================== */

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

  html {
    scroll-behavior: auto;
  }

  .reveal,
  .reveal-stagger > * {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  /* Hide non-essential elements */
  .nav,
  .footer,
  .mobile-menu,
  .btn,
  .router,
  .form-embed,
  .calculator__inputs .calc-slider {
    display: none !important;
  }

  /* Reset backgrounds */
  body {
    background: white;
    color: black;
  }

  .section,
  .section--gray,
  .section--dark {
    background: white;
    color: black;
    padding: 1rem 0;
  }

  .section--dark h2,
  .section--dark h3,
  .section--dark p {
    color: black;
  }

  /* Ensure content is visible */
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  /* Show URLs for links */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Page breaks */
  .section {
    break-inside: avoid;
  }

  h2,
  h3 {
    break-after: avoid;
  }
}
