/* =========================================================
   U Jabka — commerce pages (cart + checkout)
   Page stylesheet loaded via 'pageStyles' => ['css/commerce.css']
   after frontend.css. Built exclusively on the CANONICAL token set
   (--bg/--panel/--line/--ink/--leaf/--r-*/--font-*), never on the
   transitional legacy tokens (--green-*/--cream/--surface/...).
   All selectors are scoped under .commerce-page so nothing leaks
   into the shared shell or other public pages.
   ========================================================= */

.commerce-page {
    background: var(--bg);
    font-family: var(--font-sans);
    color: var(--ink);
    padding: clamp(26px, 4.5vw, 52px) 0 clamp(56px, 8vw, 96px);
}

.commerce-page__inner {
    display: grid;
    gap: clamp(18px, 2.6vw, 28px);
}

/* ---- Scoped shell-component alignment (first redesigned commerce
       pages move buttons + focus ring onto the canonical leaf accent,
       see docs/design/UJABKA_PUBLIC_DESIGN_SYSTEM.md) ---- */
.commerce-page :focus-visible {
    outline-color: var(--leaf);
}

.commerce-page .btn {
    font-family: var(--font-sans);
    border-radius: var(--r-sm);
    transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}

.commerce-page .btn--primary {
    background: var(--leaf);
}

.commerce-page .btn--primary:hover {
    background: var(--leaf-2);
}

.commerce-page .btn--ghost {
    color: var(--ink);
    border-color: var(--line);
    background: var(--panel);
}

.commerce-page .btn--ghost:hover {
    color: var(--leaf);
    border-color: var(--leaf-line);
    background: var(--leaf-tint);
}

.commerce-page .btn--text {
    color: var(--leaf-2);
}

.commerce-page .btn--text:hover {
    color: var(--leaf);
}

.commerce-page .eyebrow {
    color: var(--leaf-2);
    margin-bottom: 10px;
}

.commerce-page .eyebrow .ico {
    stroke: var(--leaf-2);
}

/* ---- Breadcrumbs ---- */
.commerce-crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--ink-55);
    font-size: 0.85rem;
}

.commerce-crumbs a {
    color: var(--ink-55);
    text-decoration: none;
}

.commerce-crumbs a:hover {
    color: var(--leaf);
}

.commerce-crumbs [aria-hidden] {
    color: var(--ink-38);
}

/* ---- Page head ---- */
.commerce-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

.commerce-head h1 {
    margin: 0 0 10px;
    font-family: var(--font-serif);
    font-weight: 560;
    color: var(--ink);
    font-size: clamp(1.9rem, 3.6vw, 2.9rem);
    line-height: 1.08;
    letter-spacing: -0.01em;
}

.commerce-head__lede {
    max-width: 62ch;
    color: var(--ink-70);
    line-height: 1.55;
}

.commerce-head .btn {
    flex: none;
}

/* ---- Notices (result of a cart/checkout POST) ---- */
.commerce-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--panel);
    font-weight: 600;
    line-height: 1.45;
}

.commerce-notice .ico {
    width: 18px;
    height: 18px;
    margin-top: 2px;
}

.commerce-notice--success {
    border-color: var(--leaf-line);
    background: var(--leaf-tint);
    color: var(--leaf);
}

.commerce-notice--success .ico {
    stroke: var(--leaf);
}

.commerce-notice--warning {
    border-color: rgba(140, 84, 34, .3);
    background: #FBF2E3;
    color: #7C4A1E;
}

.commerce-notice--warning .ico {
    stroke: #7C4A1E;
}

/* ---- Empty state ---- */
.commerce-empty {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 6px;
    padding: clamp(36px, 6vw, 64px) clamp(20px, 4vw, 48px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--panel);
}

.commerce-empty__icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
    border-radius: 50%;
    background: var(--leaf-tint);
}

.commerce-empty__icon .ico {
    width: 26px;
    height: 26px;
    stroke: var(--leaf);
}

.commerce-empty h2 {
    font-family: var(--font-serif);
    font-weight: 560;
    color: var(--ink);
    font-size: 1.5rem;
}

.commerce-empty p {
    max-width: 52ch;
    color: var(--ink-70);
    line-height: 1.55;
}

.commerce-empty .btn {
    margin-top: 16px;
}

/* ---- Two-column layout ---- */
.commerce-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 392px);
    gap: clamp(18px, 2.6vw, 28px);
    align-items: start;
}

/* ---- Cart line items ---- */
.commerce-lines {
    display: grid;
    gap: 14px;
}

.commerce-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: clamp(14px, 2.2vw, 22px);
    padding: clamp(16px, 2.4vw, 24px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--panel);
}

.commerce-item.is-unavailable {
    background: #FDFAF4;
    border-color: rgba(140, 84, 34, .22);
}

.commerce-item__media {
    display: grid;
    place-items: center;
    width: 84px;
    height: 104px;
    border-radius: var(--r-md);
    background: var(--bg-deep);
    color: var(--leaf);
}

.commerce-item__media .device {
    width: 48px;
    height: 64px;
}

.commerce-item__media--accessory .ico {
    width: 30px;
    height: 30px;
    fill: var(--leaf);
}

.commerce-item__kind {
    color: var(--ink-55);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.commerce-item__title {
    font-family: var(--font-serif);
    font-weight: 580;
    font-size: 1.18rem;
    color: var(--ink);
    line-height: 1.2;
    margin: 0 0 4px;
}

.commerce-item__title a {
    color: inherit;
    text-decoration: none;
}

.commerce-item__title a:hover {
    color: var(--leaf);
}

.commerce-item__spec {
    color: var(--ink-70);
    font-size: 0.94rem;
    line-height: 1.45;
}

.commerce-item__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 0;
    list-style: none;
}

.commerce-item__note {
    margin-top: 10px;
    color: var(--ink-55);
    font-size: 0.88rem;
    line-height: 1.45;
}

.commerce-item__warning {
    margin-top: 10px;
    color: #7C4A1E;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.45;
}

.commerce-item__aside {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    text-align: right;
}

.commerce-item__price {
    color: var(--ink);
    font-size: 1.16rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.commerce-item__qty {
    color: var(--ink-55);
    font-size: 0.9rem;
    font-weight: 600;
}

.commerce-item__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex-wrap: wrap;
}

.commerce-item__actions form {
    margin: 0;
}

/* Quantity update (variant lines) */
.commerce-qty-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0;
}

.commerce-qty-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-55);
    font-size: 0.85rem;
    font-weight: 600;
}

.commerce-qty-form input {
    width: 74px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.commerce-qty-form input:focus {
    outline: none;
    border-color: var(--leaf-line);
    box-shadow: 0 0 0 3px var(--leaf-tint);
}

/* ---- Status chips ---- */
.commerce-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--panel);
    color: var(--ink-70);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
}

.commerce-chip--ok {
    border-color: var(--leaf-line);
    background: var(--leaf-tint);
    color: var(--leaf);
}

.commerce-chip--muted {
    background: var(--bg-deep);
    color: var(--ink-55);
}

.commerce-chip .battery-dot {
    margin: 0;
}

/* ---- Summary / recap card ---- */
.commerce-summary {
    display: grid;
    gap: 16px;
    padding: clamp(18px, 2.6vw, 26px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--panel);
    position: sticky;
    top: 96px;
}

.commerce-summary h2 {
    font-family: var(--font-serif);
    font-weight: 580;
    color: var(--ink);
    font-size: 1.3rem;
}

.commerce-summary dl {
    display: grid;
    gap: 10px;
    margin: 0;
}

.commerce-summary dl div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-soft);
}

.commerce-summary dt {
    color: var(--ink-55);
    font-weight: 500;
}

.commerce-summary dd {
    margin: 0;
    color: var(--ink);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.commerce-summary__total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.commerce-summary__total dt,
.commerce-summary__total .commerce-summary__total-label {
    color: var(--ink);
    font-weight: 600;
}

.commerce-summary__total-value {
    color: var(--leaf);
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.commerce-summary__note {
    color: var(--ink-55);
    font-size: 0.88rem;
    line-height: 1.5;
}

.commerce-summary__note a {
    color: var(--leaf-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.commerce-summary__warning {
    padding: 11px 13px;
    border: 1px solid rgba(140, 84, 34, .3);
    border-radius: var(--r-sm);
    background: #FBF2E3;
    color: #7C4A1E;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
}

.commerce-summary form {
    margin: 0;
    justify-self: start;
}

/* Recap lines (checkout aside) */
.commerce-recap-lines {
    display: grid;
    gap: 12px;
}

.commerce-recap-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-soft);
}

.commerce-recap-line > div {
    display: grid;
    gap: 3px;
    align-content: start;
}

.commerce-recap-line > div:last-child {
    justify-items: end;
    text-align: right;
}

.commerce-recap-line strong {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.3;
}

.commerce-recap-line span {
    color: var(--ink-55);
    font-size: 0.86rem;
    line-height: 1.4;
}

.commerce-recap-line .commerce-recap-line__price {
    color: var(--ink);
    font-size: 0.98rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.commerce-recap-line__warning {
    color: #7C4A1E;
    font-weight: 600;
}

.commerce-recap-line.is-unavailable strong,
.commerce-recap-line.is-unavailable .commerce-recap-line__price {
    color: var(--ink-55);
}

/* ---- Checkout form ---- */
.commerce-form {
    display: grid;
    gap: clamp(22px, 3vw, 30px);
    padding: clamp(20px, 3vw, 32px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--panel);
}

.commerce-form fieldset {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.commerce-form legend {
    padding: 0;
    margin-bottom: 6px;
    font-family: var(--font-serif);
    font-weight: 580;
    font-size: 1.28rem;
    color: var(--ink);
}

.commerce-field {
    display: grid;
    gap: 6px;
}

.commerce-field > label {
    color: var(--ink-70);
    font-size: 0.9rem;
    font-weight: 600;
}

.commerce-field input:not([type="checkbox"]):not([type="radio"]),
.commerce-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    line-height: 1.4;
}

.commerce-field textarea {
    resize: vertical;
    min-height: 74px;
}

.commerce-field input:not([type="checkbox"]):not([type="radio"]):focus,
.commerce-field textarea:focus {
    outline: none;
    border-color: var(--leaf-line);
    box-shadow: 0 0 0 3px var(--leaf-tint);
}

.commerce-field input[aria-invalid="true"],
.commerce-field textarea[aria-invalid="true"] {
    border-color: rgba(140, 84, 34, .45);
}

.commerce-field__hint {
    color: var(--ink-55);
    font-size: 0.84rem;
    line-height: 1.45;
}

.commerce-field__error {
    color: #7C4A1E;
    font-size: 0.86rem;
    font-weight: 600;
}

/* Error summary at the top of the form */
.commerce-errors {
    display: grid;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid rgba(140, 84, 34, .3);
    border-radius: var(--r-md);
    background: #FBF2E3;
    color: #7C4A1E;
}

.commerce-errors h2 {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    color: #7C4A1E;
}

.commerce-errors ul {
    display: grid;
    gap: 4px;
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}

.commerce-errors li {
    font-size: 0.92rem;
    line-height: 1.45;
}

.commerce-errors a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Delivery choice cards */
.commerce-choice-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.commerce-choice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--panel);
    cursor: pointer;
    transition: border-color .18s var(--ease), background-color .18s var(--ease);
}

.commerce-choice:hover {
    border-color: var(--leaf-line);
}

.commerce-choice input {
    margin-top: 3px;
    accent-color: var(--leaf);
    flex: none;
}

.commerce-choice__title {
    display: block;
    color: var(--ink);
    font-weight: 600;
    line-height: 1.3;
}

.commerce-choice__desc {
    display: block;
    margin-top: 3px;
    color: var(--ink-55);
    font-size: 0.86rem;
    line-height: 1.45;
}

@supports selector(:has(*)) {
    .commerce-choice:has(input:checked) {
        border-color: var(--leaf);
        background: var(--leaf-tint);
    }

    /* The delivery address only applies to delivery_method=delivery.
       Progressive: without :has() support the field simply stays visible,
       server-side validation is unchanged either way. */
    .commerce-form:has(input[name="delivery_method"][value="pickup"]:checked) .commerce-field--address {
        display: none;
    }
}

/* Payment info block (informational, not form fields) */
.commerce-payinfo {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg);
}

.commerce-payinfo h2 {
    font-family: var(--font-serif);
    font-weight: 580;
    font-size: 1.28rem;
    color: var(--ink);
}

.commerce-payinfo ul {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.commerce-payinfo li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--panel);
}

.commerce-payinfo__method {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
    line-height: 1.3;
}

.commerce-payinfo__method .ico {
    width: 18px;
    height: 18px;
    stroke: var(--leaf-2);
    flex: none;
}

.commerce-payinfo__surcharge {
    color: var(--ink-55);
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.commerce-payinfo__note {
    color: var(--ink-55);
    font-size: 0.88rem;
    line-height: 1.5;
}

.commerce-payinfo__note a {
    color: var(--leaf-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Terms + submit */
.commerce-terms {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--panel);
    cursor: pointer;
    line-height: 1.5;
    color: var(--ink-70);
}

.commerce-terms input {
    margin-top: 4px;
    accent-color: var(--leaf);
    flex: none;
}

.commerce-terms a {
    color: var(--leaf-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---- Order confirmation (success state) ---- */
.commerce-success {
    display: grid;
    gap: 18px;
    padding: clamp(24px, 4vw, 44px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--panel);
    max-width: 860px;
}

.commerce-success h1 {
    font-family: var(--font-serif);
    font-weight: 560;
    color: var(--ink);
    font-size: clamp(1.8rem, 3.4vw, 2.6rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.commerce-success > p {
    max-width: 62ch;
    color: var(--ink-70);
    line-height: 1.55;
}

.commerce-success__facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin: 0;
}

.commerce-success__facts > div {
    display: grid;
    gap: 4px;
    align-content: start;
    padding: 14px 16px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    background: var(--bg);
}

.commerce-success__facts dt {
    color: var(--ink-55);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.commerce-success__facts dd {
    margin: 0;
    color: var(--ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.commerce-success__note {
    padding: 12px 14px;
    border: 1px solid var(--leaf-line);
    border-radius: var(--r-sm);
    background: var(--leaf-tint);
    color: var(--leaf);
    font-weight: 600;
    line-height: 1.5;
}

.commerce-success__note--expired {
    border-color: rgba(140, 84, 34, .3);
    background: #FBF2E3;
    color: #7C4A1E;
}

.commerce-success__steps {
    display: grid;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg);
}

.commerce-success__steps h2 {
    font-family: var(--font-serif);
    font-weight: 580;
    font-size: 1.28rem;
    color: var(--ink);
}

.commerce-success__steps ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: commerce-step;
}

.commerce-success__steps li {
    position: relative;
    padding-left: 36px;
    color: var(--ink-70);
    line-height: 1.5;
    counter-increment: commerce-step;
}

.commerce-success__steps li::before {
    content: counter(commerce-step);
    position: absolute;
    left: 0;
    top: 1px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--leaf-tint);
    color: var(--leaf);
    font-size: 0.8rem;
    font-weight: 700;
}

.commerce-success__steps a {
    color: var(--leaf-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.commerce-success__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---- Responsive ---- */
@media (max-width: 980px) {
    .commerce-layout {
        grid-template-columns: 1fr;
    }

    .commerce-summary {
        position: static;
    }
}

@media (max-width: 640px) {
    .commerce-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .commerce-head .btn {
        width: 100%;
    }

    .commerce-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .commerce-item__aside {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        border-top: 1px solid var(--line-soft);
        padding-top: 12px;
        flex-wrap: wrap;
    }

    .commerce-item__actions {
        justify-content: flex-start;
    }

    .commerce-qty-form {
        justify-content: flex-start;
    }

    .commerce-choice-row {
        grid-template-columns: 1fr;
    }

    .commerce-form .btn,
    .commerce-summary > .btn,
    .commerce-success__actions .btn {
        width: 100%;
    }

    .commerce-success__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .commerce-payinfo li {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
