:root {
  --color-bg: #f0f0f0;
  --color-text: #333;
  --color-text-muted: #555;
  --color-accent-blue: blue;
  --color-accent-orange: orange;
  --color-accent-purple: purple;
  --color-accent-red: #ab180e;
  --color-accent-grey: #a8a5a5;
  --color-black: #000;
  --color-white: #fff;

  /* Plot Colors */
  --color-plot-natural: rgb(58, 110, 165);

  --color-plot-anthropogenic: rgb(178, 34, 34);

  --color-plot-total: rgb(105, 47, 130);

  --color-plot-ghg: rgb(47, 128, 124);

  --color-plot-ohf: rgb(115, 124, 71);

  --color-plot-non-co2: rgb(185, 134, 86);
  --color-plot-non-co2-neg: rgb(93, 177, 162);

  --color-plot-co2: rgb(100, 60, 72);
  

  --color-plot-observations: rgb(61, 61, 61);
  --color-plot-obs-err: rgba(61, 61, 61, 0.4);

  --color-plot-residual: rgb(128, 128, 128);

  --color-plot-anthro-forcing: rgb(178, 34, 34);

  --font-base: Verdana, Helvetica, Arial, sans-serif;
  --font-mono: "Droid Sans Mono", "Courier New", Courier, monospace;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
}

html {
  background: var(--color-bg);
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  font-family: var(--font-base);
  color: var(--color-text);
  line-height: 1.6;
  text-align: left;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 1.5rem 0 1rem;
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
  text-align: left;
}

p {
  margin-bottom: 1.5rem;
  font-weight: 400;
  font-size: 1rem;
  /* text-align: left; Default is now left */
}

a {
  color: var(--color-accent-blue);
  text-decoration: underline;
}

a:hover {
  text-decoration: none;
}

/* Layout */
header,
main,
footer {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
header {
  padding: 2rem 0;
  margin: 0 auto;
  text-align: center;
}

.branding {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.stat-box {
  display: block;
  padding: 0.5rem 1rem;
  margin: 0.5rem 0;
  background: var(--color-accent-grey);
  color: var(--color-white);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  border-radius: 4px;
  text-align: center;
}

.stat-box.GWI {
  background: var(--color-plot-anthropogenic);
  font-size: 2rem;
}

.stat-box.co2 {
  background: var(--color-plot-co2);
}

.stat-box.non-co2 {
  background: var(--color-plot-non-co2);
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--color-plot-non-co2-neg) 70%, transparent),
    color-mix(in srgb, gray 70%, transparent),
    color-mix(in srgb, var(--color-plot-non-co2) 70%, transparent)
    );
}

.stat-box span {
  font-weight: bold;
}

.date-display {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: #444;
  margin: 1rem 0;
}

.paper {
  background: var(--color-white);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.paper .chart-area {
  width: 100%;
  height: 500px;
  position: relative;
}

.paper .chart-area canvas {
  display: block;
}

.btn-download {
  width: 100%;
  padding: 0.8rem;
  margin-top: 1rem;
  background: transparent;
  border: 1px solid var(--color-text-muted);
  color: var(--color-text-muted);
  font-family: var(--font-base);
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.btn-download:hover {
  background: var(--color-white);
  color: var(--color-text);
}

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

.fig-caption {
  font-size: small;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
  text-align: center;
}

.equation-container {
  overflow-x: auto;
  padding: 1rem 0;
  margin: 1rem 0;
}

li {
  margin-bottom: 1rem;
}

/* Semantic Text Colors */
.text-natural {
  color: var(--color-plot-natural);
  background-color: color-mix(in srgb, var(--color-plot-natural) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-anthropogenic {
  color: var(--color-plot-anthropogenic);
  background-color: color-mix(in srgb, var(--color-plot-anthropogenic) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-total {
  color: var(--color-plot-total);
  background-color: color-mix(in srgb, var(--color-plot-total) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-ghg {
  color: var(--color-plot-ghg);
  background-color: color-mix(in srgb, var(--color-plot-ghg) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-ohf {
  color: var(--color-plot-ohf);
  background-color: color-mix(in srgb, var(--color-plot-ohf) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-co2 {
  color: var(--color-plot-co2);
  background-color: color-mix(in srgb, var(--color-plot-co2) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-non-co2 {
  color: var(--color-plot-non-co2);
  background-color: color-mix(in srgb, var(--color-plot-non-co2) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-non-co2-neg {
  color: var(--color-plot-non-co2-neg);
  background-color: color-mix(in srgb, var(--color-plot-non-co2-neg) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-non-co2-blend {
  color:var(--color-text-muted);
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--color-plot-non-co2-neg) 20%, transparent),
    color-mix(in srgb, gray 70%, transparent),
    color-mix(in srgb, var(--color-plot-non-co2) 20%, transparent)
    );
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-obs {
  color: var(--color-plot-observations);
  background-color: color-mix(in srgb, var(--color-plot-observations) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.text-residual {
  color: var(--color-plot-residual);
  background-color: color-mix(in srgb, var(--color-plot-residual) 20%, transparent);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.references {
  font-size: 0.9rem;
  margin-top: 2rem;
  color: var(--color-text-muted);
}

.authors-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.authors-list li {
  margin-bottom: 0.75rem;
  text-align: left;
}

.biblio-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.biblio-list li {
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: left;
}

.back-link {
  margin-top: 3rem;
  border-top: 1px solid #eee;
  padding-top: 1rem;
}

.citation {
  font-size: small;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding: 1rem 0;
  border-top: 1px solid #ddd;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

footer p {
  text-align: center;
  margin: 0.5rem 0;
}

/* Responsive Images */
img {
  max-width: 100%;
  height: auto;
}

/* SVG Chart Overrides */
svg {
  overflow: visible;
}

/* Media Queries */
@media (max-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.25rem;
  }

  .stat-box {
    display: block;
    width: 100%;
    margin: 1rem 0;
    font-size: 1rem;
  }

  .stat-box.GWI {
    font-size: 1.5rem;
  }

  .paper {
    padding: 1rem;
  }

  .paper .chart-area {
    height: 350px !important; /* Force smaller height on mobile */
  }

  .paper .chart-area canvas {
    min-height: 350px;
  }
}

/* Timeline Styles */
.timeline-wrapper {
  width: 80%;
  margin: 20px auto;
  position: relative;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timeline-line-bg {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: black;
  opacity: 0.3;
  z-index: 0;
  transform: translateY(-50%);
}

.timeline-line-progress {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0%;
  height: 2px;
  background: black;
  opacity: 1;
  z-index: 0;
  transform: translateY(-50%);
  transition: width 0.3s ease;
}

.timeline-step {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  z-index: 1;
  transition: background 0.3s ease;
  position: relative;
  font-size: 14px;
}

.timeline-step.active {
  background: rgba(0, 0, 0, 1);
}

/* Animation Styles */
.animation-container {
  position: relative;
  height: 650px;
  width: 100%;
}

.rmse-indicator {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-weight: bold;
  font-size: clamp(16px, 2.5vw, 20px);
  color: #808080;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.rmse-label {
  font-size: clamp(12px, 1.8vw, 16px);
  font-weight: normal;
  color: #808080;
  margin-bottom: 0.3em;
}

.chart-annotation {
  min-height: 45px;
  margin-top: 15px;
  margin-bottom: 15px;
  font-size: 14px;
  color: #666;
}

.button-group {
  text-align: center;
  margin-top: 10px;
}

.button-group button {
  margin: 0 5px;
}

@media (max-width: 768px) {
  .animation-container {
    height: 400px;
  }
}

/* Tree Diagram Styles - Left-Right Orientation */

.tree-diagram li {
  margin-bottom: -0.3rem;
}

.tree-diagram {
  width: 100%;
  overflow-x: auto;
  padding: 20px;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 30px;
  --node-width: 150px;
}

.tree-diagram ul {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 15px;
  margin: 0;
  position: relative;
}

.tree-diagram li {
  display: flex;
  flex-direction: row;
  align-items: center;
  position: relative;
  padding: 5px 0;
  list-style-type: none;
}

/* Connectors */

/* Vertical connection line for siblings (Left side of LI) */
.tree-diagram li::before {
  content: '';
  position: absolute;
  left: -15px;
  border-left: 1px solid #ccc;
  width: 1px;
  height: 100%;
  top: 0;
}

/* Horizontal connection line to the node */
.tree-diagram li::after {
  content: '';
  position: absolute;
  left: -15px;
  border-top: 1px solid #ccc;
  width: 15px;
  top: 50%;
}

/* Adjustments for First/Last Child */
.tree-diagram li:first-child::before {
  top: 50%;
  height: 50%;
}
.tree-diagram li:last-child::before {
  height: 50%;
  bottom: 50%;
}

/* Only child: No vertical line, but keep horizontal line from parent */
.tree-diagram li:only-child::before {
  display: none;
}
.tree-diagram li:only-child::after {
  border-top: 1px solid #ccc;
  /* Ensure it connects nicely */
}

/* Root Node Override */
.tree-diagram > ul {
  padding-left: 0;
}
.tree-diagram > ul > li::before, 
.tree-diagram > ul > li::after {
  display: none;
}
.tree-diagram > ul > li {
  padding: 0;
}

/* Connector from Parent Node to Child UL */
.tree-diagram li > ul {
  position: relative;
}

/* Line extending from parent node layer to children layer */
.tree-diagram li > ul::before {
  content: '';
  position: absolute;
  left: -15px;
  top: 50%;
  width: 15px;
  border-top: 1px solid #ccc;
}

/* Node Styling */
.tree-node {
  border: 1px solid #ccc;
  padding: 4px 8px;
  text-decoration: none;
  color: #333;
  font-family: var(--font-base);
  font-size: 11px;
  display: inline-block;
  border-radius: 5px;
  background-color: white;
  transition: all 0.5s;
  position: relative;
  z-index: 10;
  min-width: var(--node-width);
  width: var(--node-width);
  margin-right: 15px; /* Space for connector to children */
  white-space: normal;
  text-align: center;
  vertical-align: middle;
}

/* Component lists inside nodes - Not used in full expansion but kept for safety */
.component-list {
  text-align: left;
  font-size: 0.85em;
  margin-top: 8px;
  padding-left: 0;
  border-top: 1px solid #eee;
  padding-top: 5px;
  list-style: none;
}
.component-list li {
  padding: 2px 0;
  text-align: left;
  float: none;
  /* Reset tree styles for internal lists if any remain */
  display: block; 
}
.component-list li::before, .component-list li::after {
  display: none;
}

/* Colors matching the variables */
.node-obs { border: 2px solid var(--color-plot-observations); color: var(--color-black); font-weight: bold; }
.node-residual { border: 2px solid var(--color-plot-residual); color: var(--color-text); }
.node-total { border: 2px solid var(--color-plot-total); color: var(--color-black); font-weight: bold; }
.node-natural { border: 2px solid var(--color-plot-natural); color: var(--color-text); }
.node-ant { border: 2px solid var(--color-plot-anthropogenic); color: var(--color-black); font-weight: bold; }
.node-ghg { border: 2px solid var(--color-plot-ghg); color: var(--color-text); }
.node-ohf { border: 2px solid var(--color-plot-ohf); color: var(--color-text); }

/* Spacer node for alignment */
.node-linespacer {
  border: none;
  background: transparent;
  min-width: var(--node-width);
  width: var(--node-width);
  padding: 0;
  height: 1px;
  margin-right: 15px; /* Match margin */
  position: relative;
  visibility: visible; /* Must be visible for pseudo-element to show */
}

/* Draw local horizontal line through the spacer */
.node-linespacer::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  border-top: 1px solid #ccc;
  height: 1px;
}
