/*
Global styles for Nestmate.
Handles font imports, resets, responsive grid layout, and hover animations
that are impractical to express through inline component styles.
*/

@import url("https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600&display=swap");

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: #0F1411;
    color: #F4F1EA;
    font-family: 'Inter', sans-serif;
    scroll-behavior: smooth;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Responsive listing grid */
.listing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .listing-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .listing-grid {
        grid-template-columns: 1fr;
    }

    .nestmate-hero-title {
        font-size: 2.2rem !important;
    }

    .nestmate-search-bar {
        flex-direction: column !important;
    }

    .nestmate-nav-links {
        display: none !important;
    }

    .nav-toggle {
        display: flex !important;
    }
}

/* Mobile nav toggle — hidden on desktop, shown via the media query above.
   A simple 3-bar hamburger that morphs into an X when open. */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle:hover {
    background: rgba(244, 241, 234, 0.06);
}

.nav-toggle-bar {
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: #F4F1EA;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Dropdown panel of nav links, revealed under the sticky navbar */
.nav-mobile-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1.25rem 1.25rem;
    background: rgba(15, 20, 17, 0.97);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #2E3A32;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.nav-mobile-panel.open {
    display: flex;
}

.nav-mobile-link {
    padding: 0.85rem 0.75rem;
    border-radius: 10px;
}

.nav-mobile-link:hover {
    background: rgba(244, 241, 234, 0.06);
}

.nav-mobile-link.btn-accent {
    text-align: center;
    margin-top: 0.35rem;
    padding: 0.85rem 0.75rem;
}

/* Card hover lift */
.listing-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.listing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.listing-card-image {
    transition: transform 0.4s ease;
}

.listing-card:hover .listing-card-image {
    transform: scale(1.05);
}

/* Filter chip interactions */
.filter-chip {
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}

.filter-chip:hover {
    border-color: #E8A33D;
}

.filter-chip.active {
    background: #E8A33D;
    color: #1A1306;
    border-color: #E8A33D;
}

/* Button hover */
.btn-accent {
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn-accent:hover {
    background: #F4B85C;
}

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

/* Fade-in animation for page content */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease both;
}

/* Image gallery thumbnails on detail page */
.gallery-thumb {
    cursor: pointer;
    transition: opacity 0.15s ease, border-color 0.15s ease;
    border: 2px solid transparent;
}

.gallery-thumb:hover,
.gallery-thumb.active {
    border-color: #E8A33D;
    opacity: 1;
}

.gallery-thumb {
    opacity: 0.7;
}

/* ==========================================================================
   Map view — inDrive-style full-bleed map with price pins and a
   draggable bottom sheet (becomes a sidebar on larger screens).
   ========================================================================== */

.map-view {
    width: 100%;
}

/* Applied the instant a stay is tapped, before the browser follows the
   link — takes this out of the stacking order immediately so it can't be
   left painting over the incoming page during the transition. */
.map-view--leaving {
    z-index: -1 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: none !important;
}

.map-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #1A211C;
}

/* Leaflet renders its own tiles/controls inside this container */
.map-canvas .leaflet-container {
    width: 100%;
    height: 100%;
    background: #1A211C;
    font-family: 'Inter', sans-serif;
}

/* Floating top bar */
.map-topbar {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 30;
    pointer-events: none;
}

.map-topbar-pill {
    pointer-events: auto;
    background: rgba(15, 20, 17, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid #2E3A32;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #F4F1EA;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.map-toggle-btn {
    cursor: pointer;
}

/* Floating "stays near me" button — answers "what's close to me right
   now" without making the visitor guess a city or scroll the full list. */
.map-locate-btn {
    position: absolute;
    top: 4.5rem;
    right: 1rem;
    z-index: 18;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(15, 20, 17, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid #2E3A32;
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #F4F1EA;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.map-locate-btn p {
    margin: 0;
    white-space: nowrap;
}

.map-locate-btn:hover {
    border-color: #E8A33D;
    transform: translateY(-1px);
}

.map-locate-btn.loading {
    opacity: 0.75;
    cursor: wait;
}

.map-locate-btn.active {
    background: #E8A33D;
    border-color: #E8A33D;
    color: #1A1306;
}

.map-locate-message {
    position: absolute;
    top: calc(4.5rem + 46px);
    right: 1rem;
    left: 1rem;
    z-index: 18;
    background: rgba(15, 20, 17, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #2E3A32;
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    font-size: 0.78rem;
    line-height: 1.4;
    color: #F4F1EA;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (min-width: 640px) {
    .map-locate-message {
        left: auto;
        width: 260px;
    }
}

/* Price pin markers */
.price-pin-wrapper {
    background: transparent !important;
    border: none !important;
}

.price-pin {
    background: #F4F1EA;
    color: #0F1411;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    transform: translate(-50%, -100%);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.price-pin.active,
.price-pin:hover {
    background: #E8A33D;
    color: #1A1306;
    transform: translate(-50%, -100%) scale(1.08);
    z-index: 1000;
}

/* "You are here" marker for the near-me feature */
.user-location-wrapper {
    background: transparent !important;
    border: none !important;
}

.user-location-marker {
    position: relative;
    width: 22px;
    height: 22px;
}

.user-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #4A9EFF;
    border: 2px solid #F4F1EA;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.user-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border-radius: 50%;
    background: rgba(74, 158, 255, 0.35);
    animation: user-pulse 1.8s ease-out infinite;
}

@keyframes user-pulse {
    0% { transform: scale(0.4); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Tap-outside-to-close scrim — sits between the map and the expanded
   sheet, giving a large, obvious hit area to dismiss it with zero drag
   precision required. */
.map-sheet-scrim {
    position: absolute;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.map-sheet-scrim.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Bottom sheet (mobile default) */
.map-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    height: 34vh;
    max-height: 34vh;
    background: #1A211C;
    border-top: 1px solid #2E3A32;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    transition: height 0.25s ease, max-height 0.25s ease, transform 0.2s ease;
}

.map-sheet.expanded {
    height: 78vh;
    max-height: 78vh;
}

/* Draggable header — a generously-sized hit area (not just the thin
   visual bar) so grabbing and closing the sheet never feels fiddly. */
.map-sheet-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    position: relative;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.map-sheet-header:active {
    cursor: grabbing;
}

.map-sheet-handle-bar {
    grid-column: 2;
    justify-self: center;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #2E3A32;
    transition: background 0.15s ease;
}

.map-sheet-header:hover .map-sheet-handle-bar {
    background: #E8A33D;
}

/* Explicit close button — a compact circular icon button, only shown
   once the sheet is expanded, so closing is always a guaranteed single
   tap rather than relying on a drag gesture. Sits in its own grid
   column so it can never drift or overlap the centered handle bar. */
.map-sheet-close {
    display: none;
    grid-column: 3;
    justify-self: end;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(244, 241, 234, 0.06);
    border: 1px solid #2E3A32;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1;
    color: #A6AFA8;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.map-sheet-close p {
    margin: 0;
    line-height: 1;
}

.map-sheet-close:hover {
    background: #E8A33D;
    border-color: #E8A33D;
    color: #1A1306;
    transform: scale(1.08);
}

.map-sheet.expanded .map-sheet-close {
    display: flex;
}

.map-sheet-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem 1.5rem;
}

.map-sort-row {
    flex-shrink: 0;
    padding: 0 1rem 0.6rem;
}

.map-sort-label {
    margin: 0;
    font-size: 0.78rem;
    color: #A6AFA8;
    font-weight: 600;
}

.map-sort-chip {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #2E3A32;
    background: transparent;
    font-size: 0.78rem;
    font-weight: 600;
    color: #A6AFA8;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.map-sort-chip p {
    margin: 0;
}

.map-sort-chip:hover {
    border-color: #E8A33D;
    color: #F4F1EA;
}

.map-sort-chip.active {
    background: #E8A33D;
    border-color: #E8A33D;
    color: #1A1306;
}

.map-sort-chip.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.map-sort-chip.disabled:hover {
    border-color: #2E3A32;
    color: #A6AFA8;
}

.map-sheet-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #A6AFA8;
}

.map-row {
    display: flex;
    gap: 0.9rem;
    padding: 0.7rem 0.3rem;
    border-bottom: 1px solid #2E3A32;
    color: #F4F1EA;
    transition: background 0.15s ease;
}

.map-row:last-child {
    border-bottom: none;
}

.map-row:hover,
.map-row.active {
    background: #222B25;
    border-radius: 10px;
}

.map-row-image {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 12px;
    flex-shrink: 0;
}

.map-row-info {
    flex: 1;
    min-width: 0;
}

.map-row-title {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-row-location {
    font-size: 0.78rem;
    color: #A6AFA8;
    margin-bottom: 0.4rem;
}

.map-row-price {
    font-weight: 700;
    color: #E8A33D;
    font-size: 0.9rem;
}

.map-row-rating {
    font-size: 0.78rem;
    color: #A6AFA8;
}

.map-row-distance {
    font-size: 0.78rem;
    font-weight: 600;
    color: #4A9EFF;
    margin: 0.15rem 0 0;
}

/* Desktop — sheet becomes a permanent sidebar next to the map. Only
   applies to the full-page map (not the homepage's embedded preview). */
@media (min-width: 1024px) {
    .map-view:not(.map-view--embedded) {
        display: flex;
    }

    .map-view:not(.map-view--embedded) .map-canvas {
        position: relative;
        inset: auto;
        flex: 1;
        height: 100%;
    }

    .map-view:not(.map-view--embedded) .map-sheet,
    .map-view:not(.map-view--embedded) .map-sheet.expanded {
        position: relative;
        flex: 0 0 380px;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border-top: none;
        border-left: 1px solid #2E3A32;
        box-shadow: none;
        order: -1;
    }

    .map-view:not(.map-view--embedded) .map-sheet-header,
    .map-view:not(.map-view--embedded) .map-sheet-scrim {
        display: none;
    }

    .map-view:not(.map-view--embedded) .map-topbar {
        left: 1.5rem;
        right: auto;
    }
}

/* Embedded homepage preview — compact card with its own peek/expanded
   heights as a percentage of its own (fixed) height rather than the
   viewport. */
.map-view--embedded .map-sheet {
    height: 42%;
    max-height: 42%;
    border-radius: 0;
}

.map-view--embedded .map-sheet.expanded {
    /* Fixed clearance rather than a flat percentage — guarantees the
       sheet's own header (and its close button) never ends up underneath
       the topbar, regardless of how tall the embedded card is. */
    height: calc(100% - 4rem);
    max-height: calc(100% - 4rem);
}

@media (max-width: 640px) {
    .map-row-image {
        width: 70px;
        height: 70px;
    }

    /* A fixed 480px preview card feels oversized/cramped on a phone;
       scale it to the actual viewport instead. */
    .map-view--embedded {
        height: min(68vh, 520px) !important;
    }

    .map-locate-btn {
        top: 4rem;
        right: 0.75rem;
        padding: 0.5rem 0.85rem;
        font-size: 0.78rem;
    }

    .map-locate-message {
        top: calc(4rem + 44px);
    }

    /* Slightly larger tap target on touch devices */
    .map-sheet-close {
        width: 36px;
        height: 36px;
    }
}

/* Custom scrollbar for a polished feel */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #0F1411;
}

::-webkit-scrollbar-thumb {
    background: #2E3A32;
    border-radius: 8px;
}
