/* At a glance: the writer's numbers, in the plain type of the working pages. */
.glance .report__table { font-family: var(--font-ui); font-size: 0.92rem; }
.glance .report__table thead th { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; }
/* Its sections are parts of a long page, not field labels, so their headings are set to be found. */
.glance h2.title-page__label { margin: 2.1rem 0 0.5rem; color: var(--sheet-ink); font: 800 1.25rem/1.2 var(--font-ui); letter-spacing: -0.01em; text-transform: none; }

.glance__sentence { margin: 0; font-size: 1.25rem; line-height: 1.5; text-align: center; text-wrap: balance; }
.glance__sentence strong { font-weight: 800; }

/* The way to each part of the page, under the opening sentence. */
.glance__jump { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem 0.4rem; margin-top: 0.9rem; }
.glance__jump a { padding: 0.25em 0.85em; border-radius: var(--radius-pill, 999px); background: var(--sheet-tint); color: var(--sheet-soft); font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.glance__jump a:hover { background: var(--sheet-rule); color: var(--sheet-ink); }
.glance :is(h2[id], .glance__row[id]) { scroll-margin-top: 4.5rem; }

.glance__undo { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin-bottom: 1rem; }
.glance__undo form { margin: 0; }

/* Rows: a line for each character or plotline. The small button at a row's end opens its form right
   under it, so nothing waits on the page until it's asked for. */
.glance__rows { display: grid; column-gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
.glance__cast { grid-template-columns: minmax(7rem, max-content) max-content max-content minmax(3rem, 1fr) 4.75rem; }
.glance__threads { grid-template-columns: minmax(9rem, 1fr) max-content max-content max-content minmax(9rem, max-content) 3.75rem; }
.glance__row { position: relative; display: grid; grid-template-columns: subgrid; grid-template-rows: minmax(2.15rem, auto) auto; grid-column: 1 / -1; align-items: center; padding: 0.3rem 0; border-bottom: 1px solid var(--sheet-rule); }
.glance__row--head { grid-template-rows: auto; padding-bottom: 0.35rem; color: var(--sheet-muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.glance__row--head .glance__count { color: inherit; font-size: inherit; }
.glance__who { font-weight: 600; overflow-wrap: anywhere; }
a.glance__who { color: inherit; text-decoration-color: var(--sheet-line); text-underline-offset: 0.15em; }
.glance__who .plotline-tab { margin-right: 0.35em; vertical-align: 0.08em; }
.glance__count { color: var(--sheet-soft); font-size: 0.9rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.glance__count b { color: var(--sheet-ink); font-weight: 600; }
.glance__quiet { font-size: 0.9rem; }
.glance__quiet a { color: inherit; }
.glance__threads .glance__unit { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.glance__bar { display: block; height: 0.45rem; min-width: 2px; border-radius: 3px; background: #c9b99c; }

.glance__more { grid-column: 1 / -1; }
.glance__more > summary { position: absolute; top: 0.4rem; right: 0; list-style: none; cursor: pointer; }
.glance__more > summary::-webkit-details-marker { display: none; }
.glance__more[open] > summary { background: var(--sheet-tint); }
.glance__form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.35rem 0 0.6rem; padding: 0.75rem; border-radius: var(--radius-control); background: var(--sheet-tint); }
.glance__form form { margin: 0; }
.glance__form > input[type="text"] { flex: 1 1 12rem; width: auto; min-width: 0; }
.glance__form .title-page__note { flex: 1 1 100%; font-size: 0.85rem; }

.glance__new { margin-top: 0.9rem; }
.glance__new > summary { display: inline-flex; list-style: none; cursor: pointer; }
.glance__new > summary::-webkit-details-marker { display: none; }
.glance__new[open] > summary { display: none; }
.glance__new .plotline-form { margin-top: 0.25rem; padding: 0.75rem; border-radius: var(--radius-control); background: var(--sheet-tint); }

/* A plotline's letter, name and yarn color. */
.plotline-form { display: flex; flex: 1 1 24rem; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
.plotline-form .plotline-form__letter { flex: 0 0 3.2rem; width: 3.2rem; text-align: center; text-transform: uppercase; font-weight: 700; }
.plotline-form .plotline-form__name { flex: 1 1 12rem; width: auto; min-width: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.1rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.swatch { position: relative; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; cursor: pointer; }
.swatch::before { content: ""; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--plotline); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18); transition: scale 120ms ease; }
.swatch:hover::before { scale: 1.12; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatch:has(:checked)::before { outline: 2px solid var(--sheet-ink); outline-offset: 2px; }
.swatch:has(:focus-visible) { outline: var(--focus-ring); }
@media (pointer: coarse) { .swatch { width: 2.5rem; height: 2.5rem; } .swatch::before { width: 1.5rem; height: 1.5rem; } }

/* The ribbon: the script's pages left to right, a row for the scenes and one for each plotline,
   with a dashed line where each corkboard marker lands, its name standing up from the line so names
   never cross or run off the paper. */
.ribbon { position: relative; display: grid; gap: 0.3rem; --names: 4rem; --marker-names: 6.5rem; }
.ribbon--marked { padding-top: calc(var(--marker-names) + 0.4rem); }
.ribbon__row { display: grid; grid-template-columns: var(--names) 1fr; align-items: center; gap: 0.5rem; }
.ribbon__name { font-size: 0.72rem; font-weight: 700; color: var(--sheet-soft); text-transform: uppercase; letter-spacing: 0.08em; }
.ribbon__track { position: relative; height: 0.9rem; border-radius: 3px; background: var(--sheet-tint); }
.ribbon__scene, .ribbon__piece { position: absolute; top: 0; bottom: 0; }
.ribbon__piece:hover { filter: brightness(0.82); }
.ribbon__scene:hover { z-index: 3; box-shadow: inset 0 0 0 99px rgb(0 0 0 / 0.16); }

/* A scene's index card, held up under its block while the pointer's on it. */
.ribbon__card {
  position: absolute; top: calc(100% + 0.55rem); left: 0; display: none; width: 14rem; padding: 0.5rem 0.65rem 0.6rem;
  border-radius: 2px; background: #fffdf6 linear-gradient(transparent 1.55rem, #e3a1a1 1.55rem, #e3a1a1 calc(1.55rem + 1px), transparent 0) no-repeat;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), 0 6px 18px rgb(0 0 0 / 0.18); color: #2b2620; rotate: -1deg; pointer-events: none;
}
.ribbon__scene--late .ribbon__card { left: auto; right: 0; rotate: 1deg; }
.ribbon__scene:hover .ribbon__card { display: grid; gap: 0.45rem; animation: card-held-up 160ms ease-out; }
.ribbon__card-heading { overflow: hidden; font: 700 0.72rem/1.2 var(--font-typed); text-transform: uppercase; text-overflow: ellipsis; white-space: nowrap; }
.ribbon__card-heading span { font-weight: 400; color: #8a7f70; }
.ribbon__card-excerpt { font: 0.72rem/1.4 var(--font-typed); color: #4a443b; }
@keyframes card-held-up { from { opacity: 0; translate: 0 4px; } }

/* The ribbon strings itself (ribbon_strings_controller.js): a plotline's yarn draws across its row, its scenes
   are pinned on as it passes, then the yarn is gone. */
.ribbon__track--stringing::after {
  content: ""; position: absolute; z-index: 1; left: -0.3rem; right: -0.3rem; top: calc(50% - 1px); height: 2px; border-radius: 1px;
  background: var(--plotline); box-shadow: 0 1px 1px rgb(0 0 0 / 0.25);
  animation: strand-strung 1300ms var(--strung-at, 0ms) ease-out both;
}
.ribbon__track--stringing .ribbon__piece { animation: piece-pinned 280ms var(--strung-at, 0ms) cubic-bezier(0.3, 1.5, 0.6, 1) both; }
@keyframes strand-strung {
  from { clip-path: inset(0 100% 0 0); }
  70% { clip-path: inset(0 0 0 0); opacity: 1; }
  to { clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes piece-pinned { from { opacity: 0; scale: 1 0.2; } }
.ribbon__scene { background: #ddd3bf; }
.ribbon__scene:nth-child(even) { background: #cbbfa6; }
/* The Scenes bar stands an inch high, each scene in its mood from the back of its card, if it has one. */
.ribbon__row--scenes .ribbon__track { height: 1in; }
.ribbon__scene--mood, .ribbon__scene--mood:nth-child(even) { background: var(--mood); box-shadow: inset -1px 0 rgb(255 255 255 / 0.5); }
.ribbon__piece { background: var(--plotline); }
.ribbon__row--pages .ribbon__track { height: 1rem; background: none; }
.ribbon__row--pages .ribbon__track span { position: absolute; translate: -50% 0; font-size: 0.7rem; color: var(--sheet-soft); font-variant-numeric: tabular-nums; }
.ribbon__row--pages .ribbon__track span:first-child { translate: 0 0; }
.ribbon__markers { position: absolute; inset: 0 0 1.3rem calc(var(--names) + 0.5rem); pointer-events: none; }
.ribbon__marker { position: absolute; top: var(--marker-names); bottom: 0; border-left: 1px dashed #8e2a24; }
.ribbon__marker span {
  position: absolute; bottom: calc(100% + 0.2rem); left: 0; translate: -50% 0; rotate: 180deg;
  max-height: var(--marker-names); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  writing-mode: vertical-rl; line-height: 1;
  font-size: 0.68rem; font-weight: 700; color: #8e2a24;
}

/* Readers' pencil marks over the scenes they're in, stacked; a count when there's more than one. */
.ribbon__row--marks { align-items: end; }
.ribbon__row--marks .ribbon__track { height: calc(1.6rem + var(--tallest, 0) * 1.1rem); background: none; border-bottom: 1px dotted var(--sheet-soft); border-radius: 0; }
.ribbon__marks {
  position: absolute; bottom: 0; translate: -50% 0;
  display: flex; flex-direction: column-reverse; align-items: center;
  color: var(--pencil); font: 1.15rem/1 var(--font-hand); text-decoration: none; white-space: nowrap;
}
.ribbon__marks:hover { color: var(--sheet-ink); z-index: 2; }
.ribbon__mark { rotate: -5deg; padding-bottom: 0.1rem; }
.ribbon__mark:nth-child(even) { rotate: 4deg; }
.ribbon__mark[data-kind="heart"] { color: #9c4a4a; }
.ribbon__mark sup { font: 600 0.55rem var(--font-ui); margin-left: 0.05rem; }

@media (max-width: 40rem) {
  .glance__sentence { font-size: 1.05rem; }
  .ribbon { --names: 1.6rem; }
  .ribbon__name { font-size: 0; }
  .ribbon__name .plotline-tab { font-size: 0.7rem; }
  .ribbon__marks { font-size: 0.95rem; }
  /* A row becomes two lines: the name, with its button at the end, then its numbers. */
  .glance__rows { column-gap: 0.9rem; }
  .glance__cast { grid-template-columns: max-content max-content minmax(2rem, 1fr); }
  .glance__threads { grid-template-columns: max-content max-content minmax(0, 1fr); }
  .glance__row { grid-template-rows: auto; padding: 0.45rem 0 0.55rem; }
  .glance__row--head { display: none; }
  .glance__who { grid-column: 1 / -1; min-height: 2rem; padding-right: 5rem; align-content: center; }
  .glance__jump a { padding-inline: 0.7em; }
  .glance__count { text-align: left; }
  .glance__threads .glance__unit { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .glance__quiet { grid-column: 1 / -1; color: var(--sheet-soft); }
  .glance__more > summary { top: 0.3rem; }
  .glance__form .button { flex: 1 1 auto; justify-content: center; }
}

/* A rename in pencil (renamed_controller.js): the old name struck through, the new one written in beside it. */
.renamed { display: inline-flex; align-items: baseline; gap: 0.45rem; }
.renamed__old { position: relative; color: var(--sheet-soft); text-decoration: none; }
.renamed__old::after {
  content: ""; position: absolute; left: -0.15em; right: -0.15em; top: 52%; height: 2px; border-radius: 1px;
  background: var(--brass); rotate: -4deg;
}
.renamed__new { color: var(--brass); font: 1.2rem/1 var(--font-hand); rotate: -2deg; }
.renamed--pencilled .renamed__old::after { animation: struck-through 380ms 250ms ease-in both; }
.renamed--pencilled .renamed__new { animation: the-end-written 800ms 700ms ease-out both; }
.renamed--plain .renamed__old { display: none; }
.renamed--plain .renamed__new { color: inherit; font: inherit; rotate: none; }
@keyframes struck-through { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .renamed--pencilled .renamed__old::after, .renamed--pencilled .renamed__new { animation: none; } }

/* The writing of it: when it started, days at the desk in pencil tallies, the busiest day. */
.writing-of-it { display: grid; grid-template-columns: max-content 1fr; margin: 0 0 0.6rem; }
.writing-of-it__row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; gap: 1.25rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid var(--sheet-rule); }
.writing-of-it dt { color: var(--sheet-muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.writing-of-it dd { margin: 0; }
.writing-of-it__days { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.6rem; }
.writing-of-it__days strong { font: 400 1.35rem/1 var(--font-hand); color: var(--pencil, #4a4a52); }
.writing-of-it__writers { display: block; margin-top: 0.3rem; color: var(--sheet-soft); font-size: 0.85rem; }
.writing-of-it__pages { font: 400 1.15rem/1 var(--font-hand); color: var(--pencil, #4a4a52); }
.tally { display: inline-flex; flex-wrap: wrap; gap: 0.1rem 0.45rem; max-width: 22rem; }
.tally__gate { width: 1.55rem; height: 1.55rem; overflow: visible; stroke: var(--pencil, #4a4a52); stroke-width: 1.7; stroke-linecap: round; opacity: 0.85; }
@media (max-width: 30rem) {
  .writing-of-it { grid-template-columns: 1fr; }
  .writing-of-it__row { gap: 0.25rem; }
}

/* On a laptop: the pitch beside the finish line and the writing of it, the ribbon and the plotlines it draws
   across the whole sheet, then the characters beside the structure. */
@media (min-width: 64rem) {
  .glance__parts { grid-template-areas: "pitch finish" "pitch writing" "pitch ." "shape shape" "plotlines plotlines" "characters structure"; grid-template-rows: auto auto 1fr; }
  .glance__part--pitch { grid-area: pitch; }
  .glance__part--shape { grid-area: shape; }
  .glance__part--characters { grid-area: characters; }
  .glance__part--plotlines { grid-area: plotlines; }
  .glance__part--structure { grid-area: structure; }
  .glance__part--finish_line { grid-area: finish; }
  .glance__part--writing { grid-area: writing; }
}
