/* ─── Meal plan detail ───────────────────────────────────────────────
   Two-column on desktop (option cards + sticky order summary), single
   column with a fixed bottom summary bar below `lg`.

   Hand-written and linked directly by the page, so it is NOT regenerated
   by `npm run build:styles` — keep layout here rather than as Tailwind
   utilities in the Blade. */

/* No global x-cloak rule exists in main.css, so define it here — without it
   x-show elements flash visible before Alpine boots. */
.plan-detail [x-cloak] {
    display: none !important;
}

.plan-detail {
    --pd-accent: #279ff9;
    --pd-green: #3fb536;
    --pd-surface: #fff;
    --pd-muted: rgba(15, 23, 42, 0.62);
    --pd-border: rgba(148, 163, 184, 0.28);
    --pd-radius: 1rem;
    /* Everything nested inside a card shell. */
    --pd-radius-inner: 0.75rem;

    background: #f5f5fa;
    padding-top: 1.25rem;
    /* Clearance for the fixed bottom bar. */
    padding-bottom: 11rem;
}

@media (min-width: 768px) {
    .plan-detail {
        padding-top: 2rem;
    }
}

@media (min-width: 1024px) {
    .plan-detail {
        padding-bottom: 4rem;
    }
}

.plan-detail__breadcrumb {
    margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
    .plan-detail__breadcrumb {
        margin-bottom: 1.75rem;
    }
}

.plan-detail__cta {
    margin-top: 1rem;
}

/* ─── Layout ─────────────────────────────────────────────────────── */

.plan-detail__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.plan-detail__main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 1024px) {
    .plan-detail__layout {
        grid-template-columns: minmax(0, 1fr) 22rem;
        gap: 1.5rem;
    }
}

/* ─── Shared card shell ──────────────────────────────────────────── */

.plan-detail__block {
    padding: 1.15rem 1.25rem;
    border-radius: var(--pd-radius);
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.plan-detail__block-head {
    margin-bottom: 0.85rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #0f172a;
}

.plan-detail__divider {
    margin: 1rem 0;
    height: 1px;
    background: #e2e8f0;
}

/* ─── Hero card ──────────────────────────────────────────────────── */

.plan-detail__hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.plan-detail__hero-media {
    width: 100%;
    max-width: 13rem;
    aspect-ratio: 16 / 10;
    flex-shrink: 0;
}

.plan-detail__hero-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.plan-detail__hero-body {
    min-width: 0;
    width: 100%;
}

.plan-detail__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
}

.plan-detail__title {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 600;
    line-height: 1.15;
    color: #0f172a;
}

.plan-detail__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
}

.plan-detail__badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: #f1f5f9;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.plan-detail__kcal {
    margin-top: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #0f172a;
}

.plan-detail__kcal .plan-detail__emoji {
    font-size: 1.15rem;
}

.plan-detail__desc {
    margin-top: 0.85rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--pd-muted);
}

/* Macro strip — program-wide envelope, independent of the selected variant */
.plan-detail__macros {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* Small screens: stack the emoji above the text at the start of each column.
   Side-by-side collides once a range gets long ("15 – 322 g"). */
.plan-detail__macro {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    flex: 1 1 0;
    min-width: 0;
}

.plan-detail__emoji {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
}

.plan-detail__macro-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.plan-detail__macro-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
    /* Wraps on narrow screens; pinned to one line from `md` below. */
}

.plan-detail__macro-label {
    font-size: 0.8125rem;
    color: var(--pd-muted);
}

@media (min-width: 768px) {
    .plan-detail__hero {
        flex-direction: row;
        align-items: center;
        text-align: start;
        gap: 1.75rem;
        padding: 0.5rem 0.75rem;
    }

    .plan-detail__hero-media {
        max-width: 15rem;
    }

    .plan-detail__title-row,
    .plan-detail__badges,
    .plan-detail__macros {
        justify-content: flex-start;
    }

    .plan-detail__macros {
        gap: 1.5rem;
    }

    /* Enough room again for icon-beside-text with dividers. */
    .plan-detail__macro {
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 0.55rem;
        justify-content: flex-start;
    }

    .plan-detail__macro-value {
        font-size: 1rem;
        white-space: nowrap;
    }

    .plan-detail__macro + .plan-detail__macro {
        padding-inline-start: 1.5rem;
        border-inline-start: 1px solid #e2e8f0;
    }
}

/* ─── Plan type cards ────────────────────────────────────────────── */

.plan-detail__types {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
}

@media (min-width: 768px) {
    .plan-detail__types {
        grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    }
}

.plan-detail__type-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.plan-detail__type-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    height: 100%;
    padding: 0.9rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: var(--pd-radius-inner);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.plan-detail__type-label:hover {
    border-color: #cbd5e1;
}

.plan-detail__type-input:checked + .plan-detail__type-label {
    border-color: var(--pd-accent);
    background: rgba(39, 159, 249, 0.06);
}

.plan-detail__type-input:focus-visible + .plan-detail__type-label {
    outline: 2px solid var(--pd-accent);
    outline-offset: 2px;
}

.plan-detail__type-text {
    flex: 1 1 auto;
    min-width: 0;
}

.plan-detail__type-title {
    /* Block so the listing below always starts on its own line, even when a long
       variant name wraps to two lines. */
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.plan-detail__type-sub {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--pd-muted);
}

.plan-detail__radio {
    position: relative;
    flex-shrink: 0;
    width: 1.35rem;
    height: 1.35rem;
    margin-top: 0.1rem;
    border-radius: 999px;
    border: 2px solid #d1d5db;
    background: #fff;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.plan-detail__radio::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.plan-detail__type-input:checked + .plan-detail__type-label .plan-detail__radio {
    border-color: var(--pd-accent);
    background: var(--pd-accent);
}

.plan-detail__type-input:checked + .plan-detail__type-label .plan-detail__radio::after {
    opacity: 1;
}

/* ─── Drag-to-scroll rail ──────────────────────────────────────────
   Base lives in src/styles.css (shared component). Here we only add the
   card-edge bleed so pills scroll under this card's padding. */

.plan-detail .scroll-rail {
    margin-inline: -1.25rem;
    padding-inline: 1.25rem;
}

/* ─── Calorie pills ──────────────────────────────────────────────── */

.plan-detail__cal-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.plan-detail__cal-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.15rem;
    border: 2px solid #e5e7eb;
    border-radius: var(--pd-radius-inner);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.plan-detail__cal-input:checked + .plan-detail__cal-label {
    border-color: var(--pd-accent);
    background: rgba(39, 159, 249, 0.08);
    color: var(--pd-accent);
}

.plan-detail__cal-input:focus-visible + .plan-detail__cal-label {
    outline: 2px solid var(--pd-accent);
    outline-offset: 2px;
}

.plan-detail__hint {
    margin-top: 0.85rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--pd-muted);
}

/* ─── Duration pills ─────────────────────────────────────────────── */

.plan-detail__dur-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.plan-detail__dur-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-width: 6.25rem;
    height: 100%;
    padding: 0.75rem 1.1rem;
    border: 2px solid #e5e7eb;
    border-radius: var(--pd-radius-inner);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.plan-detail__dur-input:checked + .plan-detail__dur-label {
    border-color: var(--pd-accent);
    background: rgba(39, 159, 249, 0.08);
}

.plan-detail__dur-input:focus-visible + .plan-detail__dur-label {
    outline: 2px solid var(--pd-accent);
    outline-offset: 2px;
}

.plan-detail__dur-title {
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.plan-detail__dur-sub {
    font-size: 0.8125rem;
    color: #94a3b8;
    white-space: nowrap;
}

.plan-detail__dur-input:checked + .plan-detail__dur-label .plan-detail__dur-title {
    color: #0f172a;
}

.plan-detail__dur-input:checked + .plan-detail__dur-label .plan-detail__dur-sub {
    color: var(--pd-accent);
}

.plan-detail__offer-badge {
    position: absolute;
    top: -0.4rem;
    inset-inline-end: -0.25rem;
    z-index: 1;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    /* Green, not red — this is a saving, not a warning. */
    background: var(--pd-green);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    pointer-events: none;
}

/* ─── Weekend toggle + start date ────────────────────────────────── */

.plan-detail__options-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem 1.5rem;
}

.plan-detail__checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    font-size: 1rem;
    color: #0f172a;
}

.plan-detail__checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.plan-detail__checkbox-face {
    position: relative;
    flex-shrink: 0;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: var(--pd-radius-inner);
    border: 2px solid #d1d5db;
    background: #fff;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.plan-detail__checkbox-face::after {
    content: '';
    position: absolute;
    /* Centred via transform so the tick is identical in LTR and RTL. */
    top: 50%;
    left: 50%;
    width: 0.35rem;
    height: 0.7rem;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.plan-detail__checkbox input:checked + .plan-detail__checkbox-face {
    border-color: var(--pd-accent);
    background: var(--pd-accent);
}

.plan-detail__checkbox input:checked + .plan-detail__checkbox-face::after {
    opacity: 1;
}

.plan-detail__checkbox input:focus-visible + .plan-detail__checkbox-face {
    outline: 2px solid var(--pd-accent);
    outline-offset: 2px;
}

/* The API can pin weekends via week_end_status; then this is display-only. */
.plan-detail__checkbox--locked {
    cursor: default;
    opacity: 0.75;
}

.plan-detail__start {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1rem;
    color: var(--pd-muted);
}

.plan-detail__start time {
    font-weight: 600;
    color: #0f172a;
}

/* ─── Summary card (desktop) ─────────────────────────────────────── */

.plan-detail__summary {
    display: none;
}

@media (min-width: 1024px) {
    .plan-detail__summary {
        display: block;
        position: sticky;
        top: 5.5rem;
    }
}

.plan-detail__summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.9375rem;
    color: var(--pd-muted);
}

.plan-detail__summary-row + .plan-detail__summary-row {
    margin-top: 0.6rem;
}

.plan-detail__summary-row dd,
.plan-detail__summary-row > :last-child {
    font-weight: 600;
    color: #0f172a;
    text-align: end;
}

.plan-detail__summary-row--strike > :last-child {
    font-weight: 500;
    color: #94a3b8;
    text-decoration: line-through;
}

.plan-detail__summary-row--discount > :last-child {
    color: var(--pd-green);
    font-weight: 600;
}

.plan-detail__summary-row--total {
    align-items: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: #0f172a;
}

/* Scoped to beat `.plan-detail__summary-row > :last-child`, which would
   otherwise win on specificity and repaint the total slate instead of green. */
.plan-detail__summary-row .plan-detail__summary-total {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    color: var(--pd-green);
    font-size: 1.5rem;
    font-weight: 600;
}

.plan-detail__summary-vat {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pd-muted);
    white-space: nowrap;
}

.plan-detail__summary-note {
    margin-top: 0.85rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--pd-muted);
}

.plan-detail__summary .btn {
    width: 100%;
}

/* ─── Fixed bottom bar (mobile / tablet) ─────────────────────────── */

.plan-detail__mobile-bar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 45;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--pd-border);
    backdrop-filter: blur(10px);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

@media (min-width: 1024px) {
    .plan-detail__mobile-bar {
        display: none;
    }
}

.plan-detail__mobile-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.plan-detail__mobile-summary {
    min-width: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    color: #0f172a;
}

.plan-detail__mobile-prices {
    flex-shrink: 0;
    text-align: end;
}

.plan-detail__mobile-old {
    display: block;
    font-size: 0.8125rem;
    color: #94a3b8;
    text-decoration: line-through;
    white-space: nowrap;
}

.plan-detail__mobile-price {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--pd-green);
    white-space: nowrap;
}

.plan-detail__mobile-vat {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--pd-muted);
}

.plan-detail__mobile-bar .btn {
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .scroll-rail {
        scroll-behavior: auto;
    }

    .plan-detail__type-label,
    .plan-detail__cal-label,
    .plan-detail__dur-label,
    .plan-detail__radio,
    .plan-detail__radio::after,
    .plan-detail__checkbox-face,
    .plan-detail__checkbox-face::after {
        transition: none;
    }
}
