/*
 * 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 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;
}

/* Painting P1: every node is a white RAIL ROW (.rail-row, base.css) and the rows touch, a surface-grey
   hairline between them; a nested level indents INSIDE its row (--place-depth, set per row), so the white
   runs the rail's width. No gender strip on places. */
.place-node-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem 0.15rem calc(0.35rem + var(--place-depth, 0) * 1rem);
    border-top: 1px solid var(--foliale-surface);
}
.place-tree > .place-node:first-child > .place-node-row {
    border-top: 0;
}
.place-node-row.is-open .place-name {
    font-weight: 500;
}
/* During a search: the tree places that MATCHED (the ones the count line counts); the ancestors and descendants drawn
   around them stay at normal weight. */
.place-node-row.is-match .place-name {
    font-weight: 500;
}

.place-toggle {
    border: 0;
    background: none;
    padding: 0;
    width: 1rem;
    flex: 0 0 auto;
    cursor: pointer;
    color: var(--foliale-muted);
}

/* 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;
    color: var(--foliale-text);
    min-width: 0;
}

.place-code {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--foliale-faint);
}

/* 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(--foliale-muted);
    line-height: 1;
    text-decoration: none;
}
.place-node-actions-toggle:hover,
.place-node-actions-toggle:focus {
    color: var(--foliale-text);
}
.place-node-actions-menu {
    font-size: 0.9rem;
}

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

/* The row's secondary facts after the name — muted 12px (Painting P1). */
.place-count,
.place-type {
    font-size: 12px;
    color: var(--foliale-muted);
}

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

.place-section {
    margin-top: 14px;   /* Painting P2: the section spacing (.fo-section) */
}

.place-event {
    background: var(--foliale-row);   /* Painting P2: each event a white row, 2px of the surface between */
    padding: 8px 12px;
    margin-bottom: 2px;
}

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

/* Places arc 2: the WITHIN list — white rows like the events'; the tree view indents by depth (as the rail does). */
.place-within-row {
    background: var(--foliale-row);
    padding: 8px 12px 8px calc(12px + var(--within-depth, 0) * 1rem);
    margin-bottom: 2px;
}
.place-within-type {
    margin-left: 0.25rem;
}

/* The rail's search: a street or site with its chain, muted 12px (as the type). */
.place-chain,
.place-matched {
    font-size: 12px;
    color: var(--foliale-muted);
}
.places-sites-head {
    padding: 0.5rem 0.5rem 0.25rem;
}
/* "Not yet used" (the search's unused seeded places): the cap's "N more — keep typing". */
.places-unused-more {
    padding: 0.25rem 0.5rem;
}

/*
 * 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; }
/* Each level is a form ROW (Painting P3b, .fo-row): the level's name in the grey label cell. */
.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(--foliale-warning-ink);
    background-color: var(--foliale-warning-tint);
}
/* SAVE-CHECK marker (server-rendered after a Save stopped by the type check). */
.place-add-row.is-untyped {
    box-shadow: inset 4px 0 0 var(--foliale-warning-ink);
}
.place-add-untyped-label { flex: 0 0 auto; white-space: nowrap; color: var(--foliale-warning-ink); }
/* ...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) {
    box-shadow: none;
}
.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) ----------------- */
/* (the map tokens — pin, a child place's pin, the edge — are base.css :root's, Dark mode 1) */
/* 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): a solid LIGHTER fill ringed in the pin colour (seen on the dimmed
   dark tiles; apart from the set location's marker in both themes) */
.place-map .place-map-pin-approx {
    fill: var(--foliale-map-pin-approx);
    fill-opacity: 1;
    stroke: var(--foliale-map-pin);
    stroke-width: 3px;
}
/* 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) ------------- */
/* (the map tokens are base.css :root's, Dark mode 1) */
/* 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) */
/* (keyed on the canvas: the canvas alone moves into the large map) */
.places-map-canvas .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); }
