/* ==========================================================================
   WebFlur Responsive System
   Single source of truth for fluid layouts, type, and spacing.
   Mobile-first. Works on any device 320px → 4K without per-page tweaks.
   ========================================================================== */

/* ---------- 1. Design Tokens ---------- */
:root {
  /* Brand */
  --cream: #f3ede2;
  --ink: #0a0a0a;
  --blue: #1f3cff;
  --blue-glow: #4d6cff;

  /* Breakpoints (reference only — used by media queries below) */
  --bp-sm: 640px;
  --bp-md: 1024px;
  --bp-lg: 1280px;
  --bp-xl: 1536px;

  /* Fluid type scale — clamp(min, preferred, max)
     Scales smoothly between 320px and 1536px viewports. */
  --fs-xs:   clamp(0.75rem,  0.70rem + 0.25vw, 0.875rem);
  --fs-sm:   clamp(0.875rem, 0.82rem + 0.27vw, 1rem);
  --fs-base: clamp(1rem,     0.93rem + 0.36vw, 1.125rem);
  --fs-md:   clamp(1.125rem, 1.04rem + 0.45vw, 1.25rem);
  --fs-lg:   clamp(1.25rem,  1.10rem + 0.75vw, 1.5rem);
  --fs-xl:   clamp(1.5rem,   1.25rem + 1.25vw, 2rem);
  --fs-2xl:  clamp(1.875rem, 1.45rem + 2.1vw,  2.75rem);
  --fs-3xl:  clamp(2.25rem,  1.65rem + 3.0vw,  3.75rem);
  --fs-4xl:  clamp(2.75rem,  1.90rem + 4.25vw, 5rem);
  --fs-5xl:  clamp(3.25rem,  2.15rem + 5.5vw,  6.25rem);

  /* Fluid spacing scale */
  --space-3xs: clamp(0.25rem, 0.23rem + 0.1vw, 0.375rem);
  --space-2xs: clamp(0.5rem,  0.45rem + 0.25vw, 0.75rem);
  --space-xs:  clamp(0.75rem, 0.65rem + 0.5vw,  1rem);
  --space-sm:  clamp(1rem,    0.85rem + 0.75vw, 1.5rem);
  --space-md:  clamp(1.5rem,  1.20rem + 1.5vw,  2.5rem);
  --space-lg:  clamp(2rem,    1.50rem + 2.5vw,  3.75rem);
  --space-xl:  clamp(3rem,    2.20rem + 4.0vw,  5.5rem);
  --space-2xl: clamp(4rem,    2.80rem + 6.0vw,  8rem);
  --space-3xl: clamp(5rem,    3.40rem + 8.0vw,  10rem);

  /* Container widths */
  --container-narrow: 720px;
  --container:        1120px;
  --container-wide:   1320px;

  /* Touch target minimum (Apple HIG / WCAG) */
  --touch-min: 44px;

  /* Radii */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 24px;
  --radius-pill: 999px;
}

/* ---------- 2. Universal safe defaults ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  /* Prevents horizontal scroll caused by stray overflowing children */
  overflow-x: clip;
  font-size: var(--fs-base);
  line-height: 1.55;
}

/* Media never overflows its container.
   NOTE: SVGs are excluded — many decorative SVGs are sized by their parent
   (e.g. orbit visuals), and forcing height:auto would collapse them. */
img, video, canvas, picture {
  max-width: 100%;
  height: auto;
  display: block;
}
svg { max-width: 100%; }

/* Long words / URLs wrap instead of forcing horizontal scroll */
p, h1, h2, h3, h4, h5, h6, li, a, span {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Tables don't blow out small screens */
table { width: 100%; border-collapse: collapse; }

/* Touch targets */
button, a.btn, .cta, [role="button"], input[type="submit"], input[type="button"] {
  min-height: var(--touch-min);
}

/* Remove tap highlight delay on iOS */
a, button { -webkit-tap-highlight-color: transparent; }

/* ---------- 3. Containers ---------- */
.r-container,
.r-container-narrow,
.r-container-wide {
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--space-sm);
}
.r-container         { max-width: var(--container); }
.r-container-narrow  { max-width: var(--container-narrow); }
.r-container-wide    { max-width: var(--container-wide); }

@media (min-width: 640px) {
  .r-container,
  .r-container-narrow,
  .r-container-wide { padding-inline: var(--space-md); }
}

/* ---------- 4. Section spacing ---------- */
.r-section    { padding-block: var(--space-xl); }
.r-section-sm { padding-block: var(--space-lg); }
.r-section-lg { padding-block: var(--space-2xl); }

/* ---------- 5. Auto-reflow grids ---------- */
/* These grids reflow themselves — no media queries needed.
   Children automatically stack on narrow screens. */
.r-grid-auto {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}
.r-grid-auto-sm {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}
.r-grid-auto-lg {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
}

/* Fixed-column grids that collapse to single column on small screens */
.r-grid-2 { display: grid; gap: var(--space-md); grid-template-columns: 1fr; }
.r-grid-3 { display: grid; gap: var(--space-md); grid-template-columns: 1fr; }
.r-grid-4 { display: grid; gap: var(--space-md); grid-template-columns: 1fr; }

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

/* ---------- 6. Flex utilities ---------- */
.r-flex      { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.r-flex-col  { display: flex; flex-direction: column; gap: var(--space-sm); }
.r-flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }

/* ---------- 7. Fluid type utilities ---------- */
.r-h1 { font-size: var(--fs-5xl); line-height: 1.05; letter-spacing: -0.03em; font-weight: 800; }
.r-h2 { font-size: var(--fs-4xl); line-height: 1.08; letter-spacing: -0.03em; font-weight: 800; }
.r-h3 { font-size: var(--fs-3xl); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
.r-h4 { font-size: var(--fs-2xl); line-height: 1.2;  letter-spacing: -0.02em; font-weight: 700; }
.r-h5 { font-size: var(--fs-xl);  line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }
.r-lead    { font-size: var(--fs-md); line-height: 1.5; }
.r-body    { font-size: var(--fs-base); line-height: 1.6; }
.r-small   { font-size: var(--fs-sm); line-height: 1.5; }

/* ---------- 8. Container queries (component-level responsiveness) ---------- */
/* Add `.r-cq` to a parent to make children respond to its width, not viewport. */
.r-cq { container-type: inline-size; }

@container (min-width: 480px) {
  .r-cq-stack-to-row { flex-direction: row; }
}

/* ---------- 9. Mobile kill-switches for problematic patterns ---------- */
/* On mobile, horizontal-scroll-pinned sections (300vw tracks, sticky orbits)
   tend to break. Add `.r-disable-pin-on-mobile` to such wrappers and they
   will fall back to a normal vertical stack on small screens. */
@media (max-width: 768px) {
  .r-disable-pin-on-mobile {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  .r-disable-pin-on-mobile > * {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
  }
  .r-disable-pin-on-mobile .service-track,
  .r-disable-pin-on-mobile .service-row {
    width: 100% !important;
    display: block !important;
  }
  .r-disable-pin-on-mobile .service-row {
    padding: var(--space-md) var(--space-sm) !important;
  }
}

/* ---------- 10. Visibility utilities ---------- */
.r-hide-mobile { display: initial; }
.r-show-mobile { display: none; }

@media (max-width: 639px) {
  .r-hide-mobile { display: none !important; }
  .r-show-mobile { display: initial !important; }
}

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

/* ---------- 12. Print ---------- */
@media print {
  .r-no-print { display: none !important; }
  body { background: #fff; color: #000; }
}
