/* ===========================
   DESIGN TOKENS
   =========================== */
:root {
    --color-bg: #f7f7f5;
    --color-surface: #ffffff;
    --color-border: #e8e8e4;
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #6b6b6b;
    --color-accent: #2563eb;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-success: #16a34a;

    --font-family: "Inter", system-ui, -apple-system, sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);

    --right-col-width: 25%;
    --header-height: 52px;
    --spacing-xs: 6px;
    --spacing-sm: 12px;
    --spacing-md: 20px;
    --spacing-lg: 28px;
    --spacing-xl: 40px;
}

/* ===========================
   RESET & BASE
   =========================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    font-family: var(--font-family);
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ===========================
   MAIN LAYOUT
   =========================== */
.main-layout {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

/* ===========================
   VIEWER PANE (dominant left)
   =========================== */
.viewer-pane {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
    background: #191919;
    border-right: 1px solid var(--color-border);
    overflow: hidden;
}

/* Camera mode toggle */
.cam-mode-toggle {
    position: fixed;
    bottom: 12px;
    left: calc((100% - var(--right-col-width)) / 2);
    transform: translateX(-50%);
    display: flex;
    gap: 0;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: visible;
    backdrop-filter: blur(8px);
    z-index: 20;
}
.ortho-wrap {
    position: relative;
}
.ortho-dropdown {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.ortho-dropdown-inner {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    overflow: hidden;
}
.ortho-wrap:hover .ortho-dropdown {
    opacity: 1;
    pointer-events: auto;
}
.ortho-option {
    padding: 6px 20px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-family: "Inter", sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.15s,
        color 0.15s;
    width: 100%;
}
.ortho-option:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.cam-mode-toggle > .cam-mode-btn:first-child {
    border-radius: 8px 0 0 8px;
}
.cam-mode-toggle > .cam-mode-btn:last-child,
.cam-mode-toggle > .ortho-wrap:last-child .cam-mode-btn {
    border-radius: 0 8px 8px 0;
}
.cam-mode-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-family: "Inter", sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition:
        background 0.2s,
        color 0.2s;
}
.cam-mode-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}
.cam-mode-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* A-Frame scene fills the viewer pane */
#aframe-scene {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

#aframe-scene canvas {
    width: 100% !important;
    height: 100% !important;
}

.viewer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    border: 1px dashed var(--color-border);
    color: var(--color-text-secondary);
    max-width: 360px;
    width: 60%;
    text-align: center;
}

.viewer-icon {
    width: 80px;
    height: 80px;
    opacity: 0.5;
    flex-shrink: 0;
}

.viewer-label {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

/* ===========================
   RIGHT COLUMN
   =========================== */
.right-col {
    flex: 0 0 var(--right-col-width);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

/* ===========================
   INFO HEADER (top of right col)
   =========================== */
.info-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: nowrap;
}

.info-header-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1 1 auto;
    min-width: 0;
}

.info-header-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.info-header-main {
    flex: 1 1 auto;
    min-width: 0;
}

.info-header-site {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-secondary);
    margin-bottom: 1px;
}

.car-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.car-subtitle {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-secondary);
    margin-top: 2px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* ===========================
   PHOTO PANE (mid of right col)
   =========================== */
.photo-pane {
    flex: 0 0 42%;
    min-height: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--color-border);
}

.photo-strip {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs);
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.photo-strip::-webkit-scrollbar {
    width: 4px;
}
.photo-strip::-webkit-scrollbar-track {
    background: transparent;
}
.photo-strip::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

.photo-card {
    width: 100%;
    aspect-ratio: 4 / 3;
    flex-shrink: 0;
    background: var(--color-surface);
    cursor: zoom-in;
    overflow: hidden;
    position: relative;
    user-select: none;
}

.photo-card-icon {
    width: 24px;
    height: 24px;
    opacity: 0.45;
}

.photo-card-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.6;
}

.photo-card-index {
    position: absolute;
    top: var(--spacing-xs);
    left: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.photo-card-index .caption {
    font-weight: 400;
    opacity: 0.85;
}

/* ===========================
   INFO PANEL (bottom of right col)
   =========================== */
.info-panel {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
    min-height: 0;
}

.info-panel::-webkit-scrollbar {
    width: 4px;
}
.info-panel::-webkit-scrollbar-track {
    background: transparent;
}
.info-panel::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

/* ===========================
   VIN BADGE
   =========================== */
.vin-wrap {
    position: relative;
    flex-shrink: 0;
}

.vin-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px var(--spacing-xs);
    cursor: pointer;
    font-family: "SF Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    transition:
        border-color 0.15s,
        color 0.15s,
        box-shadow 0.15s;
    white-space: nowrap;
}

.vin-badge:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.vin-badge:active {
    transform: scale(0.98);
}

.vin-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    font-family: var(--font-family);
}

.vin-value {
    letter-spacing: 0.05em;
}

.vin-tooltip {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--color-text-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        opacity 0.15s,
        transform 0.15s;
    font-family: var(--font-family);
}

.vin-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.vin-tooltip::before {
    content: "";
    position: absolute;
    bottom: 100%;
    right: 14px;
    border: 5px solid transparent;
    border-bottom-color: var(--color-text-primary);
}

/* ===========================
   CARDS GRID (1-col in sidebar)
   =========================== */
.cards-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.info-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-xs);
}

.card-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.card-rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xs) var(--spacing-sm);
}

.card-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.card-row-label {
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    opacity: 0.8;
}

.card-row-value {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-primary);
    line-height: 1.3;
}

/* ===========================
   FULLSCREEN OVERLAY
   =========================== */
.fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.fullscreen-overlay.active {
    display: flex;
}

.fullscreen-img {
    width: 100vw;
    height: 100vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.fullscreen-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.15s,
        color 0.15s;
    z-index: 2;
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.fullscreen-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.25rem;
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.15s,
        color 0.15s;
    z-index: 2;
}

.fullscreen-nav:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.fullscreen-prev {
    left: var(--spacing-md);
}
.fullscreen-next {
    right: var(--spacing-md);
}

.fullscreen-caption {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.fullscreen-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.fullscreen-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    padding: 0;
}

.fullscreen-dot.active {
    background: #fff;
}

/* ===========================
   POI MARKERS
   =========================== */
.poi-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
    transition:
        width 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.15s;
}

.poi-dot:hover,
.poi-dot.hovered {
    width: 22px;
    height: 22px;
}

.poi-tooltip {
    position: absolute;
    left: 50%;
    /* pad-bottom bridges the gap so mouse can travel from dot to tooltip */
    bottom: calc(100% + 2px);
    padding-bottom: 12px;
    transform: translateX(-50%) translateY(4px);
    width: 200px;
    pointer-events: none;
    opacity: 0;
    transition:
        opacity 0.18s,
        transform 0.18s cubic-bezier(0.34, 1.2, 0.64, 1);
    z-index: 30;
}

.poi-tooltip-inner {
    background: rgba(15, 15, 15, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.poi-dot:hover .poi-tooltip,
.poi-dot.hovered .poi-tooltip {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.poi-tooltip-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.06);
    display: block;
    overflow: hidden;
    cursor: zoom-in;
    transition: filter 0.15s, transform 0.15s;
}

.poi-tooltip-img:hover {
    filter: brightness(1.12);
    transform: scale(1.02);
}

.poi-tooltip-img-placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.poi-tooltip-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.35;
    margin-bottom: 4px;
}

.poi-tooltip-desc {
    font-size: 0.68rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.45;
}

/* ===========================
   RESPONSIVE
   =========================== */

/* Narrow screens — switch to fixed width */
@media (max-width: 900px) {
    :root {
        --right-col-width: 260px;
    }
}

/* Mobile — stack vertically */
@media (max-width: 640px) {
    .cam-mode-toggle {
        left: 50%;
    }
    body {
        height: auto;
        overflow: auto;
    }

    .main-layout {
        flex-direction: column;
        overflow: visible;
    }

    .viewer-pane {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        height: 50vw;
        min-height: 220px;
        flex: none;
    }

    .right-col {
        flex: none;
        width: 100%;
    }

    .photo-pane {
        flex: none;
        height: 160px;
        border-bottom: 1px solid var(--color-border);
    }

    .photo-strip {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        height: 100%;
    }

    .photo-card {
        width: 160px;
        flex-shrink: 0;
    }

    .info-panel {
        flex: none;
        overflow-y: visible;
    }

    .cards-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xs);
    }
}
