/*
File: sections.css
Purpose: Section headers, title boxes, and animated section reveals
Dependencies: style.css (custom properties), animations.css (keyframes)
Load Order: 4th (after animations.css)
*/

/* ===== SECTION HEADERS (BASE) ===== */
.section-header {
  background: transparent;
  border-radius: var(--radius-lg);
  box-shadow: none;
  box-sizing: border-box;
  color: var(--text-color);
  filter: none;
  margin-left: 9%;
  max-width: calc(100% - (var(--side-margin) * 2));
  overflow: visible;
  padding: 0;
  position: relative;
  text-align: center;
  z-index: var(--z-base);
}

.section-header h2 {
  height: 0px;
  visibility: hidden;
}

/* ===== ANIMATED TITLE BOXES ===== */
.title-box {
  max-width: 90%;
  align-items: center;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  justify-content: center;
  margin: 0;
  opacity: 1;
  overflow: hidden;
  padding: calc(var(--base-spacing) * 0.8) var(--base-spacing);
  position: relative;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.title-box:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

/* ===== TITLE BOX CONTENT ===== */
.title-content {
  display: inline-flex;
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: var(--font-weight-black);
  justify-content: center;
  line-height: 60px;
  position: relative;
  transform-origin: center;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
  left: calc(-5% - 20px);
}

.title-text {
  display: inline-block;
  text-align: center;
  white-space: nowrap;
}

/* ===== TITLE BOX REVEAL ANIMATIONS ===== */
.reveal-mask {
  animation: revealMask 1.8s ease-out forwards;
  animation-play-state: paused;
  bottom: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  z-index: 4;
}

.title-box.visible .reveal-mask {
  animation-play-state: running;
}

/* ===== ANIMATED LINE ELEMENTS ===== */
.line-static {
  height: 100%;  /* Changed from 90px */
  left: 0;
  margin-left: -40px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  z-index: 5;
}

.line-animated {
  animation: barSlideAndMorph 1.8s ease-out forwards;
  animation-play-state: paused;
  height: 100%;  /* Changed from 90px */
  left: 0;
  margin-left: -40px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transform-origin: center;
  width: 12px;
  z-index: 20;
}

.title-box.visible .line-animated {
  animation-play-state: running;
}

/* ===== ANIMATED CIRCLE ELEMENTS ===== */
.circle-1,
.circle-2 {
  border-radius: var(--radius-round);
  bottom: 12px;
  height: 12px;
  left: 100%;
  opacity: 0;
  position: absolute;
  pointer-events: none;
  transform: none;
  width: 12px;
  z-index: 25;
}

.circle-1 {
  animation: slideCircle1 0.3s ease-out forwards 1.5s;
  animation-play-state: paused;
}

.circle-2 {
  animation: slideCircle2 0.3s ease-out forwards 1.6s;
  animation-play-state: paused;
}

.title-box.visible .circle-1,
.title-box.visible .circle-2 {
  animation-play-state: running;
}

/* ===== CIRCLE ANIMATION KEYFRAMES ===== */
@keyframes slideCircle1 {
  0% {
    margin-left: 36px;
    opacity: 0;
    bottom: 12px;
    transform: none;
    width: 12px;
    height: 12px;
  }
  100% {
    margin-left: 52px;
    opacity: 1;
    bottom: 12px;
    transform: none;
    width: 12px;
    height: 12px;
  }
}

@keyframes slideCircle2 {
  0% {
    margin-left: 36px;
    opacity: 0;
    bottom: 12px;
    transform: none;
    width: 12px;
    height: 12px;
  }
  100% {
    margin-left: 72px;
    opacity: 1;
    bottom: 12px;
    transform: none;
    width: 12px;
    height: 12px;
  }
}

/* ===== TITLE BOX COLOR THEMES ===== */
/* Slate Blue with Orange Accents */
.title-box.slate-ochre {
  background-color: var(--tab-color);
}

.title-box.slate-ochre .reveal-mask {
  background-color: var(--tab-color);
}

.title-box.slate-ochre .line-static,
.title-box.slate-ochre .line-animated,
.title-box.slate-ochre .circle-1,
.title-box.slate-ochre .circle-2 {
  background: var(--highlight-color);
}

/* Forest Green with Orange Accents */
.title-box.emerald-ochre {
  background-color: var(--forest-green);
}

.title-box.emerald-ochre .reveal-mask {
  background-color: var(--forest-green);
}

.title-box.emerald-ochre .line-static,
.title-box.emerald-ochre .line-animated,
.title-box.emerald-ochre .circle-1,
.title-box.emerald-ochre .circle-2 {
  background: var(--highlight-color);
}

/* Brick Red with Orange Accents */
.title-box.brick-ochre {
  background-color: var(--rust-red);
}

.title-box.brick-ochre .reveal-mask {
  background-color: var(--rust-red);
}

.title-box.brick-ochre .line-static,
.title-box.brick-ochre .line-animated,
.title-box.brick-ochre .circle-1,
.title-box.brick-ochre .circle-2 {
  background: var(--highlight-color);
}

/* ===== SECTION WRAPPER PATTERNS ===== */
.cards-section-wrapper,
.inspiring-section-wrapper {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: 0;
  margin-bottom: var(--section-spacing);
  position: relative;
}

.cards-background-banner,
.inspiring-background-banner {
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.8);
  bottom: calc(var(--base-spacing) * -0.5);
  left: 0;
  position: absolute;
  right: 0;
  top: calc(var(--base-spacing) * -0.5);
  z-index: 0;
  pointer-events: none;
}

.cards-background-banner::before,
.inspiring-background-banner::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.04) 50%, rgba(255, 255, 255, 0.08) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  bottom: 0;
  content: '';
  left: 0;
  position: absolute;
  width: 100%;
  right: 0;
  top: 0;
}

/* ===== SCROLL WEIGHT EFFECTS ===== */
.scroll-weight-element {
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
              opacity var(--transition-base),
              filter var(--transition-base);
  will-change: transform, opacity, filter;
}

.scroll-weight-element.entering {
  filter: blur(1px);
  opacity: 0.7;
  transform: translateY(20px) scale(0.98);
}

.scroll-weight-element.active {
  filter: blur(0);
  opacity: 1;
  transform: translateY(0) scale(1);
}

.scroll-weight-element.leaving {
  filter: blur(0.5px);
  opacity: 0.8;
  transform: translateY(-10px) scale(1.02);
}

/* Enhanced scroll effects for title boxes */
.title-box.scroll-weight-element {
  transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1),
              opacity 0.4s ease,
              box-shadow 0.4s ease;
}

.title-box.scroll-weight-element.entering {
  box-shadow: var(--shadow-sm);
  opacity: 0.6;
  transform: translateY(30px) scale(0.96) rotateX(5deg);
}

.title-box.scroll-weight-element.active {
  box-shadow: var(--shadow-md);
  opacity: 1;
  transform: translateY(0) scale(1) rotateX(0);
}

.title-box.scroll-weight-element.leaving {
  box-shadow: var(--shadow-lg);
  opacity: 0.85;
  transform: translateY(-15px) scale(1.01) rotateX(-2deg);
}

/* ===== PAGE SECTION STYLING ===== */
.page-section {
  position: relative;
  padding: 40px 0;
  margin: 0;
}

/* Section Background Colors */
.page-section.bg-default {
  background: rgba(255, 255, 255, 0.9);
}

.page-section.bg-light-green {
  background: rgba(27, 81, 55, 0.1);
}

.page-section.bg-light-orange {
  background: rgba(204, 64, 32, 0.1);
}

.page-section.bg-dark-green {
  background: rgba(27, 81, 55, 0.8);
  color: white;
}

.page-section.bg-dark-green .section-title,
.page-section.bg-dark-green h1,
.page-section.bg-dark-green h2,
.page-section.bg-dark-green h3,
.page-section.bg-dark-green h4 {
  color: white;
}

/* ===== SECTION TITLE STYLING ===== */
.section-title {
  font-family: var(--font-primary);
  font-weight: 700;
  color: #1b5137;
  margin: 0 0 20px 0;
  line-height: 1.2;
}

/* Title sizes based on heading level */
.section-title.h1-title,
h1.section-title {
  font-size: 3rem;
  margin-bottom: 30px;
}

.section-title.h2-title,
h2.section-title {
  font-size: 2.5rem;
  margin-bottom: 25px;
}

.section-title.h3-title,
h3.section-title {
  font-size: 2rem;
  margin-bottom: 20px;
}

.section-title.h4-title,
h4.section-title {
  font-size: 1.5rem;
  margin-bottom: 15px;
}

/* ===== TITLE BLOCK STYLING ===== */
.title-block {
  margin: 20px 0;
}

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

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

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

.title-block h1,
.title-block h2,
.title-block h3,
.title-block h4 {
  font-family: var(--font-primary);
  font-weight: 700;
  margin: 0 0 15px 0;
  line-height: 1.2;
}

.title-block.title-default h1,
.title-block.title-default h2,
.title-block.title-default h3,
.title-block.title-default h4,
.title-block.title-green h1,
.title-block.title-green h2,
.title-block.title-green h3,
.title-block.title-green h4 {
  color: #1b5137;
}

.title-block.title-orange h1,
.title-block.title-orange h2,
.title-block.title-orange h3,
.title-block.title-orange h4 {
  color: #cc4020;
}

.title-subtitle {
  font-size: 1.1rem;
  color: #666;
  margin: 10px 0 0 0;
  font-style: italic;
  line-height: 1.4;
}

/* ===== UTILITY CLASSES FOR SECTIONS ===== */
.section-spacing-sm {
  margin-bottom: var(--base-spacing);
}

.section-spacing-md {
  margin-bottom: var(--section-spacing);
}

.section-spacing-lg {
  margin-bottom: calc(var(--section-spacing) * 1.5);
}

.section-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px);
}

.section-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: all 0.6s var(--transition-smooth);
}

.section-bg-light {
  background: rgba(255, 255, 255, 0.9);
}

.section-bg-dark {
  background: rgba(27, 81, 55, 0.9);
}

.section-bg-accent {
  background: rgba(79, 154, 168, 0.9);
}

/* ===== INTEGRATION WITH EXISTING THEME ===== */
.page-section .section,
.page-section .block {
  background: none;
  padding: 0;
  margin: 0;
}

.page-section .content-block {
  background: none;
  border: none;
  padding: 0;
  margin: 20px 0;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Large screens (1200px+) */
@media (min-width: 1200px) {
  .title-content {
    font-size: 52px;
    line-height: 68px;
  }
}

/* Medium screens (900px - 1200px) */
@media (max-width: 1200px) and (min-width: 900px) {
  .title-box {
    padding: calc(var(--base-spacing) * 0.7) calc(var(--base-spacing) * 0.9);
  }

  .title-content {
    font-size: 44px;
    line-height: 58px;
  }
}

/* Small desktop/tablet (600px - 900px) */
@media (max-width: 900px) {
  .title-box {
    padding: 30px 10px 30px 20px;
  }

  .title-content {
    font-size: 40px;
    line-height: 52px;
  }

  .line-static,
  .line-animated {
    height: 72px;
    margin-left: -32px;
    width: 10px;
  }

  .circle-1,
  .circle-2 {
    bottom: 12px;
    height: 10px;
    width: 10px;
  }

  .circle-1 {
    animation: slideCircle1 var(--transition-base) ease-out forwards 1.5s;
  }

  .circle-2 {
    animation: slideCircle2 var(--transition-base) ease-out forwards 1.6s;
  }
}

/* Mobile (480px - 600px) */
@media (max-width: 600px) {
  .title-box {
    padding: 25px 10px 25px 15px;
  }

  .title-content {
    font-size: 34px;
    line-height: 44px;
  }

  .cards-section-wrapper,
  .inspiring-section-wrapper {
    margin-bottom: calc(var(--section-spacing) * 0.75);
  }

  .line-static,
  .line-animated {
    height: 54px;
    margin-left: -24px;
    width: 8px;
  }

  .circle-1,
  .circle-2 {
    bottom: 10px;
    height: 8px;
    width: 8px;
  }
}

/* Small mobile (320px - 480px) */
@media (max-width: 400px) {
  .title-box {
    padding: 20px 5px 20px 10px;
  }

  .title-content {
    font-size: 28px;
    line-height: 36px;
  }

  .line-static,
  .line-animated {
    height: 42px;
    margin-left: -18px;
    width: 6px;
  }

  .circle-1,
  .circle-2 {
    bottom: 8px;
    height: 6px;
    width: 6px;
  }
}

/* Mobile responsive for page sections */
@media (max-width: 768px) {
  .page-section {
    padding: 20px 0;
  }

  .section-title.h1-title,
  h1.section-title {
    font-size: 2.2rem;
  }

  .section-title.h2-title,
  h2.section-title {
    font-size: 1.8rem;
  }

  .section-title.h3-title,
  h3.section-title {
    font-size: 1.5rem;
  }

  .section-title.h4-title,
  h4.section-title {
    font-size: 1.3rem;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.title-box,
.line-animated,
.circle-1,
.circle-2,
.reveal-mask {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000px;
  -webkit-perspective: 1000px;
}

/* ===== ACCESSIBILITY FEATURES ===== */
/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .scroll-weight-element {
    transition: opacity var(--transition-fast);
  }

  .scroll-weight-element.entering,
  .scroll-weight-element.leaving,
  .title-box.scroll-weight-element.entering,
  .title-box.scroll-weight-element.leaving {
    filter: none;
    transform: none;
  }

  .reveal-mask,
  .line-animated,
  .circle-1,
  .circle-2 {
    animation: none !important;
  }

  .title-box.visible .reveal-mask {
    width: 0;
  }

  .title-box.visible .circle-1,
  .title-box.visible .circle-2 {
    opacity: 1;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .title-box {
    border: 2px solid var(--text-color);
  }

  .cards-background-banner,
  .inspiring-background-banner {
    background: rgba(255, 255, 255, 0.95);
  }
}

/* Focus states for keyboard navigation */
.title-box:focus-visible {
  outline: 3px solid var(--highlight-color);
  outline-offset: 4px;
}