/* Palette inspired by Tracksmith: navy, ivory and gold, with varsity forest/crimson
   for coverage. app.js reads the map colours from these same variables. */
:root {
  --bg: #F1ECE2;          /* oatmeal */
  --panel: #F7F4EE;       /* ivory */
  --panel-alt: #FBF9F4;   /* header, search and status bar */
  --ink: #0A1E32;         /* navy */
  --muted: #5C6469;       /* slate */
  --line: #E2DCD0;        /* warm mist */
  --line-soft: #ECE7DD;
  --field: #FBF9F4;
  --gold: #9A825C;
  --gold-tint: #EFE6D2;
  --stone: #8C9196;       /* Kreis lines */
  --veil: #F4F0E9;        /* fade outside the city */
  --explored: #2E5E4E;    /* forest */
  --unexplored: #B23A3A;  /* crimson */
  --blocked: #C0812C;     /* amber, dashed on the map: cannot be walked for now (not counted) */
  --selected: #9A825C;    /* gold */
  --edited: #3B5B8C;      /* blue: a change waiting for Accept */
  --edited-tint: #E3EAF4;
  --shadow: 0 14px 34px rgba(10, 30, 50, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 10px;
  height: 100vh;
  padding: 10px;
}

.map-surface,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-surface {
  position: relative;
  min-width: 0;
}

/* Discreet link over the map's top-left corner (above Leaflet's panes). */
.map-about {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  border: 0;
  border-radius: 4px;
  padding: 3px 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  cursor: pointer;
}

.map-about:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.side-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
}

.coverage-text {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line-soft);
}

.segment {
  min-width: 0;
  height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 650;
}

.segment.active {
  color: var(--panel);
  background: var(--ink);
  box-shadow: 0 2px 8px rgba(10, 30, 50, 0.18);
}

.select-wrap {
  margin-top: 10px;
}

/* Safari draws native selects in system style; reset it to match the other fields. */
.select-field {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  font-size: 0.92rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239A825C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* "StepMap" on the left, the Statistics / Explore toggle on the right. */
.eyebrow-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 7px;
}

.eyebrow-row .eyebrow {
  margin: 0;
}

.panel-view {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.panel-header .segmented-control {
  margin-top: 10px;
}

.field {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--field);
  outline: none;
}

.field:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(154, 130, 92, 0.25);
}

.search-wrap {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
}

.feature-list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.feature-row,
.empty-row {
  min-height: 40px;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 14px;
}

.feature-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
}

.feature-row:hover {
  background: var(--panel-alt);
}

.feature-row.active {
  background: var(--gold-tint);
}

.coverage-dot {
  width: 9px;
  height: 22px;
  border-radius: 999px;
  background: var(--stone);
}

.feature-row.explored .coverage-dot {
  background: var(--explored);
}

.feature-row.unexplored .coverage-dot {
  background: var(--unexplored);
}

/* Striped like a barrier, to match the dashed line on the map. */
.feature-row.blocked .coverage-dot {
  background: repeating-linear-gradient(180deg, var(--blocked) 0 4px, transparent 4px 7px);
}

/* Name on the left, length right-aligned on the same line. */
.feature-text {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.feature-text strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.94rem;
  line-height: 1.25;
}

.feature-text small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.empty-row {
  color: var(--muted);
}

.status-bar {
  min-height: 38px;
  border-top: 1px solid var(--line);
  padding: 6px 14px;
  color: var(--muted);
  background: var(--panel-alt);
  font-size: 0.82rem;
}

/* !important: must win over components that set their own display (e.g. .add-form). */
.hidden {
  display: none !important;
}

/* Round tick on each list row: filled forest when done, empty ring when not. */
.done-toggle {
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  padding: 0;
  color: transparent;
  background: var(--field);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.done-toggle:hover {
  border-color: var(--explored);
  color: var(--explored);
}

.done-toggle.on {
  border-color: var(--explored);
  color: var(--panel);
  background: var(--explored);
}

/* "!" next to the tick: filled amber when the street is blocked. */
.blocked-toggle {
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  padding: 0;
  color: var(--muted);
  background: var(--field);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.blocked-toggle:hover {
  border-color: var(--blocked);
  color: var(--blocked);
}

.blocked-toggle.on {
  border-color: var(--blocked);
  color: var(--panel);
  background: var(--blocked);
}

.text-button {
  border: 0;
  padding: 4px 2px;
  color: var(--gold);
  background: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
}

.text-button:hover {
  color: var(--ink);
}

/* Small gold-outlined pill. */
.pill-button {
  flex: 0 0 auto;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--ink);
  background: var(--gold-tint);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 650;
}

.pill-button:hover {
  color: var(--panel);
  background: var(--ink);
  border-color: var(--ink);
}

.primary-button {
  height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--panel);
  background: var(--ink);
  cursor: pointer;
  font-weight: 650;
}

.edit-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.edit-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-dialog::backdrop {
  background: rgba(10, 30, 50, 0.25);
}

.edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edit-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.add-form {
  display: flex;
  align-items: center;
  gap: 8px;
}


.about-text {
  overflow: auto;  /* the dialog has a max height; long text scrolls */
}

.about-text p {
  margin: 0 0 8px;
  line-height: 1.45;
}

.edit-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}


.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.remove-toggle {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: var(--muted);
  background: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.remove-toggle:hover {
  color: var(--unexplored);
}

/* Pending (not yet accepted) changes. */
.feature-row.pending,
.feature-row.pending:hover {
  background: var(--edited-tint);
  box-shadow: inset 3px 0 0 var(--edited);
}

.feature-row.pending .feature-text strong {
  color: var(--edited);
}

.feature-row.removed .feature-text strong {
  text-decoration: line-through;
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-bar .add-form {
  margin: 4px 0 8px;
}

.confirm-list {
  max-height: 50vh;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: auto;
  list-style: none;
  background: var(--field);
}

.confirm-list li {
  border-bottom: 1px solid var(--line-soft);
  padding: 7px 10px;
  font-size: 0.9rem;
}

.confirm-list li span {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}




/* ---- Statistics view ---- */
.stats-view {
  overflow: auto;
}

.stat-section {
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 16px;
}

.stat-badge {
  display: inline-block;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.stat-badge.done {
  border-color: var(--explored);
  color: var(--explored);
}

.stat-meter {
  margin-bottom: 14px;
}

.stat-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

.stat-meter-head strong {
  font-size: 1.35rem;
  font-weight: 600;
}

.stat-meter small,
.stat-note,
.stat-fact small {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-meter small {
  display: block;
  margin-top: 5px;
}

/* Thin bar: forest fill on a mist track. */
.meter {
  display: block;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--explored);
}

.stat-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-fact {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--field);
}

.stat-fact strong {
  display: block;
  margin-top: 2px;
  font-size: 1.05rem;
  font-weight: 600;
}

.stat-note {
  margin: -4px 0 8px;
}

/* Leaflet sets its own font on the map (popups, attribution): use the page's. */
.leaflet-container {
  font-family: inherit;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .map-surface {
    height: 58vh;
  }

  .side-panel {
    min-height: 42vh;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 6px;
  }

  .panel-header {
    padding: 14px;
  }

  .segment {
    font-size: 0.78rem;
  }
}
