/* =============================================================================
   Planting Visualization — Gallery & Layout Styles
   Follows the design tokens from input.css (forest-green palette, stone neutrals)
   ============================================================================= */

/* ── Planting selector form ─────────────────────────────────────────────────── */
/* Ensures proper layout even if flex-1/min-w-64 Tailwind classes are not yet
   compiled into output.css (re-run `npm run css:build` to compile them). */

.pv-selector-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.pv-selector-field {
    flex: 1 1 16rem;    /* grows; min ~256px */
    min-width: 16rem;
}

/* ── Gallery counter (card header right slot) ───────────────────────────────── */

.pv-gallery-counter {
    font-size: 0.8rem;
    color: #a8a29e;
    font-weight: 500;
}

/* ── Tab Strip ──────────────────────────────────────────────────────────────── */

.pv-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 2px solid #e7e5e4;
    padding-bottom: 0;
}

.pv-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #78716c;
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.pv-tab:hover:not(.pv-tab-disabled) {
    color: #198754;
    background: #f0fdf6;
}

.pv-tab.active {
    color: #198754;
    border-bottom-color: #198754;
    font-weight: 600;
    background: #f0fdf600;
}

.pv-tab-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.pv-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: #e7e5e4;
    color: #57534e;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.pv-tab.active .pv-tab-count {
    background: #dcfce9;
    color: #156b43;
}

/* ── Carousel Panel (switchable) ────────────────────────────────────────────── */

.pv-carousel-panel {
    animation: pvFadeIn 0.22s ease;
}

.pv-carousel-panel.hidden {
    display: none;
}

@keyframes pvFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Carousel Wrapper ───────────────────────────────────────────────────────── */

.pv-carousel {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

/* ── Tree-photo Caption Bar ─────────────────────────────────────────────────── */

.pv-caption-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.45rem 1.25rem;
    background: #f0fdf6;
    border: 1px solid #bef3db;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1c1917;
    min-height: 2rem;
    transition: opacity 0.2s;
}

.pv-caption-icon {
    color: #198754;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ── Loading spinner ────────────────────────────────────────────────────────── */

/* Spinner is visible by default; hidden once pv-loaded is added */
.pv-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
}

.pv-spinner::after {
    content: '';
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 3px solid rgba(25, 135, 84, 0.2);
    border-top-color: #198754;
    animation: pvSpin 0.7s linear infinite;
}

@keyframes pvSpin {
    to { transform: rotate(360deg); }
}

/* Image hidden while loading, fades in once loaded */
.pv-car-center .pv-car-img-main {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pv-car-center.pv-loaded .pv-car-img-main {
    opacity: 1;
}

.pv-car-center.pv-loaded .pv-spinner {
    display: none;
}

/* ── Image Row ──────────────────────────────────────────────────────────────── */

.pv-car-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

/* Side thumbnails */
.pv-car-side {
    flex: 0 0 110px;
    overflow: hidden;
    border-radius: 8px;
    cursor: zoom-in;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.pv-car-side:hover {
    opacity: 0.78;
}

.pv-car-img-side {
    width: 100%;
    height: 312px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    display: block;
}

/* Center / hero image */
.pv-car-center {
    flex: 1;
    min-width: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    cursor: zoom-in;
    position: relative;
    isolation: isolate;
    background: #f5f5f4;
}

.pv-car-img-main {
    width: 100%;
    max-height: 504px;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

.pv-car-center:hover .pv-car-img-main {
    transform: scale(1.02);
}

/* Zoom hint overlay badge */
.pv-zoom-hint {
    position: absolute;
    bottom: 0.875rem;
    right: 0.875rem;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.pv-car-center:hover .pv-zoom-hint {
    opacity: 1;
}

/* Inline navigation buttons */
.pv-car-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 1px solid #e7e5e4;
    background: #fff;
    color: #57534e;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.15s ease;
}

.pv-car-btn:hover {
    background: #f5f5f4;
    border-color: #d6d3d1;
    color: #198754;
}

/* ── Dot Indicators ─────────────────────────────────────────────────────────── */

.pv-car-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0.25rem 0;
}

.pv-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: #d6d3d1;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.pv-dot.active {
    background: #198754;
    transform: scale(1.45);
}

.pv-dot:hover:not(.active) {
    background: #86efbc;
    transform: scale(1.2);
}

.pv-car-counter {
    text-align: center;
    font-size: 0.75rem;
    color: #a8a29e;
    letter-spacing: 0.03em;
}

/* ── Empty State ────────────────────────────────────────────────────────────── */

.pv-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    border: 2px dashed #e7e5e4;
    border-radius: 14px;
    color: #a8a29e;
    gap: 0;
}

.pv-empty-state p {
    font-size: 0.875rem;
    margin: 0;
}

/* ── Lightbox ────────────────────────────────────────────────────────────────── */

.pv-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 8, 5, 0.9);
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    cursor: zoom-out;
}

.pv-lightbox.pv-lightbox-open {
    display: flex;
    animation: pvLbFadeIn 0.22s ease;
}

@keyframes pvLbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pv-lb-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: min(92vw, 980px);
    max-height: 95vh;
    overflow: hidden;
    cursor: default;
}

.pv-lb-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(90vh - 6rem);
    min-height: 0;
    min-width: 0;
    flex-shrink: 1;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.75);
}

.pv-lb-caption {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    max-width: 620px;
    line-height: 1.45;
}

.pv-lb-indicator {
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.78rem;
    text-align: center;
    letter-spacing: 0.04em;
}

.pv-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 1.25rem;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
    z-index: 10000;
}

.pv-lb-nav:hover {
    background: rgba(255, 255, 255, 0.26);
}

.pv-lb-prev { left: 1.5rem; }
.pv-lb-next { right: 1.5rem; }

/* ── Per-tree lightbox loading spinner ───────────────────────────────────────── */

#pv-lb-inner,
#pv-tlb-inner,
#lv-lb-inner,
#lv-tlb-inner {
    position: relative;
}

.lv-lb-spinner {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.lv-lb-spinner::after {
    content: '';
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.22);
    border-top-color: #fff;
    animation: pvSpin 0.7s linear infinite;
}

.pv-lb-inner.lv-lb-loading .lv-lb-spinner {
    display: flex;
}

.pv-lb-inner .pv-lb-img {
    transition: opacity 0.25s ease;
}

.pv-lb-inner.lv-lb-loading .pv-lb-img {
    opacity: 0.12;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

/* Default: 5-column KPI row */
#pv-kpi-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1023px) {
    #pv-kpi-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    /* KPI: 2 columns */
    #pv-kpi-row {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Info + map: stack */
    #pv-info-map-row {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    #pv-info-map-row > * {
        grid-column: span 1 / span 1 !important;
    }

    .pv-map-wrap {
        min-height: 240px !important;
        height: 240px !important;
    }

    /* Carousel: shorter images on mobile */
    .pv-car-img-main {
        height: 300px;
    }

    .pv-car-img-side {
        height: 198px;
    }

    .pv-car-side {
        flex: 0 0 72px;
    }

    .pv-car-btn {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1rem;
    }

    .pv-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Lightbox: tighter */
    .pv-lightbox {
        padding: 0.5rem;
    }

    .pv-lb-prev { left:  0.25rem; }
    .pv-lb-next { right: 0.25rem; }

    .pv-lb-nav {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1rem;
    }
}
