/* ==========================================================================
   CLI MATE DATA STORYTELLING WEB SHELL — DESIGN SYSTEM & STYLES
   Minimalist, Competition-Quality Editorial Data Journalism
   ========================================================================== */

:root {
  /* Foundation Colors */
  --white: #FFFFFF;
  --black: #111111;
  --gray: #6B6B6B;
  --light-gray: #E5E5E5;

  /* Coastal Blue Palette */
  --blue-mist: #EAF5F8;
  --blue-light: #CFE8F0;
  --blue-soft: #A8D5E2;
  --blue-water: #6FB3C8;
  --blue-coastal: #4D96B0;
  --blue-ocean: #397E9B;

  /* Coral Accent (Used strictly <10% for human/economic impact) */
  --coral: #E58B7B;

  /* Architectural Layout Constraints */
  --text-width: 720px;
  --visual-width: 1280px;

  /* Typography System */
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

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

html {
  font-family: var(--font-family);
  background-color: var(--white);
  color: var(--black);
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--white);
  color: var(--black);
  line-height: 1.7;
  overflow-x: hidden;
  position: relative;
}

/* Accessible Focus States */
:focus-visible {
  outline: 2px solid var(--blue-coastal);
  outline-offset: 4px;
}

/* Selection Highlights */
::selection {
  background-color: var(--blue-light);
  color: var(--black);
}

/* ==========================================================================
   PROGRESS & READING INDICATORS
   ========================================================================== */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background-color: var(--blue-coastal);
  z-index: 100;
  transition: width 0.1s ease-out, background-color 0.3s ease;
}

.progress-bar.is-impact {
  background-color: var(--coral);
}

.reading-indicator {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--light-gray);
  padding: 0.5rem 0.875rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--gray);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  transition: opacity 0.3s ease, border-color 0.3s ease;
}

.reading-indicator .reading-part {
  color: var(--black);
  font-weight: 700;
  transition: color 0.3s ease;
}

.reading-indicator.is-impact .reading-part {
  color: var(--coral);
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */

.hero-section {
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7rem 1.5rem 5rem;
  position: relative;
  border-bottom: 1px solid var(--light-gray);
  background-color: var(--white);
}

.content-wrapper {
  max-width: var(--text-width);
  margin: 0 auto;
  width: 100%;
}

.hero-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-ocean);
  margin-bottom: 2rem;
}

.hero-meta-badge .meta-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--blue-coastal);
  display: inline-block;
}

.hero-title {
  font-size: clamp(2.5rem, 5.5vw, 4.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.035em;
  color: var(--black);
  margin-bottom: 1.75rem;
  text-wrap: balance;
}

.hero-subtitle {
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 400;
  line-height: 1.6;
  color: var(--gray);
  max-width: 640px;
  margin-bottom: 3.5rem;
}

.scroll-prompt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: auto;
}

.scroll-line {
  width: 40px;
  height: 1px;
  background-color: var(--gray);
  display: inline-block;
}

/* ==========================================================================
   STORY SECTIONS & EDITORIAL LAYOUT
   ========================================================================== */

.story-section {
  padding: 7rem 1.5rem;
  border-bottom: 1px solid var(--light-gray);
  background-color: var(--white);
}

.section-header {
  margin-bottom: 2rem;
}

.section-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--black);
  border-bottom: 1px solid var(--black);
  padding-bottom: 4px;
  margin-bottom: 1.5rem;
}

.section-label.label-coral {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.section-title {
  font-size: clamp(1.75rem, 3.2vw, 2.375rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--black);
  text-wrap: balance;
}

.text-body p {
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--black);
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.text-body p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   VISUALIZATION CONTAINERS & WRAPPERS
   ========================================================================== */

.viz-wrapper {
  max-width: var(--visual-width);
  margin: 3.5rem auto 0;
  width: 100%;
}

.viz-container {
  width: 90%;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
  height: auto;
  min-height: 400px;
  background: #FAFAFA;
  border: 1px dashed var(--blue-soft);
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}

.viz-container:empty::after {
  content: 'PLOTLY.JS CONTAINER [ID: ' attr(id) ']';
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: var(--blue-water);
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* Reset container background and border when Plotly chart content is injected */
.viz-container:not(:empty) {
  background: transparent;
  border: none;
  display: block;
}

.viz-caption-container {
  max-width: var(--text-width);
  margin: 1rem auto 0;
  padding: 0 0.5rem;
}

.viz-caption {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--gray);
  font-weight: 400;
  border-left: 2px solid var(--light-gray);
  padding-left: 0.75rem;
}

/* ==========================================================================
   NARRATIVE PAUSES / TRANSITIONS
   ========================================================================== */

.narrative-pause {
  padding: 8rem 1.5rem;
  background-color: var(--white);
  border-bottom: 1px solid var(--light-gray);
}

.pause-wrapper {
  max-width: var(--text-width);
  margin: 0 auto;
  text-align: left;
}

.pause-quote {
  font-size: clamp(1.875rem, 3.5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--black);
  margin-bottom: 1.25rem;
}

.pause-subtext {
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--gray);
  max-width: 620px;
}

.coral-accent-dot {
  color: var(--coral);
  font-size: 1.25em;
  line-height: 0;
  vertical-align: middle;
}

/* ==========================================================================
   FINAL SYNTHESIS & TAKEAWAY
   ========================================================================== */

.synthesis-section {
  padding: 9rem 1.5rem;
  background-color: var(--white);
  border-bottom: 1px solid var(--light-gray);
}

.final-takeaway {
  border-left: 3px solid var(--coral);
  padding-left: 2rem;
}

.takeaway-label {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 1.25rem;
}

#final-takeaway {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--black);
}

/* ==========================================================================
   SITE FOOTER (DATA & METHODS)
   ========================================================================== */

.site-footer {
  padding: 6rem 1.5rem 4rem;
  background-color: var(--white);
  color: var(--black);
}

.footer-container {
  max-width: var(--visual-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3.5rem;
  padding-bottom: 4rem;
  border-bottom: 1px solid var(--light-gray);
}

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

.footer-heading {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--black);
  margin-bottom: 1.25rem;
}

.footer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.footer-list li {
  font-size: 0.9375rem;
  color: var(--gray);
}

.footer-text {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--gray);
}

.footer-bottom {
  padding-top: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-palette-dots {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.palette-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  display: inline-block;
}

.palette-dot.dot-ocean {
  background-color: var(--blue-ocean);
}

.palette-dot.dot-water {
  background-color: var(--blue-water);
}

.palette-dot.dot-coral {
  background-color: var(--coral);
}

.copyright {
  font-size: 0.8125rem;
  color: var(--gray);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   SCROLL REVEAL ANIMATIONS
   ========================================================================== */

.reveal-element {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-element.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 1024px) {
  .hero-section {
    padding: 6rem 1.5rem 4rem;
    min-height: 75vh;
  }

  .story-section {
    padding: 5.5rem 1.25rem;
  }

  .narrative-pause {
    padding: 6rem 1.25rem;
  }

  .synthesis-section {
    padding: 6.5rem 1.25rem;
  }

  .viz-container {
    min-height: 420px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 768px) {
  .hero-section {
    min-height: auto;
    padding: 5rem 1.25rem 3.5rem;
  }

  .hero-meta-badge {
    margin-bottom: 1.25rem;
  }

  .hero-title {
    margin-bottom: 1.25rem;
  }

  .hero-subtitle {
    margin-bottom: 2.5rem;
  }

  .story-section {
    padding: 4rem 1rem;
  }

  .narrative-pause {
    padding: 4.5rem 1rem;
  }

  .synthesis-section {
    padding: 5rem 1rem;
  }

  .final-takeaway {
    padding-left: 1.25rem;
  }

  .viz-container {
    min-height: 400px;
  }

  .reading-indicator {
    bottom: 1.25rem;
    right: 1.25rem;
    font-size: 0.6875rem;
    padding: 0.375rem 0.75rem;
  }
}

/* =media prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  .reveal-element {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .progress-bar {
    transition: none !important;
  }
}


/* =========================================================
   EXPLAIN CONTROLS
   ========================================================= */

.explain-controls {
    display: flex;
    align-items: center;
    gap: 12px;

    width: 85%;
    margin: 18px auto 10px auto;

    font-family: Inter, system-ui, sans-serif;
}

.explain-controls label {
    font-size: 14px;
    color: #333;
}

.explain-audience {
    margin-left: 6px;
    padding: 8px 12px;

    border: 1px solid #d6d6d6;
    border-radius: 6px;

    background: #fff;

    font-family: inherit;
    font-size: 14px;
}

.explain-button {
    padding: 9px 18px;

    border: none;
    border-radius: 6px;

    background: #357596;
    color: white;

    font-family: inherit;
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
}

.explain-button:hover {
    background: #2f647f;
}

.explain-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.explanation-output {
    width: 85%;
    margin: 12px auto 30px auto;

    padding: 18px 20px;

    border-left: 3px solid #357596;

    background: #f7fafb;

    color: #333;

    font-family: Inter, system-ui, sans-serif;
    line-height: 1.6;
}

.explanation-output:empty {
    display: none;
}

