/* Storefront checkout presentation. Payment and activation contracts stay in page.js. */
.checkout-dialog {
    padding: 0;
    border: 0;
    color: var(--ts-text);
    background: transparent;
    font-family: var(--ts-font-sans);
}

.checkout-dialog::backdrop {
    background: rgba(3, 6, 18, 0.48);
    backdrop-filter: blur(8px);
}

.checkout-dialog .checkout-card {
    display: flex;
    flex-direction: column;
    gap: var(--ts-space-4);
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    margin: 0;
    padding: var(--ts-space-6);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding: var(--ts-space-4) 0 160px;
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-xl);
    background: var(--ts-bg-canvas-alt);
    color: var(--ts-text);
    box-shadow: var(--ts-shadow-receipt);
    font-family: var(--ts-font-sans);
    line-height: var(--ts-line-body);
}

.checkout-dialog .checkout-card > * { flex-shrink: 0; }
.checkout-dialog .checkout-card :where(h2, p) { margin: 0; }
.checkout-dialog .checkout-card :where(button, input, textarea) { font-family: inherit; }

.checkout-dialog .dialog-close {
    position: absolute;
    top: var(--ts-space-3);
    right: var(--ts-space-3);
    z-index: 5;
    display: grid;
    place-items: center;
    width: var(--ts-touch-target);
    height: var(--ts-touch-target);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-sm);
    background: var(--ts-bg-canvas-alt);
    color: var(--ts-text-muted);
    font-size: 24px;
}

.checkout-dialog .checkout-eyebrow {
    padding-right: var(--ts-space-12);
    color: var(--ts-brand-text);
    font-size: var(--ts-font-size-xs);
    font-weight: var(--ts-weight-bold);
    letter-spacing: 0.06em;
}

.checkout-dialog .checkout-card h2 {
    max-width: calc(100% - 36px);
    margin-top: -8px;
    font-size: clamp(24px, 5vw, 30px);
    font-weight: var(--ts-weight-extrabold);
    line-height: var(--ts-line-heading);
    letter-spacing: -0.035em;
}

.checkout-dialog .checkout-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ts-space-4);
    padding: var(--ts-space-4);
    border: 1px solid var(--ts-receipt-summary-border);
    border-radius: var(--ts-radius-md);
    background: var(--ts-receipt-summary-surface);
}

.checkout-dialog .checkout-summary span {
    font-size: var(--ts-font-size-md);
    font-weight: var(--ts-weight-bold);
    line-height: 1.45;
}

.checkout-dialog .checkout-summary strong {
    color: var(--ts-text);
    font-size: var(--ts-font-size-lg);
    font-weight: var(--ts-weight-extrabold);
}

.checkout-dialog .checkout-copy {
    color: var(--ts-text-muted);
    font-size: var(--ts-font-size-sm);
    font-weight: var(--ts-weight-regular);
    line-height: 1.55;
}

.checkout-dialog .checkout-field {
    display: grid;
    gap: var(--ts-space-2);
    min-width: 0;
}

.checkout-dialog .checkout-field > span,
.checkout-dialog .checkout-section-head label {
    color: var(--ts-text);
    font-size: var(--ts-font-size-sm);
    font-weight: var(--ts-weight-bold);
}

.checkout-dialog :where(.checkout-field small, .checkout-session small, .checkout-file-name) {
    color: var(--ts-text-muted);
    font-size: var(--ts-font-size-xs);
    font-weight: var(--ts-weight-regular);
    line-height: 1.5;
}

.checkout-dialog .checkout-card input:is([type="email"], [type="text"]),
.checkout-dialog .checkout-card textarea {
    width: 100%;
    border: 1px solid var(--ts-receipt-control-border);
    border-radius: var(--ts-radius-sm);
    background: var(--ts-receipt-control-surface);
    color: var(--ts-text);
    font-size: var(--ts-font-size-body);
    font-weight: var(--ts-weight-regular);
    box-shadow: none;
}

.checkout-dialog .checkout-card input:is([type="email"], [type="text"]) {
    height: var(--ts-control-height-lg);
    padding: 0 var(--ts-space-4);
}

.checkout-dialog .checkout-card textarea {
    min-height: 104px;
    padding: var(--ts-space-3);
    font-family: var(--ts-font-mono);
    font-size: var(--ts-font-size-body);
    resize: vertical;
}

.checkout-dialog :where(input, textarea)::placeholder { color: var(--ts-text-muted); opacity: 0.85; }
.checkout-dialog :where(input, textarea)[aria-invalid="true"] { border-color: var(--ts-danger); }

.checkout-dialog :where(button, a, input, textarea, summary, label[for="checkoutSessionFile"]):focus-visible {
    outline: 2px solid var(--ts-border-focus);
    outline-offset: 3px;
    box-shadow: var(--ts-shadow-focus);
}

.checkout-dialog .checkout-card :where(input, textarea):focus {
    border-color: var(--ts-border-focus);
    box-shadow: var(--ts-shadow-focus);
}

.checkout-dialog .checkout-refresh-conditions {
    padding: var(--ts-space-3) var(--ts-space-4);
    border: 1px solid var(--ts-warning-border);
    border-radius: var(--ts-radius-md);
    background: var(--ts-warning-bg);
    color: var(--ts-text);
}

.checkout-dialog .checkout-refresh-conditions > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ts-space-3);
    min-height: var(--ts-touch-target);
    list-style: none;
    color: var(--ts-text);
    font-size: var(--ts-font-size-sm);
    font-weight: var(--ts-weight-bold);
    cursor: pointer;
}

.checkout-dialog .checkout-refresh-conditions > summary::-webkit-details-marker { display: none; }
.checkout-dialog .checkout-refresh-conditions > summary::after { content: "+"; font-size: 22px; font-weight: 400; }
.checkout-dialog .checkout-refresh-conditions[open] > summary::after { content: "−"; }
.checkout-dialog .checkout-refresh-conditions .checkout-notice {
    display: block;
    margin: var(--ts-space-2) 0 0;
    padding: 0 0 var(--ts-space-2);
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ts-text);
    font-size: var(--ts-font-size-sm);
    font-weight: var(--ts-weight-regular);
    line-height: 1.65;
    overflow-wrap: anywhere;
    white-space: pre-line;
}
.checkout-dialog .checkout-notice a { color: var(--ts-brand-text); }

.checkout-dialog :where(.checkout-promo, .checkout-session, .checkout-consents) {
    display: grid;
    gap: var(--ts-space-3);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.checkout-dialog .checkout-promo { justify-items: start; }
.checkout-dialog .checkout-promo > p { display: none; }
.checkout-dialog .checkout-promo-form { width: 100%; }
.checkout-dialog :where(.checkout-promo-toggle, .checkout-ghost-link, .checkout-refresh-session-toggle) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ts-space-2);
    min-height: var(--ts-touch-target);
    padding: var(--ts-space-2) var(--ts-space-3);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-sm);
    background: var(--ts-surface-soft);
    color: var(--ts-brand-text);
    font-size: var(--ts-font-size-sm);
    font-weight: var(--ts-weight-semibold);
    text-align: left;
    cursor: pointer;
}

.checkout-dialog .checkout-promo-toggle {
    padding-inline: 0;
    border-color: transparent;
    background: transparent;
}

.checkout-dialog .checkout-promo-form .button {
    min-height: var(--ts-touch-target);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-sm);
    background: var(--ts-surface-soft);
    color: var(--ts-text);
    font-size: var(--ts-font-size-sm);
    box-shadow: none;
}

.checkout-dialog .checkout-session { padding-block: var(--ts-space-3); border-block: 1px solid var(--ts-border); }
.checkout-dialog .checkout-refresh-session-toggle { justify-content: space-between; width: 100%; background: transparent; border: 0; padding: 0; }
.checkout-dialog .checkout-refresh-session-toggle::after { content: "+"; font-size: 22px; font-weight: 400; }
.checkout-dialog .checkout-refresh-session-toggle[aria-expanded="true"]::after { content: "−"; }
.checkout-dialog .checkout-refresh-session-fields { display: grid; gap: var(--ts-space-3); }
.checkout-dialog .checkout-refresh-session-hint { margin-top: -4px; color: var(--ts-text-muted); font-size: var(--ts-font-size-xs); line-height: 1.5; }
.checkout-dialog .checkout-section-head { flex-wrap: wrap; gap: var(--ts-space-2); }
.checkout-dialog .checkout-section-head a { color: var(--ts-brand-text); font-size: var(--ts-font-size-xs); font-weight: var(--ts-weight-semibold); }
.checkout-dialog .checkout-token-actions { gap: var(--ts-space-2); }
.checkout-dialog .checkout-file-name { overflow-wrap: anywhere; }

.checkout-dialog .checkout-consents { gap: var(--ts-space-2); }
.checkout-dialog .checkout-consent {
    align-items: flex-start;
    gap: var(--ts-space-3);
    min-height: var(--ts-touch-target);
    padding: var(--ts-space-2) 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.checkout-dialog .checkout-consent input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ts-brand-indigo); }
.checkout-dialog .checkout-consent strong { color: var(--ts-text); font-size: var(--ts-font-size-sm); font-weight: var(--ts-weight-semibold); }
.checkout-dialog .checkout-consent a { color: var(--ts-brand-text); text-decoration: underline; text-underline-offset: 3px; }
.checkout-dialog .checkout-consent small,
.checkout-dialog .checkout-consents > p { color: var(--ts-text-muted); font-size: var(--ts-font-size-xs); font-weight: var(--ts-weight-regular); line-height: 1.5; }

.checkout-dialog .checkout-refresh-actions {
    position: sticky;
    bottom: calc(-1 * var(--ts-space-6));
    z-index: 4;
    display: grid;
    gap: var(--ts-space-3);
    margin: 0 calc(-1 * var(--ts-space-6)) calc(-1 * var(--ts-space-6));
    padding: var(--ts-space-4) var(--ts-space-6) calc(var(--ts-space-4) + var(--ts-safe-bottom));
    border-top: 1px solid var(--ts-border);
    background: var(--ts-bg-canvas-alt);
}
.checkout-dialog .checkout-refresh-total { display: flex; justify-content: space-between; gap: var(--ts-space-4); align-items: baseline; color: var(--ts-text-muted); font-size: var(--ts-font-size-sm); }
.checkout-dialog .checkout-refresh-total strong { color: var(--ts-text); font-size: var(--ts-font-size-xl); font-weight: var(--ts-weight-extrabold); white-space: nowrap; }
.checkout-dialog .checkout-refresh-actions > button[type="submit"] {
    width: 100%;
    min-height: var(--ts-control-height-lg);
    padding: var(--ts-space-3) var(--ts-space-4);
    border: 0;
    border-radius: var(--ts-radius-md);
    background: linear-gradient(var(--ts-storefront-action-scrim, rgba(0, 0, 0, 0.24)), var(--ts-storefront-action-scrim, rgba(0, 0, 0, 0.24))), var(--ts-brand-gradient);
    color: #fff;
    font-size: var(--ts-font-size-md);
    font-weight: var(--ts-weight-bold);
    box-shadow: var(--ts-shadow-receipt-action);
    transform: none;
}
.checkout-dialog .checkout-refresh-actions > button[type="submit"]::before,
.checkout-dialog .checkout-refresh-actions > button[type="submit"]::after { content: none; }
.checkout-dialog .checkout-refresh-actions > button[type="submit"]:hover:not(:disabled) { background: linear-gradient(var(--ts-storefront-action-scrim, rgba(0, 0, 0, 0.24)), var(--ts-storefront-action-scrim, rgba(0, 0, 0, 0.24))), var(--ts-brand-gradient); box-shadow: var(--ts-shadow-receipt-action-hover); transform: translateY(-1px); }
.checkout-dialog .checkout-refresh-actions > button[type="submit"]:disabled { cursor: wait; opacity: 0.7; transform: none; }
.checkout-dialog .checkout-payment-note { gap: 3px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ts-text-muted); font-size: var(--ts-font-size-xs); font-weight: var(--ts-weight-regular); line-height: 1.5; text-align: center; }
.checkout-dialog .checkout-payment-note strong { color: var(--ts-text-muted); font-size: inherit; font-weight: var(--ts-weight-semibold); }
.checkout-dialog .checkout-payment-note span { color: var(--ts-text-muted); }
.checkout-dialog .form-message { min-height: 0; margin: 0; color: var(--ts-text-muted); font-size: var(--ts-font-size-sm); font-weight: var(--ts-weight-semibold); line-height: 1.5; overflow-wrap: anywhere; }
.checkout-dialog .form-message:empty { display: none; }
.checkout-dialog .form-message[role="alert"] { color: var(--ts-danger); }
.checkout-dialog .checkout-inline-status { padding: var(--ts-space-3); border: 1px solid var(--ts-info-border); border-radius: var(--ts-radius-sm); background: var(--ts-info-bg); color: var(--ts-text); font-size: var(--ts-font-size-sm); font-weight: var(--ts-weight-regular); }
.checkout-dialog .checkout-inline-status[data-tone="success"] { color: var(--ts-text); border-color: var(--ts-success-border); background: var(--ts-success-bg); }
.checkout-dialog .checkout-inline-status[data-tone="warning"] { color: var(--ts-text); border-color: var(--ts-warning-border); background: var(--ts-warning-bg); }
.checkout-dialog .checkout-inline-status[data-tone="danger"] { color: var(--ts-text); border-color: var(--ts-danger-border); background: var(--ts-danger-bg); }
.checkout-dialog [hidden] { display: none !important; }

@media (max-width: 560px) {
    .checkout-dialog .checkout-card { width: calc(100vw - 16px); max-height: calc(100dvh - 24px); padding: var(--ts-space-5); border-radius: var(--ts-radius-lg); }
    .checkout-dialog .checkout-summary { flex-direction: row; align-items: flex-start; padding: var(--ts-space-3); gap: var(--ts-space-3); }
    .checkout-dialog .checkout-summary span { font-size: var(--ts-font-size-sm); }
    .checkout-dialog .checkout-summary strong { font-size: var(--ts-font-size-md); }
    .checkout-dialog .checkout-promo-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
    .checkout-dialog .checkout-promo-form .button { width: auto; min-height: var(--ts-control-height-lg); padding-inline: var(--ts-space-3); }
    .checkout-dialog .checkout-promo-form #checkoutPromoClear { grid-column: 2; min-height: var(--ts-touch-target); }
    .checkout-dialog .checkout-section-head { align-items: flex-start; }
    .checkout-dialog .checkout-refresh-actions { bottom: calc(-1 * var(--ts-space-5)); margin-inline: calc(-1 * var(--ts-space-5)); margin-bottom: calc(-1 * var(--ts-space-5)); padding-inline: var(--ts-space-5); }
}

/* Persistent chrome is outside the form's scroll viewport. Keeping the form
   unwrapped preserves direct-child insertBefore anchors used by live checkout. */
.checkout-dialog.checkout-refresh-layout {
    --checkout-refresh-gutter: 48px;
    position: fixed;
    inset: auto;
    top: calc(var(--checkout-refresh-viewport-offset, 0px) + var(--checkout-refresh-viewport-height, 100dvh) / 2);
    left: calc(var(--checkout-refresh-viewport-left, 0px) + var(--checkout-refresh-viewport-width, 100vw) / 2);
    transform: translate(-50%, -50%);
    width: min(560px, calc(var(--checkout-refresh-viewport-width, 100vw) - 32px));
    max-width: none;
    max-height: calc(var(--checkout-refresh-viewport-height, 100dvh) - var(--checkout-refresh-gutter));
    margin: 0;
    padding: 0 0 var(--checkout-refresh-footer-height, 188px);
    overflow: hidden;
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-xl);
    background: var(--ts-bg-canvas-alt);
    box-shadow: var(--ts-shadow-receipt);
}
.checkout-dialog.checkout-refresh-layout[open] { display: flex; flex-direction: column; }
.checkout-dialog .checkout-refresh-header {
    position: relative;
    flex: none;
    padding: var(--ts-space-6) var(--ts-space-6) var(--ts-space-3);
    border-bottom: 1px solid var(--ts-border);
    background: var(--ts-bg-canvas-alt);
    color: var(--ts-text);
}
.checkout-dialog .checkout-refresh-header :where(h2, p) { margin: 0; }
.checkout-dialog .checkout-refresh-header h2 {
    max-width: calc(100% - 44px);
    margin-top: var(--ts-space-2);
    font-size: clamp(24px, 5vw, 30px);
    font-weight: var(--ts-weight-extrabold);
    line-height: var(--ts-line-heading);
    letter-spacing: -0.035em;
}
.checkout-dialog.checkout-refresh-layout .checkout-card {
    position: static;
    /* Legacy glass filters create an absolute-position containing block. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none;
    filter: none;
    flex: 0 1 auto;
    width: 100%;
    min-height: 0;
    max-height: max(0px, calc(var(--checkout-refresh-viewport-height, 100dvh) - var(--checkout-refresh-gutter) - var(--checkout-refresh-header-height, 104px) - var(--checkout-refresh-footer-height, 188px)));
    margin: 0;
    padding: var(--ts-space-4) var(--ts-space-6) var(--ts-space-6);
    overflow-x: hidden;
    overflow-y: auto;
    scroll-padding: var(--ts-space-3);
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.checkout-dialog.checkout-refresh-layout .checkout-refresh-actions {
    position: absolute;
    inset: auto 0 0;
    width: 100%;
    margin: 0;
    padding: var(--ts-space-4) var(--ts-space-6) calc(var(--ts-space-4) + var(--ts-safe-bottom));
}
@media (max-width: 560px) {
    .checkout-dialog.checkout-refresh-layout { --checkout-refresh-gutter: 24px; width: calc(var(--checkout-refresh-viewport-width, 100vw) - 16px); border-radius: var(--ts-radius-lg); }
    .checkout-dialog .checkout-refresh-header { padding: var(--ts-space-5) var(--ts-space-5) var(--ts-space-3); }
    .checkout-dialog.checkout-refresh-layout .checkout-card { padding: var(--ts-space-4) var(--ts-space-5) var(--ts-space-5); }
    .checkout-dialog.checkout-refresh-layout .checkout-refresh-actions { padding-inline: var(--ts-space-5); }
}

/* A software keyboard shrinks the visual viewport without resizing the page.
   Keep the contact field, total and payment action usable in that smaller area. */
.checkout-dialog.checkout-refresh-layout.checkout-refresh-compact { --checkout-refresh-gutter: 16px; }
.checkout-dialog.checkout-refresh-compact .checkout-refresh-header {
    min-height: 56px;
    display: flex;
    align-items: center;
    padding: var(--ts-space-3) var(--ts-space-4);
}
.checkout-dialog.checkout-refresh-compact .checkout-refresh-header .checkout-eyebrow { display: none; }
.checkout-dialog.checkout-refresh-compact .checkout-refresh-header h2 {
    margin: 0;
    font-size: var(--ts-font-size-lg);
    line-height: 1.25;
}
.checkout-dialog.checkout-refresh-compact .dialog-close { top: 6px; right: 8px; }
.checkout-dialog.checkout-refresh-compact .checkout-refresh-actions {
    grid-template-columns: minmax(82px, .55fr) minmax(0, 1fr);
    align-items: center;
    gap: var(--ts-space-2) var(--ts-space-3);
    padding: var(--ts-space-2) var(--ts-space-4);
}
.checkout-dialog.checkout-refresh-compact .checkout-refresh-total {
    display: grid;
    gap: 2px;
    font-size: 11px;
    line-height: 1.3;
}
.checkout-dialog.checkout-refresh-compact .checkout-refresh-total strong { font-size: 20px; line-height: 1.25; }
.checkout-dialog.checkout-refresh-compact .checkout-refresh-actions > button[type="submit"] {
    min-height: 46px;
    padding: var(--ts-space-2) var(--ts-space-3);
    font-size: 14px;
    border-radius: var(--ts-radius-sm);
}
.checkout-dialog.checkout-refresh-compact .checkout-payment-note { display: none; }
.checkout-dialog.checkout-refresh-compact .form-message { grid-column: 1 / -1; font-size: var(--ts-font-size-xs); }
.checkout-dialog.checkout-refresh-layout.checkout-refresh-compact .checkout-card { padding: var(--ts-space-3) var(--ts-space-4) var(--ts-space-4); gap: var(--ts-space-3); }
.checkout-dialog.checkout-refresh-layout.checkout-refresh-short { --checkout-refresh-gutter: 12px; }
.checkout-dialog.checkout-refresh-layout.checkout-refresh-short .checkout-card { padding: var(--ts-space-2) var(--ts-space-3); }
.checkout-dialog.checkout-refresh-short .checkout-card textarea { min-height: 72px; height: 80px; }
@media (max-width: 620px), (pointer: coarse) {
    .checkout-dialog .checkout-card input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    .checkout-dialog .checkout-card textarea,
    .checkout-dialog .checkout-card select { font-size: var(--ts-font-size-body); }
}

@media (prefers-reduced-motion: reduce) {
    .checkout-dialog *, .checkout-dialog *::before, .checkout-dialog *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
