* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* The palette moved to css/tokens.css, which css/landing.css needs too. This
   file is unusable without it — link tokens.css before it. */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Map */
#map {
    height: 100vh;
    width: 100vw;
    background: var(--dark-bg);
}

.leaflet-container {
    background: var(--dark-bg);
}

/* Leaflet popups are no longer used. Complaints open in .detail-panel instead,
   because a popup is only ever as tall as the space around its pin — which turned
   a 7,000-character complaint into a 320px scrolling slot. The popup styling that
   used to live here went with them. */

/* Complaint pins
   The hit area and the visible dot are deliberately different sizes. .complaint-pin
   is the 30x30 box Leaflet positions and routes clicks to; .complaint-pin-dot is
   the 16px circle inside it. Growing the dot on hover therefore costs nothing —
   the target does not move or resize under the cursor. */
.complaint-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Leaflet's .leaflet-div-icon gives div icons a white box and grey border. */
    background: transparent;
    border: none;
    cursor: pointer;
}

.complaint-pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: transform 0.12s ease;
}

.complaint-pin:hover .complaint-pin-dot,
.complaint-pin:focus .complaint-pin-dot {
    transform: scale(1.4);
}

.complaint-pin:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
    border-radius: 50%;
}

/* Coarse pointers (touch) get a larger target still — a fingertip is ~9mm, well
   over the 30px box that is comfortable for a mouse. */
@media (pointer: coarse) {
    .complaint-pin-dot {
        width: 20px;
        height: 20px;
    }
}

/* Marker clusters */
.marker-cluster {
    background: rgba(233, 69, 96, 0.3) !important;
}

.marker-cluster div {
    background: rgba(233, 69, 96, 0.8) !important;
    color: white !important;
    font-weight: 600;
    font-size: 13px;
}

/* Header
   A panel rather than bare text on the map. It used to be white text with a
   text-shadow, which assumed a dark basemap — on the light CARTO/OSM tiles the
   subtitle was very nearly invisible, and so was the link to the front page that
   now sits in it. Same --panel-bg treatment as the filter and trending panels. */
.header {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    pointer-events: none;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 12px 18px;
    max-width: calc(100vw - 130px);
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    color: white;
}

.header p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* .header sets pointer-events: none so it never eats a map drag that starts
   under it. The links inside have to opt back in or they are not clickable. */
.header a {
    pointer-events: auto;
    color: inherit;
    text-decoration: none;
}

.header h1 a:hover {
    color: var(--accent);
}

.header-link {
    color: var(--accent) !important;
    border-bottom: 1px solid rgba(233, 69, 96, 0.5);
}

.header-link:hover {
    border-bottom-color: var(--accent);
}

/* Filter button */
.filter-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.filter-btn:hover {
    background: #222244;
}

/* Filter panel */
.filter-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    z-index: 1000;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 16px;
    width: 240px;
    max-height: 70vh;
    overflow-y: auto;
}

.filter-panel h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.filter-panel .cat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    margin-bottom: 2px;
}

.filter-panel .cat-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-panel .cat-btn.active {
    background: var(--accent);
    color: white;
}

.filter-panel .cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Submit button */
.submit-btn {
    position: absolute;
    bottom: 80px;
    right: 24px;
    z-index: 1000;
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(233, 69, 96, 0.5);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.close-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group textarea,
.form-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea::placeholder {
    color: var(--text-secondary);
}

.form-group select option {
    background: var(--panel-bg);
    color: var(--text-primary);
}

.char-count {
    display: block;
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.location-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.location-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.location-label {
    font-size: 13px;
    color: #4ade80;
    margin-top: 4px;
}

.form-error {
    color: #f87171;
    font-size: 13px;
    margin-bottom: 12px;
}

/* Buttons */
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Complaint detail panel
   Replaces the Leaflet popup for reading a complaint. A popup could not do this
   job: Leaflet sizes it to the space around its pin, which left roughly a 320px
   slot to read through, and complaints run to several thousand characters (CFPB
   narratives have a median of ~1,270 and reach 7,300). This gets the full height
   of the window, so a median-length complaint needs no scrolling at all.

   Sits below the filter button and above the map. z-index 1500 puts it over the
   side panels (1000) but under the submit modal (2000). */
.detail-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    bottom: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
}

.detail-category {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* The only scrolling region. Header and footer stay put so the close button and
   the location never scroll away from a long complaint. */
.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
}

.detail-text {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    /* Narratives carry their own paragraph breaks; without pre-wrap they collapse
       into one block. break-word stops VINs and case numbers forcing a sideways
       scroll. */
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.detail-truncated {
    margin-top: 16px;
    padding: 10px 12px;
    border-left: 3px solid #f39c12;
    background: rgba(243, 156, 18, 0.08);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.detail-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--panel-border);
    flex-shrink: 0;
}

.detail-meta {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
}

.detail-affiliate-link {
    display: block;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(233, 69, 96, 0.1);
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    color: #e94560;
}

.detail-affiliate-link:hover {
    background: rgba(233, 69, 96, 0.18);
}

/* On a phone a 400px side drawer would cover the map entirely, so it becomes a
   bottom sheet and leaves the pin you tapped visible above it. */
@media (max-width: 767px) {
    .detail-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-width: none;
        max-height: 72vh;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }
}

/* Trending panel */
.trending-panel {
    position: absolute;
    bottom: 24px;
    left: 70px;
    z-index: 1000;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 16px;
    width: 220px;
}

.trending-panel h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.trending-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.trending-item:last-child {
    border-bottom: none;
}

.trending-item .city-name {
    color: var(--text-primary);
}

.trending-item .complaint-count {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Affiliate panel */
.affiliate-panel {
    position: absolute;
    bottom: 24px;
    left: 310px;
    z-index: 1000;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 16px;
    width: 240px;
}

.affiliate-panel h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.affiliate-link {
    display: block;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.affiliate-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.affiliate-link .af-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.affiliate-link .af-desc {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.affiliate-disclosure {
    display: inline-block;
    margin-top: 8px;
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 18px;
    }

    .trending-panel {
        display: none;
    }

    .affiliate-panel {
        display: none;
    }

    .submit-btn {
        bottom: 16px;
        right: 16px;
        padding: 12px 18px;
        font-size: 14px;
    }

    .filter-panel {
        right: 10px;
        width: 200px;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}
