/*
 * Community page.
 *
 * The design handoff specifies exact px values (14.5px type, 11px padding, 1.5px
 * borders) that Tailwind's scale cannot express without a wall of arbitrary-value
 * brackets, so the page's components live here instead. Picked up automatically by
 * `stylesheet_link_tag :app`, which includes every file in this directory.
 *
 * Two rules from the handoff that are easy to undo by accident:
 *   - No shadows anywhere. Elevation is border + background value only.
 *   - No transitions. Hover states change instantly.
 * Secondary text is #666666, not #999999 — it has to clear WCAG AA (4.5:1) on the
 * cream ground.
 */

:root {
  --cm-ground: #FFF9D0;
  --cm-band: #F4EFD3;
  --cm-band-warm: #F6F1C9;
  --cm-card: #FFFCEB;
  --cm-surface: #FFFFFF;
  --cm-sage: #E8F0D0;
  --cm-sage-muted: #F1F5E4;
  --cm-ink: #222222;
  --cm-ink-muted: #666666;
  --cm-blue: #2DC1FF;
  --cm-blue-light: #96E0FF;
  --cm-blue-pill-border: #BEE9FF;
  --cm-blue-ink: #10333F;
  --cm-link: #0E6E9E;
  --cm-yellow: #F8F088;
  --cm-yellow-border: #E0D468;
  --cm-yellow-ink: #8A6206;
  --cm-orange: #F86028;
  --cm-border: #E2DCBC;
  --cm-border-band: #DCD5B4;
  --cm-border-sage: #CFD8B4;
  --cm-border-sage-soft: #DDE4C6;
  --cm-divider: #EDE7C8;
  --cm-divider-warm: #E6DFBE;
  --cm-dashed: #BCB28A;
  --cm-dashed-soft: #CFC7A4;
  --cm-chevron: #A89E76;
  --cm-sage-ink: #5C6647;
}

/* The layout's <body> is already this cream, and <main> supplies its own max-width
   and horizontal padding. The negative margins cancel that padding so .cm-container
   below controls the gutters — without them the page carries the layout's padding
   plus its own, which costs ~36px a side on a phone. */
.cm-page {
  background-color: var(--cm-ground);
  padding-bottom: 44px;
  margin-left: -1rem;
  margin-right: -1rem;
}

@media (min-width: 640px) {
  .cm-page { margin-left: -1.5rem; margin-right: -1.5rem; }
}

@media (min-width: 768px) {
  .cm-page { margin-left: -2rem; margin-right: -2rem; }
}

.cm-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Every interactive element gets the same ring — never the browser default. */
.cm-page :is(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid var(--cm-blue);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ heading row */

.cm-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 0;
}

.cm-heading__left {
  flex: 1;
  min-width: 260px;
}

.cm-heading__titlerow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cm-heading h1 {
  font-size: clamp(25px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.05;
  color: var(--cm-ink);
  margin: 0;
}

.cm-heading__sub {
  margin: 9px 0 0;
  max-width: 58ch;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--cm-ink-muted);
  text-wrap: pretty;
}

.cm-heading__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cm-iconchip {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.cm-iconchip--orange { background-color: var(--cm-orange); }
.cm-iconchip--yellow { background-color: var(--cm-yellow); }
.cm-iconchip--surface {
  background-color: var(--cm-surface);
  border: 1px solid var(--cm-border-band);
}
.cm-iconchip--surface-sage {
  background-color: var(--cm-surface);
  border: 1px solid var(--cm-border-sage);
}

/* Neighborhood selector */
.cm-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background-color: var(--cm-surface);
  border: 1.5px solid var(--cm-ink);
  cursor: pointer;
  max-width: 100%;
}

.cm-selector:hover { background-color: var(--cm-blue-light); }

.cm-selector__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cm-clear {
  padding: 10px 13px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--cm-dashed-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--cm-ink-muted);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.cm-clear:hover {
  color: var(--cm-ink);
  border-color: var(--cm-ink);
}

/* ------------------------------------------------------------------ quick pills */

.cm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 18px 0 0;
}

.cm-pill {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--cm-blue-pill-border);
  background: var(--cm-blue-light);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cm-blue-ink);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}

.cm-pill--active {
  border-color: var(--cm-ink);
  background: var(--cm-blue);
}

.cm-pill--ghost {
  border: 1px dashed var(--cm-dashed);
  background: transparent;
  color: var(--cm-ink-muted);
}

.cm-pill--ghost:hover {
  color: var(--cm-ink);
  border-color: var(--cm-ink);
}

/* ---------------------------------------------------------------------- panels */

.cm-panel {
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
}

.cm-panel--neighbors {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  padding: 18px 18px 20px;
  margin-top: 32px;
}

.cm-panel--listed {
  background: var(--cm-band-warm);
  border: 1px solid var(--cm-border-band);
}

.cm-panel--iso {
  background: var(--cm-sage);
  border: 1px solid var(--cm-border-sage);
}

.cm-panel--events {
  background: var(--cm-band);
  border: 1px solid var(--cm-border-band);
}

.cm-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.cm-panel__head--tight {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.cm-panel__title {
  flex: 1;
  min-width: 180px;
}

.cm-panel__title h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--cm-ink);
  margin: 0;
}

.cm-panel__title--column h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--cm-ink);
  margin: 0;
}

.cm-panel__subline {
  font-size: 13px;
  color: var(--cm-ink-muted);
  margin-top: 2px;
}

.cm-panel__scope {
  font-size: 12px;
  color: var(--cm-ink-muted);
  margin-left: auto;
  white-space: nowrap;
}

.cm-link {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cm-link);
  text-decoration: none;
  white-space: nowrap;
}

.cm-link:hover { color: #0A5477; text-decoration: underline; }

.cm-divider { height: 1px; margin: 16px 0 18px; background: var(--cm-divider); }
.cm-divider--band { height: 1px; margin: 14px 0 4px; background: var(--cm-border-band); }
.cm-divider--sage { height: 1px; margin: 14px 0; background: var(--cm-border-sage); }
.cm-divider--events { height: 1px; margin: 16px 0; background: var(--cm-border-band); }

/* ----------------------------------------------------------------------- tabs */

.cm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cm-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1.5px solid var(--cm-border);
  background: var(--cm-surface);
  color: var(--cm-ink);
  text-decoration: none;
  cursor: pointer;
}

.cm-tab--active {
  border-color: var(--cm-ink);
  background: var(--cm-ink);
  color: var(--cm-ground);
}

/* ------------------------------------------------------------- neighbor cards */

.cm-neighbors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

/* Photo-led and centred: this is a page about people, so the face leads and the
   name, neighbourhood and actions stack underneath it. */
.cm-neighbor {
  border: 1px solid var(--cm-border);
  border-radius: 14px;
  padding: 18px 14px 14px;
  background: var(--cm-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.cm-neighbor:hover { border-color: var(--cm-ink); }

.cm-neighbor__identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  text-decoration: none;
}

.cm-neighbor__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-ink);
  line-height: 1.25;
  width: 100%;
  /* Two lines, then ellipsis — long names are common and truncating them to one
     line loses more than it saves on a card this wide. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.cm-neighbor__hood {
  font-size: 11.5px;
  color: var(--cm-ink-muted);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* margin-top:auto keeps the buttons on a shared baseline no matter how the name
   above them wraps. Without it the rows go ragged. */
.cm-neighbor__actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: auto;
}

/* The follow button is a button_to, so its <form> is the flex child, not the
   button — the sizing has to live on the form. */
.cm-neighbor__actions .cm-follow-form {
  flex: 1;
  min-width: 0;
  display: flex;
}

.cm-follow {
  width: 100%;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  text-align: left;
  background: var(--cm-blue);
  border: 1.5px solid var(--cm-blue);
  color: var(--cm-blue-ink);
  font-weight: 700;
  cursor: pointer;
}

.cm-follow--following {
  background: var(--cm-ground);
  border-color: var(--cm-border);
  color: var(--cm-ink-muted);
  font-weight: 600;
}

.cm-wave {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cm-surface);
  border: 1.5px solid var(--cm-border);
  color: var(--cm-ink-muted);
  cursor: pointer;
  padding: 0;
}

.cm-wave--waved {
  background: var(--cm-yellow);
  border-color: var(--cm-yellow-border);
  color: var(--cm-yellow-ink);
}

.cm-neighbor__actions .cm-wave-form { flex: none; display: flex; }

/* ------------------------------------------------------------------- avatars */

.cm-avatar--circle { border-radius: 999px; }

.cm-avatar {
  border-radius: 9px;
  background: var(--cm-yellow);
  border: 1px solid var(--cm-yellow-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--cm-ink);
  text-transform: uppercase;
  flex: none;
  object-fit: cover;
  overflow: hidden;
}

/* Item thumbnail on a Just listed row. Square with the same 9px radius the avatars
   use, so swapping one for the other did not change the row rhythm. */
.cm-thumb {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  object-fit: cover;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border-band);
}

.cm-thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cm-band-warm);
}

/* --------------------------------------------------------------- empty states */

.cm-empty {
  border: 1px dashed var(--cm-dashed);
  border-radius: 12px;
  padding: 22px 18px;
}

.cm-empty__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-ink);
}

.cm-empty__body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--cm-ink-muted);
  max-width: 46ch;
  margin-top: 4px;
}

.cm-empty__action {
  display: inline-block;
  margin-top: 14px;
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--cm-ink);
  color: var(--cm-ground);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.cm-empty__action:hover { background: var(--cm-link); }

.cm-empty--inline {
  font-size: 13px;
  font-weight: 600;
  color: var(--cm-ink-muted);
  padding: 10px 0;
}

.cm-empty--sage { color: var(--cm-sage-ink); }

/* ------------------------------------------------------------------- two-column */

.cm-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

/* Just listed rows */
.cm-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 2px;
  text-decoration: none;
  min-width: 0;
}

.cm-row + .cm-row { border-top: 1px solid var(--cm-divider-warm); }

.cm-row__title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cm-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cm-row__meta {
  font-size: 11.5px;
  color: var(--cm-ink-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cm-showmore {
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border-band);
  font-size: 13px;
  font-weight: 700;
  color: var(--cm-ink);
  text-align: left;
  cursor: pointer;
}

.cm-showmore:hover { background: var(--cm-blue-light); }

/* Same control on the sage panel, where the cream border would look off. */
.cm-showmore--sage { border-color: var(--cm-border-sage); }

/* ISO cards */
.cm-iso-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cm-iso {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border-sage-soft);
  border-radius: 12px;
  padding: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  align-items: flex-start;
}

.cm-iso__body {
  flex: 1;
  min-width: 150px;
}

.cm-iso__text {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--cm-ink);
  text-wrap: pretty;
  text-decoration: none;
  display: block;
}

.cm-iso__byline {
  font-size: 11.5px;
  color: var(--cm-ink-muted);
  margin-top: 6px;
}

.cm-iso__action {
  flex: none;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 12px;
  white-space: nowrap;
  background: var(--cm-surface);
  border: 1.5px solid var(--cm-ink);
  color: var(--cm-ink);
  font-weight: 700;
  text-decoration: none;
  display: inline-block;
}

/* ------------------------------------------------------------------- events */

.cm-events {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 10px;
}

.cm-event {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  min-width: 0;
}

.cm-event:hover { border-color: var(--cm-ink); }

.cm-event__date {
  flex: none;
  width: 48px;
  border-radius: 9px;
  background: var(--cm-yellow);
  border: 1px solid var(--cm-yellow-border);
  padding: 7px 0 8px;
  text-align: center;
}

.cm-event__month {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--cm-yellow-ink);
}

.cm-event__day {
  font-size: 19px;
  font-weight: 700;
  color: var(--cm-ink);
  line-height: 1.05;
}

.cm-event__body { flex: 1; min-width: 0; }

.cm-event__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-ink);
  line-height: 1.3;
  text-wrap: pretty;
}

.cm-event__meta {
  font-size: 11.5px;
  color: var(--cm-ink-muted);
  line-height: 1.4;
  margin-top: 4px;
}

/* -------------------------------------------------------------------- modal */

.cm-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cm-modal[hidden] { display: none; }

.cm-modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(34, 34, 34, 0.44);
  border: 0;
  padding: 0;
  cursor: default;
}

.cm-modal__dialog {
  position: relative;
  background: var(--cm-ground);
  border: 2px solid var(--cm-ink);
  border-radius: 14px;
  max-height: 84vh;
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cm-modal__head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--cm-border-band);
}

.cm-modal__titlerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cm-modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--cm-ink);
  margin: 0;
}

.cm-modal__close {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border-band);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.cm-modal__close:hover { background: var(--cm-blue-light); }

.cm-modal__search {
  margin-top: 12px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1.5px solid var(--cm-border-band);
  background: var(--cm-surface);
  font-size: 14px;
  color: var(--cm-ink);
}

.cm-modal__search:focus {
  border-color: var(--cm-blue);
  outline: none;
}

.cm-modal__reset {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 8px;
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border-band);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--cm-ink);
  text-decoration: none;
}

.cm-modal__reset:hover { background: var(--cm-blue-light); }

.cm-modal__body {
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2px;
}

.cm-modal__row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cm-ink);
  background: transparent;
  text-decoration: none;
}

.cm-modal__row:hover { background: rgba(34, 34, 34, 0.06); }

.cm-modal__row--selected {
  font-weight: 700;
  color: var(--cm-ground);
  background: var(--cm-ink);
}

.cm-modal__row[hidden] { display: none; }

.cm-modal__rowname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rows hidden by the "show more" toggle. */
.cm-hidden-row[hidden] { display: none; }
