/* nearest.css — layout for the standalone Nearest Printings page.
   map.css (loaded first) supplies the CSS variables, chips, card internals,
   search-result rows, and the fixed #theme-toggle button; this file only adds
   the page column and the pieces unique to this page. Don't touch map.css. */

body {
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-y: auto;
}

.nearest-wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 28px 20px 40px;
    box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.nearest-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.nearest-title { margin: 0; font-size: 24px; font-weight: 700; }
.nearest-tagline { margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); }
.nearest-back {
    flex-shrink: 0;
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    padding: 7px 12px;
    background: var(--bg-panel);
    white-space: nowrap;
}
.nearest-back:hover { background: var(--bg-panel-hover-strong); color: var(--text-primary); }

/* ── Search box + dropdown (reuses .search-result-item rows from map.css) ──── */
.nearest-search { position: relative; margin-bottom: 16px; }

#place-input {
    width: 100%;
    padding: 10px 14px;
    box-sizing: border-box;
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-search-main);
    font-size: 14px;
    outline: none;
    box-shadow: var(--shadow-input);
}
#place-input::placeholder { color: var(--text-placeholder); }
#place-input:focus {
    border-color: var(--border-panel-focus);
    background: var(--bg-input-focus);
}

#place-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    background: var(--bg-dropdown);
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    max-height: 340px;
    overflow-y: auto;
    box-shadow: var(--shadow-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 100;
}

/* ── Mini map ──────────────────────────────────────────────────────────────── */
#mini-map {
    height: 400px;
    border-radius: 12px;
    border: 1px solid var(--border-panel);
    overflow: hidden;
    background: var(--bg-body);
}

/* Numbered result dot placed on the mini map */
.nearest-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #3a7fd5;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
    font-size: 12px;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
}
.nearest-marker.active { background: #e69f00; }
/* Stacked markers half-cover each other — lift the hovered/selected one */
.mapboxgl-marker:hover { z-index: 10; }
.mapboxgl-marker:has(.nearest-marker.active) { z-index: 9; }
.nearest-marker-origin {
    background: #e63939;
    cursor: default;
    font-size: 13px;
}

/* Edge indicator for an off-screen point: small circle clamped to the map
   edge in the point's direction (positioned by nearest.js on every map move) */
.nearest-edge-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3a7fd5;
    color: #fff;
    border: 1.5px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    transform: translate(-50%, -50%);
    opacity: 0.85;
    z-index: 5;
}
.nearest-edge-dot:hover { opacity: 1; }
.nearest-edge-dot.active { background: #e69f00; }
.nearest-edge-dot.nearest-edge-origin {
    background: #e63939;
    cursor: default;
    font-size: 11px;
}

/* ── Results list ──────────────────────────────────────────────────────────── */
#nearest-results { margin-top: 16px; }

.nearest-status {
    padding: 20px 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.nearest-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    background: var(--bg-panel);
    margin-bottom: 8px;
    cursor: pointer;
}
.nearest-row:hover,
.nearest-row.active { background: var(--bg-panel-hover-strong); }

.nearest-row-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3a7fd5;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
.nearest-row.active .nearest-row-num { background: #e69f00; }

.nearest-row-body { flex: 1; min-width: 0; }
.nearest-row-main {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nearest-row-heb { font-weight: 500; color: var(--text-secondary); margin-left: 6px; }
.nearest-row-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nearest-row-dist {
    flex-shrink: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Summary card (internals styled by map.css card-* / chip-* classes) ────── */
#nearest-card {
    margin-top: 16px;
    border: 1px solid var(--border-panel);
    border-radius: 12px;
    background: var(--bg-panel);
    overflow: hidden;
    position: relative;
}
#nearest-card .card-close {
    position: absolute;
    top: 8px;
    right: 10px;
}
#nearest-card .nearest-card-body { padding: 12px 16px 16px; }
/* The nearest card body pads itself, so the shared ask row drops its inset. */
#nearest-card .card-ask-row { padding: 6px 0 0; font-size: 11px; }
#nearest-card .card-btn-main {
    display: inline-block;
    text-decoration: none;
    margin-top: 12px;
}
.nearest-card-dist {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.nearest-footer {
    margin-top: 26px;
    font-size: 11px;
    color: var(--text-attribution);
    text-align: center;
}
.nearest-footer a { color: var(--text-attribution); text-decoration: none; }
.nearest-footer a:hover { color: var(--text-primary); text-decoration: underline; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .nearest-wrap { padding: 18px 14px 32px; }
    .nearest-header { flex-direction: column; gap: 10px; }
    .nearest-title { font-size: 20px; }
    #mini-map { height: 300px; }
    .nearest-row { padding: 9px 11px; }
}
