/* The house page: an open book. The left leaf is the house drawn, its tenants written as
   footnotes and its dead struck through; the right leaf is one tenant's file, or the house's
   own record of the night. */

.running-head {
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  max-width: 1480px; margin: 0 auto; padding: 18px 32px 14px;
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font: 500 22px/1 var(--book);
  font-variant: small-caps;
  letter-spacing: 0.14em;
  margin: 0;
  white-space: nowrap;
}
.running-head .here-now { color: var(--pencil); font-size: var(--small); flex: 1; min-width: 0; }
.running-head .here-now span + span::before { content: " · "; color: var(--margin); }
.running-head .controls { display: flex; gap: 16px; align-items: baseline; font-size: var(--small); }
.running-head .toggles { display: flex; gap: 14px; }
.live-state { color: var(--pencil); font-size: var(--small); }
.live-state.lost { color: var(--pencil); font-style: italic; }

.spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  max-width: 1480px; margin: 0 auto;
  min-height: calc(100vh - 64px);
}
.leaf { padding: 22px 40px 56px; min-width: 0; }
.leaf-left { border-right: 1px solid var(--rule); }
.leaf-right { background: var(--paper-2); position: relative; transition: background-color 0.6s ease-out, color 0.6s ease-out; }

/* ---- the plan */
.plan { margin: 0 0 18px; }
.plan svg { display: block; width: 100%; height: auto; max-height: 46vh; overflow: visible; }
.plan .wall { fill: none; stroke: var(--ink); stroke-width: 0.55; stroke-linejoin: miter; }
.plan .room-fill { fill: var(--paper); }
.plan .room.dark .room-fill { fill: url(#hatch); }
.plan .room.outdoors .wall { stroke-dasharray: 0.8 0.6; stroke-width: 0.25; stroke: var(--pencil); }
.plan .room.outdoors .room-fill { fill: transparent; }
.plan .gap { stroke: var(--paper); stroke-width: 0.9; stroke-linecap: butt; }
.plan .swing { fill: none; stroke: var(--pencil); stroke-width: 0.1; }
.plan .leaf-line { stroke: var(--ink); stroke-width: 0.18; }
.plan .link-line { stroke: var(--pencil); stroke-width: 0.15; stroke-dasharray: 0.4 0.4; fill: none; }
.plan .room-name { font: 400 1.2px/1 var(--book); fill: var(--ink); text-anchor: middle; }
.plan .room-name.small { font-size: 0.9px; }
.plan .room-mark { font: 700 0.8px var(--record); fill: var(--pencil); }
.plan .tenant circle { fill: var(--ink); stroke: var(--ink); stroke-width: 0.15; }
.plan .tenant text { font: 700 0.95px var(--record); fill: var(--paper); text-anchor: middle; dominant-baseline: central; }
.plan .tenant.asleep circle { fill: var(--paper); }
.plan .tenant.asleep text { fill: var(--ink); }
.plan .tenant.called circle { fill: var(--house); stroke: var(--house); }
.plan .tenant.called.asleep circle { fill: var(--paper); }
.plan .tenant.called.asleep text { fill: var(--house); }
.plan .tenant circle.ring { fill: none; stroke: var(--ink); stroke-width: 0.14; }
.plan .tenant.called circle.ring { fill: none; stroke: var(--house); }
.plan .tenant { cursor: pointer; }
/* a room is picked by a click anywhere inside its walls: names, door swings and threads let
   the click through; the picked room gets a ruled inner line, a room under the pointer a pencil one */
.plan .room { cursor: pointer; outline: none; }
.plan .room .pick { fill: none; stroke: none; stroke-width: 0.12; pointer-events: none; }
.plan .room:hover .pick { stroke: var(--pencil); }
.plan .room.selected .pick { stroke: var(--ink); stroke-width: 0.2; }
.plan .room:focus-visible .pick { stroke: var(--ink); stroke-width: 0.2; stroke-dasharray: 0.6 0.35; }
.plan .room-name, .plan .room-mark, .plan .gap, .plan .swing, .plan .leaf-line, .plan .link-line, .plan .thread { pointer-events: none; }
.plan .thread { fill: none; stroke: var(--house); stroke-width: 0.18; stroke-dasharray: 60; stroke-dashoffset: 60; animation: thread 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes thread { to { stroke-dashoffset: 0; } }
.plan .dagger { font: 700 2px var(--book); fill: var(--struck); text-anchor: middle; }
.plan .visitors { font: 400 1.6px var(--hand); fill: var(--graphite); }
.plan-notes { font-size: var(--small); color: var(--pencil); max-width: 70ch; margin-top: 8px; }
.plan-notes p { margin: 0 0 6px; }
.plan-notes .mark { color: var(--ink); }

/* ---- the five and the departed: footnotes */
.notes { list-style: none; margin: 0 0 30px; padding: 0; }
.tenant-note {
  display: grid; grid-template-columns: 2ch minmax(0, 1fr); column-gap: 8px;
  padding: 6px 0 7px; border-top: 1px solid var(--rule);
}
.tenant-note:last-child { border-bottom: 1px solid var(--rule); }
.tenant-note .num { font: 700 var(--small)/1.9 var(--record); color: var(--pencil); text-align: right; }
.tenant-note button.who {
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit;
  font: inherit; display: block; width: 100%;
}
.tenant-note .line1 { font: 400 19px/1.35 var(--book); }
.tenant-note .line1 .name { font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.tenant-note button.who:hover .name { text-decoration-color: var(--ink); }
.tenant-note.selected .name { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }
.tenant-note .line2 { font-size: var(--small); line-height: 1.4; color: var(--pencil); margin-top: 1px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.tenant-note .line2 .meter-label { color: var(--pencil); }
.tenant-note.called .line1, .tenant-note.called .num { color: var(--house); }
.tenant-note.vacant .line1 { color: var(--pencil); font-style: italic; }
.departed-note .epitaph { font: 400 var(--small)/1.5 var(--record); color: var(--pencil); margin-top: 4px; }
.departed-note .epitaph em { font: italic 400 17px/1.4 var(--book); color: var(--ink); }

/* ---- the right leaf: the house's record, or a tenant's file */
.record-head { margin-bottom: 22px; }
.record-head .chapter { margin-bottom: 6px; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li {
  display: grid; grid-template-columns: 9ch minmax(0, 1fr); column-gap: 14px;
  padding: 6px 0; border-top: 1px dotted var(--rule);
}
.feed li .text { font: 400 18px/1.45 var(--book); }
.feed li .who { font: 700 var(--small)/1 var(--record); letter-spacing: 0.02em; margin-right: 8px; }
.feed li.k-say .text { font-style: italic; }
.feed li.fresh { animation: ink-in 1.2s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes ink-in { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
.feed-empty { color: var(--pencil); font: italic 400 18px/1.5 var(--book); }

.file .back { font-size: var(--small); margin-bottom: 18px; display: inline-block; }
.file .chapter .is-in { font-style: italic; }
.file .vitals { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: var(--small); color: var(--pencil); margin: 12px 0 22px; }
.file .doing { font: italic 400 19px/1.4 var(--book); margin: 0 0 18px; }
/* how they are, at a glance: a ruled box at the head of the file */
.file .status { border: 1px solid var(--ink); padding: 12px 16px 12px; margin: 16px 0 24px; }
.house-box { border: 1px solid var(--ink); padding: 12px 16px; margin: 4px 0 8px; }
.house-box .vitals { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 8px; font-size: var(--small); }
.house-box .meter-label { color: var(--pencil); }
.house-box .effects { font-size: var(--small); margin: 0 0 10px; }
.house-box .status-rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 16px; row-gap: 4px; margin: 0; align-items: baseline; }
.house-box .status-rows dt { font-size: var(--small); color: var(--pencil); }
.house-box .status-rows dd { margin: 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.house-box .status-rows dd .why-note { color: var(--pencil); }
.house-box .status-rows dd .who { font: 700 var(--small)/1 var(--record); letter-spacing: 0.02em; }
.house-why { font: italic 17px/1.45 var(--book); color: var(--pencil); margin: 0 0 22px; }
.file .status .vitals { margin: 0 0 8px; }
.file .status .effects { font-size: var(--small); margin: 0 0 10px; }
.file .status-rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 16px; row-gap: 4px; margin: 0; align-items: baseline; }
.file .status-rows dt { font-size: var(--small); color: var(--pencil); }
.file .status-rows dd { margin: 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.file .status-rows dd .why-note { color: var(--pencil); }
.file .status-rows dd .who { font: 700 var(--small)/1 var(--record); letter-spacing: 0.02em; }
/* the room's look, on hover or focus of its name under the chapter head */
.room-hint { position: relative; text-decoration: underline dotted var(--pencil); text-underline-offset: 4px; text-decoration-thickness: 1px; cursor: help; }
.room-hint:focus { outline: 2px solid var(--ink); outline-offset: 3px; }
.room-pop {
  display: none; position: absolute; left: 0; top: calc(100% + 8px); z-index: 5; width: min(58ch, calc(100vw - 48px));
  padding: 12px 16px; background: var(--paper); border: 1px solid var(--ink);
  font: normal 400 17px/1.5 var(--book); color: var(--ink); letter-spacing: 0; text-align: left;
}
.room-pop > span { display: block; margin: 0 0 8px; }
.room-pop > span:last-child { margin-bottom: 0; }
.room-hint:hover .room-pop, .room-hint:focus .room-pop { display: block; }
/* the file in prose: now, the last hour, and the latest thing found out (a thought) */
.file .gist { margin: 0 0 24px; max-width: 62ch; }
.file .gist p { margin: 0 0 10px; font: 400 18px/1.5 var(--book); }
.file .gist p.gist-found { font-style: italic; color: var(--ink); }
/* the long parts, folded: a section head that opens */
.file .fold { margin: 0 0 6px; }
.file .fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; padding: 6px 0;
  font: 500 15px/1.2 var(--book); font-variant: small-caps; letter-spacing: 0.12em; color: var(--pencil);
}
.file .fold > summary::-webkit-details-marker { display: none; }
.file .fold > summary::before { content: "+"; font: 400 var(--small)/1 var(--record); letter-spacing: 0; width: 1ch; }
.file .fold[open] > summary::before { content: "−"; }
.file .fold > summary::after { content: ""; flex: 1; border-top: 1px solid var(--rule); transform: translateY(-4px); order: 1; }
.file .fold > summary .fold-note { order: 2; font: 400 var(--small)/1 var(--record); letter-spacing: 0; font-variant: normal; }
.file .fold > summary:hover { color: var(--ink); }
.file .fold > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.file .fold-body { padding: 8px 0 18px; }
/* why: short lines, each led by what it explains */
.file .why { list-style: none; padding: 0; margin: 0 0 24px; }
.file .why li { font-size: 15px; line-height: 1.5; padding: 3px 0 3px 2ch; text-indent: -2ch; }
.file .why .why-k { font-weight: 700; }
.file .why .why-k .who { font: inherit; letter-spacing: 0; }
.file .room-prose { margin-bottom: 24px; }
.file .room-prose p:first-child::first-letter { font-size: 1.15em; }
/* their file as scenes: a room at a time, the latest first; what they did, and who said what */
.file .scenes { list-style: none; padding: 0; margin: 0 0 12px; }
.file .scene { display: grid; grid-template-columns: 9ch minmax(0, 1fr); column-gap: 14px; padding: 10px 0 12px; border-top: 1px dotted var(--rule); }
.file .scene > .when { font-size: var(--small); color: var(--pencil); line-height: 1.9; }
.file .scene > .when .till { display: block; line-height: 1.3; }
.file .scene-head { font-size: var(--small); color: var(--pencil); margin: 0 0 6px; }
.file .scene-head .scene-room { font: 400 19px/1.35 var(--book); color: var(--ink); }
.file .beats { list-style: none; padding: 0; margin: 0; }
.file .beat { font-size: 15px; line-height: 1.5; padding: 3px 0; overflow-wrap: anywhere; }
.file .beat .who { font: 700 var(--small)/1 var(--record); letter-spacing: 0.02em; }
.file .beat .times { font-size: var(--small); color: var(--pencil); }
.file .act-line { margin: 0; }
.file .outs { list-style: none; margin: 2px 0 0; padding: 0 0 0 2ch; }
.file .outs li { padding: 1px 0; }
.file .lines-said {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 12px; row-gap: 4px; align-items: baseline;
  margin: 2px 0; padding-left: 2ch; border-left: 1px solid var(--rule);
}
.file .said { display: contents; }
.file .said > .who { justify-self: start; text-align: left; }
.file .said > span:last-child { font: italic 400 18px/1.45 var(--book); }
.file .said.stage > span { grid-column: 2; font: 400 var(--small)/1.5 var(--record); color: var(--pencil); }
.file .earlier { font-size: var(--small); margin: 0 0 26px; }
.file .found { margin: 0 0 22px; padding: 0; list-style: none; }
.file .found li { font-size: var(--small); color: var(--pencil); padding: 2px 0; }
.file .realised { font: italic 400 19px/1.5 var(--book); margin: 0 0 22px; }
.file .carrying { font-size: var(--small); color: var(--pencil); margin: 0 0 22px; }
.file .colophon { font-size: var(--small); color: var(--pencil); border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 28px; }
.file .margin-call {
  position: absolute; right: 18px; top: 120px; width: 12ch;
  font: italic 400 18px/1.3 var(--book); color: var(--house); transform: rotate(-2deg);
}

/* a room's file: its look as prose, its record, and who has been in it over the day */
.room-file .room-prose { font-size: 18px; margin: 0 0 24px; }
.room-file .way { white-space: nowrap; }
.room-file .room-prose p:first-child::first-letter { font-size: inherit; }
.room-file .room-record { margin-bottom: 12px; }
.room-file .room-record .times { font: 400 var(--small)/1 var(--record); color: var(--pencil); }
.stays { margin: 0 0 24px; }
.stay-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; column-gap: 14px; row-gap: 8px; align-items: center; }
.stay { display: contents; }
.stay-who { font: 700 var(--small)/1.2 var(--record); letter-spacing: 0.02em; white-space: nowrap; }
.stay-who .link { font: inherit; }
.stay.gone .stay-who { color: var(--pencil); }
.stay-track { position: relative; height: 12px; border-bottom: 1px solid var(--rule); }
.stay-track .tick { position: absolute; top: 0; bottom: -1px; width: 0; border-left: 1px dotted var(--rule); }
.stay-track .bar { position: absolute; top: 1px; bottom: 2px; min-width: 2px; background: var(--ink); }
.stay.gone .stay-track .bar { background: var(--pencil); }
.stay-total { font-size: var(--small); color: var(--pencil); white-space: nowrap; text-align: right; }
.stay.axis .stay-axis { position: relative; height: 1.4em; border-top: 1px solid var(--ink); margin-top: -8px; }
.stay-axis span { position: absolute; top: 3px; transform: translateX(-50%); font-size: var(--small); color: var(--pencil); white-space: nowrap; line-height: 1; }
.stays figcaption { font-size: var(--small); color: var(--pencil); margin-top: 6px; }

/* the mind over a day, drawn like a chart recorder's trace */
.trace { margin: 0 0 24px; }
.trace-plot { position: relative; margin-right: 10ch; }
.trace svg { display: block; width: 100%; height: 132px; }
.trace-bands span { position: absolute; left: calc(100% + 8px); transform: translateY(-50%); font-size: var(--small); color: var(--pencil); white-space: nowrap; line-height: 1; }
.trace-axis { display: flex; justify-content: space-between; margin-right: 10ch; font-size: var(--small); color: var(--pencil); border-top: 1px solid var(--ink); padding-top: 3px; }
.trace .grid { stroke: var(--rule); stroke-width: 1; }
.trace .line { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.trace figcaption { font-size: var(--small); color: var(--pencil); }

/* ---- what a mind does to the page (bend.ts): the true text sits beside, for screen readers */
.slip { display: inline-block; }
.fear .file { animation: pulse 0.85s ease-in-out infinite alternate; }
@keyframes pulse { from { letter-spacing: 0; } to { letter-spacing: 0.012em; } }
.lids::before, .lids::after { content: ""; position: absolute; left: 0; right: 0; height: 14vh; pointer-events: none; z-index: 2; }
.lids::before { top: 0; background: linear-gradient(var(--ink) 0, transparent); opacity: 0.16; }
.lids::after { bottom: 0; background: linear-gradient(transparent, var(--ink)); opacity: 0.16; }
.resolving { color: var(--night-pencil); }

/* ---- phones and narrow windows: one column, the file opens over the record */
@media (max-width: 1099px) {
  .spread { grid-template-columns: minmax(0, 1fr); }
  .leaf-left { border-right: 0; }
  .leaf { padding: 20px 16px 40px; }
  .running-head { padding: 14px 16px 12px; gap: 6px 14px; }
  .file .margin-call { position: static; transform: none; width: auto; margin: 0 0 14px; }
  body.reading .leaf-left { display: none; }
}
@media (min-width: 1100px) {
  .file .back { display: none; }
}
@media (max-width: 720px) {
  .running-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .running-head .wordmark { grid-column: 1; }
  .running-head .controls { display: contents; }
  .running-head .stamp { grid-column: 2; grid-row: 1; }
  .running-head .here-now { grid-column: 1 / -1; }
  .running-head .live-state, .running-head .bracket { grid-column: 1 / -1; justify-self: start; }
  .running-head .live-state { display: none; }
  .running-head .toggles { grid-column: 1 / -1; display: flex; gap: 14px; }
}
@media (max-width: 520px) {
  .wordmark { font-size: 20px; }
  .feed li { grid-template-columns: minmax(0, 1fr); }
  .feed li .when { display: block; margin-bottom: 2px; }
  .file .scene { grid-template-columns: minmax(0, 1fr); }
  .file .scene > .when .till { display: inline; margin-left: 1ch; }
  .file .lines-said { grid-template-columns: minmax(0, 1fr); padding-left: 1.5ch; }
  .file .said.stage > span { grid-column: 1; }
  .file .status { padding: 10px 12px; }
  .house-box { padding: 10px 12px; }
  .house-box .status-rows { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .house-box .status-rows dd { margin-bottom: 6px; }
  .file .status-rows { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .file .status-rows dd { margin-bottom: 6px; }
  .plan svg { max-height: none; }
  .stay-grid { column-gap: 10px; }
  .stay-axis span:nth-child(even) { display: none; }
}
