/* ============================================================
 * blog-fenwick.css — shared styles for the Fenwick Tree blog
 * series (blog/dsa/trees/fenwick-tree/*.html).
 *
 * Hoisted out of duplicated inline <style> blocks. Built on top
 * of styles.css (--ink, --ink-muted, --line, --card, --brand)
 * and blog.css.
 * ============================================================ */

:root {
  /* Semantic tokens for BIT animations. The "queried"/"updated"/
     "parent"/"range"/"inversion" colors are intentionally distinct
     from --brand so multiple states can co-occur in one widget. */
  --bit-active: var(--brand);
  --bit-queried: #10b981;
  --bit-updated: #f59e0b;
  --bit-parent: #f59e0b;
  --bit-range: #8b5cf6;
  --bit-inversion: #ef4444;
}

/* ===== BIT array cells ===== */

.bit-cell {
  display: inline-block;
  width: 36px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  margin: 1px;
  transition: all 0.3s;
}
.bit-cell.active    { background: var(--bit-active);    color: #fff; border-color: var(--bit-active); }
.bit-cell.queried   { background: var(--bit-queried);   color: #fff; border-color: var(--bit-queried); }
.bit-cell.updated   { background: var(--bit-updated);   color: #fff; border-color: var(--bit-updated); }
.bit-cell.parent    { background: var(--bit-parent);    color: #fff; border-color: var(--bit-parent); }
.bit-cell.range     { background: var(--bit-range);     color: #fff; border-color: var(--bit-range); }
.bit-cell.inversion { background: var(--bit-inversion); color: #fff; border-color: var(--bit-inversion); }

.bit-array {
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
}

/* Wrap a .bit-array with .bit-anim-wrap to overlay an SVG arrow
   layer on top. The SVG must have class .bit-anim-svg and be a
   direct sibling of .bit-array inside the wrap. */
.bit-anim-wrap {
  position: relative;
}
.bit-anim-wrap .bit-anim-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* ===== Section + control labels ===== */

.ds-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.op-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
  align-items: center;
}
.op-group label { font-size: 0.85rem; font-weight: 600; }
.op-group input,
.op-group select {
  font-family: Consolas, monospace;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 60px;
  background: var(--card);
  color: var(--ink);
}

/* The bigger-input variant used by range-operations.html */
.op-group input.op-narrow { width: 50px; }

/* ===== Step log ===== */

.step-log {
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  color: var(--ink-muted);
  max-height: 220px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-top: 0.5rem;
}
.step-log .step-active { color: var(--brand);         font-weight: 600; }
.step-log .step-done   { color: var(--bit-queried);                    }
.step-log .step-inv    { color: var(--bit-inversion); font-weight: 600; }

/* ===== Tables ===== */

.bin-table,
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.bin-table       { font-family: Consolas, monospace; font-size: 0.85rem; }
.compare-table   { font-size: 0.88rem; }
.bin-table th, .bin-table td,
.compare-table th, .compare-table td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  text-align: center;
}
.compare-table th, .compare-table td { padding: 0.5rem 0.75rem; }
.bin-table th, .compare-table th {
  background: var(--card);
  font-weight: 700;
}
.bin-table th { font-family: Manrope, sans-serif; }
.compare-table td:first-child {
  text-align: left;
  font-weight: 600;
}

/* Lowbit highlight inside the bin-table / lowbit-demo */
.lo-bit { color: var(--brand); font-weight: 700; }

.lowbit-demo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.lowbit-demo .bin {
  font-family: Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}
.lowbit-demo .bit-on { color: var(--brand); font-weight: 700; }

/* ===== 2D grid (patterns.html) ===== */

.grid-2d {
  display: inline-grid;
  gap: 1px;
  margin: 0.5rem 0;
}
.grid-2d .bit-cell {
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 0.75rem;
}

/* ===== Narrow viewports ===== */

@media (max-width: 480px) {
  .bit-cell { width: 30px; height: 30px; line-height: 30px; font-size: 0.74rem; }
}
