/**
 * Voyage Planner - Styles
 *
 * All styles scoped under .voyage-planner to prevent conflicts.
 * Design tokens match the Luxury Yacht Experiences site palette.
 */

/* === Variables ===
   Brand tokens consume :root vars from the LYE theme with hex fallbacks
   so the plugin still works if loaded outside the theme context. */
.voyage-planner {
    --vp-navy: var(--lye-brand-primary, #1e3a5f);
    --vp-gold: var(--lye-brand-secondary, #c9a959);
    --vp-dark: var(--lye-brand-dark, #0d1b2a);
    --vp-light: var(--lye-brand-light, #f8f9fa);
    --vp-white: #ffffff;
    --vp-gray-100: #f3f4f6;
    --vp-gray-200: #e5e7eb;
    --vp-gray-300: #d1d5db;
    --vp-gray-500: #6b7280;
    --vp-gray-700: #374151;
    --vp-radius: 0.5rem;
    --vp-font-body: 'Inter', sans-serif;
    --vp-font-heading: 'Playfair Display', serif;
    --vp-transition: 150ms ease;
}

/* === Layout === */

/* Prevent horizontal scroll on pages with the planner (100vw includes scrollbar).
   Also collapse the section padding above/below so the map sits flush against the hero. */
body:has(.voyage-planner) {
    overflow-x: hidden;
}

.section:has(.voyage-planner) {
    padding-top: 0;
    padding-bottom: 0;
}

/* Break out of narrow content containers (e.g. max-w-3xl). */
.voyage-planner {
    font-family: var(--vp-font-body);
    color: var(--vp-dark);
    line-height: 1.5;
    overflow: hidden;
    border-top: 1px solid var(--vp-gray-200);
    border-bottom: 1px solid var(--vp-gray-200);
    background: var(--vp-white);
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.voyage-planner *,
.voyage-planner *::before,
.voyage-planner *::after {
    box-sizing: border-box;
}

/* Height fills the viewport below the page hero, so the CTA overlay at the
   bottom of the map is on screen as soon as a route is drawn.
   The real distance from the top of the page varies with the hero, so JS
   measures it and sets --vp-layout-height. The calc() is the no-JS fallback.
   On shorter screens the min-height ensures it stays usable. */
.vp-layout {
    display: flex;
    height: var(--vp-layout-height, calc(100vh - 280px));
    /* The floor for very short windows. Kept low so the CTA overlay stays on
       screen down to roughly a 710px viewport; below that the hero above the
       planner leaves too little room and the strip needs a small scroll. */
    min-height: 360px;
}

.vp-panel {
    width: 340px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid var(--vp-gray-200);
    background: var(--vp-white);
}

.vp-map-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

.vp-map {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}

/* === Empty State === */
.vp-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    height: 100%;
    min-height: 300px;
}

.vp-empty-icon {
    color: var(--vp-gray-300);
    margin-bottom: 1rem;
}

.vp-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--vp-dark);
    margin: 0 0 0.5rem;
}

.vp-empty-hint {
    font-size: 0.8125rem;
    color: var(--vp-gray-500);
    margin: 0;
}

/* === Preset Route Selector === */
.vp-preset-wrap {
    margin-top: 1.25rem;
    width: 100%;
    max-width: 240px;
}

.vp-preset-label {
    font-size: 0.75rem;
    color: var(--vp-gray-500);
    margin: 0 0 0.375rem;
}

.vp-preset-select {
    width: 100%;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    font-family: var(--vp-font-body);
    color: var(--vp-dark);
    border: 1px solid var(--vp-gray-200);
    border-radius: 0.375rem;
    background: var(--vp-white);
    cursor: pointer;
    transition: border-color var(--vp-transition);
}

.vp-preset-select:focus {
    outline: none;
    border-color: var(--vp-navy);
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.1);
}

/* === Sections === */
.vp-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--vp-gray-100);
}

.vp-section-title {
    font-family: var(--vp-font-heading);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--vp-navy);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin: 0 0 0.75rem;
}

/* === Distance Display === */
.vp-distance-row {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
}

.vp-big-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--vp-dark);
    font-variant-numeric: lining-nums tabular-nums;
}

.vp-small-number {
    font-size: 1rem;
    font-weight: 600;
    color: var(--vp-gray-500);
    font-variant-numeric: lining-nums tabular-nums;
}

.vp-unit {
    font-size: 0.75rem;
    color: var(--vp-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 0.25rem;
}

/* === Waypoint List === */
.vp-waypoint-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.vp-waypoint-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--vp-gray-100);
}

.vp-waypoint-item:last-child {
    border-bottom: none;
}

.vp-waypoint-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--vp-navy);
    color: var(--vp-white);
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
}

.vp-waypoint-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.vp-waypoint-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--vp-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vp-waypoint-leg {
    font-size: 0.6875rem;
    color: var(--vp-gray-500);
}

.vp-waypoint-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border: none;
    background: none;
    color: var(--vp-gray-500);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: color var(--vp-transition), background var(--vp-transition);
    flex-shrink: 0;
}

.vp-waypoint-remove:hover {
    color: #dc2626;
    background: #fef2f2;
}

/* === Input Grid === */
.vp-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}

.vp-input-group label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--vp-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.vp-input-with-unit {
    position: relative;
}

.vp-input-with-unit input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    padding-right: 3rem;
    font-size: 0.875rem;
    font-family: var(--vp-font-body);
    color: var(--vp-dark);
    border: 1px solid var(--vp-gray-200);
    border-radius: 0.375rem;
    background: var(--vp-white);
    transition: border-color var(--vp-transition);
    -moz-appearance: textfield;
}

.vp-input-with-unit input::-webkit-inner-spin-button,
.vp-input-with-unit input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.vp-input-with-unit input:focus {
    outline: none;
    border-color: var(--vp-navy);
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.1);
}

.vp-input-unit {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6875rem;
    color: var(--vp-gray-500);
    pointer-events: none;
}

/* === Results Grid === */
.vp-results-grid {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.vp-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--vp-gray-100);
    border-radius: 0.375rem;
}

.vp-result-label {
    font-size: 0.8125rem;
    color: var(--vp-gray-700);
}

.vp-result-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--vp-dark);
    font-variant-numeric: lining-nums tabular-nums;
}

.vp-result-value small {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--vp-gray-500);
    margin-left: 0.125rem;
}

/* === Action Buttons === */
.vp-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
}

.vp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--vp-font-body);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background var(--vp-transition), color var(--vp-transition), border-color var(--vp-transition);
    white-space: nowrap;
    border: 1px solid transparent;
}

.vp-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.vp-btn-secondary {
    background: var(--vp-white);
    color: var(--vp-gray-700);
    border-color: var(--vp-gray-200);
}

.vp-btn-secondary:hover {
    background: var(--vp-gray-100);
    border-color: var(--vp-gray-300);
}

/* === CTA === */
.vp-cta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    background: rgba(13, 27, 42, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--vp-white);
}

.vp-cta-text {
    font-size: 0.875rem;
    font-weight: 500;
    flex: 1;
}

.vp-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--vp-dark);
    background: var(--vp-gold);
    border-radius: 0.375rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--vp-transition);
}

.vp-cta-btn:hover {
    background: color-mix(in oklch, var(--vp-gold) 88%, white);
    color: var(--vp-dark);
}

.vp-cta-btn svg {
    width: 14px;
    height: 14px;
}

/* Button reset for CTA when rendered as <button> instead of <a> */
button.vp-cta-btn {
    border: none;
    cursor: pointer;
    font-family: var(--vp-font-body);
}

/* === Inline Form Section === */
.vp-form-section {
    border-top: 1px solid var(--vp-gray-200);
    background: var(--vp-light);
}

.vp-form-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.vp-form-title {
    font-family: var(--vp-font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--vp-dark);
    margin: 0 0 0.5rem;
}

.vp-form-subtitle {
    font-size: 0.875rem;
    color: var(--vp-gray-500);
    margin: 0 0 1.5rem;
}

/* === Map Markers === */
.vp-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--vp-navy, #1e3a5f);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: grab;
    user-select: none;
    transition: transform 100ms ease;
}

.vp-marker:hover {
    transform: scale(1.15);
}

.vp-marker:active {
    cursor: grabbing;
}

/* === Control-Point Marker === */
.vp-control-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--vp-gold, #c9a959);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: grab;
    user-select: none;
    transition: transform 100ms ease;
}

.vp-control-marker:hover {
    transform: scale(1.3);
}

.vp-control-marker:active {
    cursor: grabbing;
}

/* === Control-Point Sidebar Item === */
.vp-control-point-item {
    background: rgba(201, 169, 89, 0.06);
}

.vp-control-point-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.vp-control-point-badge::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--vp-gold, #c9a959);
    border: 1.5px solid #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.vp-control-point-label {
    font-size: 0.75rem;
    font-style: italic;
    color: var(--vp-gray-500, #6b7280);
}

/* === Mapbox overrides === */
.voyage-planner .mapboxgl-ctrl-group {
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* === Responsive: Tablet & Mobile === */
@media (max-width: 900px) {
    .vp-layout {
        flex-direction: column;
        height: auto;
        min-height: auto;
        max-height: none;
    }

    .vp-panel {
        width: 100%;
        border-right: none;
        border-top: 1px solid var(--vp-gray-200);
        max-height: none;
        order: 2;
    }

    .vp-map-wrap {
        width: 100%;
        height: 50vh;
        min-height: 400px;
        order: 1;
    }

    .vp-map {
        position: absolute;
        inset: 0;
    }

    .vp-empty-state {
        min-height: 150px;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .vp-map-wrap {
        height: 45vh;
        min-height: 300px;
    }

    .vp-input-grid {
        grid-template-columns: 1fr;
    }

    .vp-cta {
        flex-direction: column;
        text-align: center;
    }

    .vp-distance-row {
        flex-direction: column;
        gap: 0.25rem;
    }
}
