:root {
  color-scheme: light;
  --bg: #f6f0e8;
  --ink: #211610;
  --muted: #6c5f57;
  --accent: #e86b3d;
  --accent-2: #1d8a7a;
  --accent-3: #f0b429;
  --panel: rgba(255, 255, 255, 0.86);
  --border: rgba(28, 18, 14, 0.12);
  --shadow: 0 24px 60px rgba(33, 22, 16, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, rgba(240, 180, 41, 0.22), transparent 55%),
    radial-gradient(circle at 80% 10%, rgba(29, 138, 122, 0.16), transparent 52%),
    linear-gradient(135deg, #f6f0e8 0%, #f2e6d6 50%, #f7efe3 100%);
  padding: 48px clamp(20px, 6vw, 72px) 80px;
  position: relative;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: "Fraunces", "Georgia", serif;
  margin: 0;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
}

a {
  color: inherit;
  text-decoration: none;
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(0);
  opacity: 0.55;
  pointer-events: none;
}

.orb-one {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(232, 107, 61, 0.35), transparent 70%);
  top: -120px;
  left: -80px;
}

.orb-two {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(29, 138, 122, 0.3), transparent 70%);
  bottom: 10%;
  right: -60px;
}

.orb-three {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(240, 180, 41, 0.3), transparent 70%);
  top: 40%;
  right: 25%;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(33, 22, 16, 0.05) 0,
    rgba(33, 22, 16, 0.05) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.2;
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.back-link {
  position: fixed;
  top: 24px;
  left: clamp(20px, 6vw, 72px);
  font-weight: 600;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 12px 24px rgba(33, 22, 16, 0.12);
  z-index: 5;
}

.hero {
  max-width: 860px;
  display: grid;
  gap: 18px;
  margin-bottom: 48px;
}

.badge {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  color: var(--ink);
}

.formula {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 20px;
  display: grid;
  gap: 6px;
  font-weight: 500;
  box-shadow: 0 16px 32px rgba(33, 22, 16, 0.12);
}

.formula-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
}

.formula-text {
  color: var(--ink);
  font-size: 1.05rem;
}

main {
  display: grid;
  gap: 32px;
}

.panel {
  background: var(--panel);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 36px);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.section-head {
  display: grid;
  gap: 10px;
  max-width: 760px;
}

.section-head h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  color: var(--ink);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.control {
  background: rgba(255, 255, 255, 0.7);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  display: grid;
  gap: 10px;
  font-weight: 600;
}

.control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.control-value {
  justify-self: start;
  color: var(--ink);
  font-weight: 700;
}

.toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle button {
  border: 1px solid var(--border);
  background: transparent;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.toggle button:hover {
  transform: translateY(-2px);
}

.toggle button.active {
  background: var(--ink);
  color: #fff;
  border-color: transparent;
}

.result-line {
  font-weight: 600;
  color: var(--ink);
}

.diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}

.ring-card,
.stat-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  display: grid;
  gap: 12px;
  place-items: center;
  text-align: center;
}

.ring {
  --value: 0;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(
    var(--ring) calc(var(--value) * 1turn),
    rgba(33, 22, 16, 0.08) 0
  );
  position: relative;
  transition: background 0.6s ease;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
}

.ring-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--ink);
}

.ring-label {
  font-weight: 600;
  color: var(--muted);
}

.stat-card h3 {
  font-size: 1.2rem;
}

.stat-card p {
  color: var(--ink);
  font-weight: 600;
}

.stat-note {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--muted);
}

.diagram-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.tree-card,
.bars-card {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.tree {
  display: grid;
  gap: 18px;
}

.tree-group {
  display: grid;
  gap: 10px;
}

.tree-node {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(33, 22, 16, 0.06);
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.tree-node.base {
  background: rgba(240, 180, 41, 0.18);
}

.tree-node.positive {
  background: rgba(29, 138, 122, 0.14);
}

.tree-node.negative {
  background: rgba(232, 107, 61, 0.14);
}

.tree-node.active {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(33, 22, 16, 0.2);
}

.tree-children {
  display: grid;
  gap: 8px;
  padding-left: 12px;
}

.bar-group {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.bar-group.active {
  border-color: var(--ink);
  background: rgba(33, 22, 16, 0.04);
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--ink);
}

.bar-track {
  height: 16px;
  border-radius: 999px;
  background: rgba(33, 22, 16, 0.08);
  overflow: hidden;
  display: flex;
}

.bar-seg {
  transition: width 0.4s ease;
}

.bar-seg.true {
  background: linear-gradient(90deg, #1d8a7a, #22a58f);
}

.bar-seg.false {
  background: linear-gradient(90deg, #e86b3d, #f0b429);
}

.bar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 6px;
}

.legend {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.legend.true::before,
.legend.false::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend.true::before {
  background: #1d8a7a;
}

.legend.false::before {
  background: #e86b3d;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.step {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.step h4 {
  font-size: 1.2rem;
  color: var(--ink);
}

.footer {
  margin-top: 48px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
}

body.loaded .reveal {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s ease;
  transition-delay: var(--delay);
}

@media (max-width: 700px) {
  body {
    padding-top: 90px;
  }

  .back-link {
    position: absolute;
  }

  .formula-text {
    font-size: 0.95rem;
  }
}
