/*
 * Issue #402 (design 402 D7, D19, section 4) - the journey map module's styles, for the owner's
 * Story Mode, the Shelf and (from S6) the public page, which links this file under /j/assets/css/.
 *
 * journey-map.js injects NO <style> element (the public page's style-src 'self' would block it), so
 * every pin, cluster, glow, pop card, Trip numbers sheet, battery profile and route-outline class
 * lives here (the sheet and the profile are shared components the public page renders too, and it
 * does not load the scoped .razor.css bundle). Colours are
 * the tokens in tokens.css only; no copied hex.
 *
 * Day colours (D19) cycle primary, tertiary, secondary, primary-dark by the day's position (jm-c0 to
 * jm-c3). The one accent, --cailo-tertiary-light, is kept out of the cycle so a selection always
 * stands out. Live uses --cailo-warning.
 */

.jm-c0 { --jm-day: var(--cailo-primary); }
.jm-c1 { --jm-day: var(--cailo-tertiary); }
.jm-c2 { --jm-day: var(--cailo-secondary); }
.jm-c3 { --jm-day: var(--cailo-primary-dark); }

/* ------------------------------------------------------------------ the map */
.jm-map { position: relative; background: var(--cailo-primary-05); }
.jm-map.leaflet-container { font-family: var(--cailo-font-family-body); }
.jm-armed, .jm-armed .leaflet-interactive { cursor: crosshair; }
.jm-map.jm-dragover { box-shadow: inset 0 0 0 3px var(--cailo-tertiary-light); }
/* A still map (journey-map.js setInteractive): a picture, so no zoom buttons and a tap cursor. */
.jm-still .leaflet-control-zoom { display: none; }
.jm-still, .jm-still .leaflet-interactive { cursor: pointer; }

/* Legs: one path each, coloured by CSS so the token is the only source (Leaflet's stroke attribute is
   a presentation attribute, which any rule outranks). */
.jm-leg { stroke: var(--jm-day, var(--cailo-primary)); stroke-width: 5px; stroke-opacity: 0.9; transition: stroke-opacity 0.25s ease; }
.jm-leg.jm-dim { stroke-opacity: 0.22; }
/* A leg's FSD (Supervised) stretches (cailoDriveAssist.draw, coloured there as on trip details) fade with it. */
.jm-fsd { transition: opacity 0.25s ease; }
.jm-fsd.jm-dim { opacity: 0.22; }
.jm-glow { stroke: var(--cailo-tertiary-light); stroke-width: 13px; stroke-opacity: 0.55; pointer-events: none; }
.jm-hover { stroke-width: 7px; }
.jm-linger { fill: var(--cailo-primary-light); fill-opacity: 0.16; stroke: none; pointer-events: none; }
/* Share readiness section 6: a circle photos taken inside a hidden area are shown in (public only, never a hidden zone). */
.jm-area, .pj-area { fill: var(--cailo-primary); fill-opacity: 0.1; stroke: var(--cailo-primary); stroke-opacity: 0.55; stroke-width: 2px; stroke-dasharray: 6 6; vector-effect: non-scaling-stroke; pointer-events: none; }
/* UI review H2 (hide v2): on the live map the circle sits over basemap tiles, whose town labels
   ("Yamba", "BRISBANE") showed through a see-through fill and made hiding look as if it had failed.
   The fill is opaque, a pale brand tint (surface first, for a browser without color-mix), so the
   tiles under it are knocked out; every route is cut at the edge, so nothing drawn is lost under it.
   The server SVG (.pj-area) has no basemap and keeps its see-through fill. */
.jm-area { fill: var(--cailo-surface); fill: color-mix(in srgb, var(--cailo-primary) 12%, var(--cailo-surface)); fill-opacity: 1; }

/* Pins (A-22: every pin is a named, keyboard-reachable button). Leaflet's divIcon box is unstyled. */
.jm-icon { background: none; border: 0; }
.jm-pin { position: relative; box-sizing: border-box; transition: transform 0.2s ease, opacity 0.25s ease; }
.jm-pin-photo { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--cailo-white); background: var(--cailo-white); box-shadow: 0 0 0 3px var(--jm-day, var(--cailo-primary)), 0 6px 14px var(--cailo-black-30); overflow: hidden; }
.jm-pin-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.jm-pin-note { width: 36px; height: 36px; border-radius: 50% 50% 50% 6px; border: 3px solid var(--cailo-white); background: var(--cailo-slate-grey); color: var(--cailo-white); display: grid; place-items: center; font: 700 24px/1 Georgia, serif; box-shadow: 0 6px 14px var(--cailo-black-30); }
.jm-pin-count { position: absolute; right: -6px; bottom: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--cailo-primary-dark); color: var(--cailo-white); border: 2px solid var(--cailo-white); font: 700 11px/16px var(--cailo-font-family-headings); text-align: center; }
.jm-pin-stop { width: 30px; height: 30px; border-radius: 50%; background: var(--cailo-warning); border: 3px solid var(--cailo-white); box-shadow: 0 0 0 2px var(--cailo-warning-dark), 0 6px 14px var(--cailo-black-30); display: grid; place-items: center; }
.jm-pin-stop svg { width: 16px; height: 16px; fill: var(--cailo-dark); }
.jm-pin.jm-dim { opacity: 0.35; }
.jm-pin.jm-sel, .jm-pin.jm-hov, .leaflet-marker-icon:hover .jm-pin, .leaflet-marker-icon:focus-visible .jm-pin { transform: scale(1.18); }
.jm-pin.jm-sel { box-shadow: 0 0 0 4px var(--cailo-tertiary-light), 0 8px 18px var(--cailo-black-30); }
.leaflet-marker-icon.jm-icon:focus-visible { outline: 3px solid var(--cailo-primary); outline-offset: 3px; border-radius: 50%; }

.jm-cluster { position: relative; width: 54px; height: 54px; }
.jm-cluster img { position: absolute; left: 0; top: 0; width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 3px solid var(--cailo-white); box-shadow: 0 6px 16px var(--cailo-black-30); background: var(--cailo-white); }
.jm-cluster-quote { position: absolute; left: 0; top: 0; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--cailo-slate-grey); color: var(--cailo-white); border: 3px solid var(--cailo-white); font: 700 26px/1 Georgia, serif; }
.jm-cluster-n { position: absolute; right: -4px; bottom: -2px; min-width: 22px; padding: 2px 6px; border-radius: 11px; background: var(--cailo-primary-dark); color: var(--cailo-white); border: 2px solid var(--cailo-white); font: 700 12px/16px var(--cailo-font-family-headings); text-align: center; }

.jm-draft { width: 22px; height: 22px; border-radius: 50%; background: var(--cailo-tertiary-light); border: 4px solid var(--cailo-white); box-shadow: 0 0 0 8px var(--cailo-primary-25), 0 6px 14px var(--cailo-black-30); }
.jm-car { width: 22px; height: 22px; border-radius: 50%; background: var(--cailo-white); border: 4px solid var(--cailo-tertiary-light); box-shadow: 0 0 0 8px var(--cailo-primary-25), 0 6px 14px var(--cailo-black-30); }
.jm-scrub-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--cailo-warning); border: 3px solid var(--cailo-white); box-shadow: 0 2px 8px var(--cailo-black-40); }

/* ------------------------------------------------------------------ the pop card (a clone of the story's [data-pop]) */
/* --jm-pop-bottom: a host with something docked along the bottom of the map (the Trip numbers pill) lifts the card above it; journey-map.js sets it from the pill. */
.jm-pop { position: absolute; z-index: 800; left: 12px; bottom: var(--jm-pop-bottom, 12px); width: min(320px, calc(100% - 24px)); max-height: calc(100% - var(--jm-pop-bottom, 12px) - 12px); overflow: auto; background: var(--cailo-surface); border-radius: var(--cailo-border-radius-lg); box-shadow: 0 14px 36px var(--cailo-black-30); padding: 14px 16px 12px; font-family: var(--cailo-font-family-body); color: var(--cailo-text-primary); animation: jm-pop-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.jm-pop[hidden] { display: none; }
.jm-pop-body img { display: block; max-width: 100%; height: auto; border-radius: var(--cailo-border-radius); }
.jm-pop-body p { margin: 6px 0 0; }
.jm-pop-close { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--cailo-light-bg); color: var(--cailo-text-primary); font: 700 18px/1 var(--cailo-font-family-body); cursor: pointer; }
.jm-pop-read { display: inline-block; margin-top: 10px; font-weight: 700; font-size: 13px; color: var(--cailo-primary-hover); text-decoration: none; }
.jm-pop-read:hover { text-decoration: underline; }
.jm-pop-close:focus-visible, .jm-pop-read:focus-visible, .jm-follow:focus-visible, .jm-replay-stop:focus-visible { outline: 3px solid var(--cailo-primary); outline-offset: 2px; }
@keyframes jm-pop-in { from { transform: translateY(8px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ map controls */
.jm-follow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 0; border-radius: 999px; background: var(--cailo-surface); color: var(--cailo-text-primary); font: 600 13px/1.2 var(--cailo-font-family-body); box-shadow: 0 4px 12px var(--cailo-black-20); cursor: pointer; }
.jm-follow-box { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--cailo-primary); display: grid; place-items: center; }
.jm-follow[aria-checked="true"] .jm-follow-box { background: var(--cailo-primary); }
.jm-follow[aria-checked="true"] .jm-follow-box::after { content: ""; width: 7px; height: 4px; border-left: 2px solid var(--cailo-white); border-bottom: 2px solid var(--cailo-white); transform: rotate(-45deg) translate(1px, -1px); }
.jm-replay-stop { position: absolute; z-index: 790; top: 12px; left: 50%; transform: translateX(-50%); padding: 7px 16px; border: 0; border-radius: 999px; background: var(--cailo-primary-dark); color: var(--cailo-white); font: 700 13px/1.2 var(--cailo-font-family-headings); box-shadow: 0 10px 26px var(--cailo-black-30); cursor: pointer; }

/* ------------------------------------------------------------------ Trip numbers: the pill and its sheet (map panel B, JourneyNumbersSheet) */
/* A layer over the map, under Leaflet's controls (z-index 1000, so the attribution stays visible) and
   over the pop card (800). It passes the map's pointer events through; only the pill and the sheet
   take them. --jms-height is set by each page (about half the map); below 1024 px the open sheet is
   a bottom sheet over the page instead (the block after these rules). */
.jms { position: absolute; inset: 0; z-index: 900; overflow: hidden; pointer-events: none; font-family: var(--cailo-font-family-body); color: var(--cailo-text-primary); }
.jms[hidden] { display: none; }
.jms-pill { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; max-width: calc(100% - 24px); min-height: 40px; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--cailo-surface); color: var(--cailo-primary-dark); font: 700 13.5px/1.2 var(--cailo-font-family-body); white-space: nowrap; box-shadow: 0 8px 22px var(--cailo-black-20); cursor: pointer; pointer-events: auto; }
.jms-pill-facts { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--cailo-text-secondary); font-weight: 600; }
.jms-pill-chev { flex: none; font-size: 14px; }
.jms.is-open .jms-pill { visibility: hidden; }
.jms-sheet { position: absolute; left: 0; right: 0; bottom: 0; height: var(--jms-height, 58%); overflow-y: auto; overscroll-behavior: contain; padding: 6px 16px 28px; background: var(--cailo-surface); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px var(--cailo-black-30); transform: translateY(105%); visibility: hidden; pointer-events: auto; transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1), visibility 0s linear 0.32s; }
.jms.is-open .jms-sheet { transform: none; visibility: visible; transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1); }
.jms-sheet:focus { outline: none; }
.jms-grab { width: 40px; height: 5px; margin: 4px auto 6px; border-radius: 3px; background: var(--cailo-border-color); }
.jms-head { position: sticky; top: -6px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 8px; background: var(--cailo-surface); }
.jms-title { margin: 0; font: 700 16px/1.25 var(--cailo-font-family-headings); color: var(--cailo-primary-dark); }
.jms-close, .jms-link { min-height: 32px; padding: 6px 4px; border: 0; background: none; color: var(--cailo-primary-hover); font: 700 13px/1.2 var(--cailo-font-family-headings); text-align: left; cursor: pointer; }
.jms-link:hover, .jms-close:hover { text-decoration: underline; }
.jms-figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin: 2px 0 12px; }
.jms-fig { display: flex; flex-direction: column; min-width: 0; padding: 7px 10px; border: 1px solid var(--cailo-border-color); border-radius: 10px; }
.jms-fig dt { order: 2; font-size: 11.5px; color: var(--cailo-text-secondary); }
.jms-fig dd { order: 1; margin: 0; font: 700 15px/1.3 var(--cailo-font-family-headings); color: var(--cailo-primary-dark); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.jms-foot, .jms-note { margin: 10px 0 0; }
.jms-note { font-size: 12.5px; color: var(--cailo-text-secondary); }
.jms-pill:focus-visible, .jms-close:focus-visible, .jms-link:focus-visible { outline: 3px solid var(--cailo-primary); outline-offset: 2px; }
.jms-highlights { margin: 12px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.45; }
.jms-highlights li + li { margin-top: 4px; }

/* S11 defect 1: below 1024 px both pages stack the map as a band over the story (38vh on Story Mode,
   42vh on the public page), and a sheet inside it had under 210 px to scroll 700+ px through, with
   the story card painted over the rest. There the sheet is a bottom sheet over the PAGE: fixed, about
   85% of the viewport (clear of an app bar), its own scroll, so the battery profile is seen whole and
   the top of the map band stays in view above it. Open, its layer rises over Leaflet's controls
   (1000) and, on Story Mode, the map column rises over the story card (z-index 2), whose stacking
   context would otherwise hold the fixed sheet under it. The slide and reduced motion are unchanged. */
@media (max-width: 1023.98px) {
    .jms.is-open { z-index: 1100; }
    .jms-sheet {
        position: fixed;
        height: min(85vh, calc(100vh - 72px));
        height: min(85dvh, calc(100dvh - 72px));
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    }
    .jr-mapcol:has(.jms.is-open) { z-index: 3; }
}

/* UI review H1 (390): under Fine-tune the phone composer is a slim bar, and the map must be seen
   to drag the pin. Opened partway down the page, the story card (z-index 2) painted over the sticky
   map column (z-index 1); while Fine-tune is on, the column rises over it, as for the open sheet above. */
@media (max-width: 599.98px) {
    .jr-stage:has(.mc.is-finetune) .jr-mapcol { z-index: 3; }
}

/* ------------------------------------------------------------------ the battery profile (map panel B, JourneyBatteryProfile) */
/* x is a percentage of the plot's width and y a pixel of its fixed 176 px height (no style attribute
   on the public page), so nothing here sets a width or a height on the drawing beyond those two. */
.jbp { margin: 4px 0 0; }
.jbp-title { margin: 4px 0 6px; font: 700 12px/1.3 var(--cailo-font-family-headings); letter-spacing: 0.08em; text-transform: uppercase; color: var(--cailo-primary-hover); }
.jbp-chart { position: relative; display: flex; }
.jbp-yaxis { flex: none; display: block; width: 34px; height: 176px; overflow: visible; }
.jbp-plot { position: relative; flex: 1 1 auto; min-width: 0; height: 176px; border-radius: 8px; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.jbp-plot[role="slider"] { cursor: crosshair; }
.jbp-plot:focus { outline: none; }
.jbp-plot:focus-visible { outline: 3px solid var(--cailo-primary); outline-offset: 2px; }
.jbp-svg, .jbp-marks { display: block; width: 100%; height: 176px; overflow: visible; }
.jbp-marks { position: absolute; top: 0; left: 34px; width: calc(100% - 34px); pointer-events: none; }
.jbp-day, .jbp-bolt { overflow: visible; }
.jbp-marks [role="button"] { pointer-events: auto; cursor: pointer; }
.jbp-marks [role="button"]:focus { outline: none; }
.jbp-grid { stroke: var(--cailo-border-color); stroke-width: 1; shape-rendering: crispEdges; }
.jbp-dayline { stroke: var(--cailo-text-disabled); stroke-width: 1; }
.jbp-axis { font: 600 10px var(--cailo-font-family-body); fill: var(--cailo-text-secondary); }
.jbp-area { fill: var(--jm-day, var(--cailo-primary)); opacity: 0.12; }
.jbp-line { stroke: var(--jm-day, var(--cailo-primary)); stroke-width: 2.5; stroke-linecap: round; }
.jbp-end { fill: var(--jm-day, var(--cailo-primary)); stroke: var(--cailo-surface); stroke-width: 2; }
.jbp-jump { stroke: var(--cailo-warning-dark); stroke-width: 2; }
.jbp-gap { stroke: var(--cailo-text-disabled); stroke-width: 1.5; stroke-dasharray: 2 3; }
.jbp-hatch-bg { fill: var(--cailo-surface); }
.jbp-hatch-line { stroke: var(--cailo-border-color); stroke-width: 2.5; }
.jbp-hidden-t { font: 600 10px var(--cailo-font-family-body); fill: var(--cailo-text-secondary); }
.jbp-label, .jbp-label-s { paint-order: stroke; stroke: var(--cailo-surface); stroke-width: 3px; stroke-linejoin: round; }
.jbp-label { font: 700 10.5px var(--cailo-font-family-body); fill: var(--cailo-text-primary); }
.jbp-label-s { font: 600 9.5px var(--cailo-font-family-body); fill: var(--cailo-text-secondary); }
.jbp-day-swatch { fill: var(--jm-day, var(--cailo-primary)); }
.jbp-day-t { font: 700 10.5px var(--cailo-font-family-headings); fill: var(--cailo-text-primary); }
.jbp-day-date { font: 600 10px var(--cailo-font-family-body); fill: var(--cailo-text-secondary); }
.jbp-day[role="button"]:hover .jbp-day-t, .jbp-day[role="button"]:focus-visible .jbp-day-t { fill: var(--cailo-primary-hover); text-decoration: underline; }
.jbp-day[role="button"]:focus-visible .jbp-day-swatch { stroke: var(--cailo-primary); stroke-width: 3; }
.jbp-bolt circle { fill: var(--cailo-warning); stroke: var(--cailo-surface); stroke-width: 2; }
.jbp-bolt path { fill: var(--cailo-primary-dark); }
.jbp-bolt[role="button"]:hover circle, .jbp-bolt[role="button"]:focus-visible circle { stroke: var(--cailo-primary); stroke-width: 3; }
.jbp-cross { stroke: var(--cailo-text-primary); stroke-width: 1; pointer-events: none; }
.jbp-cdot { fill: var(--jm-day, var(--cailo-primary)); stroke: var(--cailo-surface); stroke-width: 2; pointer-events: none; }
.jbp-tip { position: absolute; z-index: 3; top: 24px; left: 0; max-width: 260px; padding: 5px 9px; border-radius: 8px; background: var(--cailo-dark); color: var(--cailo-white); font-size: 12px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; transform: translate(-50%, -100%); }
.jbp-tip[hidden] { display: none; }
.jbp-tip b { font-family: var(--cailo-font-family-headings); }
.jbp-summary { margin: 8px 0 0; font-size: 13px; color: var(--cailo-text-primary); }
.jbp-table { margin-top: 6px; font-size: 13px; }
.jbp-table summary { min-height: 32px; padding: 6px 0; color: var(--cailo-primary-hover); font-weight: 700; cursor: pointer; }
.jbp-table summary:focus-visible { outline: 3px solid var(--cailo-primary); outline-offset: 2px; }
.jbp-tablewrap { overflow-x: auto; }
.jbp-table table { width: 100%; border-collapse: collapse; }
.jbp-table th, .jbp-table td { padding: 6px 8px; border-bottom: 1px solid var(--cailo-border-color); text-align: left; vertical-align: top; }
.jbp-table thead th { font: 700 12px var(--cailo-font-family-headings); color: var(--cailo-primary-dark); }
.jbp-table tbody th { font-weight: 600; }
/* Its colour is the shared FSD figure's (.fsd-figure, wwwroot/css/drive-assist.css). */
.jbp-fsd { display: block; font-weight: 400; font-size: 12px; }

/* A narrow sheet keeps the levels and drops the words that would collide. */
@media (max-width: 599.98px) {
    .jbp-label-s, .jbp-day-date { display: none; }
}

/* ------------------------------------------------------------------ the route outline (server SVG)
   Copied from journey.css's map classes for the owner pages, which do not load journey.css. S6
   deletes them from journey.css when the public page links this file (design D7). */
.pj-map { margin: 0; }
.pj-map-svg { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--cailo-primary-05); }
.pj-route { stroke: var(--cailo-primary); stroke-width: 4px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.pj-end { fill: var(--cailo-white); stroke: var(--cailo-primary); stroke-width: 3px; vector-effect: non-scaling-stroke; }
.pj-pin { stroke: var(--cailo-white); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.pj-pin-chargingstop { fill: var(--cailo-primary-hover); }
.pj-pin-photo { fill: var(--cailo-tertiary); }
/* Moment (note) pins are Slate Grey (brand neutral, style-guide.md) on every journey map and the legend (.jm-pin-note, .jm-cluster-quote, .pj-pin-note, .pj-key-note):
   not a route or day colour, not a charging colour, and not violet, which means FSD only. 8.2:1 against the white outline. */
.pj-pin-note { fill: var(--cailo-slate-grey); }

/* A cover without a photo is THE route cover (JourneyCoverArt, journey-story.css .jca-*), owner requirement 2026-11-07. */

/* Animate (PublicJourneyMapSvg): each run has pathLength="1", so one dash of length 1 draws it in. */
.pj-map-svg--animate .pj-route { stroke-dasharray: 1; stroke-dashoffset: 1; animation: jm-draw 1.6s ease-out 0.2s forwards; }
@keyframes jm-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    .pj-map-svg--animate .pj-route { animation: none; stroke-dashoffset: 0; }
    .jm-pop { animation: none; }
    .jm-pin, .jm-leg, .jm-fsd { transition: none; }
    .jms-sheet, .jms.is-open .jms-sheet { transition: none; }
}
