/*
 * Global Styles
 *
 * Core typography, layout containers, and reusable patterns
 * used across all pages of the Rooted Financial Wellness website.
 */

/* ============================================
   BODY & ROOT
   ============================================ */

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

/* ============================================
   TYPOGRAPHY
   ============================================ */

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-charcoal);
  margin-bottom: var(--space-md);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

h5, h6 {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
}

/* Paragraphs */
p {
  margin-bottom: var(--space-sm);
  text-wrap: pretty;
}

p:last-child {
  margin-bottom: 0;
}

/* Emphasized text for lead paragraphs */
.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-charcoal);
  opacity: 0.9;
}

/* Small text */
small, .text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

/* Strong and emphasis */
strong, b {
  font-weight: var(--font-weight-bold);
}

em, i {
  font-style: italic;
}

/* Links */
a {
  color: var(--color-sage);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-sage-dark);
  text-decoration: underline;
}

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

/* Links in paragraphs */
p a {
  text-decoration: underline;
  text-decoration-color: var(--color-sage);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* ============================================
   LAYOUT CONTAINERS
   ============================================ */

/*
 * .container: Centers content with max-width and horizontal padding
 * Use this as the main wrapper for page content
 */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-sm);
  padding-right: var(--space-sm);
}

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

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

/*
 * .container-narrow: Smaller max-width for focused content
 * Good for forms, articles, or centered text
 */
.container-narrow {
  max-width: var(--container-md);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-sm);
  padding-right: var(--space-sm);
}

/*
 * .section: Adds consistent vertical spacing between page sections
 */
.section {
  padding-top: var(--space-lg);
  padding-bottom: var(--space-lg);
}

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

/*
 * .section-sm: Smaller section spacing
 */
.section-sm {
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
}

/* ============================================
   GRID LAYOUTS
   ============================================ */

/*
 * Responsive grid: 1 column on mobile, 2 on tablet+
 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

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

/*
 * Responsive grid: 1 column on mobile, 3 on desktop
 */
.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

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

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

/*
 * Responsive grid: 1 column on mobile, 4 on large desktop
 */
.grid-4 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

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

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

/* ============================================
   FLEXBOX UTILITIES
   ============================================ */

.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-xs {
  gap: var(--space-xs);
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

/* ============================================
   TEXT ALIGNMENT
   ============================================ */

.text-left {
  text-align: left;
}

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

.text-right {
  text-align: right;
}

/* Center text on mobile, left-align on desktop */
.text-center-mobile {
  text-align: center;
}

@media (min-width: 768px) {
  .text-center-mobile {
    text-align: left;
  }
}

/* ============================================
   BACKGROUND COLORS
   ============================================ */

.bg-cream {
  background-color: var(--color-cream);
}

.bg-white {
  background-color: var(--color-white);
}

.bg-sage {
  background-color: var(--color-sage);
  color: var(--color-white);
}

.bg-purple {
  background-color: var(--color-purple);
  color: var(--color-white);
}

.bg-sage h1,
.bg-sage h2,
.bg-sage h3,
.bg-sage h4,
.bg-sage h5,
.bg-sage h6,
.bg-purple h1,
.bg-purple h2,
.bg-purple h3,
.bg-purple h4,
.bg-purple h5,
.bg-purple h6 {
  color: var(--color-white);
}

/* ============================================
   SPACING UTILITIES
   ============================================ */

/* Margin utilities */
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

/* ============================================
   CONTENT WIDTH UTILITIES
   ============================================ */

/*
 * Limit text width for better readability
 */
.max-w-prose {
  max-width: 65ch;
}

.max-w-sm {
  max-width: var(--container-sm);
}

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

.max-w-lg {
  max-width: var(--container-lg);
}

.max-w-full {
  max-width: 100%;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/*
 * Skip to main content link (for keyboard navigation)
 * Hidden by default, visible on focus
 */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-sage);
  color: white;
  padding: var(--space-xs) var(--space-sm);
  text-decoration: none;
  z-index: var(--z-tooltip);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: var(--space-xs);
  left: var(--space-xs);
}

/* ============================================
   ANIMATIONS
   ============================================ */

/*
 * Scroll Animation System (Progressive Enhancement)
 *
 * IMPORTANT: Content is ALWAYS visible by default.
 * JavaScript adds .js-ready to <html> when animations are set up.
 * Only THEN do elements hide and wait for scroll-triggered reveal.
 * This ensures content is never invisible if JS fails.
 */

/* Animation keyframes */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Only hide elements when JS has confirmed it's ready */
html.js-ready .animate-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Reveal elements when they scroll into view */
html.js-ready .animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   LISTS
   ============================================ */

/*
 * Styled lists (when you want bullet points)
 */
ul.styled-list,
ol.styled-list {
  padding-left: var(--space-md);
  margin-bottom: var(--space-sm);
}

ul.styled-list {
  list-style-type: disc;
}

ol.styled-list {
  list-style-type: decimal;
}

ul.styled-list li,
ol.styled-list li {
  margin-bottom: var(--space-xs);
  padding-left: var(--space-xs);
}

/*
 * Checkmark list (for features, benefits, etc.)
 */
ul.check-list {
  list-style: none;
  padding-left: 0;
}

ul.check-list li {
  position: relative;
  padding-left: var(--space-md);
  margin-bottom: var(--space-sm);
}

ul.check-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--color-sage);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
}

/* ============================================
   IMAGES
   ============================================ */

img {
  border-radius: var(--radius-md);
}

figure {
  margin: var(--space-md) 0;
}

figcaption {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-charcoal);
  opacity: 0.7;
  text-align: center;
}

/* ============================================
   HORIZONTAL RULES
   ============================================ */

hr {
  border: none;
  border-top: var(--border-width) solid var(--color-charcoal);
  opacity: 0.2;
  margin: var(--space-lg) 0;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */

blockquote {
  border-left: 4px solid var(--color-sage);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  font-style: italic;
  color: var(--color-charcoal);
  opacity: 0.9;
  text-wrap: balance;
}

blockquote p {
  margin-bottom: var(--space-sm);
}

blockquote cite {
  display: block;
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  font-style: normal;
  color: var(--color-charcoal);
  opacity: 0.7;
}

blockquote cite::before {
  content: '— ';
}
