/* The Second World — isometric atlas, sepia-nostalgic, scholarly */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sepia: #e8dcc4;
  --atlas-brown: #6a5040;
  --iso-blue: #4a7aa8;
  --terrain-green: #5a8a50;
  --data-orange: #d48040;
  --parchment: #f0e8d8;
  --deep-earth: #3a2e20;
  --scroll: 0;
}

html { scroll-behavior: smooth; }

body {
  background: var(--sepia);
  color: var(--atlas-brown);
  font-family: "Merriweather", Georgia, serif;
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.8;
  overflow-x: hidden;
}

/* HEADER bar */
.atlas-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--parchment);
  border-bottom: 1px solid rgba(106,80,64,0.25);
}
.header-bar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px clamp(20px, 4vw, 60px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  font-family: "Fira Code", monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--atlas-brown);
}
.folio { color: var(--data-orange); font-weight: 500; }
.header-title {
  font-family: "Barlow Condensed", "Inter", sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2em;
}

/* HERO */
.hero {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  align-items: center;
  gap: clamp(24px, 4vw, 60px);
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 60px);
  min-height: calc(100vh - 56px);
}

.eyebrow {
  display: inline-block;
  font-family: "Fira Code", monospace;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--data-orange);
  margin-bottom: 18px;
  text-transform: uppercase;
}

.hero-title {
  font-family: "Barlow Condensed", "Inter", sans-serif;
  font-weight: 900;
  font-size: clamp(46px, 8vw, 110px);
  line-height: 0.94;
  letter-spacing: 0.01em;
  color: var(--deep-earth);
  text-transform: uppercase;
  margin-bottom: 28px;
}
.hero-title span { display: block; }
.title-accent { color: var(--iso-blue); -webkit-text-stroke: 1px var(--iso-blue); }

.hero-lead {
  font-size: clamp(16px, 1.5vw, 19px);
  color: var(--atlas-brown);
  max-width: 540px;
}

/* ISO STAGE */
.iso-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.iso-world {
  width: 100%;
  max-width: 760px;
  height: auto;
  display: block;
  filter: drop-shadow(0 16px 30px rgba(58,46,32,0.18));
}

/* Animate the ground in */
.iso-ground path {
  stroke-dasharray: 1600;
  stroke-dashoffset: 1600;
  animation: drawIso 2.4s ease forwards 0.2s;
}
.iso-underground path {
  opacity: 0;
  animation: fadeIn 0.9s ease 1.4s forwards;
}
@keyframes drawIso { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }

/* Buildings: scale-up from baseline using transform-origin trick.
   We use translateY/scaleY on the building groups, controlled by --scroll. */
.iso-buildings .bld {
  transform-origin: center;
  transform: translateY(40px) scale(0.6);
  opacity: 0;
  transition: transform 0.9s cubic-bezier(0.34,1.56,0.64,1), opacity 0.9s ease;
}
.is-built .bld-1 { transform: translateY(-15px) scale(1); opacity: 1; transition-delay: 1.6s; }
.is-built .bld-2 { transform: translateY(-30px) scale(1); opacity: 1; transition-delay: 1.8s; }
.is-built .bld-3 { transform: translateY(-12px) scale(1); opacity: 1; transition-delay: 2.0s; }
.is-built .bld-4 { transform: translateY(-22px) scale(1); opacity: 1; transition-delay: 2.2s; }
.is-built .bld-5 { transform: translateY(-34px) scale(1); opacity: 1; transition-delay: 2.4s; }

.iso-flora .tree { opacity: 0; transition: opacity 0.7s ease; }
.is-built .iso-flora .tree { opacity: 1; transition-delay: 2.6s; }

.iso-atmosphere ellipse { opacity: 0; transition: opacity 1s ease; }
.is-built .iso-atmosphere ellipse { opacity: var(--atm-op, 0.18); transition-delay: 3s; }

.hero-tag {
  margin-top: 18px;
  font-family: "Fira Code", monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--atlas-brown);
  opacity: 0.7;
  text-transform: uppercase;
}

/* STRATA section */
.strata {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 60px) clamp(60px, 9vw, 120px);
}

.stratum-intro {
  border-top: 2px solid var(--atlas-brown);
  padding: 36px 0 60px;
  margin-bottom: 30px;
  position: relative;
}
.stratum-num {
  position: absolute;
  top: 24px;
  right: 0;
  font-family: "Fira Code", monospace;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--data-orange);
}
.stratum-intro h2 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(32px, 5vw, 56px);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--deep-earth);
  margin-bottom: 16px;
}
.stratum-intro p { max-width: 720px; }

.stratum {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: clamp(24px, 4vw, 60px);
  padding: clamp(40px, 5vw, 70px) 0;
  border-top: 1px dashed rgba(106,80,64,0.4);
  align-items: start;
  position: relative;
}

.stratum-side .stratum-tag {
  display: inline-block;
  font-family: "Fira Code", monospace;
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--data-orange);
  margin-bottom: 14px;
  padding: 4px 12px;
  border: 1px solid rgba(212,128,64,0.4);
  border-radius: 999px;
}
.stratum-side h3 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(30px, 4.4vw, 48px);
  text-transform: uppercase;
  color: var(--deep-earth);
  margin-bottom: 16px;
  line-height: 1.05;
  letter-spacing: 0.02em;
}
.stratum-side h3::after {
  content: "";
  display: block;
  width: 60px;
  height: 3px;
  background: var(--iso-blue);
  margin-top: 14px;
}
.stratum-side p { color: var(--atlas-brown); }

.stratum-bedrock .stratum-side h3::after { background: var(--atlas-brown); }
.stratum-infra .stratum-side h3::after { background: var(--iso-blue); }
.stratum-surface .stratum-side h3::after { background: var(--terrain-green); }
.stratum-atmos .stratum-side h3::after { background: var(--data-orange); }

/* Data cards */
.stratum-data {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.data-card {
  background: var(--parchment);
  border: 1px solid rgba(106,80,64,0.25);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.data-label {
  font-family: "Fira Code", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--atlas-brown);
  text-transform: uppercase;
}
.data-value {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 3.6vw, 42px);
  color: var(--deep-earth);
  line-height: 1;
}
.data-value em {
  font-style: normal;
  font-weight: 500;
  color: var(--data-orange);
  font-size: 0.55em;
  margin-left: 4px;
  letter-spacing: 0.05em;
}

/* Pulse animation when in view */
.pulse.is-pulsing {
  animation: pulseAttn 1.5s cubic-bezier(0.4,0,0.2,1) 1;
}
@keyframes pulseAttn {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 rgba(212,128,64,0); }
  50% { transform: scale(1.05); box-shadow: 0 0 12px rgba(212,128,64,0.3); }
}

/* Bar chart */
.bar-row {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--parchment);
  border: 1px solid rgba(106,80,64,0.25);
  padding: 18px 20px;
}
.bar {
  display: grid;
  grid-template-columns: 70px 1fr 50px;
  gap: 10px;
  align-items: center;
}
.bar-name {
  font-family: "Fira Code", monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--atlas-brown);
}
.bar-track {
  position: relative;
  background: rgba(106,80,64,0.12);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: var(--data-orange);
  width: 0;
  transition: width 1s cubic-bezier(0.4,0,0.2,1) 0.2s;
}
.is-charted .bar-fill { width: var(--w); }
.bar-pct {
  font-family: "Fira Code", monospace;
  font-size: 12px;
  color: var(--deep-earth);
  text-align: right;
}

/* Ring grid */
.ring-grid {
  grid-column: span 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  background: var(--parchment);
  border: 1px solid rgba(106,80,64,0.25);
  padding: 18px;
}
.ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ring svg { width: 76px; height: 76px; }
.ring span {
  font-family: "Fira Code", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--atlas-brown);
}

/* Sparkline */
.spark {
  grid-column: span 2;
  background: var(--parchment);
  border: 1px solid rgba(106,80,64,0.25);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.spark-label {
  font-family: "Fira Code", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--atlas-brown);
  text-transform: uppercase;
}
.spark svg { width: 100%; height: 56px; }

/* REVEAL */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* FOOTER */
.atlas-footer {
  background: var(--deep-earth);
  color: var(--parchment);
  padding: clamp(50px, 8vw, 90px) 24px;
  text-align: center;
}
.footer-inner { max-width: 720px; margin: 0 auto; }
.footer-tag {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--data-orange);
  font-size: 14px;
  margin-bottom: 14px;
}
.atlas-footer p {
  font-family: "Merriweather", serif;
  color: rgba(240,232,216,0.85);
}
.atlas-footer em { color: var(--data-orange); font-style: italic; }

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; padding-top: 24px; }
  .stratum { grid-template-columns: 1fr; }
  .header-bar { flex-direction: column; gap: 6px; align-items: flex-start; }
  .header-title { font-size: 12px; }
}
