/* ========== The Places page (6D): the list beside the open place ==========
   Mockups [PlacesPage] (1440: list 340 px, the detail's side column 300 px) and [PlacesPortrait]
   (820: list 260 px, the side column becomes a 2-column band under the map). */

/* Both panes stick under the app bar (--chrome-h) and the adventure's sub-tab bar
   (.anima-subtab-bar, sticky at --chrome-h: --subtab-bar-h plus its 1 px rule), 12 px below it,
   and stop 12 px above the bottom of the screen: the adventure's title scrolls away, then the
   panes fill the screen and each scrolls inside itself (the patrons.css recipe). */
/* The detail pane is as tall as that space, so it is the page's last 12 px that decide where
   the panes stop: the main content's 64 px bottom padding would leave the scrolled page with
   the detail's top 52 px under the sub-tab bar. */
.anima-main-content:has(.places-page) {
  padding-bottom: 12px;
}
.places-page {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.places-list,
.place-detail {
  position: sticky;
  top: calc(var(--chrome-h) + var(--subtab-bar-h) + 1px + 12px);
  max-height: calc(100dvh - var(--chrome-h) - var(--subtab-bar-h) - 1px - 24px);
  min-width: 0;
  box-sizing: border-box;
}

/* ── The list ── */
.places-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.places-list-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.places-list-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-title);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.places-new {
  min-height: var(--touch-min);
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
}
.places-new:hover {
  background: var(--accent-hover);
}
.places-search {
  width: 100%;
  min-height: var(--touch-min);
  box-sizing: border-box;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
}
/* The pane is sticky, so a stacking context of its own: while one of its dialogs is open it
   rises above the app bar (1046), the sub-tab bar (1040) and the ambient button (1150), so the
   scrim covers them. */
.place-detail:has(.anima-modal-backdrop, .anima-modal-overlay) {
  z-index: 1300;
}

/* On this page the ambient button leaves the bottom-right corner, where it hid the encounters
   card's « Ouvrir » (precedent: combat-player.css). The list keeps room under its last row. */
body:has(.places-page) .anima-ambient-fab {
  right: auto;
  left: 24px;
}

.places-groups {
  padding-bottom: 9rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  scrollbar-width: thin;
}
.places-group-title {
  margin: 6px 0 0;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.places-row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  text-align: left;
}
.places-row:hover {
  border-color: var(--border-strong);
}
/* The open place: a 2 px accent border, the padding 1 px less so the row does not move. */
.places-row[aria-current='true'] {
  padding: 5px 9px;
  border: 2px solid var(--accent);
  background: var(--selected);
}
.places-row-thumb {
  flex: none;
  width: 44px;
  height: 44px;
  box-sizing: border-box;
  border-radius: 8px;
  object-fit: cover;
  background: var(--board);
}
.places-row-thumb--empty {
  border: 1px dashed var(--border-strong);
  background: transparent;
}
.places-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}
.places-row-name {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.places-row-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.places-empty {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── The open place ──
   Landscape: name, action row and map on the left, the side column (300 px) on the right with
   the foot under it. The pane has the screen's height: the map takes what the rest leaves. */
.place-detail {
  height: calc(100dvh - var(--chrome-h) - var(--subtab-bar-h) - 1px - 24px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'header side'
    'map side'
    'map foot';
  gap: 10px 16px;
  overflow-y: auto;
}
.place-detail-header {
  grid-area: header;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.place-detail-title {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.place-detail-actions {
  flex: none;
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.place-detail-map {
  grid-area: map;
  position: relative;
  min-height: 200px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--board);
}
.place-detail-map--empty {
  border: 2px dashed var(--border-strong);
}
.place-detail-map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.place-detail-no-map {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}
.place-detail-no-map-icon {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
}
.place-detail-no-map-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}
.place-detail-no-map-hint {
  max-width: 20rem;
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.place-detail-side {
  grid-area: side;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.place-detail-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.place-detail-card {
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.place-detail-description {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.place-detail-card-label {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}
.place-detail-description-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.place-detail-description-text--none {
  color: var(--muted);
}
.place-detail-visibility {
  display: flex;
  align-items: center;
  gap: 10px;
}
.place-detail-visibility-label {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--ink);
}
/* The visibility switch (56 × 32, the knob right when on). */
.place-switch {
  flex: none;
  position: relative;
  width: 56px;
  height: var(--touch-min);
  padding: 0;
  border: none;
  background: transparent;
}
/* The track stays 56 x 32; the button around it is the 44 px hit area. */
.place-switch::before {
  content: '';
  position: absolute;
  inset: 50% 0 auto;
  height: 32px;
  margin-top: -16px;
  border-radius: 16px;
  background: var(--border-strong);
}
.place-switch[aria-checked='true']::before {
  background: var(--accent);
}
.place-switch:disabled {
  opacity: 0.7;
}
.place-switch-knob {
  position: absolute;
  top: 50%;
  margin-top: -12px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--on-accent);
}
.place-switch[aria-checked='true'] .place-switch-knob {
  left: auto;
  right: 4px;
}
.place-detail-foot {
  grid-area: foot;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.place-detail--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
}
.place-detail-empty {
  margin: 0;
  padding: 24px;
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
}

/* Portrait: a 260 px list; the detail stacks name, actions, map, the side column turned into a
   2-column band (description | visibility and encounters), then the foot. */
@media (max-width: 1023.98px) {
  .places-page {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .place-detail {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      'header'
      'map'
      'side'
      'foot';
  }
  /* The action row sits under the title, as on the portrait board. */
  .place-detail-actions {
    flex: 1 0 100%;
    margin-left: 0;
  }
  /* The band scrolls within itself so the map keeps the rest of the height. */
  .place-detail-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    max-height: 24rem;
    overflow-y: auto;
  }
  /* The band's two columns: Description then Catégories on the left, the switch then the
     encounters on the right. The stack dissolves so its cards place on the band's grid. */
  .place-detail-stack {
    display: contents;
  }
  .place-detail-description {
    grid-column: 1;
    grid-row: 1;
  }
  .place-detail-visibility {
    grid-column: 2;
    grid-row: 1;
  }
  .place-detail-categories {
    grid-column: 1;
    grid-row: 2;
  }
  .place-encounters {
    grid-column: 2;
    grid-row: 2;
  }
  .place-detail-map {
    min-height: 300px;
  }
  /* A player's band holds the description alone: it takes the whole width. */
  .place-detail-side > :only-child {
    grid-column: 1 / -1;
  }
}

/* ── The GM's actions (Task 3) ── */
.place-fav {
  flex: none;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.place-fav svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.place-fav[aria-pressed='true'] {
  color: var(--accent);
}
.place-fav[aria-pressed='true'] svg {
  fill: currentColor;
}
.place-detail-header .place-detail-error {
  order: 3;
  flex: 1 0 100%;
}
.place-detail-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
}
.place-detail-file {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  white-space: nowrap;
}
.place-detail-file:focus-visible + .place-btn {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.place-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.place-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.place-btn--outline {
  border-color: var(--border-strong);
  background: var(--surface);
}
.place-btn--outline:hover {
  border-color: var(--accent);
}
.place-btn--primary {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.place-btn--primary:hover {
  background: var(--accent-hover);
}
.place-btn--danger {
  background: var(--danger);
  color: var(--on-accent);
  font-weight: 700;
}
.place-btn--text {
  padding: 0 8px;
  color: var(--muted);
  text-decoration: underline;
}
.place-btn--link {
  min-height: var(--touch-min);
  padding: 0 4px;
  color: var(--accent);
}
.place-btn--danger-text {
  color: var(--danger);
}
.place-detail-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* the 44 px « Modifier » button must not grow the card */
  margin: -10px 0 -10px;
}
.place-detail-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
  resize: vertical;
}
.place-detail-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.place-detail-visibility-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.place-detail-visibility-hint {
  font-size: 0.8rem;
  color: var(--muted);
}
.place-detail-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.place-detail-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.place-tag-remove {
  position: relative;
}
/* A pill is small; the cross answers a finger over a 44 px square. */
.place-tag-remove::after {
  content: '';
  position: absolute;
  inset: -14px -10px;
}
.place-tag-add {
  min-height: var(--touch-min);
  font-size: 0.85rem;
}
.place-dialog-title {
  margin: 0 0 8px;
  font-family: var(--font-title);
  font-size: 1.1rem;
}
.places-new-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 16rem;
}
.places-new-title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1rem;
}
.places-new-label {
  font-size: 0.8rem;
  color: var(--muted);
}
.places-new-submit {
  align-self: flex-end;
}

/* ── A place's encounters and the board (Task 4) ──
   The button sits on the map box's bottom-right corner; the card is in the side column. */
.place-board-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 1;
  min-height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: var(--chrome);
  color: var(--chrome-ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.place-encounters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.place-encounter-row {
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  gap: 8px;
}
.place-encounter-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.place-encounter-name {
  font-size: 0.9rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.place-encounter-status {
  font-size: 0.8rem;
  color: var(--muted);
}
.place-dashed {
  min-height: var(--touch-min);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.place-chooser {
  width: 300px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}
.place-chooser-title {
  margin: 0;
  padding: 0 4px 4px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}
.place-choice {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
}
.place-choice .place-encounter-name {
  font-weight: 700;
}

/* ========== « Générer une carte » (6D): the 560 px side panel ==========
   Mockups [PlacesPage] / [PlacesPortrait] with `gen`: a tablist, the type chips (44 px pills), the
   seed and the 1-to-4 stepper, then « Propositions » in a 2x2 grid that takes the height that is
   left; the foot (52 px buttons) is the side panel's action bar. */
.map-panel .anima-side-panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 0 14px;
  position: relative;
}
.map-panel .anima-side-panel-body > :not(.map-panel-tabs, .map-panel-lightbox) {
  margin-inline: 20px;
}
.map-panel .anima-side-panel-actions {
  justify-content: space-between;
  padding: 14px 20px;
}
.map-panel-tabs {
  display: flex;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
}
.map-panel-tab {
  flex: 1;
  height: 48px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.map-panel-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.map-panel-fields {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
}
.map-panel-label {
  font-size: 0.8rem;
  color: var(--muted);
}
.map-panel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.map-panel-chip {
  min-height: var(--touch-min);
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.map-panel-chip[aria-pressed="true"] {
  padding: 0 17px;
  border: 2px solid var(--accent);
  background: var(--selected);
}
.map-panel-input {
  min-height: var(--touch-min);
  font-size: 0.9rem;
}
.map-panel-city {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.map-panel-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}
.map-panel-row--seed {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 12px;
}
.map-panel-seed {
  display: flex;
  gap: 6px;
}
.map-panel-seed-input {
  flex: 1;
  min-width: 0;
  font-family: 'JetBrains Mono', monospace;
}
.map-panel-btn,
.map-panel-step {
  min-height: var(--touch-min);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.map-panel-btn:disabled,
.map-panel-step:disabled,
.map-panel-chip:disabled,
.map-panel-foot-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.map-panel-btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.map-panel-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-panel-step {
  width: var(--touch-min);
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.map-panel-count-value {
  flex: 1;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
}
.map-panel-hint {
  color: var(--muted);
}
.map-panel-error {
  margin-bottom: 0;
}
.map-panel-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.map-panel-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-panel-spin 0.8s linear infinite;
}
@keyframes map-panel-spin {
  to { transform: rotate(360deg); }
}
.map-panel-grid {
  display: grid;
  flex: 1 1 auto;
  min-height: 280px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.map-panel-cell {
  position: relative;
  min-height: 0;
}
.map-panel-candidate {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--board);
  cursor: pointer;
}
.map-panel-candidate[aria-pressed="true"] {
  border: 3px solid var(--accent);
}
.map-panel-candidate img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.map-panel-enlarge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: var(--touch-min);
  height: var(--touch-min);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}
.map-panel-foot-btn {
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.map-panel-foot-btn--primary {
  padding: 0 22px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
/* The enlarged view: over the whole screen, above the panel (1250 to 1299), below the short modals. */
.map-panel-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: rgba(12, 10, 8, 0.97); /* a viewing room: dark whatever the theme */
}
.map-panel-lightbox-toolbar,
.map-panel-lightbox-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.map-panel-lightbox-actions {
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: none;
}
.map-panel-lightbox-zoom {
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-panel-lightbox .map-panel-btn:not(.map-panel-btn--primary) {
  border-color: rgba(255, 255, 255, 0.5);
  color: #eee;
}
.map-panel-lightbox-pct {
  min-width: 3.5rem;
  text-align: center;
  color: #eee;
  font-variant-numeric: tabular-nums;
}
.map-panel-lightbox-canvas {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px;
  text-align: center;
}
/* max-width: none lets the image overflow so the scroll pans when it is zoomed. */
.map-panel-lightbox-canvas img {
  display: inline-block;
  height: auto;
  max-width: none;
}
