/* ============================================================
   ecologie.css — Biosphère Vivante
   Palette : #050d18 nuit | #00e676 émeraude | #00bcd4 turquoise | #e07b39 terra
   Polices  : Cormorant Garamond (display) + Nunito (corps) + DM Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,700&family=Nunito:wght@400;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --night:   #050d18;
  --night2:  #071322;
  --night3:  #0b1e33;
  --card:    #0a1929;
  --border:  #0f2d44;
  --border2: #163d57;
  --emerald: #00e676;
  --emerald2:#00c853;
  --teal:    #00bcd4;
  --terra:   #e07b39;
  --terra2:  #c56a2b;
  --coral:   #ff6e6e;
  --gold:    #ffc107;
  --text:    #b0cfe0;
  --text-hi: #e8f4f8;
  --muted:   #4a7a96;
  --bg-grad: linear-gradient(160deg, #050d18 0%, #071a2e 50%, #050d18 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--night);
  color: var(--text);
  line-height: 1.78;
  font-size: 1.02rem;
  overflow-x: hidden;
}

/* ── AURORA BACKGROUND ────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%,   rgba(0,188,212,.07) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%,  rgba(0,230,118,.07) 0%, transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 50%,   rgba(224,123,57,.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── ORGANIC BLOB ─────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  top: -200px; right: -200px;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(0,188,212,.05), transparent 70%);
  border-radius: 60% 40% 70% 30% / 40% 60% 30% 70%;
  animation: blob-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes blob-drift {
  0%  { transform: translate(0,0) scale(1); }
  50% { transform: translate(-80px, 60px) scale(1.1); }
  100%{ transform: translate(40px, -40px) scale(.95); }
}

/* ── PROGRESS BAR ─────────────────────────────── */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--emerald));
  z-index: 1000;
  box-shadow: 0 0 10px var(--emerald);
  transition: width .1s linear;
}

/* ── NAV ──────────────────────────────────────── */
nav {
  position: fixed;
  top: 3px; left: 0; right: 0;
  z-index: 900;
  background: rgba(5,13,24,.93);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 32px;
  height: 54px;
  overflow-x: auto;
}
.nav-brand {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-style: italic;
  font-size: 1.25rem;
  color: var(--emerald);
  letter-spacing: .02em;
  text-decoration: none;
  margin-right: 22px;
  flex-shrink: 0;
}
nav a:not(.nav-brand) {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 4px;
  white-space: nowrap;
  transition: color .2s, background .2s;
  letter-spacing: .04em;
  text-transform: uppercase;
}
nav a:not(.nav-brand):hover,
nav a.active {
  color: var(--emerald);
  background: rgba(0,230,118,.08);
}

/* ── HERO ─────────────────────────────────────── */
.hero {
  position: relative;
  padding: 118px 56px 80px;
  overflow: hidden;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: 860px; position: relative; z-index: 2; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--teal);
  border: 1px solid rgba(0,188,212,.3);
  padding: 5px 16px;
  border-radius: 999px;
  margin-bottom: 24px;
  background: rgba(0,188,212,.05);
}
.hero-eyebrow .dot {
  width: 6px; height: 6px;
  background: var(--teal);
  border-radius: 50%;
  animation: pulse-eco 2.4s infinite;
}
@keyframes pulse-eco {
  0%,100%{ opacity:1; transform:scale(1); box-shadow:0 0 0 0 rgba(0,188,212,.4); }
  50%{ opacity:.5; transform:scale(1.4); box-shadow:0 0 0 6px rgba(0,188,212,0); }
}

.hero h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(4rem, 9vw, 8rem);
  font-weight: 700;
  line-height: .9;
  letter-spacing: -.02em;
  color: var(--text-hi);
  margin-bottom: 22px;
}
.hero h1 em { color: var(--emerald); font-style: italic; }

.hero p.lead {
  font-size: 1.1rem;
  color: var(--text);
  max-width: 640px;
  line-height: 1.78;
}

/* ── STATS STRIP ──────────────────────────────── */
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 38px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}
.stat-pill {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 14px 20px;
  flex: 1;
  min-width: 130px;
  position: relative;
  overflow: hidden;
}
.stat-pill::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--emerald), var(--teal));
}
.stat-pill .sv {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--emerald);
  line-height: 1;
  display: block;
}
.stat-pill .sl {
  font-family: 'DM Mono', monospace;
  font-size: .62rem;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── LAYOUT ───────────────────────────────────── */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 64px 40px;
  position: relative;
  z-index: 1;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 36px;
}
@media (max-width: 940px) { .two-col { grid-template-columns: 1fr; } }

/* ── SECTIONS ─────────────────────────────────── */
.section {
  margin-bottom: 68px;
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .6s ease, transform .6s ease;
}
.section.visible { opacity: 1; transform: none; }

.sec-label {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--terra);
  margin-bottom: 8px;
}
.section h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text-hi);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 24px;
  position: relative;
}
.section h2::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  height: 2px; width: 64px;
  background: var(--terra);
}
.section h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--teal);
  margin: 28px 0 10px;
}

/* ── CARDS ────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: border-color .25s, transform .25s;
}
.card:hover { border-color: rgba(0,230,118,.3); transform: translateY(-2px); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

/* ── BIOME CARDS ──────────────────────────────── */
.biome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.biome-card {
  border-radius: 14px;
  padding: 18px;
  border: 1px solid;
  transition: transform .2s;
  cursor: default;
}
.biome-card:hover { transform: translateY(-4px); }
.biome-card.tropical  { border-color: rgba(0,230,118,.3); background: rgba(0,230,118,.05); }
.biome-card.taiga     { border-color: rgba(0,188,212,.3); background: rgba(0,188,212,.05); }
.biome-card.desert    { border-color: rgba(255,193,7,.3);  background: rgba(255,193,7,.05); }
.biome-card.tundra    { border-color: rgba(176,207,224,.3);background: rgba(176,207,224,.04); }
.biome-card.ocean     { border-color: rgba(0,188,212,.4);  background: rgba(0,188,212,.07); }
.biome-card.grassland { border-color: rgba(224,123,57,.3); background: rgba(224,123,57,.05); }

.biome-icon { font-size: 2.2rem; display: block; margin-bottom: 10px; }
.biome-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-hi);
  margin-bottom: 4px;
}
.biome-desc { font-size: .83rem; color: var(--text); line-height: 1.55; }

/* ── LEVEL CARDS (trophic) ────────────────────── */
.trophic-chain {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
  position: relative;
}
.trophic-chain::before {
  content: '';
  position: absolute;
  left: 22px; top: 44px; bottom: 44px;
  width: 2px;
  background: linear-gradient(to bottom, var(--emerald), var(--terra));
}
.tl-level {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.tl-num {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.tl-level:nth-child(1) .tl-num { background: rgba(0,230,118,.2); border: 2px solid var(--emerald); color: var(--emerald); }
.tl-level:nth-child(2) .tl-num { background: rgba(0,188,212,.2); border: 2px solid var(--teal);    color: var(--teal);    }
.tl-level:nth-child(3) .tl-num { background: rgba(255,193,7,.2);  border: 2px solid var(--gold);   color: var(--gold);   }
.tl-level:nth-child(4) .tl-num { background: rgba(224,123,57,.2); border: 2px solid var(--terra);  color: var(--terra);  }
.tl-level:nth-child(5) .tl-num { background: rgba(255,110,110,.2);border: 2px solid var(--coral);  color: var(--coral);  }
.tl-body { flex: 1; }
.tl-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-hi);
}
.tl-detail { font-size: .88rem; color: var(--text); margin-top: 3px; }

/* ── RELATION TAG ─────────────────────────────── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.tag-green  { background: rgba(0,230,118,.1); color: var(--emerald); border: 1px solid rgba(0,230,118,.2); }
.tag-teal   { background: rgba(0,188,212,.1); color: var(--teal);    border: 1px solid rgba(0,188,212,.2); }
.tag-terra  { background: rgba(224,123,57,.1);color: var(--terra);   border: 1px solid rgba(224,123,57,.2);}
.tag-coral  { background: rgba(255,110,110,.1);color:var(--coral);   border: 1px solid rgba(255,110,110,.2);}
.tag-gold   { background: rgba(255,193,7,.1);  color: var(--gold);   border: 1px solid rgba(255,193,7,.2); }

/* ── BOX ALERTS ───────────────────────────────── */
.box {
  border-radius: 10px;
  padding: 14px 18px;
  margin: 16px 0;
  border-left: 4px solid;
  font-size: .96rem;
}
.box-eco   { background: rgba(0,230,118,.05); border-color: var(--emerald); }
.box-warn  { background: rgba(255,193,7,.05); border-color: var(--gold);    }
.box-alert { background: rgba(255,110,110,.05);border-color: var(--coral);  }
.box-info  { background: rgba(0,188,212,.05); border-color: var(--teal);    }

/* ── TABLE ────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: .93rem;
}
th {
  background: var(--night3);
  color: var(--teal);
  font-family: 'DM Mono', monospace;
  font-size: .67rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border2);
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
tr:hover td { background: rgba(0,230,118,.02); }

/* ── SUCCESSION STEPS ─────────────────────────── */
.succession {
  display: flex;
  gap: 0;
  margin: 20px 0;
  overflow-x: auto;
  padding-bottom: 8px;
}
.succ-step {
  flex: 1;
  min-width: 120px;
  text-align: center;
  padding: 16px 12px;
  background: var(--card);
  border-top: 3px solid var(--emerald);
  position: relative;
}
.succ-step:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -12px; top: 50%;
  transform: translateY(-50%);
  color: var(--emerald);
  font-size: 1.2rem;
  z-index: 1;
}
.succ-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.succ-name { font-family: 'Cormorant Garamond', serif; font-size: 1rem; font-weight: 700; color: var(--text-hi); }
.succ-eg   { font-size: .75rem; color: var(--muted); margin-top: 4px; font-style: italic; }

/* ── TIMELINE ─────────────────────────────────── */
.timeline { padding-left: 30px; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, var(--teal), var(--emerald));
}
.tl-item { position: relative; margin-bottom: 24px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -37px; top: 6px;
  width: 10px; height: 10px;
  background: var(--emerald);
  border-radius: 50%;
  border: 2px solid var(--night);
  box-shadow: 0 0 6px var(--emerald);
}
.tl-year  { font-family: 'DM Mono', monospace; font-size: .78rem; color: var(--terra); letter-spacing:.04em; }
.tl-title { font-family: 'Cormorant Garamond', serif; font-size: 1.05rem; font-weight: 700; color: var(--text-hi); }
.tl-desc  { font-size: .9rem; color: var(--text); }

/* ── SIDEBAR ──────────────────────────────────── */
.sidebar { position: sticky; top: 68px; }
.sb-card {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.sb-card h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--emerald);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.sb-toc a {
  display: block;
  padding: 5px 8px;
  font-family: 'DM Mono', monospace;
  font-size: .67rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 4px;
  transition: color .2s, background .2s;
  letter-spacing: .04em;
}
.sb-toc a:hover, .sb-toc a.active {
  color: var(--emerald);
  background: rgba(0,230,118,.07);
}

ul { padding-left: 22px; }
li { margin: 5px 0; }
ul li::marker { color: var(--emerald); }
strong { color: var(--text-hi); font-weight: 700; }
code {
  font-family: 'DM Mono', monospace;
  background: var(--night3);
  color: var(--teal);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .87em;
}

#back-top {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 44px; height: 44px;
  background: var(--emerald2);
  color: var(--night);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 800;
  font-weight: 700;
}
#back-top.visible { opacity: 1; pointer-events: auto; }
#back-top:hover { transform: translateY(-4px); }

footer {
  border-top: 1px solid var(--border);
  padding: 28px 40px;
  text-align: center;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  letter-spacing: .06em;
  position: relative;
  z-index: 1;
}

@media (max-width: 768px) {
  .hero { padding: 90px 22px 50px; }
  .container { padding: 36px 18px; }
  nav { padding: 0 16px; }
}
