/* Widget styling for THIS post's two explorables (bytes + plan).
   Loaded only on /posts/building-a-database-intro. The shared panel/controls
   styling comes from the site-wide explorable kit (web/static/css/explorables.css). */

/* legend swatches (bytes) */
.sw-head { background: var(--ink-faint); }
.sw-slot { background: var(--accent); }
.sw-free { background: transparent; border: 1px dashed var(--line-strong); }
.sw-rec  { background: color-mix(in srgb, var(--ink) 22%, transparent); }

/* --- bytes: a slotted page --- */
.bytes-body { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: clamp(24px, 4vw, 48px); align-items: stretch; }
.page-stack { display: flex; flex-direction: column; gap: 6px; }
.page-axis { font-size: 10px; color: var(--ink-faint); letter-spacing: .1em; }
.page {
  flex: 1; min-height: 440px; border: 1.5px solid var(--line-strong); display: flex; flex-direction: column;
  overflow: hidden;
}
.reg { position: relative; display: flex; overflow: hidden; }
.reg-lab { position: absolute; left: 8px; top: 6px; font-size: 9.5px; letter-spacing: .1em; }
.reg-head { height: 34px; background: color-mix(in srgb, var(--ink-faint) 28%, transparent); align-items: flex-start; flex: none; }
.reg-slots { flex-direction: column; flex: none; }
.slot {
  height: 26px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px;
  background: var(--accent); color: #fff; border-bottom: 1px solid rgba(255,255,255,.25);
  font-size: 10.5px; transition: filter .15s, transform .15s; flex: none;
}
.slot.hot { filter: brightness(1.15); transform: translateX(3px); }
.slot-n { opacity: .8; } .slot-ptr { font-weight: 500; }
.reg-free {
  flex: 1; min-height: 40px; border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong);
  align-items: center; justify-content: center;
  background: repeating-linear-gradient(0deg, transparent, transparent 11px, var(--grid) 11px, var(--grid) 12px);
}
.reg-free.is-full { background: var(--accent-soft); border-color: var(--accent); }
.reg-free .reg-lab { position: static; }
.reg-recs { flex-direction: column; flex: none; }
.rec {
  height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: color-mix(in srgb, var(--ink) 14%, var(--bg-elev)); border-top: 1px solid var(--line);
  font-size: 11px; overflow: hidden; transition: background .15s; flex: none;
}
.rec.hot { background: var(--accent-soft); }
.rec-i { color: var(--accent); flex: none; }
.rec-data { font-family: var(--font-mono); font-size: 11px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.rec-len { color: var(--ink-faint); flex: none; }

.bytes-side { display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.meter-row { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 6px; white-space: nowrap; gap: 10px; }
.meter-bar { height: 8px; border: 1px solid var(--line-strong); padding: 1px; }
.meter-fill { height: 100%; background: var(--accent); transition: width .4s var(--ease); }
.meter-sub { font-size: 10px; color: var(--ink-faint); margin-top: 6px; }

/* --- plan: query-plan walker --- */
.qp-seg { display: inline-flex; border: 1px solid var(--line-strong); }
.seg { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; padding: 8px 14px; background: none; border: 0; color: var(--ink-dim); cursor: pointer; }
.seg.on { background: var(--accent); color: #fff; }
.qp-query { background: var(--bg); border: 1px solid var(--line); padding: 12px 16px; font-size: 13.5px; color: var(--ink); margin-bottom: 20px; letter-spacing: .02em; }
.qp-body { display: grid; grid-template-columns: 1fr minmax(220px, 300px); gap: clamp(24px, 4vw, 44px); }
.qp-stage { display: flex; flex-direction: column; gap: 18px; }
.qp-pages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.qp-page { border: 1px solid var(--line); transition: border-color .2s, opacity .2s; }
.qp-page.read { border-color: var(--line-strong); }
.qp-page.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.qp-page-h { font-size: 9.5px; padding: 4px 6px; color: var(--ink-faint); border-bottom: 1px solid var(--line); letter-spacing: .1em; }
.qp-rows { display: grid; grid-template-columns: 1fr 1fr; }
.qp-cell { font-size: 11px; padding: 7px 0; text-align: center; color: var(--ink-dim); border: 1px solid transparent; transition: all .12s; }
.qp-cell.seen { color: var(--ink-faint); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.qp-cell.cur { background: var(--accent); color: #fff; }
.qp-cell.match { background: var(--accent); color: #fff; box-shadow: 0 0 0 2px var(--accent); animation: pop .3s var(--ease); }
@keyframes pop { from { transform: scale(.7); } }

.btree { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0 12px; }
.btree-row { display: flex; gap: 40px; }
.bnode { font-family: var(--font-mono); font-size: 11px; padding: 7px 12px; border: 1px solid var(--line-strong); background: var(--bg); display: inline-flex; gap: 6px; align-items: center; color: var(--ink-dim); position: relative; z-index: 1; transition: all .2s; }
.bnode .mono { font-size: 9px; color: var(--ink-faint); }
.bnode.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.bnode.on .mono { color: rgba(255,255,255,.8); }
.bnode.leaf { border-style: solid; }
.btree-wires { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: .6; }

.qp-side { display: flex; flex-direction: column; gap: 14px; }
.qp-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qp-metric { border: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.qp-metric .display { font-size: 34px; line-height: .9; color: var(--ink); }
.qp-metric.cost { grid-column: 1 / -1; flex-direction: row; align-items: baseline; justify-content: space-between; }
.qp-metric.cost.done { border-color: var(--accent); }
.qp-metric.cost .display { color: var(--accent); font-size: 40px; }
.qp-step { background: var(--bg); border-left: 2px solid var(--accent); padding: 12px 14px; font-size: 12px; color: var(--ink); line-height: 1.5; min-height: 44px; }
.qp-foot { font-size: 10.5px; }

@media (max-width: 760px) {
  .bytes-body, .qp-body { grid-template-columns: 1fr; }
  .qp-pages { grid-template-columns: repeat(4, 1fr); }
  .page { min-height: 340px; }
}
