:root {
    --bg: #fbfaf7;
    --surface: #ffffff;
    --text: #1d2420;
    --muted: #5f6b64;
    --line: #dfe3dd;
    --accent: #0b6b4f;
    --mark-quiet: #aab5ae; /* the other estates on a chart: present, not competing */
    /* Chart colours, checked for colour-blind separation and contrast against --surface. */
    --chart-commute: #0a8a5f;
    --chart-outage: #c2570c;
    --chart-rent: #3b6fd4;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141816;
        --surface: #1c221f;
        --text: #e8ece9;
        --muted: #9aa69f;
        --line: #2e3732;
        --accent: #5fd0a8;
        --mark-quiet: #56635c;
        --chart-commute: #27a577;
        --chart-outage: #cf7f1c;
        --chart-rent: #5b8def;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.site-header,
main,
.site-footer {
    max-width: 60rem;
    margin: 0 auto;
    padding: 1rem;
}

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    color: var(--text);
}

nav { display: flex; gap: 1.25rem; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 1rem 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.5rem; }

.lede, .breadcrumb, .site-footer { color: var(--muted); }
.breadcrumb { margin: 1rem 0 0; font-size: 0.9rem; }
.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
tbody th { font-weight: 600; }

.facts {
    margin: 1rem 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    padding: 0.25rem 1rem;
}
.facts dt { color: var(--muted); font-size: 0.85rem; margin-top: 0.75rem; }
.facts dd { margin: 0 0 0.75rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.facts dd:last-child { border-bottom: 0; }
.facts .pending { font-weight: 400; font-style: italic; color: var(--muted); }
.facts .detail { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); }

.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }

.compare-form { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin: 1rem 0; }
.compare-form label { display: grid; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }

select, button {
    font: inherit;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    background: var(--surface);
    color: var(--text);
}
button { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; cursor: pointer; }

.notice { color: var(--muted); }

/* Charts. One hue per measure (commute times, outages); everything else is quiet.
   Text on a chart always uses the text colours, never the bar colour. */
.chart { margin: 1.5rem 0 2rem; }
.chart-note { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tabs a {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
}
.tabs a[aria-current] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }

/* Ranked horizontal bars: a name, a bar from the shared baseline, the value at its tip. */
.bars { list-style: none; margin: 0.75rem 0; padding: 0.5rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 0.5rem; }
.bars li { display: grid; grid-template-columns: 11rem 1fr; align-items: center; gap: 0.75rem; padding: 0.3rem 0.25rem; border-radius: 0.25rem; }
.bars li:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.bar-cell { display: flex; align-items: center; gap: 0.5rem; border-left: 1px solid var(--line); min-width: 0; }
.bar { flex: none; height: 12px; width: calc((100% - 4.5rem) * var(--v)); min-width: 2px; background: var(--chart-commute); border-radius: 0 4px 4px 0; }
.bars.outages .bar { background: var(--chart-outage); }
.bars.rents .bar { background: var(--chart-rent); }
.bars.rents .bar { width: calc((100% - 6rem) * var(--v)); }
.bar-value { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 34rem) {
    .bars li { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* Strip: every estate as a tick on one axis, this estate as the dot. */
.strip { display: block; position: relative; height: 28px; margin: 0.4rem 7px 0; border-bottom: 1px solid var(--line); }
.strip .tick, .strip .dot { position: absolute; left: calc(var(--v) * 100%); bottom: -1px; transform: translateX(-50%); }
.strip .tick { width: 12px; height: 20px; } /* wider than the mark, so it can be hit */
.strip .tick::before { content: ""; position: absolute; left: 5px; bottom: 0; width: 2px; height: 12px; background: var(--mark-quiet); border-radius: 1px; }
.strip .tick:hover::before, .strip .tick:focus-visible::before { background: var(--text); height: 16px; }
.strip .tick:focus-visible { outline: none; }
.strip .dot { width: 12px; height: 12px; bottom: -7px; border-radius: 50%; background: var(--chart-commute); box-shadow: 0 0 0 2px var(--surface); }
.strip [data-tip]:hover::after, .strip [data-tip]:focus-visible::after,
.days [data-tip]:hover::after, .days [data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    background: var(--text);
    color: var(--bg);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1;
    pointer-events: none;
}
.strip-axis { display: flex; justify-content: space-between; margin: 0.5rem 7px 0.35rem; font-size: 0.7rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
td .pending { color: var(--muted); }

/* Day strip: one cell per day, the last 30 days then the week ahead. A filled cell is a day
   with a planned outage. */
.days { display: flex; gap: 2px; margin: 0.5rem 0 0; }
.days .day { position: relative; flex: 1 1 0; height: 16px; min-width: 3px; border-radius: 2px; background: var(--line); }
.days .day.ahead { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.days .day.out { background: var(--chart-outage); box-shadow: none; }
.days .day.out.ahead { background: repeating-linear-gradient(135deg, var(--chart-outage) 0 3px, transparent 3px 5px); box-shadow: inset 0 0 0 1px var(--chart-outage); }
.days .day.today { margin-right: 4px; }
.days .day.today::before { content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 2px; background: var(--text); border-radius: 1px; }
.days .day.out:hover, .days .day.out:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.days-axis { margin-left: 0; margin-right: 0; }
