/* The server-rendered screens: the shell, and the component vocabulary they are
 * assembled from.
 *
 * Milestone 7 builds the first four of the eight components named in the PRD --
 * the stat, the table, the pill and the timeline -- plus the empty state, which
 * this platform leans on constantly because it refuses to show thin numbers.
 * A ninth component gets added only when a real need cannot be met by the eight.
 *
 * No gradients, no shadows for depth's own sake, no rounded-corner-and-accent-bar
 * card treatment. Structure appears only where it reflects something true about
 * the content.
 */

/* --- base ---------------------------------------------------------------- */

html {
  background-color: var(--page);
  color: var(--ink-body);
  font-family: var(--font-sans);
  font-size: 106.25%; /* 17px base, matching the React half */
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--page);
  color: var(--ink-body);
  line-height: 1.6;
  margin: 0;
}

h1, h2, h3 {
  color: var(--ink-display);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.95rem; }

a {
  color: var(--accent-display);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

/* Visible keyboard focus on everything interactive, in both themes. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --- shell --------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

/* Fixed sidebar that does not move between screens. */
.sidebar {
  background-color: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 2px;
  padding: 1rem 0.75rem;
  width: 210px;
}

.sidebar__brand {
  color: var(--ink-display);
  font-family: var(--font-display);
  font-weight: 600;
  padding: 0.25rem 0.6rem 1rem;
}

.sidebar__link {
  border-radius: var(--radius);
  color: var(--ink-body);
  display: block;
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
}

.sidebar__link:hover { background-color: var(--page); text-decoration: none; }

.sidebar__link--current {
  background-color: var(--accent-faded);
  color: var(--accent-display);
  font-weight: 500;
}

.sidebar__footer { margin-top: auto; padding: 0.6rem; }

.main { flex: 1; min-width: 0; padding: 2rem 2.5rem; }
.main__inner { margin: 0 auto; max-width: 60rem; }

.page-header { margin-bottom: 1.5rem; }
.page-header p { color: var(--ink-muted); margin: 0.35rem 0 0; }

.section { margin-top: 2.25rem; }
.section__head {
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
}

.section__head p { color: var(--ink-muted); font-size: 0.85rem; margin: 0; }

/* --- the stat ------------------------------------------------------------ */
/* A number, its label, its sample size, and its change against the comparison
   period. Four things, always in that order. */

.stats {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  background-color: var(--hairline);
  border: 1px solid var(--hairline);
}

.stat { background-color: var(--page); padding: 0.85rem 1rem; }

.stat__value {
  color: var(--ink-display);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.1;
}

.stat__label {
  color: var(--ink-body);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* A metric rendered without its n is a design bug, not just an omission. */
.stat__sample, .stat__change {
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.stat__change { display: block; margin-top: 0.15rem; }

/* --- the table ----------------------------------------------------------- */
/* Dense, tabular numerals, thin rules, no striping. Status appears as a text
   pill, never as a colour on the row. */

.table-scroll { overflow-x: auto; }

.table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
}

.table th {
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-muted);
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}

.table td {
  border-bottom: 1px solid var(--hairline);
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

.table tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table__muted { color: var(--ink-muted); }

/* --- the pill ------------------------------------------------------------ */
/* Text with a thin outline in semantic colour. Always readable as words
   without the colour. */

.pill {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.05rem 0.45rem;
  white-space: nowrap;
}

.pill--neutral { color: var(--ink-muted); }
.pill--good { color: var(--good); }
.pill--caution { color: var(--caution); }
.pill--broken { color: var(--broken); }
.pill--accent { color: var(--accent-display); }

.pills { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }

/* --- the timeline -------------------------------------------------------- */
/* Dated events running down the page. One component, three uses: a listing's
   price and status history, a property's listings across the years, and a
   source's recent runs. */

.timeline { border-left: 1px solid var(--hairline); list-style: none; margin: 0; padding: 0; }

.timeline__entry { padding: 0 0 1.1rem 1.1rem; position: relative; }
.timeline__entry:last-child { padding-bottom: 0; }

.timeline__entry::before {
  background-color: var(--hairline);
  border-radius: 50%;
  content: "";
  height: 7px;
  left: -4px;
  position: absolute;
  top: 0.5rem;
  width: 7px;
}

.timeline__entry--major::before { background-color: var(--accent); }

.timeline__date {
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.timeline__title { color: var(--ink-display); font-weight: 500; }
.timeline__detail { color: var(--ink-muted); font-size: 0.85rem; }

.timeline__nested { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.timeline__nested li {
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* --- the empty state ----------------------------------------------------- */
/* One sentence saying why there is nothing here and what would change that.
   Load-bearing, because this platform refuses thin numbers by design. */

.empty {
  border: 1px dashed var(--hairline);
  color: var(--ink-muted);
  font-size: 0.9rem;
  padding: 1.25rem;
}

/* --- forms and buttons --------------------------------------------------- */
/* Controls say exactly what happens. No apologies, no vague failure toasts. */

.field { display: flex; gap: 0.5rem; }

.input {
  background-color: var(--page);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink-body);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  width: 100%;
}

.input::placeholder { color: var(--ink-muted); }

.button {
  background-color: var(--accent-display);
  border: 1px solid var(--accent-display);
  border-radius: var(--radius);
  color: var(--page);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
}

.button:hover { text-decoration: none; }

.button--quiet {
  background-color: transparent;
  border-color: var(--hairline);
  color: var(--ink-body);
}

.button-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* --- the banner ---------------------------------------------------------- */
/* Staleness and failure. One per screen, at the top, and it clears when the
   condition clears rather than when the reader dismisses it. */

.banner {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  padding: 0.6rem 0.9rem;
}

.banner--good { background-color: var(--good-faded); border-left-color: var(--good); }
.banner--caution { background-color: var(--caution-faded); border-left-color: var(--caution); }
.banner--broken { background-color: var(--broken-faded); border-left-color: var(--broken); }

/* --- small ------------------------------------------------------------- */

.muted { color: var(--ink-muted); }
.num { font-variant-numeric: tabular-nums; }
.prose { max-width: 34rem; }

.panel {
  background-color: var(--surface);
  border: 1px solid var(--hairline);
  padding: 0.9rem 1.1rem;
}

.review-pair {
  border: 1px solid var(--hairline);
  display: grid;
  gap: 1px;
  grid-template-columns: 1fr 1fr;
  background-color: var(--hairline);
  margin-bottom: 0.9rem;
}

.review-pair__side { background-color: var(--page); padding: 0.8rem 1rem; }
.review-pair__actions {
  background-color: var(--page);
  border-top: 1px solid var(--hairline);
  grid-column: 1 / -1;
  padding: 0.7rem 1rem;
}

@media (max-width: 44rem) {
  .sidebar { width: 62px; }
  .sidebar__brand, .sidebar__label { display: none; }
  .main { padding: 1.25rem; }
  .review-pair { grid-template-columns: 1fr; }
}

/* --- the map ------------------------------------------------------------- */
/* Full width, and tall enough to be worth looking at. A map in a small box is
   a picture of a map. */

.map {
  border: 1px solid var(--hairline);
  height: 26rem;
  width: 100%;
}

/* A drawing vertex. A styled div rather than Leaflet's default pin, so nothing
   depends on the library's marker images being on the asset path -- the usual
   way Leaflet breaks in a Rails app. */
.vertex {
  background-color: var(--page);
  border: 2px solid var(--accent-display);
  border-radius: 50%;
  cursor: move;
}

/* Leaflet paints its own controls and popups white. Without this they stay
   white in dark mode and read as holes punched in the page. */
.dark .leaflet-control-zoom a,
.dark .leaflet-control-attribution {
  background-color: var(--surface);
  color: var(--ink-body);
}

.dark .leaflet-control-zoom a { border-color: var(--hairline); }
