@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap");

/* Theme tokens aligned to Stitch (primary/backgrounds/typography). */
:root {
    color-scheme: light dark;

    --primary: #11d411;
    --bg: #f6f8f6;
    --panel: rgba(255, 255, 255, 0.85);
    --panel-solid: #ffffff;
    --text: #0f172a;
    --muted: rgba(15, 23, 42, 0.72);
    --border: rgba(15, 23, 42, 0.12);
    --shadow: 0 24px 50px rgba(2, 6, 23, 0.12);
    --shadow-soft: 0 10px 30px rgba(2, 6, 23, 0.10);

    --radius: 16px;
    --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #102210;
        --panel: rgba(16, 34, 16, 0.72);
        --panel-solid: rgba(16, 34, 16, 0.92);
        --text: #f1f5f9;
        --muted: rgba(241, 245, 249, 0.70);
        --border: rgba(255, 255, 255, 0.10);
        --shadow: 0 30px 70px rgba(0, 0, 0, 0.40);
        --shadow-soft: 0 14px 40px rgba(0, 0, 0, 0.30);
    }
}

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

html,
body {
    height: 100%;
}

body {
    font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1100px 600px at 10% 0%, rgba(17, 212, 17, 0.10), transparent 55%),
        radial-gradient(900px 500px at 90% 10%, rgba(17, 212, 17, 0.08), transparent 60%),
        var(--bg);
    min-height: 100vh;
    padding: 16px;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--panel) 0%, rgba(255, 255, 255, 0.65) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

@media (prefers-color-scheme: dark) {
    .container {
        background: linear-gradient(180deg, rgba(16, 34, 16, 0.78) 0%, rgba(16, 34, 16, 0.58) 100%);
    }
}

/* Header */
header {
    color: #ffffff;
    padding: 28px 28px 26px;
    text-align: center;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(900px 280px at 15% 0%, rgba(17, 212, 17, 0.35), rgba(17, 212, 17, 0.05) 55%, transparent 70%),
        linear-gradient(180deg, rgba(16, 34, 16, 0.92) 0%, rgba(16, 34, 16, 0.80) 100%);
}

header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(rgba(17, 212, 17, 0.55) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.08;
    pointer-events: none;
}

header h1 {
    font-size: 2.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
    letter-spacing: -0.03em;
}

header p {
    opacity: 0.88;
    font-size: 1rem;
    position: relative;
    z-index: 1;
    font-weight: 500;
    color: rgba(241, 245, 249, 0.90);
}

/* Main content */
main {
    padding: 26px;
}

/* Location controls */
.location-controls {
    margin-bottom: 18px;
    background: rgba(16, 34, 16, 0.08);
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
    .location-controls {
        background: rgba(16, 34, 16, 0.45);
        backdrop-filter: blur(16px);
        border-color: rgba(17, 212, 17, 0.22);
    }
}

.control-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 14px;
}

.control-btn {
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 46px;
}

/* Emphasize primary action (matches Stitch: primary green). */
#myLocationBtn {
    background: var(--primary);
    color: #102210;
    border-color: rgba(17, 212, 17, 0.45);
    box-shadow: 0 16px 30px rgba(17, 212, 17, 0.18);
}

.control-btn:hover {
    border-color: rgba(17, 212, 17, 0.50);
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.15);
}

#myLocationBtn:hover {
    background: rgba(17, 212, 17, 0.92);
    box-shadow: 0 18px 40px rgba(17, 212, 17, 0.20);
}

.control-btn:active {
    transform: scale(0.98);
}

.control-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.control-btn svg {
    opacity: 0.95;
}

/* Search */
.location-search {
    display: flex;
    gap: 12px;
    max-width: 740px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
}

.location-search input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    background: rgba(255, 255, 255, 0.70);
    color: var(--text);
}

@media (prefers-color-scheme: dark) {
    .location-search input {
        background: rgba(16, 34, 16, 0.60);
        border-color: rgba(255, 255, 255, 0.12);
    }
}

.location-search input::placeholder {
    color: rgba(100, 116, 139, 0.85);
}

@media (prefers-color-scheme: dark) {
    .location-search input::placeholder {
        color: rgba(241, 245, 249, 0.55);
    }
}

.location-search input:focus {
    border-color: rgba(17, 212, 17, 0.65);
    box-shadow: 0 0 0 4px rgba(17, 212, 17, 0.16);
}

.location-search button {
    padding: 12px 16px;
    background: rgba(16, 34, 16, 0.92);
    color: rgba(241, 245, 249, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.9rem;
    transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 16px 30px rgba(2, 6, 23, 0.18);
    min-height: 46px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.location-search button:hover {
    border-color: rgba(17, 212, 17, 0.35);
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.22);
}

.location-search button:active {
    transform: scale(0.98);
}

/* Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 18px;
    margin-top: 18px;
}

.map-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.map-container {
    height: 520px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border);
    position: relative;
}

/* Results panel */
.results-section {
    background: rgba(16, 34, 16, 0.06);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

@media (prefers-color-scheme: dark) {
    .results-section {
        background: rgba(16, 34, 16, 0.50);
        border-color: rgba(17, 212, 17, 0.18);
        backdrop-filter: blur(16px);
    }
}

.results-section .mountains-container {
    margin: 0;
    padding: 18px;
}

.results-section .mountains-list {
    max-height: 520px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(17, 212, 17, 0.55) rgba(2, 6, 23, 0.08);
}

.results-section .mountains-list::-webkit-scrollbar {
    width: 8px;
}

.results-section .mountains-list::-webkit-scrollbar-track {
    background: rgba(2, 6, 23, 0.06);
    border-radius: 9999px;
}

.results-section .mountains-list::-webkit-scrollbar-thumb {
    background: rgba(17, 212, 17, 0.45);
    border-radius: 9999px;
}

/* Status */
.status {
    text-align: center;
    padding: 12px 14px;
    margin: 14px 0;
    background: rgba(17, 212, 17, 0.10);
    border-radius: 14px;
    border: 1px solid rgba(17, 212, 17, 0.20);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
}

/* Location info */
.location-info {
    background: var(--panel-solid);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

@media (prefers-color-scheme: dark) {
    .location-info {
        background: rgba(16, 34, 16, 0.70);
        border-color: rgba(255, 255, 255, 0.10);
        backdrop-filter: blur(14px);
    }
}

.location-info h3 {
    color: var(--text);
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.location-info h3 svg {
    color: var(--primary);
}

.location-info p {
    color: var(--muted);
    margin: 6px 0;
    font-size: 0.9rem;
    line-height: 1.45;
}

/* Mountains list */
.mountains-container h3 {
    color: var(--text);
    margin-bottom: 14px;
    font-size: 1.05rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.mountains-list {
    display: grid;
    gap: 12px;
}

.mountain-card {
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(17, 212, 17, 0.14);
    touch-action: manipulation;
    box-shadow: 0 10px 20px rgba(2, 6, 23, 0.08);
}

.mountain-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

.detail-btn {
    flex: 1;
    border-radius: 14px;
    padding: 10px 12px;
    font-weight: 900;
    cursor: pointer;
    border: 1px solid rgba(17, 212, 17, 0.35);
    background: var(--primary);
    color: #102210;
    transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    box-shadow: 0 14px 28px rgba(17, 212, 17, 0.14);
}

.detail-btn:hover {
    filter: brightness(0.98);
    box-shadow: 0 18px 36px rgba(17, 212, 17, 0.18);
    border-color: rgba(17, 212, 17, 0.55);
}

.detail-btn:active {
    transform: scale(0.98);
}

.detail-btn--secondary {
    background: rgba(16, 34, 16, 0.92);
    color: rgba(241, 245, 249, 0.95);
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow: 0 16px 30px rgba(2, 6, 23, 0.18);
}

.detail-btn--secondary:hover {
    border-color: rgba(17, 212, 17, 0.30);
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.22);
}

@media (prefers-color-scheme: dark) {
    .mountain-card {
        background: rgba(16, 34, 16, 0.68);
        border-color: rgba(255, 255, 255, 0.10);
    }
}

.mountain-card:hover {
    border-color: rgba(17, 212, 17, 0.55);
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.18);
    transform: translateY(-1px);
}

.mountain-name {
    font-size: 1rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.mountain-details {
    display: grid;
    gap: 8px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.detail-item .icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: rgba(17, 212, 17, 0.85);
}

.detail-item strong {
    color: var(--text);
    font-weight: 800;
}

.elevation {
    color: rgba(17, 212, 17, 0.95);
    font-weight: 900;
}

.distance {
    color: rgba(16, 34, 16, 0.95);
    font-weight: 900;
}

@media (prefers-color-scheme: dark) {
    .distance {
        color: rgba(241, 245, 249, 0.90);
    }
}

/* Error message */
.error-message {
    background: rgba(239, 68, 68, 0.12);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(239, 68, 68, 0.22);
    margin: 14px 0;
    font-size: 0.9rem;
    font-weight: 700;
}

/* Footer */
footer {
    background: rgba(16, 34, 16, 0.04);
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
    footer {
        background: rgba(16, 34, 16, 0.50);
        border-top-color: rgba(255, 255, 255, 0.08);
    }
}

/* Utilities */
.hidden {
    display: none;
}

.hide-scrollbar::-webkit-scrollbar,
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar,
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.loading {
    position: relative;
}

.loading::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }
    100% {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Leaflet popup */
.leaflet-popup-content {
    font-family: inherit;
    line-height: 1.4;
}

.mountain-popup {
    text-align: left;
    min-width: 200px;
    font-size: 0.9rem;
}

.mountain-popup h4 {
    color: #0f172a;
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 900;
}

.mountain-popup p {
    margin: 4px 0;
    color: rgba(15, 23, 42, 0.72);
    font-size: 0.9rem;
}

.mountain-popup .elevation {
    color: rgba(17, 212, 17, 0.95);
    font-weight: 900;
}

@media (prefers-color-scheme: dark) {
    .mountain-popup h4 {
        color: #0f172a;
    }
}

/* Responsive */
@media (min-width: 1400px) {
    .container {
        max-width: 1600px;
    }

    .main-content {
        grid-template-columns: 1fr 460px;
        gap: 22px;
    }

    .map-container {
        height: 600px;
    }

    .results-section .mountains-list {
        max-height: 600px;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 360px;
        gap: 18px;
    }

    .map-container {
        height: 480px;
    }
}

@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        margin: 0;
    }

    main {
        padding: 18px;
    }

    header h1 {
        font-size: 1.9rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .results-section .mountains-list {
        max-height: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 22px 18px 20px;
    }

    main {
        padding: 16px;
    }

    .location-controls {
        padding: 14px;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .control-btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }

    .location-search {
        flex-direction: column;
        gap: 10px;
        max-width: none;
    }

    .location-search input {
        font-size: 16px; /* iOS zoom guard */
        min-height: 48px;
    }

    .location-search button {
        width: 100%;
        min-height: 48px;
    }

    .map-container {
        height: 380px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    header h1 {
        font-size: 1.7rem;
    }

    .map-container {
        height: 320px;
    }

    .mountain-card {
        padding: 12px;
    }
}
