/* ────────────────────────────────────────────────────────────
   Memory Allocators Tutorial · Extra styles
   Builds on tutorial.css. Self-contained: includes the timeline
   primitives so this page doesn't depend on other tutorials' CSS.
   ──────────────────────────────────────────────────────────── */

/* ── History timeline (§2) ── */
.timeline-block {
  margin: 1.5rem 0 2rem;
  border-left: 2px solid var(--tut-border);
  padding-left: 1.3rem;
  display: grid;
  gap: 1.1rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 1rem;
  align-items: start;
}

.timeline-year {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--tut-accent);
  font-weight: 700;
  letter-spacing: 0.05em;
  position: relative;
  padding-top: 0.05rem;
}

.timeline-year::before {
  content: '';
  position: absolute;
  left: -1.42rem;
  top: 0.45rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tut-accent);
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.18);
}

.timeline-body {
  font-size: 0.97rem;
  line-height: 1.6;
  color: var(--tut-soft);
}

.timeline-body strong { color: var(--tut-text); }

@media (max-width: 640px) {
  .timeline-block { padding-left: 1rem; }
  .timeline-row { grid-template-columns: 50px 1fr; gap: 0.5rem; }
  .timeline-year::before { left: -1.12rem; }
}

/* ── Allocator comparison / cheat-sheet table ── */
.alloc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.5rem;
  font-size: 0.86rem;
}
.alloc-table th, .alloc-table td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--tut-border-soft);
  color: var(--tut-soft);
  vertical-align: top;
}
.alloc-table th {
  color: var(--tut-text);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--tut-surface);
  font-family: var(--mono);
  font-size: 0.76rem;
  text-transform: uppercase;
}
.alloc-table tr:last-child td { border-bottom: 0; }
.alloc-table td:first-child {
  color: var(--tut-text);
  font-weight: 600;
}
.alloc-table code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(167, 139, 250, 0.08);
  padding: 0.05em 0.35em;
  border-radius: 3px;
  color: var(--tut-text);
}

/* Verdict pills inside cheat-sheet cells */
.alloc-table .verdict {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.1em 0.5em;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.alloc-table .verdict.good { background: rgba(52, 211, 153, 0.13); color: var(--tut-success); }
.alloc-table .verdict.ok   { background: rgba(96, 165, 250, 0.13); color: var(--tut-info); }
.alloc-table .verdict.bad  { background: rgba(248, 113, 113, 0.13); color: var(--tut-danger); }
.alloc-table .verdict.warn { background: rgba(251, 191, 36, 0.13); color: var(--tut-warn); }

/* ── Race / latency widget output stat grids ── */
#widget-malloc-latency .stat-grid,
#widget-frag-race .stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

/* ── Buddy widget tree controls ── */
#widget-buddy .controls,
#widget-tlsf .controls,
#widget-slab .controls,
#widget-pool .controls,
#widget-linear .controls,
#widget-stack .controls,
#widget-soa .controls,
#widget-handles .controls {
  font-family: var(--mono);
}

/* ── Allocator-op log inside the SoA/AoS, handles, and race widgets ── */
.alloc-log {
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--tut-soft);
  background: var(--tut-bg);
  border: 1px solid var(--tut-border-soft);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.alloc-log .row {
  display: flex;
  gap: 0.4rem;
  padding: 0.1rem 0;
}
.alloc-log .row .tag {
  flex-shrink: 0;
  width: 4ch;
  color: var(--tut-muted);
  text-align: right;
}
.alloc-log .row .msg { flex: 1; color: var(--tut-soft); }
.alloc-log .row.ok   .msg { color: var(--tut-success); }
.alloc-log .row.warn .msg { color: var(--tut-warn); }
.alloc-log .row.err  .msg { color: var(--tut-danger); }
.alloc-log .row.info .msg { color: var(--tut-info); }

/* ── Allocator size legend (color = size class) ── */
.size-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--tut-soft);
  margin-top: 0.4rem;
}
.size-legend .swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--tut-border-soft);
  border-radius: 4px;
}
.size-legend .swatch::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

/* ── Buddy-tree controls: dropdown + add/remove buttons share row ── */
#widget-buddy .btn-group,
#widget-tlsf .btn-group {
  flex-wrap: wrap;
}

/* ── Generational-handles widget: handle pill ── */
.handle-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.15em 0.55em;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-text);
}
.handle-pill .hidx { color: var(--tut-accent); font-weight: 700; }
.handle-pill .hsep { color: var(--tut-muted); }
.handle-pill .hgen { color: var(--tut-info); font-weight: 700; }
.handle-pill.stale { opacity: 0.55; text-decoration: line-through; }

/* ── SoA / AoS layout cards ── */
.layout-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 1.25rem 0;
}
@media (max-width: 720px) {
  .layout-cards { grid-template-columns: 1fr; }
}

.layout-card {
  background: var(--tut-surface);
  border: 1px solid var(--tut-border);
  border-radius: 10px;
  padding: 0.85rem 1rem 1rem;
}
.layout-card-title {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tut-accent);
  margin-bottom: 0.55rem;
}
.layout-card-title.aos { color: var(--tut-warn); }
.layout-card-title.soa { color: var(--tut-success); }
.layout-card pre {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--tut-soft);
  margin: 0;
  white-space: pre-wrap;
}
.layout-card pre .kw { color: #c084fc; }
.layout-card pre .fn { color: #60a5fa; }
.layout-card pre .num { color: #fb923c; }
.layout-card pre .com { color: #5b5b78; font-style: italic; }

/* ── Tutorial card background for the index page ── */
.game-card-visual.alloc-bg {
  background: linear-gradient(135deg, #0a1218 0%, #14283d 35%, #1a2452 70%, #0d0a1f 100%);
  position: relative;
  overflow: hidden;
}
.game-card-visual.alloc-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 30%, rgba(96, 165, 250, 0.28), transparent 45%),
    radial-gradient(circle at 78% 72%, rgba(52, 211, 153, 0.22), transparent 45%);
  pointer-events: none;
}
.game-card-visual.alloc-bg canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Canvas background consistency for every allocator widget ── */
#widget-malloc-latency canvas,
#widget-linear canvas,
#widget-stack canvas,
#widget-pool canvas,
#widget-buddy canvas,
#widget-tlsf canvas,
#widget-slab canvas,
#widget-frag-race canvas,
#widget-soa canvas,
#widget-handles canvas {
  background: #07070d;
}
