/* rail.css: owned by the rail agent. Everything inside #rail-body and the rows of #q-list. Tokens and the frame live in app.css
   (docs/site-modules.md). */

/* ===================== rail agent: #rail-body ===================== */

.rail-section { position: relative; }
/* A heading with its one control at the end of the line. */
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin: var(--s-6) 0 var(--s-3); }
.rail-head h2 { margin: 0; }

/* A chart is a positioned box so its tooltip (tip.js) places itself inside it. */
.chart { position: relative; margin: 0; }
.chart .tip { width: max-content; max-width: 260px; }
.rail-tip-counts { grid-template-columns: auto auto auto; }
.rail-tip-counts .swatch[data-zone="liq"] { background: var(--zone-liq-tint); }
.rail-tip-counts .swatch[data-zone="sl"] { background: var(--zone-slide-tint); }
.rail-tip-counts .swatch[data-zone="ap"] { background: var(--zone-ap-tint); outline: 1px dashed var(--zone-ap-line); outline-offset: -1px; }

/* One zone share: the zone's color under the number, stronger the larger the share. */
.zc { position: relative; z-index: 0; font-size: var(--t-12); line-height: 20px; text-align: center; color: var(--ink); }
.zc::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: var(--a, 0.2); }
.zc[data-zone="liq"]::before { background: var(--zone-liq); }
.zc[data-zone="sl"]::before { background: var(--zone-slide); }
.zc[data-zone="ap"]::before { background: var(--zone-ap); }
.zc[data-zone="ne"]::before { background: var(--hatch); opacity: 0.7; }
/* No liquefaction or landslide map for part of a place: the hatch over the share. */
.zc[data-ne]::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--hatch); opacity: var(--ne); }
.zc > span { padding: 0 3px; border-radius: var(--radius); }
.zc[data-zone="ne"] > span, .zc[data-ne] > span { background: rgb(241 242 246 / 0.88); }

/* ---------- By era: columns standing on the ground, zone rows under them ---------- */
.era-grid {
  display: grid; column-gap: 2px; row-gap: 2px; align-items: end;
  grid-template-columns: 84px repeat(5, minmax(0, 1fr)) 8px 28px;
}
.era-col { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: calc(120px + 16px); }
.era-count { display: block; margin-bottom: var(--s-1); text-align: center; color: var(--ink-2); white-space: nowrap; }
.era-bar { display: block; border-radius: var(--radius) var(--radius) 0 0; }
.era-bar[data-light] { box-shadow: inset 0 0 0 1px var(--edge); }
/* The ground line: one 1px ink rule under every column, no gap at the joints. */
.era-axis { position: relative; align-self: start; height: 20px; margin: -2px -1px 4px; border-top: 1px solid var(--ink); color: var(--ink-2); }
.era-axis:last-of-type { margin-right: 0; }
.era-tick { position: absolute; top: 4px; right: 0; transform: translateX(50%); }
.era-none-label { position: absolute; top: 4px; right: 0; white-space: nowrap; }
/* Two lines at most, so a cell reads with its column: the era, the share, the row's words. */
.era-row-label { align-self: center; padding-right: var(--s-1); color: var(--ink-2); }
.era-grid .zc { line-height: 28px; }
.era-tip { max-width: 30ch; }
.era-tip b { font-weight: 700; }

/* ---------- By place ---------- */
.place-table { width: 100%; border-collapse: separate; border-spacing: 0 2px; table-layout: fixed; }
.place-table col.c-n { width: 60px; }
.place-table col.c-z { width: 60px; }
.place-table thead th { padding: 0 0 var(--s-1); font-weight: 600; color: var(--ink); text-align: center; vertical-align: bottom; white-space: nowrap; }
.place-table thead th:first-child { text-align: left; }
.place-table thead th:nth-child(2) { padding-right: var(--s-2); text-align: right; }
/* Each header is the control that sorts by it; the sorted one carries a small triangle. */
.sort {
  position: relative; max-width: 100%; min-height: 24px; padding: 0; border: 0; border-radius: 0;
  font: inherit; font-weight: inherit; text-align: inherit; cursor: pointer;
}
.sort:hover { text-decoration: underline; text-underline-offset: 2px; }
th[aria-sort] .sort::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -3px;
  border: 3px solid transparent; border-top: 4px solid currentColor; border-bottom: 0;
}
th[aria-sort="ascending"] .sort::after { border-top: 0; border-bottom: 4px solid currentColor; }
.place-table thead th:first-child .sort::after { left: 3px; }
.place-table th, .place-table td { height: 28px; padding: 0; }
.place-table tbody th { padding-right: var(--s-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; text-align: left; }
.place-table .place-n { padding-right: var(--s-2); text-align: right; color: var(--ink-2); font-size: var(--t-12); }
.place-table td.zc { line-height: 28px; border-left: 2px solid var(--ground); }
.place-more { flex: none; min-height: 32px; padding: 0 var(--s-3); border-color: var(--ink); color: var(--ink); }
.place-more:hover { background: var(--wash); }

/* ---------- Milestones ---------- */
.milestones { margin: 0; padding: 0; list-style: none; }
.milestones li { display: grid; grid-template-columns: 64px minmax(0, 1fr); padding: var(--s-3) 0; border-top: 1px solid var(--rule); }
.milestones li:first-child { border-top: 0; padding-top: 0; }
.milestone-year { display: block; padding-top: 1px; }
/* The era that ends in the milestone's year and the one after it, joined edge to edge. */
.era-pair { display: flex; width: 40px; margin-top: var(--s-2); outline: 1px solid var(--edge); outline-offset: -1px; }
.era-pair i { flex: 1; height: 8px; }
.milestones h3 { margin: 0; font-size: var(--t-14); font-weight: 600; line-height: 1.2; }
.milestones p { margin: var(--s-1) 0 var(--s-1); text-wrap: pretty; max-width: 65ch; }
.milestones a { color: var(--ink-2); }

/* ---------- footer ---------- */
/* Top and bottom only: on the phone the side margins are the page gutter (app.css). */
.rail-foot { display: flex; gap: var(--s-3); margin-top: var(--s-6); margin-bottom: 0; color: var(--ink-3); }
.rail-foot a { color: var(--ink); font-weight: 600; }

/* Phone: 44px targets from padding, not bigger type. */
@media (max-width: 820px), (max-height: 520px) {
  .place-more { min-height: 44px; }
  .sort::before { content: ""; position: absolute; inset: -10px 0; } /* a 24px header, a 44px target */
  .milestones a, .rail-foot a { display: inline-block; padding: 14px 0; margin: -14px 0; }
}

/* ===================== end rail agent ===================== */
