/* Wraps the entire content of the home page, limits its width, and centers it */
.home-page {
    max-width: 1000px;
    margin: 50px auto;
    text-align: center;
    padding: 0 18px 6px;
}

/* Search */
.search-area {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    align-items: center;
    gap: 34px;
    padding: 34px;
    border-radius: 26px;
    text-align: left;
    background:
        radial-gradient(circle at top right, rgba(220, 238, 243, 0.62), transparent 34%),
        radial-gradient(circle at bottom left, rgba(115, 178, 135, 0.12), transparent 34%),
        linear-gradient(145deg, rgba(254, 250, 245, 0.98), rgba(244, 236, 224, 0.94));
    border: 2px solid var(--border-green-strong);
    box-shadow: 0 26px 54px rgba(63, 53, 40, 0.08);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.search-area::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 26px;
    box-shadow: inset 0 0 0 3px rgba(34, 82, 50, 0.34);
    pointer-events: none;
}

.search-area::after {
    content: "";
    position: absolute;
    inset: auto -18% -36% auto;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(115, 178, 135, 0.12), transparent 68%);
    pointer-events: none;
}

.search-copy {
    position: relative;
    z-index: 1;
    max-width: 620px;
}

.search-kicker {
    font-size: var(--text-caption);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--brown);
    margin-bottom: 10px;
}

/* Styling for the main heading above the search bar */
.search-area h2 {
    font-size: var(--text-hero);
    margin-bottom: 12px; /* Adds space between the heading and the descriptive paragraph */
    max-width: 12ch;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.search-area p {
    font-size: 1.04rem;
    max-width: 620px;
    margin-inline: 0;
    color: rgba(46, 50, 48, 0.84);
}

.search-visual {
    position: relative;
    z-index: 1;
}

.hero-globe-stage {
    position: relative;
    width: min(100%, 520px);
    margin: 0 auto 14px;
}

.hero-globe-frame {
    position: relative;
    width: 100%;
    height: 360px;
    margin: 0 auto 14px;
    background:
        radial-gradient(circle at 50% 46%, rgba(220, 238, 243, 0.52), transparent 48%),
        radial-gradient(circle at 52% 100%, rgba(115, 178, 135, 0.18), transparent 54%);
    overflow: hidden;
}

.hero-globe-frame::before,
.hero-globe-frame::after {
    content: "";
    position: absolute;
    inset: 12% 18%;
    border-radius: 50%;
    pointer-events: none;
}

.hero-globe-frame::before {
    border: 1px solid rgba(77, 132, 98, 0.14);
    transform: rotate(-18deg);
}

.hero-globe-frame::after {
    border: 1px solid rgba(77, 132, 98, 0.1);
    transform: rotate(62deg);
}

#heroGlobeContainer {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#heroGlobeContainer canvas {
    display: block;
    margin: 0 auto;
}

.search-visual-note {
    max-width: 360px;
    margin: 0 auto;
    font-size: var(--text-small);
    text-align: center;
    color: rgba(129, 105, 74, 0.82);
}

/* Flexbox container for the search input and button to align them perfectly side-by-side */
.search-box {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 28px;
    align-items: flex-start;
}

.search-input-group {
    position: relative;
    width: min(100%, 360px);
}

.search-input-group input {
    width: 100%;
}

.search-box .button {
    min-width: 148px;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 10;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    background: rgba(253, 249, 244, 0.98);
    box-shadow: var(--shadow-medium);
    text-align: left;
}

.suggestion-item {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--brown);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.suggestion-item:hover,
.suggestion-item.is-active {
    background: rgba(77, 132, 98, 0.12);
    color: var(--green);
}

.recent-searches-panel {
    width: 100%;
    margin: 34px auto 0;
    padding: 24px;
    border-radius: 18px;
    text-align: left;
    background: var(--surface-main);
    border: 2px solid var(--border-green);
    box-shadow: var(--shadow-soft);
    position: relative;
}

.home-divider {
    width: 100%;
    height: 2px;
    margin: 28px auto 0;
    background: linear-gradient(90deg, rgba(34, 82, 50, 0), rgba(34, 82, 50, 0.72), rgba(34, 82, 50, 0));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.32);
}

.recent-searches-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 18px;
    box-shadow: inset 0 0 0 2px rgba(34, 82, 50, 0.26);
    pointer-events: none;
}

.recent-searches-panel::after {
    content: "";
    position: absolute;
    inset: auto 24px 16px auto;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(220, 238, 243, 0.28), transparent 72%);
    pointer-events: none;
}

.recent-searches-header h3 {
    color: var(--green);
    font-size: var(--text-section);
    margin-bottom: 6px;
}

.recent-searches-header p {
    font-size: var(--text-small);
    color: rgba(129, 105, 74, 0.82);
    margin-bottom: 18px;
}

.recent-searches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.recent-search-chip {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(220, 231, 218, 0.88);
    color: var(--green);
    font-weight: 700;
    text-decoration: none;
}

.empty-state-text {
    color: rgba(129, 105, 74, 0.76);
    font-size: var(--text-small);
}

/* Map */
.map-area {
    margin-top: 42px;
    padding: 28px;
    border-radius: 18px;
    background: var(--surface-main);
    border: 2px solid var(--border-green);
    box-shadow: var(--shadow-soft);
    position: relative;
    width: 100%;
}

.map-area::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 18px;
    box-shadow: inset 0 0 0 2px rgba(34, 82, 50, 0.26);
    pointer-events: none;
}

.map-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.map-header h3 {
    margin: 0;
    color: var(--green);
    font-size: var(--text-section);
}

.map-feedback {
    margin: 0;
    font-size: var(--text-small);
    color: rgba(129, 105, 74, 0.8);
}

#worldMapContainer {
    height: 460px;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(34, 82, 50, 0.38);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.map-text {
    color: var(--brown);
    margin-top: 16px;
}

.map-legend {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    color: rgba(129, 105, 74, 0.8);
    font-size: var(--text-small);
}

.map-legend-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 999px;
    background: #67a86f;
    border: 2px solid #3c7551;
    box-shadow: 0 0 0 4px rgba(78, 131, 95, 0.14);
}

.country-marker-icon {
    background: transparent;
    border: 0;
    position: relative;
}

.country-marker-shell {
    position: absolute;
    top: 0;
    left: 50%;
    width: 20px;
    height: 20px;
    display: block;
    border-radius: 999px;
    transform: translateX(-50%);
}

.country-marker-icon span {
    position: absolute;
    display: block;
    border-radius: 999px;
}

.country-marker-pole {
    top: 14px;
    left: 50%;
    width: 2px;
    height: 16px;
    background: #6c562f;
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px rgba(46, 35, 18, 0.25);
}

.country-marker-halo {
    background: rgba(252, 248, 243, 0.94);
    box-shadow: 0 0 0 2px var(--marker-ring), 0 3px 8px rgba(63, 53, 40, 0.14);
    inset: 0;
}

.country-marker-core {
    inset: 1px;
    background: linear-gradient(145deg, var(--marker-start), var(--marker-end));
    border: 1px solid rgba(52, 56, 44, 0.16);
}

.country-marker-dot {
    inset: 5px;
    background: linear-gradient(145deg, var(--marker-end), var(--marker-start));
}

.country-marker-flag {
    inset: 3px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    z-index: 2;
}

.country-marker-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.country-marker-shell.has-flag .country-marker-dot {
    opacity: 0;
}

@media (max-width: 980px) {
    .search-area {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 30px 24px;
        text-align: center;
    }

    .search-area h2,
    .search-area p,
    .search-kicker {
        margin-inline: auto;
    }

    .search-area h2 {
        max-width: 12ch;
    }

    .search-box {
        justify-content: center;
    }

    .home-divider {
        margin-top: 24px;
    }
}

/* Responsive Design (Mobile & Tablets) */
@media (max-width: 768px) {
    /* Reduce the main heading size for smaller screens to prevent awkward text wrapping */
    .search-area h2 {
        font-size: 1.95rem;
        max-width: 14ch;
    }

    .search-area {
        padding: 24px 18px;
        gap: 12px;
    }

    .hero-globe-stage {
        width: 100%;
        margin-top: 20px;
    }

    .hero-globe-frame {
        height: 280px;
        margin-bottom: 4px;
    }

    /* Stack the search input and button vertically (top-to-bottom) instead of side-by-side */
    .search-box {
        flex-direction: column;
        align-items: stretch;
    }

    /* Make both the input field and the button span the full width of their container for easier touch interaction */
    .search-input-group,
    .search-box input, 
    .search-box button {
        width: 100%;
    }

    /* Reduce the inner padding of the map area to save precious screen space on mobile devices */
    .map-area {
        padding: 20px;
    }

    .home-divider {
        margin-top: 20px;
    }

    .compare-form,
    .compare-result {
        grid-template-columns: 1fr;
    }

    .map-header {
        flex-direction: column;
        align-items: flex-start;
    }

    #worldMapContainer {
        height: 340px;
    }
}

@media (max-width: 980px) {
    .home-page {
        margin: 40px auto 60px;
        padding: 0 16px;
    }

    .hero-globe-frame {
        height: 320px;
    }

    .recent-searches-panel,
    .map-area {
        padding: 22px;
    }

    #worldMapContainer {
        height: 390px;
    }
}

@media (max-width: 768px) {
    .hero-globe-frame {
        height: min(78vw, 300px);
    }

    .recent-searches-panel,
    .map-area {
        padding: 20px;
    }

    #worldMapContainer {
        height: 340px;
    }

    .home-page {
        margin: 34px auto 56px;
        padding: 0 14px;
    }
}

@media (max-width: 480px) {
    .search-area h2 {
        font-size: 1.72rem;
    }

    .hero-globe-frame {
        height: min(80vw, 260px);
    }

    .recent-searches-panel,
    .map-area {
        padding: 18px 16px;
    }

    #worldMapContainer {
        height: 300px;
    }

    .map-legend {
        flex-wrap: wrap;
        justify-content: center;
    }
}
