/* The Places page (views/places.erb, public/js/places.js). Loaded after
   style.css, whose tokens, rail and dark theme it builds on. */

/* Category group tints, by index into Place::CATEGORY_GROUPS (plus Other):
   Where to sleep, Getting out, Logistics, Food & people, Other. */
.places-page [data-group="0"] { --group-bg: #e4eeea; --group-ink: #345c53; }
.places-page [data-group="1"] { --group-bg: #fdf0da; --group-ink: #7f5312; }
.places-page [data-group="2"] { --group-bg: #e3e8f0; --group-ink: #3d5170; }
.places-page [data-group="3"] { --group-bg: #f6e4dc; --group-ink: #8a4530; }
.places-page [data-group="4"] { --group-bg: var(--parchment-dark); --group-ink: var(--muted-strong); }
:root[data-theme="dark"] .places-page [data-group="0"] { --group-bg: #22362f; --group-ink: #9fcfc1; }
:root[data-theme="dark"] .places-page [data-group="1"] { --group-bg: #3d311d; --group-ink: #f0c27a; }
:root[data-theme="dark"] .places-page [data-group="2"] { --group-bg: #26303f; --group-ink: #a9bcdb; }
:root[data-theme="dark"] .places-page [data-group="3"] { --group-bg: #3d2720; --group-ink: #eeac94; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The rail's links look like its buttons; the current page is pressed. */
.places-page a.rail__btn { text-decoration: none; }
.places-page .rail__btn[aria-current="page"] {
  background: var(--ink);
  color: var(--parchment);
}

/* ---------- Page ---------- */

.places {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 1.75rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.places__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.places__head h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 2.1rem;
  line-height: 1.1;
}
/* The header's buttons (Import places + New place, and on the Trips
   page Add a shared trip + New trip). */
.places__head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.places__stats {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: var(--text-md);
}

.places__loading { color: var(--muted); margin: 0; }
.places__loading[hidden] { display: none; }

/* ---------- Buttons ---------- */

.places-page .pl-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 400;
}
.places-page .pl-btn svg { width: 18px; height: 18px; flex: none; }
.places-page .pl-btn:hover { background: var(--parchment); border-color: var(--fainter); }
.places-page .pl-btn--gold {
  min-height: 44px;
  padding: 0 1.1rem;
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-accent);
  font-weight: 600;
}
.places-page .pl-btn--gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.places-page .pl-btn--gold:disabled:hover { background: var(--gold); }
.places-page .pl-btn--quiet { border-color: transparent; background: transparent; color: var(--muted); }
.places-page .pl-btn--quiet:hover { background: var(--parchment-dark); border-color: transparent; color: var(--ink); }
.places-page .pl-btn--danger { color: var(--danger); }
.places-page .pl-btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.places-page .pl-btn[hidden] { display: none; }
/* The import dialog's full-width actions (Choose file, Find places...). */
.places-page .import-places .pl-btn { justify-content: center; }

.places-page .pl-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tool-ink);
}
.places-page .pl-icon svg { width: 18px; height: 18px; }
.places-page .pl-icon:hover { background: var(--parchment-dark); }

.places-page .pl-star svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.places-page .pl-star[aria-pressed="true"] { color: var(--gold-dark); }
.places-page .pl-star[aria-pressed="true"] svg { fill: var(--gold); }

/* A place's name, which opens it for editing. */
.places-page .pl-title {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.25;
}
.places-page .pl-title:hover {
  background: none;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}

/* ---------- Toolbar ---------- */

.places__toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.places__toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.places__search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
}
.places__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.places__search input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 0.75rem 0 2.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-md);
}

/* Categories and States: the map's category chips (style.css) in a
   pop-down under their toggle. */
.pl-dropdown { position: relative; }
.places-page .pl-dropdown__toggle { min-height: 42px; }
.places-page .pl-dropdown__toggle svg { width: 12px; height: 12px; transition: transform 0.15s; }
.places-page .pl-dropdown__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.places-page .pl-dropdown__toggle[aria-expanded="true"] { border-color: var(--route); }
.pl-dropdown__menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  max-width: min(560px, calc(100vw - 2rem));
  max-height: min(420px, 60vh);
}
.pl-dropdown__menu[hidden] { display: none; }
.pl-dropdown__menu .category-filters__list { max-width: none; }
.places-page .pl-dropdown__menu .category-filter-btn { min-height: 36px; }
/* State flags in the States menu. Contained, since flags aren't all 3:2
   (Ohio's is a swallowtail), with a hairline so white ones show on any
   chip. */
.pl-flag {
  flex: none;
  width: 21px;
  height: 14px;
  object-fit: contain;
}
img.pl-flag { filter: drop-shadow(0 0 0.5px var(--fainter)); }
.pl-flag--none { display: inline-block; }
.pl-dropdown__menu .pl-chip__count { margin-left: var(--space-1); font-weight: 400; }

.places__sort {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted-strong);
  font-size: var(--text-sm);
}
.places__sort select {
  min-height: 42px;
  border-radius: 8px;
  font-size: var(--text-sm);
}

/* Segmented controls: View and Columns. */
.pl-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--parchment-dark);
  border-radius: 9px;
}
.pl-seg[hidden] { display: none; }
.places-page .pl-seg button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 0.7rem;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong);
  font-size: var(--text-sm);
  font-weight: 400;
}
.places-page .pl-seg button svg { width: 16px; height: 16px; }
.places-page .pl-seg button:hover { background: var(--surface-warm); color: var(--ink); }
.places-page .pl-seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--border);
}

.places__filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.places-page .pl-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 400;
  white-space: nowrap;
}
.places-page .pl-chip:hover { background: var(--surface); border-color: var(--fainter); }
.places-page .pl-chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--parchment);
}
.pl-chip__count { font-size: var(--text-xs); opacity: 0.75; }

/* ---------- Tags ---------- */

.pl-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pl-tag {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--parchment-dark);
  color: var(--muted-strong);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.pl-tag--cat {
  background: var(--group-bg);
  color: var(--group-ink);
  font-weight: 600;
}

/* ---------- Gallery ---------- */

/* As many 260px+ columns as the width allows. */
.pl-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.pl-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s, transform 0.15s;
}
.pl-card:hover {
  box-shadow: 0 6px 18px rgba(27, 36, 48, 0.12);
  transform: translateY(-1px);
}

.pl-card__cover {
  position: relative;
  height: 128px;
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: 0.75rem 0.9rem;
  background: var(--group-bg);
  color: var(--group-ink);
}
.pl-card__contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  opacity: 0.2;
}
.pl-card__icon { position: relative; font-size: 2.25rem; line-height: 1; }
.pl-card__where {
  position: relative;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}
.pl-card__coords { font-weight: 600; }
.pl-card__elev { display: inline-flex; align-items: center; gap: 4px; }
.pl-card__elev svg { width: 13px; height: 13px; }
.pl-card__cover .pl-star {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--label-bg);
}
.pl-card__cover .pl-star:hover { background: var(--surface); }

.pl-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem 1rem 0.6rem;
}
.pl-card__title { margin: 0; font-size: inherit; }
.pl-card__notes {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted-strong);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.pl-card__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--parchment-dark);
}
.pl-card__added { flex: 1; color: var(--muted); font-size: var(--text-xs); }

.places-page .pl-add-tile {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: 400;
}
.places-page .pl-add-tile svg { width: 28px; height: 28px; }
.places-page .pl-add-tile:hover { background: var(--surface-warm); color: var(--ink); border-color: var(--fainter); }

/* ---------- Table ---------- */

.pl-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.pl-table-wrap > .pl-btn { margin: 0.4rem; }
.pl-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.pl-table thead th {
  padding: 0.6rem 0.75rem;
  background: var(--parchment-dark);
  color: var(--muted-strong);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}
.pl-table td,
.pl-table tbody th {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--parchment-dark);
  color: var(--muted-strong);
  text-align: left;
  vertical-align: middle;
}
.pl-table tbody tr:hover { background: var(--surface-warm); }
.pl-table .pl-table__fav { width: 84px; padding: 0.2rem 0.4rem; white-space: nowrap; }
.pl-table .pl-table__edit { width: 92px; padding: 0.2rem 0.4rem; white-space: nowrap; }
.pl-table__name { font-weight: 400; }
.pl-table__name > * { vertical-align: middle; }
.pl-table__name .pl-title { font-size: var(--text-base); }
.pl-table__name .pl-icon { width: 32px; height: 32px; }
.pl-table__icon { margin-right: var(--space-3); font-size: 1.1rem; }
.pl-table .pl-table__num { text-align: right; white-space: nowrap; }
.pl-table__notes {
  max-width: 28rem;
}
.pl-table__added { white-space: nowrap; }

/* ---------- Board ---------- */

.pl-board {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: var(--space-3);
}
.pl-board__col {
  flex: 1 0 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  background: var(--parchment-dark);
  border-radius: 12px;
}
.pl-board__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.1rem 0.25rem;
}
.pl-board__head h2 { flex: 1; margin: 0; font-size: var(--text-md); }
.pl-board__dot { width: 10px; height: 10px; border-radius: 999px; background: var(--group-ink); }
.pl-board__count { color: var(--muted-strong); font-size: var(--text-sm); }

.pl-mini {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.3rem 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.pl-mini__icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--group-bg);
  font-size: 1.15rem;
}
.pl-mini__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pl-mini__text .pl-title { font-size: var(--text-md); }
.pl-mini__text > span { color: var(--muted); font-size: var(--text-xs); }
.pl-mini .pl-icon { width: 36px; height: 36px; }

/* ---------- Empty states ---------- */

.pl-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 3.5rem 1.5rem;
  border: 1px dashed var(--fainter);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}
.pl-empty p { margin: 0; }
.pl-empty__title {
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.25rem;
}

/* ---------- Add / edit sheet ---------- */

.pl-sheet {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, 100%);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface-warm);
  color: var(--ink);
  box-shadow: -8px 0 32px rgba(27, 36, 48, 0.18);
}
.pl-sheet::backdrop { background: rgba(27, 36, 48, 0.4); }
.pl-sheet__form {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.pl-sheet__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 1rem 1rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.pl-sheet__head h2 {
  flex: 1;
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.4rem;
}
.pl-sheet__body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.25rem 1.5rem;
}
.pl-sheet__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: 0.9rem 1.5rem calc(0.9rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.pl-sheet__spacer { flex: 1; }

.pl-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.places-page .pl-field input,
.places-page .pl-field textarea {
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 400;
}

.pl-location { position: relative; }
.pl-location input { width: 100%; box-sizing: border-box; }
.pl-suggestions {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-float);
}
.pl-suggestions[hidden] { display: none; }
.pl-suggestions li {
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  font-weight: 400;
  cursor: pointer;
}
.pl-suggestions li:hover,
.pl-suggestions li[aria-selected="true"] { background: var(--parchment-dark); }
.pl-where {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 400;
}

.pl-cats { margin: 0; padding: 0; border: 0; }
.pl-cats legend { padding: 0; margin-bottom: var(--space-2); }
.pl-cat-group { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.pl-cat-group__name {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.pl-cat-group__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pl-cat { position: relative; }
.pl-cat input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.pl-cat > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 400;
  cursor: pointer;
}
.pl-cat:hover > span { border-color: var(--fainter); }
.pl-cat input:checked + span {
  background: var(--group-bg);
  border-color: var(--group-ink);
  color: var(--group-ink);
  font-weight: 600;
}
.pl-cat input:focus-visible + span { outline: 2px solid var(--gold-dark); outline-offset: 2px; }

.pl-fav {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.pl-fav input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold); }
.pl-fav > span { display: flex; flex-direction: column; gap: 2px; font-size: var(--text-sm); }
.pl-fav > span > span { color: var(--muted); font-size: var(--text-xs); }

/* "Open on map" under the location line (and on the Trips sheet). */
.places-page a.pl-btn { text-decoration: none; }
.places-page a.pl-sheet__map {
  align-self: flex-start;
  color: var(--ink);
  font-weight: 400;
}
.places-page a.pl-sheet__map[hidden] { display: none; }

.pl-error { margin: 0; color: var(--danger); font-size: var(--text-sm); }
.pl-error[hidden] { display: none; }

/* ---------- Import dialog ---------- */

/* A centered modal (unlike the side sheet), holding the map's old Import
   panel; its form styles come from style.css. */
.pl-modal {
  width: min(560px, calc(100% - 2rem));
  max-height: min(860px, calc(100dvh - 2rem));
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface-warm);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(27, 36, 48, 0.3);
}
.pl-modal[open] { display: flex; flex-direction: column; }
.pl-modal::backdrop { background: rgba(27, 36, 48, 0.4); }
.pl-modal__body {
  overflow-y: auto;
  padding: 1.1rem 1.5rem 1.5rem;
}
.pl-modal__body > .hint { margin-top: 0; }

@media (max-width: 760px) {
  .places-page .places { order: 1; padding: 1.25rem 1rem 2rem; }
  .places__head h1 { font-size: 1.7rem; }
  .places-page .rail { order: 3; }
}

/* "Share as map" dialog: the maps already shared, one per row. */
.share-map__heading {
  margin: 1.2rem 0 0.4rem;
  font-size: var(--text-md);
}
.share-map__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.share-map__list li {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}
.share-map__list a { flex: 1; color: var(--route); }
.share-map__list span { color: var(--muted); }

/* Map queue: each card's / row's toggle, and the bar along the bottom
   while anything is queued. */
.pl-card__cover .pl-queue {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--label-bg);
}
.pl-card__cover .pl-queue:hover { background: var(--surface); }
.places-page .pl-queue[aria-pressed="true"] {
  background: var(--route);
  color: #fff;
}
.places-page .pl-card.is-queued { box-shadow: 0 0 0 2px var(--route); }

.map-queue {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem auto 0;
  padding: 0.6rem 0.75rem;
  max-width: 640px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
}
.map-queue[hidden] { display: none; }
.map-queue__count {
  flex: 1 1 12rem;
  font-weight: 700;
  font-size: var(--text-sm);
}
