/* ================================================================
   FriendsByChance — map.css
   The Map page (130): the map and what floats over it, the details
   view in the right pane, and the journey overlay.

   Stacking inside the main pane (an isolated context, below):
     Leaflet's own panes and controls   up to 1000
     the tools, the bar, the hint       1050
     a pin's card (inside the map)      1060
     the toast                          1150
     the journey overlay                1200
   ================================================================ */

/* ── Map page — main pane needs isolation for overlay z-index ────── */
#map-page .fbc-pane-main {
    position:  relative;
    overflow:  hidden;
    isolation: isolate;
}

.map-container {
    width:  100%;
    height: 100%;
}

/* The left pane: the mode buttons, the time shown, then the mode's own
   list — the one part that scrolls.  My journeys' parts are its world's
   (map-journeys.js), in a column of their own. */
.map-world {
    flex:           1;
    min-height:     0;
    display:        flex;
    flex-direction: column;
}
.map-mode-body {
    flex:           1;
    min-height:     0;
    overflow-y:     auto;
    display:        flex;
    flex-direction: column;
}

/* ── Leaflet overrides ───────────────────────────────────────────── */
/* Remove default blue outline on divIcon markers */
.fbc-map-pin {
    background: transparent !important;
    border:     none        !important;
}
/* The marker's face is redrawn as its state changes; the pointer's
   target must stay the marker itself, or a double click lands on two
   different elements and is not one. */
.fbc-map-pin svg     { pointer-events: none; display: block; }
.fbc-map-pin--dim    { opacity: 0.35; }

/* A PERSON (map-engine 'person'): their picture in a circle, ringed in
   the colour the host gives (--person-ring), a white edge between the
   ring and the map; pointed at, a halo in the ring's ink; selected, a
   dark ring outside.  Never a target itself: the marker is (see above). */
/* Its size and the room for its halo: map-engine.js's PERSON_SIZE (34),
   +4 grown (hovered, highlighted), +8 selected, HALO_PX + 2 (9) around. */
.fbc-map-person {
    width:         34px;
    height:        34px;
    margin:        9px;
    box-sizing:    border-box;
    border:        3px solid var(--person-ring);
    border-radius: 50%;
    overflow:      hidden;
    background:    #ececec;
    box-shadow:    0 0 0 1.5px #fff, 0 1px 3px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}
.fbc-map-person--hover {
    box-shadow: 0 0 0 1.5px #fff, 0 0 0 7px color-mix(in srgb, var(--person-ink) 30%, transparent);
}
.fbc-map-person--selected {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4.5px #1f1f1f;
}
.fbc-map-person--grown    { width: 38px; height: 38px; }
.fbc-map-person--selected { width: 42px; height: 42px; }
.fbc-map-person-photo {
    display:    block;
    width:      100%;
    height:     100%;
    object-fit: cover;
}
.fbc-map-person-none      { display: block; width: 100%; height: 100%; }
.fbc-map-person-none *    { fill: #9e9e9e; }

/* A person's name sits UNDER their circle (nameUnder), always shown. */
.leaflet-tooltip.fbc-map-name.fbc-map-name--under {
    margin-top: 2px;
    max-width:  10em;
}

/* A marker's NAME beside it, while the names layer is on (map-engine
   setNames): a Leaflet tooltip that is always open — a small plate rather
   than a speech bubble, and never a target. */
.leaflet-tooltip.fbc-map-name {
    margin-left:   0;
    padding:       1px 6px;
    max-width:     16em;
    overflow:      hidden;
    text-overflow: ellipsis;
    border:        0;
    border-radius: 4px;
    background:    var(--color-surface);
    box-shadow:    0 1px 2px rgba(0, 0, 0, 0.3);
    color:         var(--color-text);
    font-size:     0.72rem;
    font-weight:   600;
    line-height:   1.4;
    white-space:   nowrap;
}
.leaflet-tooltip.fbc-map-name::before { display: none; }

/* A route's direction: a chevron the engine turns along its segment.
   Drawn, never pressed — the markers it may sit near are the targets. */
.fbc-map-arrow {
    background:     transparent !important;
    border:         none        !important;
    pointer-events: none;
}
.fbc-map-arrow svg { display: block; }

/* ── Area shape handles (map-engine _shapeLayer) ─────────────────── */
/* Same reason as .fbc-map-pin: a divIcon carries Leaflet's own box.
   Shared by every map the engine mounts, which is why they live here
   rather than in a feature sheet.                                    */
.fbc-map-handle {
    background: transparent !important;
    border:     none        !important;
    cursor:     grab;
    /* The ring is only ~20px; this is what makes it a real touch target
       without making the drawn circle look heavier. */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
.fbc-map-handle:active    { cursor: grabbing; }
.fbc-map-handle--mid      { cursor: copy; opacity: 0.85; }
.fbc-map-handle--mid:hover { opacity: 1; }

/* While a shape is being drawn the map is a canvas, not a map — and a
   click on a marker is a click on the canvas under it. */
.fbc-map--drawing,
.fbc-map--drawing .leaflet-grab      { cursor: crosshair; }
.fbc-map--drawing .leaflet-container { cursor: crosshair; }
.fbc-map--drawing .fbc-map-pin       { pointer-events: none; }

/* ── The tools, top right ────────────────────────────────────────── */
.map-tools {
    position:       absolute;
    top:            10px;
    right:          10px;
    z-index:        1050;
    display:        flex;
    flex-direction: column;
    gap:            10px;
}
.map-tools-group {
    display:        flex;
    flex-direction: column;
    gap:            4px;
    padding:        4px;
    border-radius:  10px;
    background:     var(--color-surface);
    box-shadow:     0 1px 5px rgba(0, 0, 0, 0.28);
}
/* A map tool is a touch target first: bigger than a form's icon button. */
.map-tools .map-tool {
    width:        36px;
    height:       36px;
    border-color: transparent;
    background:   var(--color-surface);
}
.map-tools .map-tool svg     { width: 18px; height: 18px; }
.map-tools .map-tool:hover   { background: var(--color-hover); }
.map-tools .map-tool.fbc-icon-btn--active {
    background:   var(--color-primary);
    border-color: var(--color-primary);
    color:        var(--color-text-on-primary);
}

/* A layer switched off: the layers button carries a dot, like a filter. */
.map-tools .map-tool.map-tool--filtered { position: relative; }
.map-tools .map-tool.map-tool--filtered::after {
    content:       '';
    position:      absolute;
    top:           4px;
    right:         4px;
    width:         7px;
    height:        7px;
    border-radius: 50%;
    background:    var(--color-danger);
    box-shadow:    0 0 0 1.5px var(--color-surface);
}

/* The "+": its four ways to add a location unfold below it — or, where
   the map is too short, to its left (map.js _placeAddOptions). */
.map-tools-add { position: relative; }
.map-tools-options {
    display:        flex;
    flex-direction: column;
    gap:            4px;
    padding-top:    4px;
    border-top:     1px solid var(--color-divider);
}
.map-tools-add--left .map-tools-options {
    position:       absolute;
    top:            0;
    right:          calc(100% + 8px);
    flex-direction: row;
    padding:        4px;
    border-top:     none;
    border-radius:  10px;
    background:     var(--color-surface);
    box-shadow:     0 1px 5px rgba(0, 0, 0, 0.28);
}

/* ── The layers popover ──────────────────────────────────────────── */
.map-layers {
    display:        flex;
    flex-direction: column;
    gap:            2px;
    min-width:      190px;
}
.map-layers-title { padding: 2px 4px 6px; }   /* its look: .fbc-section-title (components/shared.css) */
.map-layers-row {
    display:       flex;
    align-items:   center;
    gap:           10px;
    min-height:    40px;
    padding:       0 6px;
    border-radius: 6px;
    cursor:        pointer;
    font-size:     0.9rem;
    color:         var(--color-text);
}
.map-layers-row:hover { background: var(--color-hover); }
.map-layers-row input {
    width:        18px;
    height:       18px;
    margin:       0;
    accent-color: var(--color-primary);
}

/* ── WHERE THE MAP IS: the bar at its top (map-journeys.js) ────────
   Beside the zoom buttons: up, the way down as crumbs, the journey the map
   is in as its chip, when and how much, the journeys before and after it,
   its panel.  One line: what gives way is the chip's name; on a narrow
   map the crumbs and the words after the chip go ("up" is the way out). */
.map-crumbs {
    position:      absolute;
    top:           10px;
    left:          54px;
    z-index:       1050;
    display:       flex;
    align-items:   center;
    gap:           4px;
    box-sizing:    border-box;
    max-width:     calc(100% - 54px - 62px);     /* the zoom buttons, the tools */
    padding:       5px;
    border-radius: 12px;
    background:    var(--color-surface);
    color:         var(--color-text);
    box-shadow:    0 2px 8px rgba(0, 0, 0, 0.25);
    font-size:     0.86rem;
}
/* Finger-sized, as every choice is (000 §1.13). */
.map-crumbs .fbc-icon-btn {
    width:      40px;
    height:     40px;
    border:     0;
    background: transparent;
}
.map-crumbs .fbc-icon-btn:hover { background: var(--color-hover); }
.map-crumbs .fbc-icon-btn.fbc-icon-btn--active,
.map-crumbs .fbc-icon-btn.fbc-icon-btn--active:hover { background: var(--color-primary); }
.map-crumbs .fbc-icon-btn:disabled { opacity: 0.3; }
.map-crumb {
    flex:          0 1 auto;
    min-width:     2.5em;
    height:        40px;
    padding:       0 8px;
    border:        0;
    border-radius: 8px;
    background:    transparent;
    color:         var(--color-text-secondary);
    font-size:     0.9rem;
    font-weight:   600;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    cursor:        pointer;
}
.map-crumb:hover { background: var(--color-hover); color: var(--color-text); }
.map-crumb-sep {
    flex:    none;
    display: flex;
    color:   var(--color-text-muted);
}
.map-crumb-sep svg { width: 14px; height: 14px; }
.map-crumbs-chip,
.map-crumbs-now {
    flex:      0 1 auto;
    min-width: 3em;
    margin:    0 4px;
}
.map-crumbs-now  { font-weight: 700; }
.map-crumbs-meta {
    flex:        none;
    padding:     0 6px;
    color:       var(--color-text-secondary);
    font-size:   0.8rem;
    white-space: nowrap;
}
.map-crumbs-rule {
    flex:       none;
    width:      1px;
    height:     24px;
    margin:     0 2px;
    background: var(--color-divider);
}
.map-crumbs .map-journey-row-actions { display: flex; flex: none; }

/* ── Top centre, under the bar: an armed tool's hint ───────────────── */
.map-top {
    position:       absolute;
    top:            66px;
    left:           50%;
    transform:      translateX(-50%);
    z-index:        1050;
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            6px;
    /* Clear of the zoom control on the left and the tools on the right. */
    max-width:      calc(100% - 132px);
    pointer-events: none;
}
.map-top > * { pointer-events: auto; }

.map-hint {
    display:       flex;
    align-items:   center;
    flex-wrap:     wrap;
    justify-content: center;
    gap:           8px;
    max-width:     100%;
    padding:       6px 8px 6px 14px;
    border-radius: 22px;
    box-shadow:    0 2px 8px rgba(0, 0, 0, 0.25);
    font-size:     0.86rem;
}

.map-hint {
    background: rgba(33, 33, 33, 0.88);
    color:      #fff;
}
.map-hint-text { line-height: 1.35; }

/* ── The toast (FBC.ui.Toast — its look components/toast.css): over the map ── */
.map-toast { z-index: 1150; }

/* ── A card on the map (map-engine openPopup) ────────────────────
   The FRAME is what the engine places: it carries the caret, so it does
   not scroll.  The card inside it does, when a spot has many journeys. */
.fbc-map-popup {
    position:      absolute;
    z-index:       1060;
    width:         min(336px, calc(100% - 16px));
    padding:       10px 12px 12px;
    border-radius: 12px;
    background:    var(--color-bg);
    color:         var(--color-text);
    box-shadow:    0 6px 24px rgba(0, 0, 0, 0.3);
    cursor:        auto;
    font-size:     0.9rem;
}
.fbc-map-popup > .map-spot {
    max-height: min(58vh, 420px);
    overflow-y: auto;
}
.fbc-map-popup.map-popup-frame--ctx { width: auto; min-width: 180px; }
/* The caret points at the pin; map-engine says where along the edge. */
.fbc-map-popup::after {
    content:     '';
    position:    absolute;
    left:        var(--fbc-popup-caret-x, 50%);
    bottom:      -7px;
    width:       14px;
    height:      14px;
    margin-left: -7px;
    background:  var(--color-bg);
    transform:   rotate(45deg);
    box-shadow:  3px 3px 5px rgba(0, 0, 0, 0.12);
}
.fbc-map-popup.fbc-map-popup--below::after {
    top:        -7px;
    bottom:     auto;
    box-shadow: -3px -3px 5px rgba(0, 0, 0, 0.08);
}

/* ── A spot: its places, and the journeys that went there ────────── */
.map-spot {
    display:        flex;
    flex-direction: column;
    gap:            12px;
}
.map-spot-place {
    display:        flex;
    flex-direction: column;
    gap:            5px;
}
.map-spot-place + .map-spot-place {
    border-top:  1px solid var(--color-divider);
    padding-top: 10px;
}
.map-spot-head {
    display:     flex;
    align-items: center;
    gap:         8px;
}
.map-spot-chip   { max-width: 100%; min-width: 0; }
.map-spot-close  { margin-left: auto; border-color: transparent; }
.map-spot-sub {
    font-size:   0.84rem;
    color:       var(--color-text-secondary);
    line-height: 1.4;
    word-break:  break-word;
}
.map-spot-coords {
    font-size:   0.78rem;
    color:       var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}
.map-spot-actions {
    display:     flex;
    align-items: center;
    flex-wrap:   wrap;
    gap:         5px;
    margin-top:  3px;
}
.map-spot-actions .fbc-icon-btn { width: 28px; height: 28px; }
.map-spot-spacer { flex: 1; }

.map-spot-journeys {
    display:        flex;
    flex-direction: column;
    gap:            6px;
    border-top:     1px solid var(--color-divider);
    padding-top:    10px;
}
.map-spot-label {
    font-size:      0.72rem;
    font-weight:    700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color:          var(--color-text-muted);
}
.map-spot-none {
    font-size:  0.85rem;
    font-style: italic;
    color:      var(--color-text-muted);
}
.map-spot-journey-list {
    display:        flex;
    flex-direction: column;
    gap:            4px;
}
/* A combo's members, under its chip: what its one marker stands for. */
.map-spot-members {
    display:        flex;
    flex-direction: column;
    gap:            4px;
}
.map-spot-member-chips {
    display:   flex;
    flex-wrap: wrap;
    gap:       4px;
}

/* A check-in's card (map.js _checkinCard). */
.map-ccard-title { font-weight: 700; font-size: 0.9rem; color: var(--color-text); }
.map-ccard-place { font-size: 0.95rem; color: var(--color-text); word-break: break-word; }

/* A journey listed anywhere on this page: its chip, and what can be done. */
.map-journey-row {
    display:       flex;
    align-items:   center;
    gap:           6px;
    min-width:     0;
    padding:       2px 0;
}
.map-journey-row-chip {
    min-width: 0;
    flex:      0 1 auto;
    cursor:    pointer;
}
.map-journey-row-chip:hover { filter: brightness(1.06); }
.map-journey-row-actions {
    display:     flex;
    gap:         3px;
    margin-left: auto;
    flex-shrink: 0;
}
.map-journey-row-actions .fbc-icon-btn { width: 28px; height: 28px; }

/* ── The context card (a right click on the map) ─────────────────── */
.map-ctx {
    display:        flex;
    flex-direction: column;
    align-items:    flex-start;
    gap:            8px;
}
.map-ctx-coords {
    font-size:   0.8rem;
    color:       var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ── The details view (the page's own right-pane view) ───────────── */
.map-details {
    display:        flex;
    flex-direction: column;
    flex:           1;
    min-height:     0;
}
.map-details-back:disabled { opacity: 0.3; }
.map-details-body {
    flex:       1;
    min-height: 0;
    overflow-y: auto;
    padding:    14px 14px 32px;
}
.map-details-empty {
    margin-top:  48px;
    text-align:  center;
    font-size:   0.9rem;
    line-height: 1.5;
    color:       var(--color-text-muted);
    padding:     0 12px;
}

/* ── The journey overlay (over the map) ──────────────────────────── */
.map-overlay-backdrop {
    position:        absolute;
    inset:           0;
    z-index:         1200;
    background:      rgba(0, 0, 0, 0.42);
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         24px 16px;
    box-sizing:      border-box;
}

.map-overlay {
    width:          100%;
    max-width:      680px;
    height:         100%;
    background:     var(--color-bg);
    border-radius:  12px;
    display:        flex;
    flex-direction: column;
    box-shadow:     0 8px 32px rgba(0, 0, 0, 0.35);
    overflow:       hidden;
}
.map-overlay-new {
    font-weight: 600;
    font-size:   0.95rem;
}
.map-overlay-body {
    flex:       1;
    overflow-y: auto;
    overflow-x: hidden;
    padding:    22px 26px 40px;
    box-sizing: border-box;
}

/* Narrow screens: the overlay is the whole pane. */
@media (max-width: 639px) {
    .map-overlay-backdrop { padding: 0; align-items: stretch; justify-content: stretch; }
    .map-overlay          { max-width: 100%; border-radius: 0; }
    .map-overlay-body     { padding: 16px 14px 32px; }
    .map-top              { max-width: calc(100% - 110px); }
    /* The bar keeps its line: the chip, and the buttons. */
    .map-crumb, .map-crumb-sep, .map-crumbs-meta { display: none; }
    .map-crumbs-chip, .map-crumbs-now            { flex: 1 1 auto; }
}

/* A PLACE's name plate (map-engine nameKind 'place'): lighter and slanted
   beside a journey's bold one, so a label says which kind of marker it
   belongs to before it says which one. */
.leaflet-tooltip.fbc-map-name.fbc-map-name--place {
    font-style:  italic;
    font-weight: 500;
    color:       var(--color-text-secondary);
    background:  rgba(255, 255, 255, 0.86);
    box-shadow:  none;
    outline:     1px solid rgba(0, 0, 0, 0.18);
}

/* "2 journeys hidden — Show all", above the tree (map.js HIDDEN). */
.map-hidden-note {
    display:       flex;
    align-items:   center;
    gap:           8px;
    margin:        4px 10px 6px;
    padding:       4px 6px 4px 10px;
    border-radius: 8px;
    background:    var(--color-hover);
    color:         var(--color-text-secondary);
    font-size:     0.8rem;
}
.map-hidden-note svg  { flex-shrink: 0; }
.map-hidden-text      { flex: 1; min-width: 0; }

/* A journey's own place, in its card: whose it is, where its actions would be. */
.map-spot-own {
    font-size:  0.8rem;
    font-style: italic;
    color:      var(--color-text-muted);
}

/* ── The timeline (map.js TIMELINE) ───────────────────────────────────
   Along the bottom of the map, clear of the attribution line under it —
   or down its left side, under the zoom buttons, where the map is a fifth
   taller than wide.  Over the map, so it never moves the map itself.  Its
   words on top, the strip under them. */
.map-timeline {
    position:       absolute;
    left:           10px;
    right:          10px;
    bottom:         24px;
    height:         94px;
    z-index:        1040;
    padding:        4px 6px;
    border-radius:  10px;
    background:     rgba(255, 255, 255, 0.93);
    box-shadow:     0 2px 8px rgba(0, 0, 0, 0.25);
    display:        flex;
    flex-direction: column;
    gap:            2px;
}
.map-timeline:not([hidden]) { display: flex; }
.map-timeline .fbc-tl { flex: 1 1 auto; min-height: 0; }
.map-timeline-caption {
    flex:          none;
    padding:       0 4px;
    font-size:     0.78rem;
    font-weight:   600;
    color:         var(--color-text);
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
}
.map-timeline--vertical {
    right:  auto;
    top:    var(--map-tl-top, 120px);
    width:  120px;
    height: auto;
}
/* Narrow: its words wrap rather than vanish. */
.map-timeline--vertical .map-timeline-caption { white-space: normal; }
/* A message stays above the strip. */
.map-has-timeline .map-toast { bottom: 130px; }

/* Its button, under the zoom buttons (a Leaflet control: leaflet-bar). */
.map-timeline-toggle {
    display:         flex;
    align-items:     center;
    justify-content: center;
    width:           30px;
    height:          30px;
    padding:         0;
    border:          none;
    background:      #fff;
    color:           var(--color-text-secondary);
    cursor:          pointer;
}
.map-timeline-toggle svg { width: 16px; height: 16px; }
.map-timeline-toggle:hover { background: #f4f4f4; }
.map-timeline-toggle--on { color: var(--color-primary); background: var(--color-selected); }
.map-timeline-toggle[aria-disabled="true"] { opacity: 0.4; cursor: default; }

/* ── The Map: Discover mode's left pane (map-discover.js) ──────────── */

.map-discover {
    display:        flex;
    flex-direction: column;
    gap:            12px;
    padding:        12px;
}
.map-discover[hidden] { display: none; }
.map-discover-intro,
.map-discover-note {
    margin:    0;
    font-size: 0.8rem;
    color:     var(--color-text-secondary);
}
.map-discover-list {
    list-style:     none;
    margin:         0;
    padding:        0;
    display:        flex;
    flex-direction: column;
    gap:            8px;
}
.map-discover-item {
    padding:       8px 10px;
    border:        1px solid var(--color-divider);
    border-radius: 10px;
}
/* An item: its chip, whose it is, where in their tree — the row's and the marker's card alike. */
.map-discover-card {
    display:        flex;
    flex-direction: column;
    align-items:    flex-start;
    gap:            4px;
    min-width:      0;
}
.map-discover-who {
    display:     flex;
    align-items: center;
    gap:         6px;
    font-size:   0.85rem;
    min-width:   0;
}
.map-discover-face {
    width:         22px;
    height:        22px;
    border-radius: 50%;
    object-fit:    cover;
    flex:          0 0 auto;
}
.map-discover-name   { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-discover-handle { color: var(--color-text-secondary); }
.map-discover-path   { font-size: 0.8rem; color: var(--color-text-secondary); }
