/*
  App-specific styles only.
  Load order: vendor/marinos/marinos.css, then this file.

  The shell bundles the shared Marin UI/Pico baseline and shell components.
  Use the components and tokens provided by the pinned shell before adding CSS.
  Scope new rules to the application's workflow or its own class prefix.
  Do not override shell-owned header, banner, footer, or information-section
  layout here. Shared fixes belong upstream in marin-app-shell (or marin-ui),
  followed by a reviewed shell release, not an edit to vendor/marinos/.
*/

/* The filter column (layout, Filters button, search, date range and filter groups) is drawn by the shell from
   filters.json. Only the card checkboxes are the app's own. */
/* Checkboxes are 24 px square (WCAG 2.5.8 target size), larger than Pico's default of about 18 px. */
.mm-card__select input[type="checkbox"],
.mm-select-all input[type="checkbox"] {
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
}

/* The tab row (.tab-list) and its buttons (.tab-button) come from the shell. */
#view-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mm-results-summary {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.mm-results-summary p {
  margin: 0;
}

#active-filters {
  font-weight: 700;
}

.mm-copy-fallback {
  margin: 0 0 1rem;
}

.mm-copy-fallback textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.8125rem;
}

.mm-select-all {
  margin: 0 0 0.5rem;
}

.mm-select-all label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9375rem;
  color: var(--app-muted);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-results-list > .app-card {
  margin-bottom: 0;
  list-style: none;
}

/* Result cards: checkbox column plus body, as in marin-mentions. */
.mm-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0;
}

.mm-card__select {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
}

.mm-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.mm-card__title {
  margin: 0 0 0.5rem;
}

.mm-card__title.is-canceled,
[data-status="canceled"] .reach-cal-label {
  text-decoration: line-through;
}

.reach-record__meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.15rem 1rem;
  margin: 0;
  font-size: 0.9375rem;
}

.reach-record__meta dt {
  color: var(--app-muted);
}

.reach-record__meta dd {
  margin: 0;
}

.mm-card .app-badge {
  font-weight: 400;
}

/* Calendar */
.reach-cal-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.reach-cal-controls {
  align-items: center;
}

.reach-cal-controls button {
  width: auto;
  margin: 0;
}

.reach-cal-nav button {
  min-width: 2.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.reach-cal-controls select.reach-cal-range {
  width: auto;
  margin: 0;
}

/* Day range is a list on every screen size. */
#panel-calendar[data-range="day"] .reach-cal {
  display: none;
}

#panel-calendar[data-range="day"] .reach-agenda {
  display: block;
}

#panel-calendar[data-range="week"] .reach-cal td {
  height: 9rem;
}

.reach-cal-title {
  margin: 0.75rem 0 0.5rem;
}

#cal-status {
  margin: -0.5rem 0 0.5rem;
}

#cal-status:empty {
  display: none;
}

.reach-cal {
  table-layout: fixed;
  width: 100%;
}

.reach-cal th,
.reach-cal td {
  border: 1px solid var(--app-border);
  vertical-align: top;
  padding: 0.25rem;
}

.reach-cal td {
  height: 6.5rem;
}

.reach-cal td.is-outside {
  background: var(--app-bg-soft);
}

.reach-cal-day {
  display: block;
  font-size: 0.8rem;
  color: var(--app-muted);
}

.reach-cal-day[aria-current="date"] {
  display: inline-block;
  padding: 0 0.4rem;
  border: 2px solid var(--app-text);
  border-radius: 999px;
  font-weight: 700;
  color: var(--app-text);
}

.reach-cal-events,
.reach-agenda__events {
  margin: 0;
  padding: 0;
  list-style: none;
}

.reach-cal-events li,
.reach-agenda__events li {
  margin: 0 0 0.25rem;
  padding: 0;
  list-style: none;
}

.reach-cal-event {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.15rem 0.35rem;
  background: var(--app-surface);
  color: var(--app-text);
  border: 2px solid var(--app-brand);
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: left;
}

.reach-cal-event[data-status="planned"] {
  border-style: dashed;
}

.reach-cal-event[data-status="canceled"] {
  border-style: dotted;
  color: var(--app-muted);
}

.reach-cal-time {
  font-weight: 700;
  margin-right: 0.25rem;
}

.reach-agenda {
  display: none;
}

.reach-agenda h4 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}

.reach-agenda .reach-cal-event {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

/* Stats: KPI row and chart cards, same as marin-mentions. */
.mm-stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 1rem 0;
}

.mm-stats-grid canvas {
  max-height: 320px;
}

.mm-chart-download {
  display: flex;
  margin: 0.75rem auto 0;
}

.mm-stats-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.mm-stats-kpi {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-surface);
}

.mm-stats-kpi p {
  margin: 0;
}

.mm-stats-kpi__value {
  margin: 0.25rem 0 0;
  font-family: var(--app-font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--app-text);
}

/* Pico makes <dialog> a full-screen flex overlay; the panel holds the card with Close below it. */
.reach-dialog__panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.reach-dialog__panel > div {
  width: 100%;
}

.reach-dialog__panel .app-card {
  margin: 0;
}

.reach-dialog__actions {
  display: flex;
  gap: 0.5rem;
}

.reach-dialog__actions button {
  width: auto;
  margin: 0;
}

.reach-dialog__panel > p {
  margin: 0;
}

.mm-card__copy-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.mm-card__copy-status {
  margin: 0;
}

@media (max-width: 850px) {
  /* The stacked layout and the Filters button are Marin UI's (.search-layout, .filter-toggle); this is the app's panel look. */
  .search-sidebar {
    padding: 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--pico-border-radius);
    background: var(--app-surface);
  }

  /* A month grid is not practical this narrow: use the agenda instead. */
  .reach-cal {
    display: none;
  }

  .reach-agenda {
    display: block;
  }
}

@media (max-width: 480px) {
  .mm-card {
    flex-direction: column;
  }

  .mm-card__select {
    align-self: flex-start;
  }

  .reach-record__meta {
    grid-template-columns: 1fr;
  }
}

/* Map view. The pin uses the Marin blue token; every pin looks the same, and meaning is never carried by color. */
.reach-map {
  height: clamp(18rem, 60vw, 32rem);
  width: 100%;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-bg-soft);
}

.reach-pin svg {
  width: 36px;
  height: 36px;
  fill: var(--marin-blue);
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.reach-pin svg circle {
  fill: #ffffff;
  stroke: none;
}

.reach-pin.is-selected svg {
  width: 44px;
  height: 44px;
  margin: -4px 0 0 -4px;
}

.leaflet-marker-icon.reach-pin:focus-visible,
.leaflet-marker-icon.reach-cluster:focus-visible {
  /* The tiles are always light, so the ring is black with a white edge in both color schemes. */
  outline: 3px solid #000000;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #ffffff;
  border-radius: 50%;
}

.reach-map-selection {
  margin-top: 1rem;
}

.reach-map-events {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.reach-map-events > li {
  list-style: none;
  margin-bottom: 1rem;
}

/* Pico styles every [role="button"] as a filled button; Leaflet's markers and zoom controls need to stay plain. */
.reach-map .leaflet-marker-icon[role="button"] {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin-right: 0;
  margin-bottom: 0;
  color: inherit;
}

.reach-map .leaflet-bar a[role="button"] {
  display: block;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #ccc;
  border-radius: 0;
  background: #ffffff;
  color: #000000;
  line-height: 30px;
  text-align: center;
  box-shadow: none;
}

.reach-map .leaflet-bar a[role="button"]:hover,
.reach-map .leaflet-bar a[role="button"]:focus {
  background: #f4f4f4;
}

.reach-map .leaflet-bar a[role="button"]:focus-visible {
  outline: 3px solid #000000;
  outline-offset: -3px;
}

.reach-map .leaflet-bar a[role="button"]:last-child {
  border-bottom: 0;
}

.reach-map .leaflet-bar a[role="button"]:focus-visible {
  box-shadow: none;
}

/* The shell's Feedback button covers the map's corner. Same pattern as the shell uses over the footer: it is
   hidden, but appears when it receives keyboard focus, so it stays reachable. */
body[data-view="map"] .app-feedback:not(:focus) {
  opacity: 0;
  pointer-events: none;
}

.reach-map-selection h3 {
  margin-bottom: 0.25rem;
}

.reach-map-line {
  margin: 0;
}

.reach-map-count {
  margin: 1rem 0 0;
}


.reach-map-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.reach-map-actions > button,
.reach-map-actions > a {
  width: auto;
  margin: 0;
}

.reach-map-places {
  margin-top: 1.25rem;
}

.reach-map-places label {
  font-weight: 700;
}

.reach-map-places select {
  max-width: 28rem;
  margin: 0.25rem 0 0;
}

/* A cluster of nearby markers: one look, the count as text, white on Marin blue (4.6:1). */
.reach-map .leaflet-marker-icon.reach-cluster[role="button"] {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--marin-blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  color: #ffffff;
}

.reach-cluster__count {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.reach-fw-enter[hidden],
.reach-fw-exit[hidden] {
  display: none;
}

/* The full window view: Pico already makes <dialog> a viewport-sized overlay; the panel fills it and scrolls. */
.reach-map-dialog__panel {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 1rem;
  background: var(--app-bg);
  color: var(--app-text);
}

.reach-map-dialog__panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.reach-map-dialog .reach-map {
  height: max(18rem, calc(100dvh - 11rem));
}

/* Pico turns a link with role="button" into a block; the directions link needs the same centered layout as the Copy button. */
a.copy-button.directions-button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

a.copy-button.directions-button svg {
  display: block;
}
