/*
 * Coach seat map (tour page). Colours are the theme's Tailwind tokens (tailwind.config.js);
 * the font is inherited from the theme.
 *
 * Narrow containers (default): front of the coach at the top, driver side on the right.
 * Containers 600px and wider: front on the left, driver side at the top.
 * --coach-rows / --coach-cols are set inline by coach_renderer.php from the API's dimensions.
 */
.coach-layout {
    /* The theme's variable font (elza-round) takes its weight from font-variation-settings,
       which is inherited and overrides font-weight, so every weight below sets both. */
    --coach-blue: #154396;        /* alfa-dark-blue */
    --coach-black: #130c0e;       /* alfa-black */
    --coach-muted: #5b6472;
    --coach-border: #e2e6ee;
    --coach-shell: #f7f9fc;
    --coach-shell-border: #c9d3e6;
    --coach-fixed: #eaeef5;
    --coach-taken-border: #d5dae2;
    --coach-taken-text: #5f6876;
    --coach-taken-fill: repeating-linear-gradient(135deg, #eceff3 0 5px, #e1e5eb 5px 10px);

    container-type: inline-size;
    font-weight: 400;
    font-variation-settings: 'wght' 400;
    color: var(--coach-black);
}

/* Key */
.coach-layout__key {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.coach-layout__key-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 6px 12px;
    border: 1px solid var(--coach-border);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    font-variation-settings: 'wght' 600;
    white-space: nowrap;
}

.coach-layout__key-swatch {
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    border-radius: 5px 5px 3px 3px;
}

.coach-layout__key-swatch--available {
    border: 1.5px solid var(--coach-blue);
    background: #fff;
}

.coach-layout__key-swatch--taken {
    border: 1.5px solid var(--coach-taken-border);
    background: repeating-linear-gradient(135deg, #eceff3 0 3px, #dde2e9 3px 6px);
}

/* Map: narrow (portrait) layout by default */
.coach-layout__map {
    --seat: clamp(28px, calc((100cqi - 80px) / var(--coach-cols, 5) - 6px), 38px);
    --seat-gap: 6px;

    display: flex;
    flex-direction: column;
    gap: 8px;
}

.coach-layout__side-label {
    display: none;
    margin: 0;
    padding-left: 44px;
    font-size: 12px;
    font-weight: 700;
    font-variation-settings: 'wght' 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--coach-muted);
}

.coach-layout__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
}

.coach-layout__front {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--coach-blue);
    font-size: 11px;
    font-weight: 700;
    font-variation-settings: 'wght' 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.coach-layout__front svg {
    transform: rotate(90deg);
}

.coach-layout__sides {
    display: flex;
    align-self: stretch;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 11px;
    font-weight: 700;
    font-variation-settings: 'wght' 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--coach-muted);
}

.coach-layout__shell {
    max-width: 100%;
    box-sizing: border-box;
    padding: 14px;
    overflow-x: auto;
    background: var(--coach-shell);
    border: 2px solid var(--coach-shell-border);
    border-radius: 48px 48px 16px 16px;
}

.coach-layout__grid {
    display: flex;
    flex-direction: column;
    gap: var(--seat-gap);
}

.coach-layout__row {
    display: grid;
    grid-template-columns: repeat(var(--coach-cols, 5), var(--seat));
    grid-template-rows: var(--seat);
    gap: var(--seat-gap);
    direction: rtl; /* driver side (column 0) on the right */
}

/* Wide (landscape) layout */
@container (min-width: 600px) {
    .coach-layout__map {
        --seat: clamp(26px, calc((100cqi - 130px) / var(--coach-rows, 13) - 7px), 40px);
        --seat-gap: 7px;

        padding: 20px 18px;
        border: 1px solid var(--coach-border);
        border-radius: 16px;
        box-shadow: 0 2px 10px rgba(21, 67, 150, 0.06);
    }

    .coach-layout__side-label {
        display: block;
    }

    .coach-layout__body {
        flex-direction: row;
        gap: 12px;
        width: auto;
        margin: 0;
    }

    .coach-layout__front {
        flex: 0 0 32px;
        gap: 6px;
    }

    .coach-layout__front svg {
        transform: none;
    }

    .coach-layout__sides {
        display: none;
    }

    .coach-layout__shell {
        padding: 16px 20px 16px 18px;
        border-radius: 56px 18px 18px 56px;
    }

    .coach-layout__grid {
        flex-direction: row;
    }

    .coach-layout__row {
        grid-template-columns: var(--seat);
        grid-template-rows: repeat(var(--coach-cols, 5), var(--seat));
        direction: ltr;
    }
}

/* Cells */
.coach-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--seat);
    height: var(--seat);
    box-sizing: border-box;
    border-radius: 10px 10px 6px 6px;
    font-size: clamp(12px, calc(var(--seat) * 0.37), 14px);
    font-weight: 700;
    font-variation-settings: 'wght' 700;
    line-height: 1;
    user-select: none;
}

.coach-cell--selectable.coach-cell--available {
    border: 1.5px solid var(--coach-blue);
    background: #fff;
    color: var(--coach-blue);
}

.coach-cell--selectable.coach-cell--reserved {
    border: 1.5px solid var(--coach-taken-border);
    background: var(--coach-taken-fill);
    color: var(--coach-taken-text);
    font-weight: 600;
    font-variation-settings: 'wght' 600;
}

.coach-cell--fixed {
    border-radius: 10px;
    background: var(--coach-fixed);
    color: #4a5568;
    font-size: 12px;
}

.coach-cell--driver {
    background: transparent;
    color: var(--coach-muted);
}

.coach-cell--driver svg {
    width: 80%;
    height: 80%;
}

.coach-cell--aisle,
.coach-cell--empty {
    background: transparent;
    border: none;
}

.coach-layout__stale-note {
    margin: 0 0 16px;
    padding: 8px 12px;
    background: #fff6e5;
    border: 1px solid #e0a800;
    border-radius: 8px;
    color: #6a4d00;
    font-size: 14px;
}
