/* ===========================
   VIVLY LIVING - Interactive Site Map
   Professional Site Plan Style
   =========================== */

/* --- Map Container --- */
.sitemap {
    position: relative;
    margin: var(--space-lg) 0;
    background: #f7f5f0;
    border-radius: 12px;
    border: 1px solid #e0dbd2;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

/* --- Layout: Key on left, map on right --- */
.sitemap__layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 520px;
}

/* --- Key Panel (left side) --- */
.sitemap__key {
    background: #fff;
    border-right: 1px solid #e0dbd2;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.sitemap__key-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--color-primary, #1B3A2D);
}

.sitemap__key-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--color-accent, #C4A35A);
    margin-bottom: 0.25rem;
}

.sitemap__key-title {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary, #1B3A2D);
    line-height: 1.2;
}

/* House type entries in the key */
.sitemap__key-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sitemap__key-item {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sitemap__key-item:hover {
    background: #f5f2ec;
}

.sitemap__key-swatch {
    width: 36px;
    height: 26px;
    border-radius: 4px;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sitemap__key-swatch svg {
    width: 18px;
    height: 14px;
    opacity: 0.6;
}

.sitemap__key-swatch--2bed {
    background: #e8c5ce;
}

.sitemap__key-swatch--3bed {
    background: #9cc8db;
}

.sitemap__key-swatch--4bed {
    background: #e6cc82;
}

.sitemap__key-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text, #2a2a2a);
    line-height: 1.2;
}

.sitemap__key-type {
    font-size: 0.68rem;
    color: var(--color-text-muted, #8a8a8a);
    line-height: 1.3;
}

.sitemap__key-plots {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-muted, #8a8a8a);
    text-align: right;
    white-space: nowrap;
}

/* Status legend at bottom of key */
.sitemap__key-status {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #e8e4dc;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sitemap__key-status-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted, #8a8a8a);
    margin-bottom: 0.15rem;
}

.sitemap__status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--color-text-light, #5a5a5a);
}

.sitemap__status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.sitemap__status-indicator--available {
    background: #3a8c55;
    box-shadow: 0 0 0 2px rgba(58, 140, 85, 0.2);
}

.sitemap__status-indicator--reserved {
    background: #c4993a;
    box-shadow: 0 0 0 2px rgba(196, 153, 58, 0.2);
}

.sitemap__status-indicator--sold {
    background: #b55a50;
    box-shadow: 0 0 0 2px rgba(181, 90, 80, 0.2);
}

/* --- Map Canvas --- */
.sitemap__map-area {
    position: relative;
    padding: 1rem;
    overflow: visible;
}

.sitemap__canvas {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 500px;
}

.sitemap__canvas svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Plot Shapes --- */
.plot {
    cursor: pointer;
    transition: transform 0.25s ease, filter 0.25s ease;
    transform-origin: center center;
}

.plot:hover,
.plot:focus {
    transform: scale(1.06);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.plot:focus {
    outline: none;
}

.plot__shape {
    stroke-width: 1.5;
    transition: stroke-width 0.2s ease;
}

.plot:hover .plot__shape {
    stroke-width: 2.5;
}

/* Status-based strokes */
.plot--available .plot__shape {
    stroke: #3a8c55;
}

.plot--reserved .plot__shape {
    stroke: #c4993a;
    stroke-dasharray: 5 3;
}

.plot--sold .plot__shape {
    stroke: #b55a50;
    opacity: 0.55;
}

/* Bedroom colour fills */
.plot--2bed .plot__shape {
    fill: #e8c5ce;
}

.plot--3bed .plot__shape {
    fill: #9cc8db;
}

.plot--4bed .plot__shape {
    fill: #e6cc82;
}

/* Sold overlay */
.plot--sold {
    opacity: 0.5;
}

.plot--sold:hover {
    opacity: 0.7;
}

/* Plot number labels */
.plot__number {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 11px;
    font-weight: 700;
    fill: #3a3a3a;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

/* Available pulse indicator */
.plot--available .plot__pulse {
    animation: plotPulse 3s ease-in-out infinite;
}

@keyframes plotPulse {

    0%,
    100% {
        opacity: 0;
        r: 3;
    }

    50% {
        opacity: 0.5;
        r: 6;
    }
}

/* --- Map Labels --- */
.map-label {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 9px;
    font-weight: 600;
    fill: #7a7568;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    pointer-events: none;
}

.map-label--road {
    font-size: 8px;
    letter-spacing: 0.2em;
    fill: #9a9080;
}

.map-label--area {
    font-size: 8.5px;
    fill: #6a8a6a;
    font-weight: 500;
    font-style: italic;
    letter-spacing: 0.08em;
    text-transform: none;
}

/* --- Map Infrastructure --- */
.map-road {
    fill: none;
    stroke: #d8d0c0;
    stroke-width: 16;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.map-road--outline {
    stroke: #ccc4b0;
    stroke-width: 20;
}

.map-road--secondary {
    stroke-width: 12;
}

.map-road--secondary.map-road--outline {
    stroke-width: 15;
}

.map-pavement {
    fill: none;
    stroke: #e0d8c8;
    stroke-width: 2;
    stroke-dasharray: 4 3;
    stroke-linecap: round;
}

/* --- Green Spaces & Landscaping --- */
.map-green {
    fill: #d4e5c8;
    opacity: 0.5;
}

.map-green--dark {
    fill: #b5d4a0;
    opacity: 0.4;
}

.map-field {
    fill: #e2ecda;
    opacity: 0.35;
    stroke: #c5d5b5;
    stroke-width: 0.5;
    stroke-dasharray: 3 4;
}

/* Trees — small circles for overhead view */
.map-tree {
    pointer-events: none;
}

.map-tree circle {
    fill: #6a9a5a;
    opacity: 0.7;
}

.map-tree--light circle {
    fill: #8ab87a;
    opacity: 0.6;
}

.map-tree--dark circle {
    fill: #4a7a3a;
    opacity: 0.55;
}

/* Hedgerow — line of small shapes */
.map-hedge {
    fill: #5a8848;
    opacity: 0.5;
}

/* --- Tooltip --- */
.sitemap-tooltip {
    position: absolute;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.97);
    transition: opacity 0.2s ease, transform 0.2s ease;
    width: 260px;
}

.sitemap-tooltip--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: none;
}

.sitemap-tooltip__card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e0dbd2;
    position: relative;
}

/* Close button (visible on touch devices) */
.sitemap-tooltip__close {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.sitemap-tooltip__close:active {
    background: rgba(0, 0, 0, 0.7);
}

/* Show close button on touch/mobile devices */
@media (hover: none) and (pointer: coarse) {
    .sitemap-tooltip__close {
        display: flex;
    }

    .sitemap-tooltip--visible {
        pointer-events: auto;
    }
}

.sitemap-tooltip__img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.sitemap-tooltip__body {
    padding: 0.75rem 0.9rem 0.85rem;
}

.sitemap-tooltip__arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #e0dbd2;
    border-bottom: 1px solid #e0dbd2;
}

/* Arrow flip when tooltip is below the plot */
.sitemap-tooltip--below .sitemap-tooltip__arrow {
    bottom: auto;
    top: -6px;
    border-right: none;
    border-bottom: none;
    border-left: 1px solid #e0dbd2;
    border-top: 1px solid #e0dbd2;
}

.sitemap-tooltip__plot {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent, #C4A35A);
    margin-bottom: 0.1rem;
}

.sitemap-tooltip__name {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-primary, #1B3A2D);
    margin-bottom: 0.3rem;
}

.sitemap-tooltip__details {
    font-size: 0.78rem;
    color: #6a6a6a;
    line-height: 1.4;
    margin-bottom: 0.4rem;
}

.sitemap-tooltip__price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text, #1a1a1a);
    margin-bottom: 0.5rem;
}

.sitemap-tooltip__badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    margin-bottom: 0.5rem;
}

.sitemap-tooltip__badge--available {
    background: #3a8c55;
}

.sitemap-tooltip__badge--reserved {
    background: #c4993a;
}

.sitemap-tooltip__badge--sold {
    background: #b55a50;
}

.sitemap-tooltip__link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-primary, #1B3A2D);
    text-decoration: none;
    transition: gap 0.2s ease, color 0.2s ease;
}

.sitemap-tooltip__link:hover {
    gap: 0.5rem;
    color: var(--color-accent, #C4A35A);
}

/* --- Entrance Animations --- */
.sitemap .plot {
    opacity: 0;
    transform: scale(0.85);
    animation: plotFadeIn 0.4s ease forwards;
}

.sitemap .plot:nth-child(1) {
    animation-delay: 0.05s;
}

.sitemap .plot:nth-child(2) {
    animation-delay: 0.08s;
}

.sitemap .plot:nth-child(3) {
    animation-delay: 0.11s;
}

.sitemap .plot:nth-child(4) {
    animation-delay: 0.14s;
}

.sitemap .plot:nth-child(5) {
    animation-delay: 0.17s;
}

.sitemap .plot:nth-child(6) {
    animation-delay: 0.2s;
}

.sitemap .plot:nth-child(7) {
    animation-delay: 0.23s;
}

.sitemap .plot:nth-child(8) {
    animation-delay: 0.26s;
}

.sitemap .plot:nth-child(9) {
    animation-delay: 0.29s;
}

.sitemap .plot:nth-child(10) {
    animation-delay: 0.32s;
}

.sitemap .plot:nth-child(11) {
    animation-delay: 0.35s;
}

.sitemap .plot:nth-child(12) {
    animation-delay: 0.38s;
}

.sitemap .plot:nth-child(13) {
    animation-delay: 0.41s;
}

.sitemap .plot:nth-child(14) {
    animation-delay: 0.44s;
}

@keyframes plotFadeIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .sitemap {
        overflow: visible;
    }

    .sitemap__layout {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .sitemap__key {
        border-right: none;
        border-bottom: 1px solid #e0dbd2;
        padding: 1rem 1.25rem;
    }

    .sitemap__key-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem;
    }

    .sitemap__key-status {
        flex-direction: row;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .sitemap__map-area {
        padding: 0.5rem;
        min-width: 0;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }

    .sitemap__canvas {
        min-height: 320px;
        width: 600px;
    }

    .sitemap__canvas svg {
        width: 600px;
        height: auto;
    }
}

@media (max-width: 600px) {
    .sitemap__key-list {
        grid-template-columns: 1fr;
    }

    .sitemap__key-item {
        padding: 0.35rem 0.4rem;
    }

    .sitemap-tooltip {
        width: 220px;
    }

    .sitemap-tooltip__img {
        height: 90px;
    }

    .sitemap-tooltip__name {
        font-size: 0.95rem;
    }
}

/* --- Scroll hint for mobile --- */
.sitemap__scroll-hint {
    display: none;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted, #8a8a8a);
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid #e8e4dc;
}

@media (max-width: 900px) {
    .sitemap__scroll-hint {
        display: block;
    }
}