/* =================================================================
   MAPS - the Maps center (/maps) and the three map pages in the new frame
   (portal-look-and-feel.md 3.18 - Data Studio's lane: the frame around the
   map control only; Shared.UI.Components/Maps' MapControl is untouched).
   -----------------------------------------------------------------
   A TOKEN-ONLY DOOR, whole (Tests/ShellTokensOnlyTests): every colour reads
   a --theme-* / --wf-* token. ONE OWNER: map-studio__*, maps-center__*,
   dispatch__*, ans-map__* and ac-map__* (the Answers page's own map,
   /answer-center/map - its colours only) are styled here and nowhere else
   (Tests/ConversationBuilderCssOwnershipTests).

   The three map pages are APP pages: the rail is a card column on the left
   (its head names the page), the map fills the rest in a card of its own -
   the sheet's frame around them, never edge to edge. Under 900px of page the
   rail stacks above the map.
   ================================================================= */

/* ---- The Maps center (/maps) ---- */

.maps-center__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: var(--wf-space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.maps-center__card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    padding: 20px;
    color: inherit;
    text-decoration: none;
}

.maps-center__card:hover { color: inherit; }
.maps-center__card:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 2px; }
.maps-center__words { display: flex; flex: 1 1 auto; flex-direction: column; gap: 4px; }
.maps-center__title { color: var(--theme-text-emphasis); font-size: var(--wf-text-h3); font-weight: 650; }
.maps-center__desc { color: var(--theme-text-secondary); font-size: var(--wf-text-sm); line-height: 1.5; }
.maps-center__open { display: inline-flex; align-items: center; gap: 6px; color: var(--wf-primary-ink); font-size: var(--wf-text-sm); font-weight: 600; }

/* ---- The shared frame of the three map pages ---- */

.map-studio,
.dispatch,
.ans-map {
    position: relative;
    display: flex;
    flex: 1;
    gap: var(--wf-space-4);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.map-studio__rail,
.dispatch__panel,
.ans-map__rail {
    display: flex;
    flex: 0 0 340px;
    flex-direction: column;
    width: 340px;
    min-height: 0;
    background: var(--wf-card);
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-lg);
    box-shadow: var(--wf-elev-1);
}

.map-studio__rail,
.ans-map__rail {
    gap: 4px;
    padding: 16px;
    overflow-y: auto;
}

.dispatch__panel { width: 360px; flex-basis: 360px; overflow: hidden; }

.map-studio__main,
.dispatch__map {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--wf-card);
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-lg);
    box-shadow: var(--wf-elev-1);
}

.ans-map__canvas {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--wf-card);
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-lg);
    box-shadow: var(--wf-elev-1);
}

/* The head names the page: an icon tile, the title, one sentence (the PageHeader's shape, inside the rail). */
.map-studio__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.dispatch__panel > .map-studio__head { margin: 0; padding: 16px 16px 12px; }
.map-studio__head-words { flex: 1 1 auto; min-width: 0; }
.map-studio__title {
    margin: 0;
    color: var(--theme-text-emphasis);
    font-size: var(--wf-text-h2);
    font-weight: 650;
    letter-spacing: -0.012em;
    line-height: 1.3;
}
.map-studio__sub { margin: 2px 0 0; color: var(--theme-text-secondary); font-size: var(--wf-text-sm); line-height: 1.45; }

.map-studio__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    margin-bottom: 4px;
    color: var(--theme-text-muted);
    font-size: var(--wf-text-sm);
    text-decoration: none;
}
.map-studio__back:hover { color: var(--wf-primary-ink); }

/* A read that failed: a calm line with Try again. */
.map-studio__failed {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 4px 0 12px;
    padding: 12px 14px;
    border-radius: var(--wf-radius-md);
    background: var(--wf-inset);
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
}
.dispatch__panel > .map-studio__failed { margin: 0 16px 12px; }

.map-studio__skel { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.map-studio__skel-map { position: absolute; inset: 12px; min-height: 0; }

.map-studio__group { margin-bottom: 16px; }
.map-studio__label {
    display: block;
    margin-bottom: 6px;
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
    font-weight: 600;
}

/* The segmented control is the shared .wf-seg (components.css); here it spans the rail. */
.map-studio__seg { display: flex; width: 100%; margin-bottom: 10px; }
.map-studio__seg > button { flex: 1 1 0; min-width: 0; }

.map-studio__mb { margin-bottom: 8px; }
.map-studio__check { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--theme-text); font-size: var(--wf-text-sm); }
.map-studio__rule { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.map-studio__rule .form-control,
.map-studio__rule .form-select { flex: 1; min-width: 0; }
.map-studio__iconbtn {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    padding-inline: 0;
}
.map-studio__iconbtn > .bi { margin: 0; }
.map-studio__iconbtn[aria-pressed="true"] { background: var(--wf-primary-soft); border-color: var(--wf-primary-ink); color: var(--wf-primary-ink); }
.map-studio__wide { width: 100%; margin-top: 6px; justify-content: center; }
.map-studio__actions { display: flex; gap: 8px; margin: 4px 0 20px; }
.map-studio__hint { margin: 4px 0 0; color: var(--theme-text-muted); font-size: var(--wf-text-sm); }
.map-studio__hint--err { color: var(--wf-danger-ink); }
.map-studio__poi-brands { display: flex; gap: 6px; margin-bottom: 8px; }
.map-studio__poi-brands .btn { flex: 1; }

.map-studio__shortcuts { margin: 8px 0 0; padding: 0; list-style: none; }
.map-studio__shortcuts li { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.map-studio__shortcut-load {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--wf-line-strong);
    border-radius: var(--wf-radius-sm);
    background: var(--wf-card);
    color: var(--theme-text);
    font: inherit;
    font-size: var(--wf-text-sm);
    text-align: left;
    cursor: pointer;
}
.map-studio__shortcut-load:hover { background: var(--wf-card-hover); border-color: var(--wf-primary-ink); }

.map-studio__dir { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--wf-line); }
.map-studio__dir-summary { margin-bottom: 6px; color: var(--theme-text-emphasis); font-size: var(--wf-text-sm); font-weight: 600; }
.map-studio__dir-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.map-studio__dir-steps { max-height: 240px; margin: 0; padding-left: 1.1rem; overflow-y: auto; font-size: var(--wf-text-sm); }
.map-studio__dir-steps li { margin-bottom: 4px; }

.map-studio__linklike {
    padding: 0;
    border: 0;
    background: none;
    color: var(--wf-primary-ink);
    font-size: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* The facts line over the map: what was plotted, in words. */
.map-studio__stats {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--wf-line);
    font-size: var(--wf-text-sm);
}
.map-studio__stat { color: var(--theme-text); }
.map-studio__stat--muted { color: var(--theme-text-muted); }
.map-studio__stat--err { color: var(--wf-danger-ink); font-weight: 600; }
.map-studio__stat--warn { color: var(--wf-warning-ink); cursor: help; }

.map-studio__canvas,
.dispatch__canvas,
.ac-map__canvas { position: relative; flex: 1; min-height: 0; }

.map-studio__canvas .wf-map,
.dispatch__canvas .wf-map,
.ans-map__canvas .wf-map,
.ac-map__canvas .wf-map { height: 100%; border-radius: 0; }

.map-studio__nokey {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
    padding: 24px;
    background: var(--wf-inset);
    color: var(--theme-text-muted);
    text-align: center;
}

/* ---- The Job Map (/maps/dispatch) ---- */

.dispatch__config { padding: 0 16px 14px; border-bottom: 1px solid var(--wf-line); }
.dispatch__refresh { width: 100%; justify-content: center; }
.dispatch__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--wf-line); }
.dispatch__dot { display: inline-block; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--theme-text-muted); }
.dispatch__list { flex: 1; min-height: 0; padding: 8px; overflow-y: auto; }
.dispatch__job { display: flex; align-items: center; gap: 6px; border-radius: var(--wf-radius-sm); }
.dispatch__job:hover { background: var(--wf-card-hover); }
.dispatch__job-main {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    border: 0;
    border-radius: var(--wf-radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.dispatch__job-main:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: -2px; }
.dispatch__job-words { display: flex; flex-direction: column; min-width: 0; }
.dispatch__job-label { overflow: hidden; color: var(--theme-text-emphasis); font-size: var(--wf-text-sm); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dispatch__job-status { color: var(--theme-text-muted); font-size: var(--wf-text-xs); }

/* ---- The Answers map (/maps/answers) ---- */

.ans-map__mode { margin-bottom: 14px; }
.ans-map__stats { margin-bottom: 14px; color: var(--theme-text-muted); font-size: var(--wf-text-sm); }
.ans-map__stats strong { color: var(--theme-text-emphasis); }
.ans-map__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ans-map__wfs { display: flex; flex-direction: column; gap: 4px; max-height: 14rem; overflow-y: auto; }
.ans-map__wf { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0; font-size: var(--wf-text-sm); cursor: pointer; }
.ans-map__dot { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; }
.ans-map__wf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ans-map__wf-count { color: var(--theme-text-muted); font-size: var(--wf-text-xs); font-variant-numeric: tabular-nums; }
.ans-map__locate { display: flex; gap: 6px; }
.ans-map__locate .form-control { flex: 1; min-width: 0; }
.ans-map__hint { margin-top: 6px; color: var(--theme-text-muted); font-size: var(--wf-text-xs); }
.ans-map__skel-photos { height: 96px; }

/* The story side panel - floats over the map (elevation 3, the float surface). */
.ans-map__panel {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: 340px;
    overflow: hidden;
    background: var(--theme-background-float);
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-lg);
    box-shadow: var(--wf-elev-3);
}
.ans-map__panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 14px 16px 8px; }
.ans-map__panel-title { display: flex; align-items: center; gap: 6px; color: var(--theme-text-emphasis); font-weight: 650; }
.ans-map__panel-sub { color: var(--theme-text-muted); font-size: var(--wf-text-sm); }
.ans-map__panel-close {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--wf-radius-sm);
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
}
.ans-map__panel-close:hover { background: var(--wf-card-hover); color: var(--theme-text-emphasis); }
.ans-map__panel-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 0 16px 10px;
    border-bottom: 1px solid var(--wf-line);
    color: var(--theme-text-muted);
    font-size: var(--wf-text-sm);
}

/* A run's state: a word with a dot in its state ink (3.3 - the Answer Center's grammar): created neutral, in progress
   the brand, completed success, abandoned (stopped early) warning, errored danger. */
.ans-map__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 9px 0 7px;
    border-radius: var(--wf-radius-pill);
    background: var(--wf-neutral-soft);
    color: var(--theme-text-secondary);
    font-size: 11.5px;
    font-weight: 600;
}
.ans-map__badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ans-map__badge--2 { background: var(--wf-primary-soft); color: var(--wf-primary-ink); }
.ans-map__badge--3 { background: var(--wf-success-soft); color: var(--wf-success-ink); }
.ans-map__badge--4 { background: var(--wf-warning-soft); color: var(--wf-warning-ink); }
.ans-map__badge--5 { background: var(--wf-danger-soft); color: var(--wf-danger-ink); }
.ans-map__badge--geo { background: var(--wf-neutral-soft); color: var(--theme-text-secondary); }
.ans-map__badge--geo::before { content: none; }

.ans-map__panel-body { flex: 1; min-height: 0; padding: 12px 16px; overflow-y: auto; }
.ans-map__summary {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: var(--wf-radius-md);
    background: var(--wf-inset);
    font-size: var(--wf-text-sm);
    white-space: pre-wrap;
}
.ans-map__photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ans-map__photos img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-sm);
    transition: transform 0.12s ease;
}
.ans-map__photos a:hover img { transform: scale(1.04); }
.ans-map__panel-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--wf-line); }

/* ---- The Answers page's own map (/answer-center/map - AnswerCenterMap.razor): its colours on tokens ---- */

.ac-map { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.ac-map__bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--wf-line);
    background: var(--wf-card);
}
.ac-map__back { display: inline-flex; align-items: center; gap: 6px; color: var(--theme-text-muted); font-size: var(--wf-text-sm); text-decoration: none; }
.ac-map__back:hover { color: var(--wf-primary-ink); }
.ac-map__title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 1.05rem; }
.ac-map__count { margin-left: auto; color: var(--theme-text-muted); font-size: var(--wf-text-sm); }
.ac-map__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--wf-line); background: var(--wf-card); }
.ac-map__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--wf-line-strong);
    border-radius: var(--wf-radius-pill);
    background: var(--wf-card);
    color: var(--theme-text);
    font-size: 12.5px;
    cursor: pointer;
}
.ac-map__chip--active { background: var(--wf-primary-soft); border-color: var(--wf-primary-ink); color: var(--wf-primary-ink); }

/* ---- A narrow page, and a touch screen ---- */

/* Under 900px of page the rail stacks above the map (the rail keeps at most half the height). */
@container page (max-width: 900px) {
    .map-studio,
    .dispatch,
    .ans-map { flex-direction: column; gap: 12px; }

    .map-studio__rail,
    .dispatch__panel,
    .ans-map__rail { flex: 0 0 auto; width: auto; max-height: 50%; }

    .ans-map__panel { left: 12px; width: auto; }
}

/* 44px targets and 16px inputs on a coarse pointer (3.17). */
@media (pointer: coarse) {
    .map-studio__rail .btn,
    .dispatch__panel .btn,
    .ans-map__rail .btn,
    .map-studio__iconbtn,
    .map-studio__seg > button,
    .ans-map__panel-close { min-width: 44px; min-height: 44px; }

    .map-studio__rail .form-control,
    .map-studio__rail .form-select,
    .dispatch__panel .form-control,
    .dispatch__panel .form-select,
    .ans-map__rail .form-control { min-height: 44px; font-size: 16px; }

    .map-studio__shortcut-load,
    .map-studio__back,
    .ans-map__wf { min-height: 44px; }
    /* A checkbox's target is its label (Geocode addresses, Share with my team). */
    .map-studio__check { min-height: 44px; }
}
