/**
 * FYSH — TN Postcode Search Pilot
 * CR: fysh-tn-pilot-2026-07-15
 * Namespace: tnp-
 * Page: /tn-pilot
 */

/* ── Page root — fills viewport, stacks hero + workspace ───────────────────── */
#tnp-root {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 69px); /* full viewport minus sticky header */
    overflow: hidden;
}
.tnp-hero {
    background: var(--navy);
    padding: 28px 0 24px;
    border-bottom: 3px solid var(--gold);
    flex-shrink: 0;
}
.tnp-hero__inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.tnp-hero__tag { margin-bottom: 10px; }
.tnp-hero__headline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 260px;
}
.tnp-hero__title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--cream);
    margin: 0;
    line-height: 1.2;
}
.tnp-hero__sub {
    font-size: 0.875rem;
    color: rgba(246,245,242,0.72);
    margin: 0;
    line-height: 1.6;
    max-width: 640px;
}
.tnp-hero__meta {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding-top: 4px;
}
.tnp-hero__stat {
    text-align: center;
}
.tnp-hero__stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}
.tnp-hero__stat-lbl {
    font-size: 0.7rem;
    color: rgba(246,245,242,0.55);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* ── Live badge ────────────────────────────────────────────────────────────── */
.tnp-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    border: 1px solid rgba(34,197,94,0.4);
    background: rgba(34,197,94,0.12);
    color: #86EFAC;
}
.tnp-badge__dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #22C55E;
    border-radius: 50%;
    flex-shrink: 0;
    animation: tnp-pulse 2s ease-in-out infinite;
}
@keyframes tnp-pulse {
    0%, 100% { opacity: 1; transform: scale(1);   }
    50%       { opacity: 0.5; transform: scale(1.4); }
}

/* ── Workspace (map + sidebar) ─────────────────────────────────────────────── */
.tnp-workspace {
    display: flex;
    /* Fill exactly what remains after the sticky header and hero.
       flex:1 on #tnp-root handles this — no hard-coded pixel guessing. */
    flex: 1;
    min-height: 480px;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.tnp-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--white, #fff);
    border-right: 1px solid var(--border);
    overflow: hidden;
    z-index: 10;
}
.tnp-sidebar__filters {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}
.tnp-sidebar__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--navy);
    margin: 0 0 14px;
}
.tnp-sidebar__results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.tnp-sidebar__results-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--navy);
    margin: 0 0 4px;
}
.tnp-sidebar__hint {
    font-size: 13px;
    color: var(--muted, #9BA8B4);
    text-align: center;
    padding: 32px 12px;
    line-height: 1.6;
}
.tnp-sidebar__hint i { font-size: 2rem; display: block; margin-bottom: 8px; opacity: 0.4; }

/* ── Filter toggle rows ─────────────────────────────────────────────────────── */
.tnp-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    cursor: pointer;
    user-select: none;
}
.tnp-filter input[type="checkbox"] { display: none; }
.tnp-filter__track {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--border);
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}
.tnp-filter input:checked ~ .tnp-filter__track { background: var(--navy); }
.tnp-filter__thumb {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.2s;
}
.tnp-filter input:checked ~ .tnp-filter__track .tnp-filter__thumb {
    transform: translateX(18px);
}
.tnp-filter__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tnp-filter__body { flex: 1; min-width: 0; }
.tnp-filter__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--navy);
    display: block;
    line-height: 1.3;
}
.tnp-filter__desc {
    font-size: 11px;
    color: var(--muted, #9BA8B4);
    display: block;
}

/* ── Search button ──────────────────────────────────────────────────────────── */
.tnp-search-prompt {
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0 0;
    font-style: italic;
}

/* ── Map container ──────────────────────────────────────────────────────────── */
.tnp-map-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}
#tnp-map {
    width: 100%;
    height: 100%;
}

/* ── No-filter prompt (map overlay) ────────────────────────────────────────── */
.tnp-prompt {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    background: var(--navy);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(15,35,64,0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    pointer-events: none;
    animation: tnp-fadein 0.2s ease;
}
.tnp-prompt i { color: var(--gold); }
@keyframes tnp-fadein {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Results panel ──────────────────────────────────────────────────────────── */
.tnp-district-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gold);
}
.tnp-result-section {
    margin-bottom: 16px;
}
.tnp-result-section__header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
}
.tnp-result-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tnp-result-section__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--navy);
    flex: 1;
}
.tnp-result-section__count {
    font-size: 11px;
    font-weight: 700;
    background: var(--navy);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}
.tnp-listing-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    margin-bottom: 5px;
    transition: border-color 0.15s, background 0.15s;
}
.tnp-listing-row:hover { border-color: var(--blue); background: #F4F8FF; }
.tnp-listing-row__price {
    font-size: 12px;
    font-weight: 700;
    color: var(--navy);
}
.tnp-listing-row__title {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tnp-result-names {
    font-size: 12px;
    color: var(--slate, #5A6B7B);
    margin: 2px 0 0;
    line-height: 1.5;
}
.tnp-result-none {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
    margin: 2px 0 0;
}
.tnp-result-error {
    font-size: 12px;
    color: #C0392B;
    margin: 2px 0 0;
}
.tnp-result-more {
    font-size: 11px;
    color: var(--blue);
    margin: 4px 0 0;
}

/* ── Loading ────────────────────────────────────────────────────────────────── */
.tnp-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--muted);
    padding: 16px 0;
}
.tnp-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: tnp-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes tnp-spin { to { transform: rotate(360deg); } }

/* ── Leaflet overrides ──────────────────────────────────────────────────────── */
.tnp-tooltip {
    background: var(--navy) !important;
    border: none !important;
    border-radius: 4px !important;
    color: var(--cream) !important;
    font-family: var(--font-body) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 4px 9px !important;
    box-shadow: 0 2px 8px rgba(15,35,64,0.3) !important;
}
.tnp-tooltip::before { border-top-color: var(--navy) !important; }

.tnp-price-pill {
    background: var(--navy);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(15,35,64,0.35);
    cursor: pointer;
    border: 1.5px solid rgba(201,168,76,0.6);
}

.tnp-dot {
    border: 2px solid #fff;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.leaflet-popup-content-wrapper { border-radius: 8px !important; }
.tnp-popup { font-family: var(--font-body); min-width: 160px; }
.tnp-popup__price { font-size: 14px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.tnp-popup__cat   { font-size: 11px; font-weight: 600; margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.tnp-popup__title { font-size: 13px; color: #3A4A5C; margin-bottom: 6px; }
.tnp-popup__link  { font-size: 12px; font-weight: 600; color: var(--blue); text-decoration: none; }
.tnp-popup__link:hover { text-decoration: underline; }
.tnp-popup__beds  { font-size: 11px; color: var(--muted); }

/* ── Map error ──────────────────────────────────────────────────────────────── */
#tnp-map-error {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    background: #FCEBEB;
    border: 1px solid #F09595;
    color: #A32D2D;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

/* ── Suppress Leaflet polygon focus rectangle ───────────────────────────────
   Browsers (especially Chrome) render a native focus outline around the
   bounding-box rectangle of a focused SVG path. Suppress it for the map. */
.tnp-map-wrap path.leaflet-interactive:focus,
.tnp-map-wrap path.leaflet-interactive:focus-visible {
    outline: none !important;
}
.tnp-district-chip {
    background: rgba(15,35,64,0.85);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
    #tnp-root {
        height: auto;
        overflow: visible;
    }
    .tnp-workspace {
        flex-direction: column;
        height: auto;
        min-height: unset;
        overflow: visible;
    }
    .tnp-map-wrap {
        height: 50vh;
        min-height: 320px;
    }
    .tnp-sidebar {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        overflow: auto;
        height: 340px;
        flex-shrink: 0;
    }
    .tnp-sidebar__filters {
        min-width: 220px;
        border-bottom: none;
        border-right: 1px solid var(--border);
        flex-shrink: 0;
    }
    .tnp-sidebar__results { flex: 1; }
}
@media (max-width: 599px) {
    .tnp-sidebar { flex-direction: column; height: auto; }
    .tnp-sidebar__filters { border-right: none; border-bottom: 1px solid var(--border); }
    .tnp-hero__meta { display: none; }
}
