/* ============================================================
   Supply Chain Lab — shared styles (warm theme)
   ============================================================ */

:root {
  --bg:        #f8f2e9;
  --bg-deep:   #f1e7d8;
  --panel:     #fffcf7;
  --ink:       #3d2f24;
  --ink-soft:  #6b5847;
  --muted:     #9a8471;
  --line:      #e6d8c4;
  --accent:    #c96f3b;   /* terracotta */
  --accent-dk: #a8552a;
  --gold:      #e0a458;
  --sage:      #7d9b76;
  --sage-dk:   #5f7d59;
  --danger:    #b5493c;
  --shadow:    0 2px 12px rgba(90, 62, 40, 0.08);
  --radius:    14px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

/* ---------- Layout ---------- */

.site {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar navigation ---------- */

.sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: block;
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 30px;
}
.brand .brand-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: bold;
  letter-spacing: 0.01em;
}
.brand .brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.nav-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 22px 0 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-bottom: 2px;
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(201, 111, 59, 0.10); }
.nav-link.active {
  background: var(--accent);
  color: #fff8f0;
  font-weight: 600;
}
.nav-link .nav-emoji { font-size: 1.05rem; }

/* ---------- Main content ---------- */

.content {
  padding: 40px 48px 80px;
  max-width: 1100px;
  width: 100%;
}

h1 {
  font-family: var(--serif);
  font-size: 2.1rem;
  margin: 0 0 6px;
}
.page-lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 60ch;
  margin: 0 0 30px;
}

h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 36px 0 12px;
}

a { color: var(--accent-dk); }

/* ---------- Cards (home page topic grid) ---------- */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.topic-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(90, 62, 40, 0.14);
}
.topic-card .card-emoji { font-size: 1.8rem; }
.topic-card h3 {
  font-family: var(--serif);
  margin: 10px 0 6px;
  font-size: 1.15rem;
}
.topic-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.topic-card.coming-soon {
  opacity: 0.55;
  pointer-events: none;
}
.topic-card .card-tag {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-dk);
  background: rgba(201, 111, 59, 0.12);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 12px;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.panel h2:first-child { margin-top: 0; }

/* ---------- Simulator layout ---------- */

.sim-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 22px;
  align-items: start;
}

/* ---------- Controls ---------- */

.controls .control { margin-bottom: 16px; }

.controls label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.controls label .value {
  font-weight: 700;
  color: var(--accent-dk);
  font-variant-numeric: tabular-nums;
}

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

.controls input[type="number"],
.controls select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  font-family: var(--sans);
}

/* number input + unit dropdown side by side */
.controls .input-row {
  display: flex;
  gap: 8px;
}
.controls .input-row input { flex: 1.2; min-width: 0; }
.controls .input-row select { flex: 1; min-width: 0; }

.control-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ---------- Buttons ---------- */

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }

button.btn {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
button.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff8f0; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg-deep); }

/* ---------- Stats strip ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.stat {
  background: var(--bg-deep);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
/* keep specific glyphs (e.g. σ) as-is inside uppercased labels, so a
   lowercase sigma doesn't become Σ (which reads as a summation sign) */
.stat .stat-label .lc { text-transform: none; }
.stat .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.stat .stat-value.good { color: var(--sage-dk); }
.stat .stat-value.bad  { color: var(--danger); }

/* ---------- Chart canvas ---------- */

.chart-wrap { position: relative; }
canvas.sim-canvas {
  width: 100%;
  height: 380px;
  display: block;
  border-radius: 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .swatch {
  width: 14px; height: 14px;
  border-radius: 4px;
  display: inline-block;
}

/* ---------- Formula box ---------- */

.formula {
  font-family: var(--serif);
  background: var(--bg-deep);
  border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  margin: 14px 0;
  font-size: 1.02rem;
}
.formula .live { color: var(--accent-dk); font-weight: bold; }

/* small print inside a formula box: variable definitions */
.formula small {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 5px 0 7px;
}

/* ---------- Mobile top bar + off-canvas nav ---------- */
/* Hidden on desktop; the media query below switches everything over. */

.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}
.mobile-topbar .mt-brand {
  font-family: var(--serif);
  font-weight: bold;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
}
.nav-toggle:hover { background: rgba(201, 111, 59, 0.10); }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 47, 36, 0.35);
  z-index: 45;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .site { grid-template-columns: 1fr; }
  .mobile-topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    height: auto;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 24px rgba(61, 47, 36, 0.18);
    z-index: 46;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  body.nav-open .sidebar {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .sidebar .brand { display: none; }   /* shown instead in .mobile-topbar */

  body.nav-open .nav-backdrop { display: block; }

  .content { padding: 20px 20px 60px; }
  .sim-layout { grid-template-columns: 1fr; }
}
