/* Grown in Place: an interactive essay. Text in a narrow column on the left, its figure on the right,
   held in view while you read; numbers with a dotted underline can be dragged. */
.g-head { max-width: 1160px; margin: 0 auto; padding: clamp(40px, 7vw, 96px) var(--gutter) 0; }
.g-head h1 { margin: 0; font-weight: 400; font-size: clamp(44px, 7vw, 88px); line-height: 1; letter-spacing: -.02em; }
.g-sub { margin: 14px 0 0; font-family: var(--serif); font-style: italic; font-size: clamp(19px, 2.2vw, 24px); color: #444; }
.g-by { margin: 18px 0 0; font-size: 14px; color: var(--quiet); max-width: 40em; }
.g { max-width: 1160px; margin: 0 auto; padding: 0 var(--gutter); }
.g-row { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: clamp(32px, 5vw, 72px); align-items: start; margin: 40px 0 0; }
.g-txt p { margin: 0 0 1.05em; font-family: var(--serif); font-size: 17px; line-height: 1.72; color: #2a2a2a; }
.g-txt .g-lead { font-size: 19px; color: #111; }
.g-txt code { font-size: 14px; background: #f1f1f1; padding: 0 4px; border-radius: 2px; }
.g-principle { padding: 14px 16px; background: #f3f3f3; border-left: 3px solid var(--lapis); font-size: 17.5px !important; }
.g-principle b { font-family: var(--sans); font-weight: 500; display: block; font-size: 13px; color: var(--lapis); margin-bottom: 2px; }
.g-h { margin: clamp(72px, 10vw, 128px) 0 0; font-weight: 400; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; letter-spacing: -.01em; max-width: 400px; }
.g-fig { margin: 0; position: sticky; top: 20px; }
.g-fig figcaption { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--quiet); }
.g-fig > img { width: 100%; height: auto; display: block; border: 1px solid var(--edge); border-radius: 4px; }
.g-code { margin-top: 10px; border-radius: 3px; font-size: 12.5px; line-height: 1.65; }
.g-code .c { color: #8a8a8a; }

/* the dotted-underline numbers you can drag */
.scrub { color: var(--lapis); border-bottom: 1.5px dotted currentColor; cursor: ew-resize; font-weight: 600; font-variant-numeric: tabular-nums; user-select: none; touch-action: none; outline: none; padding: 0 1px; }
.scrub:hover, .scrub.on, .scrub:focus-visible { background: rgba(31, 79, 163, .1); border-radius: 2px; }
.am-code .scrub { color: #8fc4ff; }
[data-out] { font-variant-numeric: tabular-nums; }

/* figure 1: shipped vs grown */
.g-fig svg { width: 100%; height: auto; display: block; background: #f6f6f6; border: 1px solid var(--edge-soft); border-radius: 4px; }
.sv-h { font: 500 15px var(--sans); fill: #111; }
.sv-t { font: 500 14px var(--sans); fill: #222; }
.sv-s { font: 12px var(--sans); fill: #666; }
.sv-box { fill: #d9d9d9; stroke: #999; }
.sv-arrow path { stroke: #999; stroke-width: 2; fill: none; marker-end: none; }
.sv-k rect { fill: #fff; stroke: #bbb; }
.sv-same rect { fill: #d9d9d9; }
.sv-grow rect { fill: #2ec6e6; fill-opacity: .55; }
.sv-grow rect.gone { fill: none; stroke: #e58; stroke-dasharray: 3 2; }
.sv-src circle { fill: #ffaa1d; }

/* figure 2: the recipe and what it becomes */
.g-recipe { padding: 14px 16px; background: #fff; border: 1px solid var(--edge-soft); border-radius: 4px; font-family: var(--serif); font-size: 16px; line-height: 1.6; }
.g-recipe p { margin: 0 0 4px; }
.g-recipe [data-n] { border-radius: 2px; cursor: default; outline: none; }
.g-needs { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 14px; background: var(--field); border: 1px solid var(--edge-soft); }
.g-needs th, .g-needs td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--edge-soft); }
.g-needs th { font-weight: 500; font-size: 12.5px; color: var(--panel-quiet); }
.hot { background: rgba(255, 170, 29, .32); }

/* figure 3: questions */
.g-qs { display: grid; gap: 1px; background: var(--edge-soft); border: 1px solid var(--edge-soft); border-radius: 4px; overflow: hidden; }
.g-qs .q { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 12px; background: var(--field); }
.g-qs .qq { font-size: 15px; }
.g-qs .qa { font-size: 13px; color: #fff; background: #3a8a9e; padding: 1px 8px; border-radius: 3px; align-self: start; }
.g-qs .q.warn .qa { background: #c25a6a; }
.g-qs .q.later .qa { background: #888; }
.g-qs code { grid-column: 1 / -1; font-size: 12.5px; color: var(--panel-quiet); }

/* figure 4: streams */
.g-streams .plot { background: #1e1e1e; border-radius: 4px; padding: 8px 10px 4px; cursor: ew-resize; touch-action: pan-y; outline: none; }
.g-streams .plot:focus-visible { box-shadow: 0 0 0 2px #2ec6e6; }
.g-streams svg { background: none; border: 0; }
.g-streams .lane { fill: #262626; }
.g-streams .ln { font: 11.5px var(--mono); fill: #bbb; }
.g-streams .tk { stroke: #2b2b2b; } .g-streams .tk.mj { stroke: #3a3a3a; }
.g-streams .tl { font: 10.5px var(--mono); fill: #888; }
.g-streams .hd { stroke: #fff; stroke-width: 1.4; }
.g-streams .hdb { fill: #fff; } .g-streams .hdt { font: 500 10.5px var(--mono); fill: #000; }
.g-streams .read { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.g-streams .read span { display: inline-flex; gap: 6px; padding: 2px 8px; background: var(--field); border: 1px solid var(--edge-soft); border-radius: 3px; font: 12.5px var(--mono); }
.g-streams .read i { font-style: normal; color: var(--panel-quiet); }

/* figure 5: the story, stacked to fit the column */
.g-story .ks { grid-template-columns: minmax(0, 1fr); grid-template-areas: "steps" "frame" "code"; }
.g-story .ks-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-story .ks-frame figcaption { font-size: 15px; min-height: 0; }
.g-story .ks-prog { max-height: 22rem; }

/* figure 6: status */
.g-status { display: grid; gap: 1px; background: var(--edge-soft); border: 1px solid var(--edge-soft); border-radius: 4px; overflow: hidden; }
.g-status > div { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; background: var(--field); }
.g-status p { margin: 0; font-size: 14.5px; line-height: 1.45; }
.g-status .st { font-size: 12.5px; padding: 1px 8px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); text-align: center; }
.g-status .st.has { background: var(--c-works); } .g-status .st.next { background: var(--field-alt); color: var(--panel-quiet); }

@media (max-width: 900px) {
  .g-row { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .g-fig { position: static; }
  .g-h { max-width: none; }
}

/* calibration */
.g-cal canvas { width: 100%; height: auto; display: block; border-radius: 4px; border: 1px solid var(--edge); cursor: grab; touch-action: none; }
.cal-row { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.mat { display: grid; grid-template-columns: repeat(3, auto); gap: 2px 14px; padding: 6px 12px; background: #1e1e1e; color: #9fd8ef; font: 12px var(--mono); border-radius: 3px; border-left: 2px solid #777; border-right: 2px solid #777; }
.mat span { text-align: right; font-variant-numeric: tabular-nums; }
.cal-row .reset { margin-left: auto; font: inherit; font-size: 13px; padding: 3px 10px; border: 1px solid var(--edge); border-radius: 3px; background: var(--field); cursor: pointer; }

/* two kinds of seeing */
.g-see svg { width: 100%; height: auto; display: block; border-radius: 4px; border: 1px solid var(--edge); }
.g-see .roi { fill: rgba(255, 170, 29, .12); stroke: #ffaa1d; stroke-width: 2.5; }
.g-see .roi.hot { stroke: #2ec6e6; fill: rgba(46, 198, 230, .14); stroke-width: 3.5; }
.g-see .rl { font: 600 34px var(--sans); fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 4px; }
.g-see .rl2 { font: 500 30px var(--sans); fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 5px; }
.g-see .motion { fill: none; stroke: #5fd068; stroke-width: 3; }
.g-see .crop { fill: none; stroke: #ff8aa8; stroke-width: 3; stroke-dasharray: 10 7; }

/* the stream graph */
.g-graph .gr svg { width: 100%; height: auto; display: block; background: #1e1e1e; border-radius: 4px; }
.g-graph .ed { fill: none; stroke: #4a4a4a; stroke-width: 2; }
.g-graph .ed.on { stroke: #fff; stroke-width: 2.5; }
.g-graph .nd { cursor: pointer; outline: none; }
.g-graph .nd rect { fill: #262626; stroke: var(--c); stroke-width: 2; }
.g-graph .nd.on rect, .g-graph .nd:focus-visible rect { fill: color-mix(in srgb, var(--c) 30%, #262626); stroke-width: 3; }
.g-graph .nd text { font: 12px var(--mono); fill: #eee; }
.g-graph .gi { margin-top: 8px; padding: 10px 12px; background: var(--field); border: 1px solid var(--edge-soft); border-radius: 4px; min-height: 5.5em; }
.g-graph .gi b { font: 500 14px var(--mono); }
.g-graph .gi .kd { margin-left: 8px; font-size: 12px; padding: 0 7px; border-radius: 3px; background: var(--c); color: #000; }
.g-graph .gi p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; }
.g-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--panel-quiet); }
.g-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; background: var(--c); vertical-align: -1px; }
.g-budget { margin-top: 12px; display: grid; gap: 4px; font-size: 12.5px; }
.g-budget > div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 11rem; gap: 10px; align-items: center; }
.g-budget i { display: block; height: 10px; width: var(--w); background: #2ec6e6; border-radius: 2px; }
.g-budget .slow i { background: repeating-linear-gradient(90deg, #ff8aa8 0 10px, transparent 10px 14px); }
.g-budget b { font: 500 12px var(--mono); color: var(--panel-quiet); }

/* the writer's loop */
.loop { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--edge-soft); border: 1px solid var(--edge-soft); border-radius: 4px; overflow: hidden; counter-reset: lp; }
.loop li { background: var(--field); padding: 10px 12px; counter-increment: lp; }
.loop li b { display: block; font-weight: 500; font-size: 15px; }
.loop li b::before { content: counter(lp) "  "; font: 500 12px var(--mono); color: var(--panel-quiet); }
.loop li span { font-size: 13px; color: var(--panel-quiet); line-height: 1.45; }
.g-trace { white-space: pre-wrap; }
@media (max-width: 900px) { .loop { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-budget > div { grid-template-columns: 7.5rem minmax(0, 1fr) 8rem; } }

/* Built Like a Cell: the opening drawing */
.sv-bricks rect { fill: #d6c8a8; stroke: #a8996f; stroke-width: .8; }
.sv-arch { fill: #cfcfcf; stroke: #8a8a8a; stroke-width: 1.5; }
.sv-cell { fill: rgba(95, 208, 104, .12); stroke: #5fd068; stroke-width: 3; }
.sv-nuc { fill: rgba(46, 198, 230, .35); stroke: #2ec6e6; stroke-width: 1.5; }
.sv-org { fill: rgba(255, 170, 29, .4); }
.sv-msg path { stroke: #ff8aa8; stroke-width: 2; } .sv-msg circle { fill: #ff8aa8; }

/* existing site figures, fitted into the essay's figure column */
.g-fig .panel + .panel { margin-top: 14px; }
.g-fig .pkt { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.g-fig .truss-how { grid-template-columns: minmax(0, 1fr); }
.g-fig .truss-how .am-code { border-left: 0; border-top: 1px solid #111; }
.g-fig .truss-lang { margin-top: 14px; }
.g-fig .grammars { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 1fr); }
.g-wide .g-txt { max-width: 640px; }
.g-wide .g-fig { position: static; }

/* =========================================================
   Essay layout, after Learnable Programming: one 640px column for text and figures,
   a quarter-width column on the right for sidenotes, big headings, a contents list.
   (Overrides the earlier side-by-side layout.)
   ========================================================= */
.g-head, .g { max-width: 1200px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.g-head h1, .g-head .g-sub, .g-head .g-by { max-width: 640px; }
.g-row { display: block; max-width: 640px; margin: 0; }
.g-txt p { font-size: 17px; }
.g-fig { position: static; margin: 26px 0 30px; max-width: 640px; }
.g-fig.g-break, .g-wide .g-fig { max-width: 930px; width: min(930px, calc(100vw - 2 * var(--gutter))); }
.g-wide .g-txt { max-width: 640px; }
.g-h { max-width: 640px; margin: clamp(80px, 11vw, 136px) 0 18px; font-weight: 500; font-size: clamp(40px, 5.6vw, 64px); line-height: 1; letter-spacing: -.025em; }
.g-note { float: right; clear: right; width: 250px; margin: 4px -290px 12px 0; font-family: var(--sans); font-size: 12.5px; line-height: 1.55; color: #8a8a8a; }
.g-note b { color: #555; font-weight: 500; }
.g-note code { font-size: 11.5px; }
.g-toc { max-width: 640px; margin: 36px 0 0; padding: 14px 18px; background: #f4f4f4; border-radius: 4px; }
.g-toc h2 { margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--quiet); }
.g-toc ol { margin: 0; padding-left: 1.4em; columns: 2; column-gap: 32px; font-size: 15px; line-height: 1.75; }
.g-toc a { color: var(--ink); text-decoration: none; }
.g-toc a:hover { color: var(--lapis); text-decoration: underline; }
.g-story .ks-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1040px) {
  .g-note { float: none; width: auto; margin: -6px 0 16px; padding-left: 12px; border-left: 2px solid #e2e2e2; }
  .g-toc ol { columns: 1; }
}
