/* ==========================================================
   iNaturalist Species Overlap Mapper — Styles
   Matches joepaquin.com: dark naturalist theme,
   bone text on near-black, gold / rust / sage accents.
   Fonts: Cormorant Garamond (display) + DM Mono (labels).
   ========================================================== */

/* Self-hosted fonts — shared with the main site (same origin, no CDN).
   Resolves to joepaquin.com/static/fonts on deploy; falls back to the
   system serif/mono stack locally. */
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 300 400;
    font-display: swap;
    src: url('/static/fonts/cormorant-garamond-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 300 400;
    font-display: swap;
    src: url('/static/fonts/cormorant-garamond-italic.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/fonts/dm-mono-300.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/dm-mono-400.woff2') format('woff2');
}

/* ===== Tokens (mirrors main-site) ===== */
:root {
    --black:        #0c0c0c;
    --dark:         #141412;
    --panel:        #1c1b18;
    --bone:         #f0ebe0;
    --warm:         #c8b98a;
    --gold:         #a8924a;
    --rust:         #b54a28;
    --sage:         #4a7a58;
    --muted:        rgba(240, 235, 224, 0.45);
    --faint:        rgba(240, 235, 224, 0.06);
    --border:       rgba(240, 235, 224, 0.12);
    --border-hover: rgba(240, 235, 224, 0.30);

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-mono:    'DM Mono', 'Courier New', monospace;

    --radius: 4px;
    --transition: 0.25s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-display);
    font-weight: 300;
    line-height: 1.7;
    color: var(--bone);
    background: var(--black);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--warm);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--gold); }

/* ===== Header ===== */
.site-header {
    text-align: center;
    padding: 48px 20px 36px;
    border-bottom: 1px solid var(--border);
    background: var(--dark);
}

.header-content { max-width: 760px; margin: 0 auto; }

.eyebrow {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--warm);
    margin-bottom: 14px;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2.1rem, 6vw, 3.2rem);
    line-height: 1.1;
    color: var(--bone);
    letter-spacing: 0.01em;
}

.tagline {
    font-size: 1.05rem;
    color: var(--muted);
    margin-top: 12px;
}

/* ===== Container ===== */
.container {
    max-width: 760px;
    margin: 28px auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
}

/* ===== Typography ===== */
h1, h2, h3 { font-family: var(--font-display); font-weight: 300; color: var(--bone); }
h2 { font-size: 1.7rem; margin-bottom: 14px; }
h3 { font-size: 1.25rem; margin-bottom: 12px; }

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

label {
    display: block;
    margin-bottom: 9px;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--warm);
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--black);
    color: var(--bone);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input::placeholder { color: var(--muted); }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(168, 146, 74, 0.25);
}

.help-text {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.5;
}

/* ===== Buttons ===== */
button {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 13px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--gold);
    color: var(--black);
}

button:hover { background: var(--rust); color: var(--bone); }
button:active { transform: translateY(1px); }

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--faint);
    color: var(--muted);
}

.secondary-btn {
    background: transparent;
    color: var(--bone);
    border: 1px solid var(--border);
    margin-bottom: 22px;
    letter-spacing: 0.1em;
    padding: 11px 20px;
}
.secondary-btn:hover {
    background: var(--faint);
    border-color: var(--border-hover);
    color: var(--bone);
}

/* ===== Species fields ===== */
.species-field label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remove-species-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    margin-left: 10px;
    flex-shrink: 0;
}
.remove-species-btn:hover {
    background: transparent;
    border-color: var(--rust);
    color: var(--rust);
}

/* ===== Autocomplete ===== */
.autocomplete-wrapper { position: relative; }

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border-hover);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}
.autocomplete-results.active { display: block; }

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.selected { background: var(--faint); }

.autocomplete-item-name { color: var(--bone); }
.autocomplete-item-detail {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 3px;
}

.autocomplete-loading,
.autocomplete-no-results {
    padding: 10px 14px;
    text-align: center;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

/* ===== Location input ===== */
.location-input-group { display: flex; gap: 10px; align-items: flex-start; }
.location-input-group .autocomplete-wrapper { flex: 1; }

.map-picker-btn {
    width: auto;
    padding: 0 14px;
    height: 46px;
    font-size: 18px;
    flex-shrink: 0;
    background: transparent;
    color: var(--bone);
    border: 1px solid var(--border);
}
.map-picker-btn:hover {
    background: var(--faint);
    border-color: var(--border-hover);
    color: var(--bone);
}

/* ===== Loading ===== */
.loading { display: none; text-align: center; padding: 40px; }
.loading.active { display: block; }
.loading p { color: var(--muted); }
.loading-note { font-family: var(--font-mono); font-size: 0.74rem; }

.spinner {
    border: 3px solid var(--faint);
    border-top: 3px solid var(--gold);
    border-radius: 50%;
    width: 46px;
    height: 46px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Error ===== */
.error {
    display: none;
    padding: 14px 16px;
    margin-top: 20px;
    border-radius: var(--radius);
    border-left: 3px solid var(--rust);
    background: rgba(181, 74, 40, 0.12);
    color: var(--bone);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}
.error.active { display: block; }

/* ===== Result ===== */
.result { display: none; margin-top: 32px; }
.result.active { display: block; }

.rank-banner {
    background: rgba(168, 146, 74, 0.12);
    border: 1px solid var(--gold);
    color: var(--bone);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.86rem;
    line-height: 1.5;
}

.result-map {
    width: 100%;
    height: 540px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
/* Species heatmap layers combine so overlaps read as a distinct tone: on dark
   themes they SCREEN (overlap brightens), on the light theme they MULTIPLY
   (overlap darkens). */
.heat-screen { mix-blend-mode: screen; }
.heat-multiply { mix-blend-mode: multiply; }

.map-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
}
.map-controls label { text-transform: uppercase; letter-spacing: 0.06em; }
.map-controls select {
    width: auto;
    padding: 6px 10px;
    background: var(--black);
    color: var(--bone);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    margin: 0;
}
.map-controls select:focus { border-color: var(--gold); outline: none; }

.map-legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 14px 0 6px;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}
.map-legend li { display: flex; align-items: center; gap: 8px; color: var(--bone); }
.map-legend .swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}
.map-legend .count { color: var(--muted); }

.map-note {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.5;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }

.modal-content {
    background: var(--panel);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 1.3rem; }

.modal-close {
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 15px;
}
.modal-close:hover { background: transparent; border-color: var(--rust); color: var(--rust); }

.modal-body { padding: 20px 28px; flex: 1; overflow-y: auto; }

.modal-footer {
    padding: 20px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.modal-footer button { width: auto; }
.modal-footer .secondary-btn { margin-bottom: 0; }

#locationPickerMap {
    width: 100%;
    height: 400px;
    border-radius: var(--radius);
    margin: 14px 0;
    border: 1px solid var(--border);
}

.selected-coords {
    padding: 12px 15px;
    background: var(--black);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--bone);
}
.selected-coords strong { color: var(--warm); }

/* ===== About (collapsible disclosure, closed by default) ===== */
.about {
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}
.about-toggle {
    cursor: pointer;
    list-style: none;            /* hide default disclosure triangle (most engines) */
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    user-select: none;
    transition: color 0.15s ease;
}
.about-toggle::-webkit-details-marker { display: none; }  /* hide triangle (WebKit/Blink) */
.about-toggle::before {
    content: '+ ';
    color: var(--sage);
}
.about[open] .about-toggle::before { content: '\2212  '; }  /* minus sign when open */
.about-toggle:hover { color: var(--bone); }
.about > h3 { margin-top: 22px; }
.about-intro { color: var(--bone); margin: 22px 0; }
.about-intro.placeholder { color: var(--muted); font-style: italic; }

.credits {
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.7;
}
.credits li {
    padding-left: 16px;
    position: relative;
    margin: 8px 0;
}
.credits li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 5px;
    height: 5px;
    background: var(--sage);
    border-radius: 50%;
}

/* ===== Footer ===== */
footer {
    margin-top: 32px;
    text-align: center;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
}
footer p { margin: 5px 0; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-header { padding: 36px 16px 28px; }
    .container { margin: 14px; padding: 24px; }
    .map-container iframe { height: 460px; }
}
