/* ============================================================
   main.css — Meat Scrollytelling prototype
   All color/font values use CSS custom properties so the
   entire theme can be swapped by overriding :root (see bottom).
   ============================================================ */

/* ── Theme variables (Paper / Earthy) ─────────────────────── */
:root {
  --color-primary:        #3d5a3e;
  --color-primary-light:  #5e7d5f;
  --color-secondary:      #8b6f47;
  --color-accent:         #3b5068;
  --color-accent-soy:     #f85205;
  --color-maize:          #c4a84a;
  --color-feed-other:     #5e7d8e;
  --color-bg:             #f5efe6;
  --color-bg-section:     #ede5d8;
  --color-bg-card:        rgba(245, 239, 230, 0.97);
  --color-text:           #2c2418;
  --color-text-muted:     #6b5a48;
  --color-map-ocean:      #b8ccd8;
  --color-map-land:       #cec4b0;
  --color-map-border:     rgba(44, 36, 24, 0.22);
  --color-map-selected:   #3d5a3e;
  --font-heading:         Georgia, 'Times New Roman', serif;
  --font-body:            'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --color-bg-dark:        #2c2418;
  --color-bg-forest:      #1a2018;
  --color-bg-overlay:     rgba(245, 239, 230, 0.92);
  --color-bg-tint:        rgba(44, 36, 24, 0.04);
  --color-border:         #b0a090;
  --color-text-on-dark:   rgba(245, 239, 230, 0.65);
  --card-radius:          6px;
  --card-shadow:          0 2px 14px rgba(44, 36, 24, 0.10);
  --transition-fast:      0.3s ease;
  --transition-mid:       0.6s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--color-bg);
  color:            var(--color-text);
  font-family:      var(--font-body);
  font-size:        1rem;
  line-height:      1.65;
  margin: 0; padding: 0;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.25;
  color: var(--color-text);
}

/* Bootstrap overrides */
:root {
  --bs-body-bg:       var(--color-bg);
  --bs-body-color:    var(--color-text);
  --bs-primary:       var(--color-primary);
  --bs-primary-rgb:   61, 90, 62;
  --bs-form-select-bg: var(--color-bg-section);
}

.form-select {
  background-color: var(--color-bg-section);
  color:            var(--color-text);
  border-color:     var(--color-border);
}
.form-select:focus { border-color: var(--color-primary); box-shadow: none; }
.form-label { color: var(--color-text-muted); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* ── Narrative (non-sticky) sections ────────────────────────── */
.narrative-section {
  position: relative;
  z-index: 20;
  padding: 7rem 0;
}

/* ── INTRO ───────────────────────────────────────────────────── */
#intro {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(150deg, #ede5d8 0%, #f5efe6 55%, #eee6d8 100%);
  padding: 0;
}
#intro .intro-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 4rem 2rem;
}
.intro-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 1rem;
}
.intro-headline {
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  margin-bottom: 1.5rem;
  color: var(--color-text);
}
.intro-lead {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  max-width: 560px;
}
#scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: opacity 0.4s;
}
.scroll-hint-arrow {
  display: block;
  margin: 0.4rem auto 0;
  width: 18px; height: 18px;
  border-right: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  transform: rotate(45deg);
  animation: bounce 1.6s infinite;
}
@keyframes bounce {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50%       { transform: rotate(45deg) translateY(5px); }
}

/* ── SELECTION SECTION ───────────────────────────────────────── */
#selections {
  background-color: var(--color-bg-section);
  border-top:    1px dashed rgba(44, 36, 24, 0.18);
  border-bottom: 1px dashed rgba(44, 36, 24, 0.18);
  padding: 4rem 0;
}
.selection-panel { max-width: 860px; margin: 0 auto; }
.indicator-preview {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--color-bg-tint);
  border-left: 3px dashed var(--color-primary);
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.indicator-preview strong { color: var(--color-accent); }

/* ── FADE-ON-SCROLL (Intersection Observer) ──────────────────── */
.fade-on-scroll {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.fade-on-scroll.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ── SCROLLAMA: shared layout ─────────────────────────────────── */
.scrolly {
  position: relative;
}

/* Sticky graphic panel */
.sticky-fig {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  margin: 0;
  overflow: hidden;
  z-index: 0;
  background: var(--color-bg);
}

/* Steps container overlays the sticky figure */
.scroll-steps {
  position: relative;
  z-index: 10;
  margin-top: -100vh;
  pointer-events: none;
}

.step {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 2rem;
}

/* Step card */
.step-card {
  pointer-events: auto;
  background:    var(--color-bg-card);
  border:        1.5px dashed var(--color-primary);
  border-radius: var(--card-radius);
  box-shadow:    var(--card-shadow);
  padding:       1.5rem 1.75rem;
  max-width:     340px;
  backdrop-filter: blur(6px);
  transition:    opacity var(--transition-fast), box-shadow var(--transition-fast);
}
.step-card h4 {
  font-size:     1.1rem;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}
.step-card p { font-size: 0.9rem; color: var(--color-text-muted); margin: 0; }
.step.is-active .step-card {
  border-color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(61, 90, 62, 0.18);
}

/* Card positioning helpers */
.step-card-left  { margin-right: auto; }
.step-card-right { margin-left: auto; }
.step-card-center { margin: auto; text-align: center; }

/* ── VIS LAYERS (position:absolute within sticky-fig) ──────────── */
.vis-layer {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  transition: opacity var(--transition-mid);
}
.vis-layer.hidden,
.vis-layer[style*="opacity: 0"] { pointer-events: none; }

/* ── MEAL image layer ─────────────────────────────────────────── */
#layer-meal {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-dark);
}
#meal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
#meal-label {
  position: absolute;
  bottom: 2.5rem; left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-overlay);
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 3vw, 2.2rem);
  padding: 0.4rem 1.2rem;
  border-radius: 4px;
  border: 1px dashed var(--color-primary);
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* ── INGREDIENTS layer ────────────────────────────────────────── */
#layer-ingredients {
  background: var(--color-bg-dark);
}

/* Thumbnail: occupies top 4 % – 40 % of the sticky figure       */
.ing-meal-thumb-wrap {
  position: absolute;
  top: 4%; left: 50%;
  transform: translateX(-50%);
  width: 55%;
  height: 36%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
#meal-img-thumb {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

/* SVG for lines — covers the full layer                          */
#ing-lines-svg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Ingredient images row */
.ing-row {
  position: absolute;
  top: 60%;
  left: 0; right: 0;
  height: 22%;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 0 3%;
  z-index: 6;
}
.ing-item {
  flex: 1;
  max-width: 17%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ing-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 3px dashed var(--color-primary-light);
  transition: border-color 0.3s ease;
}
.ing-name   { font-size: 0.65rem; text-align: center; color: var(--color-text-muted); }
.ing-weight { font-size: 0.7rem;  text-align: center; color: var(--color-accent); font-weight: 600; }

/* Stacked bar */
.ing-stacked-wrap {
  position: absolute;
  bottom: 3%;
  left: 3%; right: 3%;
  height: 13%;
  z-index: 6;
}
#ing-stacked-bar {
  width: 100%; height: 100%;
}
/* Tooltip for the stacked bar (appended to body by JS) */
.bar-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--color-bg-overlay);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px dashed var(--color-primary);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  line-height: 1.5;
}

/* ── ANIMAL + FEED CHART layer ────────────────────────────────── */
#layer-animal-section {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 2rem;
}
.animal-col {
  flex: 0 0 42%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#animal-img {
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
#feed-chart-wrapper {
  flex: 0 0 56%;
  height: 60vh;
  transition: opacity 0.8s ease;
}
#feed-chart-plotly {
  width: 100%;
  height: 100%;
}

/* ── MAP sticky figure ────────────────────────────────────────── */
#scrolly-map .sticky-fig {
  background: var(--color-map-ocean);
}
#world-map-svg {
  width: 100%; height: 100%;
}
.map-title-bar {
  position: absolute;
  top: 1rem; left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-overlay);
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 1.1rem;
  padding: 0.35rem 1rem;
  border-radius: 4px;
  border: 1px dashed var(--color-primary);
  pointer-events: none;
  backdrop-filter: blur(4px);
  min-width: 200px;
  text-align: center;
}

/* Map text overlay (transition steps) */
#map-text-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
  transition: opacity var(--transition-mid);
}
.map-transition-box {
  background: var(--color-bg-card);
  border: 1.5px dashed var(--color-accent);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 2rem 2.5rem;
  max-width: 520px;
  text-align: center;
  backdrop-filter: blur(10px);
}
.map-transition-box h3 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
  color: var(--color-accent);
}
.map-transition-box p {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* ── FOREST section ───────────────────────────────────────────── */
#scrolly-forest .sticky-fig { background: var(--color-bg-forest); }

.full-bg-img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
}
.image-caption {
  position: absolute;
  bottom: 1rem; right: 1.5rem;
  font-size: 0.7rem;
  color: var(--color-text-on-dark);
  font-style: italic;
}
.satellite-attribution {
  position: absolute;
  bottom: 0.5rem; right: 0.75rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.75);
  pointer-events: none;
}

/* ── TRANSITION / POST-MAP narrative sections ─────────────────── */
.transition-section,
#post-map, #outro {
  background: var(--color-bg-section);
  text-align: center;
}
.transition-section h2,
#post-map h2, #outro h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.8rem);
  margin-bottom: 1rem;
}
.transition-section p,
#post-map p, #outro p {
  max-width: 600px;
  margin: 0 auto;
  color: var(--color-text-muted);
}

/* ── Context / short-text section ────────────────────────────── */
#context-text { background: var(--color-bg-section); }
.context-inner {
  border-left: 3px dashed var(--color-primary);
  padding-left: 1.5rem;
}
.context-inner p { color: var(--color-text-muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .step { padding: 1rem; }
  .step-card { max-width: 100%; }
  .step-card-right, .step-card-left { margin-left: 0; margin-right: 0; }

  #layer-animal-section { flex-direction: column; padding: 1rem; }
  .animal-col { flex: 0 0 auto; max-width: 60%; }
  #feed-chart-wrapper { flex: 0 0 auto; width: 100%; height: 40vh; }

  .ing-row { gap: 0.2rem; }
  .ing-item { max-width: 18%; }
  .ing-name { font-size: 0.55rem; }
  .ing-weight { font-size: 0.6rem; }

  .intro-headline { font-size: 2rem; }
}

@media (max-width: 480px) {
  .ing-item { max-width: 19%; }
  .ing-name, .ing-weight { display: none; }
  .step-card { padding: 1rem 1.2rem; }
  .step-card h4 { font-size: 0.95rem; }
  .step-card p  { font-size: 0.8rem; }
}

/* ── Soy-highlighted card variant ──────────────────────────────── */
.step-card.soy-card {
  border-color: var(--color-accent-soy);
  box-shadow: 0 4px 20px rgba(46, 74, 94, 0.18);
}
.step-card.soy-card h4 { color: var(--color-accent); }

/* ── Language toggle button ───────────────────────────────────── */
#lang-toggle {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  z-index: 1000;
  background: var(--color-bg-overlay);
  color: var(--color-primary);
  border: 1.5px dashed var(--color-primary);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-family: var(--font-body);
  letter-spacing: 0.08em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s, color 0.2s;
}
#lang-toggle:hover {
  background: var(--color-primary);
  color: var(--color-bg);
}

/* ── Custom scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar        { width: 5px; }
::-webkit-scrollbar-track  { background: var(--color-bg); }
::-webkit-scrollbar-thumb  { background: var(--color-primary); border-radius: 3px; }

/* ── Utility classes (replace inline styles in index.html) ────── */
.text-intro-footnote {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.text-secondary-note {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.outro-footer-note {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  border-top: 1px dashed var(--color-primary);
  padding-top: 1.5rem;
}
