/**
 * Multicolumn Pricing Table — Frontend Styles
 *
 * Row-major CSS Grid: every row is a real element whose columns are laid out
 * with a shared grid-template, so cells align at natural content height and no
 * fixed row heights are needed. The label column is pinned with position:sticky
 * so the table can scroll horizontally on narrow viewports.
 *
 * @version 1.0.0
 */

.ew-mcpt {
    --ew-mcpt-label-width: 30%;
    --ew-mcpt-column-gap: 0px;
    --ew-mcpt-divider: #e6eaf2;
    --ew-mcpt-surface: #ffffff;
    --ew-mcpt-tip-bg: #1d2939;
    --ew-mcpt-tip-color: #ffffff;
    --ew-mcpt-tip-arrow: 6px;
}

/* Horizontal scroller. The small vertical padding gives tooltips breathing
   room, since overflow-x also makes overflow-y scrollable. */
.ew-mcpt__scroll {
    overflow-x: auto;
    /* padding-block: 10px; */
    -webkit-overflow-scrolling: touch;
}

.ew-mcpt__table {
    display: flex;
    flex-direction: column;
    min-width: 720px;
    background: var(--ew-mcpt-surface);
}

/* ── Rows ──────────────────────────────────────────────────────────────── */

.ew-mcpt__row {
    display: grid;
    column-gap: var(--ew-mcpt-column-gap);
}

/* Static templates: repeat() with a var() count has patchy browser support. */
.ew-mcpt--cols-1 .ew-mcpt__row { grid-template-columns: var(--ew-mcpt-label-width) 1fr; }
.ew-mcpt--cols-2 .ew-mcpt__row { grid-template-columns: var(--ew-mcpt-label-width) 1fr 1fr; }
.ew-mcpt--cols-3 .ew-mcpt__row { grid-template-columns: var(--ew-mcpt-label-width) 1fr 1fr 1fr; }
.ew-mcpt--cols-4 .ew-mcpt__row { grid-template-columns: var(--ew-mcpt-label-width) 1fr 1fr 1fr 1fr; }
.ew-mcpt--cols-5 .ew-mcpt__row { grid-template-columns: var(--ew-mcpt-label-width) 1fr 1fr 1fr 1fr 1fr; }

.ew-mcpt__row--hidden {
    display: none;
}

/* ── Cells ─────────────────────────────────────────────────────────────── */

.ew-mcpt__cell {
    display: flex;
    align-items: center;
    min-width: 0;
    background: var(--ew-mcpt-cell-bg, transparent);
}

/* Sticky cells need an opaque background or the scrolled columns show through. */
.ew-mcpt__corner,
.ew-mcpt__label {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--ew-mcpt-cell-bg, var(--ew-mcpt-surface));
}

.ew-mcpt__corner {
    padding: 24px 20px;
    color: #101828;
    border-bottom: 1px solid var(--ew-mcpt-divider);
}

.ew-mcpt__corner-icon,
.ew-mcpt__label-icon,
.ew-mcpt__value-icon,
.ew-mcpt__badge-icon,
.ew-mcpt__toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ew-mcpt__corner-image {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Label column ──────────────────────────────────────────────────────── */

.ew-mcpt__label {
    gap: 8px;
    padding: 16px 20px;
    color: #344054;
}

.ew-mcpt__label-text {
    min-width: 0;
}

/* Row icon placement (Modern layout only). */
.ew-mcpt--icon-right .ew-mcpt__label { flex-direction: row-reverse; justify-content: flex-end; }
.ew-mcpt--icon-top .ew-mcpt__label { flex-direction: column; align-items: flex-start; }
.ew-mcpt--icon-bottom .ew-mcpt__label { flex-direction: column-reverse; align-items: flex-start; }

/* ── Package header ────────────────────────────────────────────────────── */

.ew-mcpt__package {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    padding: 24px 20px;
    text-align: center;
}

.ew-mcpt__package-title {
    margin: 0 0 8px;
    color: #101828;
    font-size: 1.25em;
    line-height: 1.3;
}

.ew-mcpt__prices {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin-bottom: 0 !important;
}

.ew-mcpt__price {
    color: #101828;
    font-size: 1.75em;
    font-weight: 700;
    line-height: 1.1;
}

.ew-mcpt__old-price {
    color: #98a2b3;
    text-decoration: line-through;
}

.ew-mcpt__old-price-wrap {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    text-decoration: line-through;
}

.ew-mcpt__old-price-wrap .ew-mcpt__old-price {
    text-decoration: none;
}

.ew-mcpt__period {
    color: #667085;
    font-size: 0.875em;
}

/* ── Featured badge ────────────────────────────────────────────────────── */

.ew-mcpt__badge-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.ew-mcpt__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    background-color: #2f6bff;
    color: #ffffff;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ── Value cells ───────────────────────────────────────────────────────── */

.ew-mcpt__value {
    position: relative;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    color: #475467;
    text-align: center;
}

.ew-mcpt__value-icon {
    color: #12b76a;
    font-size: 18px;
    flex-shrink: 0;
}

.ew-mcpt__value-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.ew-mcpt__value-text {
    min-width: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.ew-mcpt__button-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}

.ew-mcpt__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 12px 20px;
    border-radius: 6px;
    background-color: #101828;
    color: #ffffff;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ew-mcpt__button:hover,
.ew-mcpt__button:focus-visible {
    background-color: #2f6bff;
    color: #ffffff;
}

.ew-mcpt__button-cell {
    padding: 16px;
}

/* ── Collapse toggle ───────────────────────────────────────────────────── */

.ew-mcpt__toggle-wrap {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.ew-mcpt__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 0;
    border-radius: 6px;
    background-color: transparent;
    color: #101828;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ew-mcpt__toggle-label {
    display: none;
    align-items: center;
    gap: 8px;
}

/* Collapsed is the server-rendered starting state. */
.ew-mcpt__toggle[aria-expanded="false"] .ew-mcpt__toggle-label--collapsed,
.ew-mcpt__toggle[aria-expanded="true"] .ew-mcpt__toggle-label--expanded {
    display: inline-flex;
}

/* ── Tooltips (CSS only) ───────────────────────────────────────────────── */

.ew-mcpt__value[data-ew-tip] {
    cursor: help;
}

.ew-mcpt__value[data-ew-tip]::after,
.ew-mcpt__value[data-ew-tip]::before {
    position: absolute;
    left: 50%;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.ew-mcpt__value[data-ew-tip]::after {
    content: attr(data-ew-tip);
    max-width: 220px;
    width: max-content;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--ew-mcpt-tip-bg);
    color: var(--ew-mcpt-tip-color);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
    white-space: normal;
}

.ew-mcpt__value[data-ew-tip]::before {
    content: "";
    border: var(--ew-mcpt-tip-arrow) solid transparent;
}

/* Tooltip above the cell (default). */
.ew-mcpt--tip-top .ew-mcpt__value[data-ew-tip]::after {
    bottom: calc(100% - 6px);
    transform: translateX(-50%);
}

.ew-mcpt--tip-top .ew-mcpt__value[data-ew-tip]::before {
    bottom: calc(100% - 6px - var(--ew-mcpt-tip-arrow) * 2);
    transform: translateX(-50%);
    border-top-color: var(--ew-mcpt-tip-bg);
}

/* Tooltip below the cell. */
.ew-mcpt--tip-bottom .ew-mcpt__value[data-ew-tip]::after {
    top: calc(100% - 6px);
    transform: translateX(-50%);
}

.ew-mcpt--tip-bottom .ew-mcpt__value[data-ew-tip]::before {
    top: calc(100% - 6px - var(--ew-mcpt-tip-arrow) * 2);
    transform: translateX(-50%);
    border-bottom-color: var(--ew-mcpt-tip-bg);
}

.ew-mcpt__value[data-ew-tip]:hover::after,
.ew-mcpt__value[data-ew-tip]:hover::before,
.ew-mcpt__value[data-ew-tip]:focus::after,
.ew-mcpt__value[data-ew-tip]:focus::before,
.ew-mcpt__value[data-ew-tip]:focus-visible::after,
.ew-mcpt__value[data-ew-tip]:focus-visible::before {
    opacity: 1;
    visibility: visible;
}

/* A hovered cell must sit above its neighbours or the tooltip is overlapped. */
.ew-mcpt__value[data-ew-tip]:hover,
.ew-mcpt__value[data-ew-tip]:focus,
.ew-mcpt__value[data-ew-tip]:focus-visible {
    z-index: 3;
}

/* ── Title effects ─────────────────────────────────────────────────────── */

.ew-mcpt--marquee .ew-mcpt__package {
    overflow: hidden;
}

.ew-mcpt--marquee .ew-mcpt__package-title {
    white-space: nowrap;
    animation-name: ew-mcpt-scroll-left;
    animation-duration: 10s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes ew-mcpt-scroll-left {
    from { transform: translateX(100%); }
    to   { transform: translateX(-100%); }
}

@keyframes ew-mcpt-scroll-right {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .ew-mcpt--marquee .ew-mcpt__package-title {
        animation: none;
        white-space: normal;
    }
}

.ew-mcpt--reflect .ew-mcpt__package-title {
    -webkit-box-reflect: below 4px linear-gradient(transparent, rgba(0, 0, 0, 0.25));
}

/* ── Retro layout ──────────────────────────────────────────────────────── */

.ew-mcpt--retro .ew-mcpt__row--head .ew-mcpt__cell,
.ew-mcpt--retro .ew-mcpt__row--feature .ew-mcpt__cell {
    border-bottom: 1px solid var(--ew-mcpt-divider);
}

.ew-mcpt--retro .ew-mcpt__row--feature:last-child .ew-mcpt__cell {
    border-bottom: 0;
}

.ew-mcpt--retro .ew-mcpt__cell + .ew-mcpt__cell {
    border-left: 1px solid var(--ew-mcpt-divider);
}

/* No overflow:hidden here — it would become the sticky containing block and
   silently kill the pinned label column. Corners are rounded on the edge cells
   instead. */
.ew-mcpt--retro .ew-mcpt__table {
    border: 1px solid var(--ew-mcpt-divider);
    border-radius: 8px;
}

.ew-mcpt--retro .ew-mcpt__row--head .ew-mcpt__cell:first-child {
    border-top-left-radius: 8px;
}

.ew-mcpt--retro .ew-mcpt__row--head .ew-mcpt__cell:last-child {
    border-top-right-radius: 8px;
}

.ew-mcpt--retro .ew-mcpt__row--feature:last-child .ew-mcpt__cell:first-child {
    border-bottom-left-radius: 8px;
}

.ew-mcpt--retro .ew-mcpt__row--feature:last-child .ew-mcpt__cell:last-child {
    border-bottom-right-radius: 8px;
}

/* ── Modern layout ─────────────────────────────────────────────────────── */

.ew-mcpt--modern .ew-mcpt__row--feature .ew-mcpt__cell {
    border-bottom: 1px solid var(--ew-mcpt-divider);
}

.ew-mcpt--modern .ew-mcpt__package {
    border-bottom: 1px solid var(--ew-mcpt-divider);
}

.ew-mcpt--modern .ew-mcpt__row--foot .ew-mcpt__cell {
    padding-top: 20px;
}

.ew-mcpt--modern .ew-mcpt__label {
    justify-content: flex-start;
}

/* ── Small viewports ───────────────────────────────────────────────────── */

@media screen and (max-width: 767px) {
    .ew-mcpt {
        --ew-mcpt-label-width: 42%;
    }

    .ew-mcpt__corner,
    .ew-mcpt__package {
        padding: 16px 12px;
    }

    .ew-mcpt__value,
    .ew-mcpt__label {
        padding: 12px;
    }

    .ew-mcpt__price {
        font-size: 1.375em;
    }
}
