/* Notes — essay pages. Leans on style.css for tokens and patterns.css for
   code blocks, buttons, and the shared page chrome. */

.notes {
  display: flex;
  width: min(100%, 760px);
  min-height: 100svh;
  padding: clamp(1.5rem, 4vh, 3rem) var(--page-pad) 1.75rem;
  margin-inline: auto;
  flex-direction: column;
}

.notes .patterns-foot {
  margin-top: auto;
}

/* Matches .patterns h1 exactly — /notes/ and /patterns/ are the same kind
   of section-landing page, and this one had no rule at all before,
   silently falling back to the browser default h1 */
.notes h1 {
  margin-top: clamp(2.5rem, 7vh, 4.5rem);
  font-size: clamp(2.4rem, 5.5vw, 4.2rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.95;
  text-wrap: balance;
}

/* Breathing room above the footer rule; .patterns-app does the same job
   on the drills page */
.note-article,
.note-list {
  padding-bottom: clamp(2rem, 5vh, 3.5rem);
}

/* ------------------------------------------------------------------ index */

.note-list {
  display: flex;
  margin-top: clamp(2rem, 5vh, 3.5rem);
  flex-direction: column;
  gap: 1.25rem;
}

/* Entry cards reuse .deck-card / .deck-meta / .deck-blurb from patterns.css */

/* ---------------------------------------------------------------- article */

.note-article {
  margin-top: clamp(2rem, 6vh, 3.5rem);
}

.note-article h1 {
  margin-top: 0.85rem;
  font-size: clamp(2.1rem, 4.8vw, 3.4rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
  text-wrap: balance;
}

.note-article > p,
.note-article > ul,
.note-article > ol {
  max-width: 640px;
  margin-top: 1.1rem;
  color: var(--text-soft);
  font-size: 1.02rem;
  letter-spacing: -0.011em;
  line-height: 1.65;
}

.note-article > p:first-of-type {
  margin-top: clamp(1.5rem, 4vh, 2.25rem);
  color: var(--text);
  font-size: clamp(1.08rem, 1.5vw, 1.2rem);
}

.note-article h2 {
  margin: clamp(2rem, 5vh, 2.75rem) 0 0;
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.note-article ul,
.note-article ol {
  padding-left: 1.2rem;
}

.note-article li {
  margin-top: 0.5rem;
}

.note-article li::marker {
  color: var(--accent);
}

.note-article code {
  padding: 0.1em 0.35em;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.85em;
}

.note-article pre.code {
  margin-top: 1.25rem;
}

/* Essay code and panels get solid, theme-derived surfaces: unlike the
   drills page there's no glass card behind them, so translucent tints
   let the grid texture bleed through the code */
.note-article pre.code,
.loop-viz .viz-code {
  background: color-mix(in srgb, var(--bg) 93%, var(--mesh-dot));
}

.loop-viz {
  background: color-mix(in srgb, var(--bg) 97%, var(--mesh-dot));
}

.note-article pre.code code {
  padding: 0;
  background: none;
  font-size: 1em;
}

.note-foot-nav {
  margin-top: clamp(2.5rem, 6vh, 3.5rem);
}

/* ------------------------------------------------- event-loop visualizer */

.loop-viz {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.viz-modes {
  display: flex;
  margin-top: 0.85rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.loop-viz .btn {
  padding: 0.5rem 0.95rem;
  font-size: 0.66rem;
}

.viz-mode.is-on {
  border-color: var(--accent);
  color: var(--accent);
}

.viz-code {
  margin-top: 1rem;
}

.viz-code .viz-line {
  display: block;
  padding: 0 0.35rem;
  border-radius: 4px;
}

.viz-line.is-current {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.viz-lanes {
  display: grid;
  margin-top: 1rem;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

.viz-slots {
  display: flex;
  min-height: 84px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  flex-direction: column;
  gap: 0.4rem;
  justify-content: flex-end;
  align-items: flex-start;
  transition: border-color 250ms ease;
}

.viz-lane.is-hot .viz-slots {
  border-color: var(--accent);
  border-style: solid;
}

.viz-slots[data-lane="queue"] {
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-start;
}

.viz-chip {
  width: fit-content;
  padding: 0.35rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.66rem;
  animation: chip-in 220ms ease both;
}

@keyframes chip-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.viz-empty {
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 0.64rem;
}

.viz-status {
  min-height: 3em;
  margin-top: 0.9rem;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Phase badge in the status line, matching the drill-type pill language */
.viz-phase {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  margin-right: 0.6rem;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 0.12em;
}

.viz-counters {
  margin-top: 0.35rem;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.viz-controls {
  display: flex;
  margin-top: 1rem;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.viz-bench {
  display: flex;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.viz-bench-result {
  margin: 0;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

@media (prefers-reduced-motion: reduce) {
  .viz-chip {
    animation: none;
  }
}

/* --------------------------------------------------- cursor-sync playground */

.cviz-stage {
  position: relative;
  height: 260px;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  touch-action: none;
}

.cviz-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  transform: translate(-50%, -50%);
}

.cviz-you {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-mute);
  opacity: 0.6;
  pointer-events: none;
}

.cviz-remote {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--accent);
  filter: drop-shadow(0 1px 4px rgba(3, 8, 20, 0.4));
  pointer-events: none;
}

/* SVG doesn't get the UA's [hidden] treatment reliably; enforce it */
.cviz-remote[hidden] {
  display: none;
}

.cviz-sliders {
  display: flex;
  margin-top: 1rem;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.cviz-sliders label {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cviz-sliders input[type="range"] {
  width: clamp(110px, 18vw, 180px);
  accent-color: var(--accent);
}

.cviz-sliders span {
  min-width: 4ch;
  color: var(--text-soft);
}

/* --------------------------------------------------------- CRDT playground */

.crdt-panes {
  display: grid;
  margin-top: 1rem;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
}

.crdt-pane .deck-meta {
  margin-bottom: 0.5rem;
}

.crdt-text {
  width: 100%;
  height: 130px;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 93%, var(--mesh-dot));
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
}

.crdt-text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Live internal representation: every element in the doc array, in
   position order, including tombstones — this is what the prose
   describes, made visible rather than just narrated */
.crdt-chips {
  display: flex;
  overflow-y: auto;
  max-height: 96px;
  padding: 0.5rem;
  margin-top: 0.6rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-content: flex-start;
}

.crdt-chip {
  padding: 0.2rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.3;
}

.crdt-chip.is-deleted {
  border-color: var(--line);
  color: var(--text-mute);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--text-mute) 70%, transparent);
  opacity: 0.6;
}

.crdt-controls {
  display: flex;
  margin-top: 1rem;
  gap: 0.6rem;
}

@media (max-width: 620px) {
  .crdt-panes {
    grid-template-columns: 1fr;
  }
}
