/* block.css: owned by the block agent. Everything inside #drawer (the block panel and the
   building card, docs/design.md section 8), plus the rows of the search dropdown #q-list.
   Tokens and the drawer frame live in app.css (docs/site-modules.md). Selection, hover and
   focus here are ink; the signal color belongs to the quake replay. */

/* ---------- shared: title, close, receipts ---------- */
.block-panel, .card-panel { position: relative; padding: var(--s-4) var(--s-5); }

.panel-title { margin: 0; font: 600 var(--t-16) / 1.25 var(--font); font-stretch: var(--wdth-text); }
/* Focus lands on the title so a screen reader announces the panel; it is not a control. */
.panel-title:focus-visible { outline: none; }

/* Pulled up and out so the glyph centers on the title's first line and ends at the text edge. */
.panel-close {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; margin: -6px -8px 0 0; padding: 0;
  border: 0; color: var(--ink); transition: background-color var(--t-fast) var(--ease);
}
.panel-close:hover { background: var(--wash); }

.receipts { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.receipt { min-width: 0; }
.receipt p { margin-block: 0; }
.receipt-label { font-size: var(--t-12); line-height: 1.35; font-weight: 600; }
.receipt-main { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.receipt-year { flex: none; font-size: var(--t-20); line-height: 1.2; font-weight: 700; }
.receipt[data-noyear] .receipt-year { font-size: var(--t-14); font-weight: 600; }
.receipt-addr { min-width: 0; font-size: var(--t-14); overflow-wrap: anywhere; }
button.receipt-addr {
  padding: 0; border: 0; text-align: left; line-height: 1.35;
  text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px;
}
button.receipt-addr:hover { text-decoration-color: currentColor; }
/* Second lines sit under the address, past the swatch and its gap. */
.receipt-ground, .receipt-facts, .receipt-link {
  display: block; margin-left: calc(10px + var(--s-2)); font-size: var(--t-12); line-height: 1.35; color: var(--ink-2);
}
/* A term stays whole while it fits the line; one longer than the line wraps inside it. The dot
   between two terms sits in the gap before the second. At the start of a line that is left of
   the paragraph, which clips it there (4px out, the reach of a focus ring). */
.receipt-ground { display: flex; flex-wrap: wrap; column-gap: 12px; clip-path: inset(-4px); }
.receipt-ground .term { position: relative; max-width: 100%; color: inherit; text-decoration-color: var(--rule); }
.receipt-ground .term::before {
  content: ""; position: absolute; left: -7.5px; top: calc(50% - 1.5px); width: 3px; height: 3px;
  border-radius: 50%; background: currentColor;
}
.receipt-ground .term:hover { text-decoration-color: currentColor; }
.receipt-link { width: fit-content; }
.receipt-link a { color: var(--ink); }

/* ---------- building card ---------- */
.card-panel { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); }
.card { min-width: 0; }
.card .panel-title { font-size: var(--t-16); }
.card .receipt-main { align-items: baseline; }
.card .receipt-main .swatch { align-self: center; }
.card .receipt-facts, .card .receipt-ground { margin-top: 2px; }

/* ---------- block panel ---------- */
/* --roof: a strip's top to its ground line. --plot: the tallest bar and the milestone rules,
   under the height label and the diamond (street) or the rule years (years). */
.block-panel { --roof: 144px; --plot: calc(var(--roof) - 24px); container-type: inline-size; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.diamond { display: block; flex: none; width: 5px; height: 5px; background: var(--ink); transform: rotate(45deg); }

/* The receipts come first in the panel (the phone order) and stand in the right column here.
   That column holds the longest single-permit term on one line (12px, past the swatch). */
.panel-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) 272px; gap: var(--s-6); align-items: start; }
.receipts { grid-column: 3; grid-row: 1; }

/* Each strip under its title, set like the rail's section titles; both title lines are one
   height, so the two strips keep one ground line. */
.strip-group { min-width: 0; }
.strip-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); height: 20px; margin-bottom: var(--s-2); }
.strip-title { margin: 0; font: 600 var(--t-14) / 1.2 var(--font); font-stretch: var(--wdth-text); }
.panel-legend {
  position: relative; display: flex; align-items: center; gap: 6px; flex: none;
  font-size: var(--t-12); line-height: 1.35; color: var(--ink-2); text-decoration-color: var(--rule);
}
.panel-legend:hover { text-decoration-color: currentColor; }

/* The street strip and the years strip share one ground line, var(--roof) from their tops. */
.strip { position: relative; min-width: 0; }
.strip::after {
  content: ""; position: absolute; left: 0; right: 0; top: var(--roof); height: 1px;
  background: var(--ink); pointer-events: none;
}
.strip .axis { color: var(--ink-2); white-space: nowrap; }

/* ---------- street strip ---------- */
/* The lane names sit in a gutter left of the row; the row scrolls, the gutter does not. */
.street { --names: 60px; display: grid; grid-template-columns: var(--names) minmax(0, 1fr); column-gap: var(--s-2); }
.street::after { left: calc(var(--names) + var(--s-2)); }
/* A name's 12px row centers on its 10px lane (lanes: 2px down, a 12px pitch). */
.lane-names { display: flex; flex-direction: column; padding-top: calc(var(--roof) + 1px); }
.lane-names span { height: 12px; font-size: var(--t-11); line-height: 12px; text-align: right; }
/* The inline padding is the reach of the selected bar's outline (2px, 1px out). */
.slots {
  position: relative; display: flex; align-items: flex-start; padding-inline: 3px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
}
/* An edge the row can scroll past (data-more, blockview.js) fades over 20px, under one phone
   slot, so no bar loses its era color; the 20px is EDGE_FADE in blockview.js. */
.slots[data-more] {
  --fade-start: 0px; --fade-end: 0px;
  mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
}
.slots[data-more="start"], .slots[data-more="both"] { --fade-start: 20px; }
.slots[data-more="end"], .slots[data-more="both"] { --fade-end: 20px; }
.slot {
  --gap: clamp(1px, calc((100% - 9.99px) * 1000), 2px); /* 2px, or 1px once a slot is under 10px */
  position: relative; display: flex; flex: none; flex-direction: column;
  width: clamp(6px, calc(100% / var(--n)), 44px); padding: 0 0 18px; border: 0; border-radius: 0;
}
.slot .roof { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: var(--roof); }
.slot .bar {
  display: block; height: max(3px, calc(var(--bar) * var(--plot))); margin-right: var(--gap);
  background: var(--c); border-radius: var(--radius) var(--radius) 0 0;
}
.slot .diamond { align-self: center; margin: 0 var(--gap) 5px 0; }
.bar-label { align-self: center; margin: 0 var(--gap) var(--s-1) 0; }
/* Lit (pointed at here or on the map): a 1px ink outline. Selected: 2px, over its neighbors. */
.slot[data-lit] { z-index: 1; }
.slot[data-lit] .bar { outline: 1px solid var(--ink); outline-offset: 1px; }
.slot[aria-pressed="true"] { z-index: 2; }
.slot[aria-pressed="true"] .bar { outline: 2px solid var(--ink); outline-offset: 1px; }

.lanes { display: flex; flex-direction: column; gap: 2px; margin: 2px var(--gap) 0 0; }
.lane { display: block; height: 10px; background: var(--wash); }
.lane[data-ne] { background: var(--hatch); }
.lane[data-on][data-zone="liq"] { background: var(--zone-liq); }
.lane[data-on][data-zone="sl"] { background: var(--zone-slide); }
.lane[data-on][data-zone="ap"] { background: var(--zone-ap); }
.slot .num { position: absolute; bottom: 0; }
.slot .num.first { left: 0; }
.slot .num.last { right: 0; }
.slot .num.first.last { right: auto; }

/* ---------- years strip ---------- */
.years { display: flex; gap: var(--s-3); }
.years .roof { position: relative; height: var(--roof); }
.years-plot { position: relative; flex: 1; min-width: 0; }
.ybar {
  position: absolute; bottom: 0; display: block; height: var(--y);
  width: max(4px, calc(100% / var(--span) - 1px)); background: var(--c);
}
.ybar.none { left: 0; width: 10px; background: var(--era-none); }
.ybar[data-lit] { z-index: 1; outline: 1px solid var(--ink); outline-offset: 1px; }
.ybar[data-selected] { z-index: 2; outline: 2px solid var(--ink); outline-offset: 1px; }
.rule { position: absolute; bottom: 0; width: 1px; height: var(--plot); background: color-mix(in srgb, var(--ink) 35%, transparent); }
.rule-label { position: absolute; bottom: calc(100% + var(--s-1)); left: 0; transform: translateX(-50%); color: var(--ink); }
.era-band { position: relative; height: 4px; margin-top: 2px; }
.era-band i { position: absolute; top: 0; height: 100%; }
.decades { position: relative; height: 14px; margin-top: var(--s-1); }
.decades span { position: absolute; top: 0; transform: translateX(-50%); }
.years-none { flex: none; width: 36px; }
.years-none .axis { display: block; margin-top: 10px; }
.years .rule-label { z-index: 3; }

/* A narrow stage (the 821-1099px rail) puts the receipts in a row of three under the strips. */
@container (max-width: 760px) {
  .panel-body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s-5) var(--s-5); }
  .receipts { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); }
}

/* ---------- phone: the drawer is a block in the page flow ---------- */
@media (max-width: 820px), (max-height: 520px) {
  /* The title, the receipts and the By address strip fit under a 44svh map: a shorter roof,
     and the oldest and the newest side by side under the selected building. */
  .block-panel { --roof: 120px; }
  .block-panel, .card-panel { padding: var(--s-4) var(--gutter) var(--s-5); }
  .panel-head { margin-bottom: var(--s-3); }
  .panel-body { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .receipts { grid-column: auto; grid-row: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); }
  /* The selected building takes the row; so does the one receipt left when it is also the
     oldest or the newest. */
  .receipts > [data-selected], .receipts > [data-selected] + :last-child { grid-column: 1 / -1; }
  /* An address too long for its column goes under the year whole and in line with it: the
     swatch hangs in the margin the second lines keep. */
  .receipt-main { flex-wrap: wrap; row-gap: 0; padding-left: calc(10px + var(--s-2)); }
  .receipt-main .swatch { margin-left: calc(-10px - var(--s-2)); }
  .receipt-ground { font-size: var(--t-14); }
  .panel-close { width: 44px; height: 44px; margin: -12px -12px 0 0; }
  /* The row scrolls sideways under a finger-sized slot. */
  .slot { width: clamp(28px, calc(100% / var(--n)), 44px); }
  /* An address, a term and the legend stay lines of text; their touch targets reach past
     them to 44px. */
  button.receipt-addr, .receipt-link a { position: relative; }
  button.receipt-addr::after, .receipt a::after, .panel-legend::after { content: ""; position: absolute; inset: -12px 0; }
}

/* ---------- search dropdown rows (#q-list, the search agent's) ---------- */
#q-list { overflow: hidden auto; max-height: min(320px, 60svh); }
#q-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 40px; padding: 0 var(--s-3); cursor: pointer;
}
#q-list li.active { background: var(--wash); }
#q-list li.q-none { color: var(--ink-2); cursor: default; }
.q-place { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-city { color: var(--ink-2); }
.q-year { display: flex; flex: none; align-items: center; gap: 6px; font-size: var(--t-12); color: var(--ink-2); }
@media (max-width: 820px), (max-height: 520px) {
  #q-list li { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel-close { transition: none; }
}
