/*
 * place.css — the Places rail (tree) + the read-only place view. BASELINE-loaded (see
 * Assets::VIEW_CSS) so the place view is styled when swapped in as an htmx fragment.
 * Structural only — no theming (deferred to the painting pass).
 */

/* --- rail: fixed search, scrolling tree beneath (like the People list) ------------- */
.places-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.places-search {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

.places-search input[type="search"]::-webkit-search-cancel-button {
    display: none;   /* our own clear button */
}

.places-search .form-control:placeholder-shown ~ .places-clear {
    display: none;   /* clear shown only when the box has a value */
}

.places-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;   /* only the tree scrolls */
}

/* --- the tree ----------------------------------------------------------------------- */
.place-tree,
.place-children {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Each nested level indents a little. */
.place-children {
    padding-left: 1rem;
}

.place-node-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.05rem 0;
    line-height: 1.3;
}

.place-toggle {
    border: 0;
    background: none;
    padding: 0;
    width: 1rem;
    flex: 0 0 auto;
    cursor: pointer;
    color: var(--bs-secondary-color, #6c757d);
}

/* Keep leaf rows aligned with rows that have a toggle. */
.place-toggle-spacer {
    display: inline-block;
    width: 1rem;
    flex: 0 0 auto;
}

.place-link {
    text-decoration: none;
}

.place-code {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--bs-secondary-color, #6c757d);
}

/* The row's caret action menu (shared _action-menu.php) — inline at the row's end, muted. */
.place-node-actions {
    margin-left: auto;
    flex: 0 0 auto;
}
.place-node-actions-toggle {
    color: var(--bs-secondary-color, #6c757d);
    line-height: 1;
    text-decoration: none;
}
.place-node-actions-toggle:hover,
.place-node-actions-toggle:focus {
    color: var(--bs-body-color, #212529);
}
.place-node-actions-menu {
    font-size: 0.9rem;
}

/* The NEEDS-RESEARCH marker (G3b-5) — ONE amber flag, shared by tree nodes and the place view. Only
   the ICON takes the amber token; the place view's "Needs research" label keeps the readable text
   colour (amber text on white fails contrast). */
.place-research > .bi {
    color: var(--foliale-research);
}

.place-count,
.place-type {
    color: var(--bs-secondary-color, #6c757d);
}

/* --- place view (centre) ------------------------------------------------------------ */
.place-view {
    max-width: 720px;
}

.place-section {
    margin-top: 1.25rem;
}

.place-event {
    padding: 0.15rem 0;
}

.place-event-type {
    font-weight: 600;
}

/*
 * Stacked ADD-PLACE form (G3b-4): rows top-down, each a scoped search + its type slot; the dropdown
 * sits inline under its row and scrolls (row 1 browses ~250 countries).
 */
.place-add { max-width: 40rem; }
.place-add-row + .place-add-row { margin-top: 0.6rem; }
.place-add-search { flex: 1 1 auto; min-width: 0; }
.place-add-type { flex: 0 0 auto; width: auto; }
.place-add-type-text { flex: 0 0 auto; white-space: nowrap; }
.place-add-dropdown { max-height: 16rem; overflow-y: auto; background: var(--bs-body-bg); }
.place-add-cands li + li { margin-top: 0.1rem; }
.place-add-cand { border-radius: 0; line-height: 1.25; }
.place-add-lineage { line-height: 1.2; }
.place-add-create { text-decoration: none; }
/* G3b-4b: a new row's Unknown / Needs-research boxes + its research note, tucked under the field. */
.place-add-extras { line-height: 1.2; }
.place-add-extras .form-check-inline { margin-right: 1rem; }
.place-add-note textarea { max-width: 100%; }
/* G3b-4b-2 advisories. TYPE HIGHLIGHT (CSS only): a new row's selector stands out while its type is
   Unknown, unless the row is research-flagged (deliberately incomplete — no nag). Each :has() rule
   stands alone: a browser without :has() drops just that rule (no highlight); the save-check is
   server-side and still runs. */
.place-add-row.is-new:not(:has(.place-add-research:checked)) .place-add-type:has(option[value="Unknown"]:checked) {
    border-color: var(--bs-warning);
    background-color: var(--bs-warning-bg-subtle);
}
/* SAVE-CHECK marker (server-rendered after a Save stopped by the type check). */
.place-add-row.is-untyped {
    border-left: 3px solid var(--bs-warning);
    padding-left: 0.5rem;
}
.place-add-untyped-label { flex: 0 0 auto; white-space: nowrap; color: var(--bs-warning-text-emphasis); }
/* ...cleared live once the row gets a type or a research flag (old browsers: until the next redraw). */
.place-add-row.is-untyped:has(.place-add-research:checked),
.place-add-row.is-untyped:has(.place-add-type option:not([value="Unknown"]):checked) {
    border-left-color: transparent;
}
.place-add-row.is-untyped:has(.place-add-research:checked) .place-add-untyped-label,
.place-add-row.is-untyped:has(.place-add-type option:not([value="Unknown"]):checked) .place-add-untyped-label {
    display: none;
}
/* SOFT-DUPLICATE warning: one line per near-match, each with its "Use existing". */
.place-add-dup-match + .place-add-dup-match { margin-top: 0.25rem; }

/* --- MP1: the place view's MAP block (_place-map.php; drawn by place-map.js with Leaflet) ----------------- */
.place-map {
    --foliale-map-pin: var(--bs-primary);
    --foliale-map-child: var(--bs-success);
    --foliale-map-pin-edge: var(--bs-body-bg);
}
/* the canvas keeps Leaflet's own stacking (panes 400+, controls 1000) INSIDE it, under the app's menus / modals */
.place-map-canvas {
    position: relative;
    z-index: 0;
    isolation: isolate;
    height: 22rem;
    max-height: 60vh;
}
.place-map-canvas.is-picking { cursor: crosshair; }
/* the APPROXIMATE pin (the nearest located ancestor): hollow, dashed */
.place-map .place-map-pin-approx {
    fill: none;
    stroke: var(--foliale-map-pin);
    stroke-width: 3px;
    stroke-dasharray: 4 3;
}
/* a located CHILD place: a small filled dot, clickable */
.place-map .place-map-pin-child {
    fill: var(--foliale-map-child);
    fill-opacity: 0.9;
    stroke: var(--foliale-map-pin-edge);
    stroke-width: 1.5px;
}
.place-map-lookup-list .place-map-result.active {
    background: var(--bs-primary-bg-subtle);
}

/* --- MP3: the PLACES MAP page (places-map.php; drawn by places-map.js with the shared Leaflet) ------------- */
.places-map {
    --foliale-map-pin: var(--bs-primary);
    --foliale-map-pin-edge: var(--bs-body-bg);
}
/* the canvas keeps Leaflet's own stacking (panes 400+, controls 1000) INSIDE it, under the app's menus / modals */
.places-map-canvas {
    position: relative;
    z-index: 0;
    isolation: isolate;
    height: 32rem;
    max-height: 65vh;
}
/* one pin style: a small filled disc, clickable (the count lives in the tooltip) */
.places-map .places-map-pin {
    fill: var(--foliale-map-pin);
    fill-opacity: 0.85;
    stroke: var(--foliale-map-pin-edge);
    stroke-width: 2px;
}
.places-map-list { max-width: 36rem; }
.places-map-list .places-map-item { padding-block: 0.1rem; border-bottom: 1px solid var(--bs-border-color-translucent); }
