/* Suntc cart design system: tokens, buttons, fields, modal window.
   Loaded on the cart, the «thank you» page and product pages (for «Купить в 1 клик»).
   Spacing step 4 · type 13/15/16/17/24/26 · radii 6/10/999 · one focus ring · one error red. */
.sc-checkout, .sc-dialog, .suntc-one-click-row {
  --ink: #23241f;          /* text, selected fill, secondary border */
  --ink-2: #53564d;        /* second tone, hints: 7.4:1 on white */
  --line: #d6d8cf;         /* dividers */
  --control: #a8aaa2;      /* field and control borders */
  --surface: #f6f6f2;      /* panel, info blocks, hover on white */
  --surface-2: #ebebe5;    /* hover on the panel */
  --gold: #ffad17;
  --gold-hover: #ffbb3c;
  --on-gold: #1d180d;
  --selected-bg: #fff6e0;  /* chosen card */
  --focus: #995c00;        /* focus outline, 5.2:1 */
  --focus-halo: #ffad1740;
  --error: #ad402c;        /* error border, 5.5:1 */
  --error-text: #8f2a1a;   /* 7.3:1 */
  --error-bg: #fdf1ed;
  --error-line: #efc9bd;
  --attention: #fff4dc;
  --success: #2f6b2f;
  --success-bg: #e9f4e9;
  --disabled-bg: #ececE7;
  --disabled-text: #6a6c63;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --r-ctl: 6px; --r-card: 10px; --r-pill: 999px;
  --h-ctl: 44px; --h-btn: 48px;
  --t-fast: 140ms;
  --sh-dialog: 0 24px 64px #1a1b1640;
  --sh-sticky: 0 -4px 16px #23241f1a;
  color: var(--ink);
}

/* ---- Buttons ---- */
:is(.sc-checkout, .sc-dialog) :is(.sc-primary, .sc-button, .sc-link) { font-family: inherit; cursor: pointer; text-decoration: none; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
:is(.sc-checkout, .sc-dialog) .sc-primary {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--h-btn);
  padding: 12px 20px; border: 0; border-radius: var(--r-ctl);
  background: var(--gold); color: var(--on-gold); font-size: 16px; font-weight: 700; line-height: 1.25; text-align: center;
}
:is(.sc-checkout, .sc-dialog) .sc-primary.sc-auto { display: inline-flex; width: auto; padding-inline: 28px; }
:is(.sc-checkout, .sc-dialog) .sc-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--h-ctl);
  padding: 10px 16px; border: 1px solid var(--ink); border-radius: var(--r-ctl);
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 500; line-height: 1.25;
}
:is(.sc-checkout, .sc-dialog) .sc-link {
  display: inline; min-height: 0; padding: var(--s-1) 0; border: 0; background: none;
  color: var(--ink); font-size: 15px; text-decoration: underline; text-underline-offset: 3px;
}
@media (hover: hover) {
  :is(.sc-checkout, .sc-dialog) .sc-primary:hover:enabled, :is(.sc-checkout, .sc-dialog) a.sc-primary:hover { background: var(--gold-hover); }
  :is(.sc-checkout, .sc-dialog) .sc-button:hover:enabled, :is(.sc-checkout, .sc-dialog) a.sc-button:hover { background: var(--ink); color: #fff; }
  :is(.sc-checkout, .sc-dialog) .sc-link:hover { text-decoration-thickness: 2px; }
}
:is(.sc-checkout, .sc-dialog) :is(.sc-primary, .sc-button):disabled {
  background: var(--disabled-bg); color: var(--disabled-text); border-color: var(--disabled-bg); cursor: not-allowed; opacity: 1;
}

/* ---- Focus: one ring for everything ---- */
:is(.sc-checkout, .sc-dialog) :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:is(.sc-checkout, .sc-dialog) :is(input:not([type=checkbox]):not([type=radio]), select, textarea):focus-visible {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px var(--focus-halo);
}
:is(.sc-checkout, .sc-dialog) :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--error) !important; box-shadow: 0 0 0 1px var(--error); }
:is(.sc-checkout, .sc-dialog) :is(input:not([type=checkbox]), select, textarea)[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 1px var(--error), 0 0 0 4px #ad402c33; }
:is(.sc-checkout, .sc-dialog) input[type=checkbox][aria-invalid="true"] { border: 2px solid var(--error) !important; box-shadow: 0 0 0 3px #ad402c26; outline: none; }

/* ---- Fields ---- */
:is(.sc-checkout, .sc-dialog) label { display: block; margin: 0; font-size: 15px; font-weight: 400; line-height: 1.4; color: inherit; }
:is(.sc-checkout, .sc-dialog) :is(input:not([type=radio]):not([type=checkbox]):not([type=hidden]):not([type=file]), select, textarea) {
  display: block; width: 100%; max-width: 100%; min-height: var(--h-ctl); margin-top: 6px;
  padding: 10px 12px; border: 1px solid var(--control); border-radius: var(--r-ctl);
  background: #fff; color: var(--ink); font: inherit; font-size: 16px; line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
:is(.sc-checkout, .sc-dialog) input::placeholder, :is(.sc-checkout, .sc-dialog) textarea::placeholder { color: #8a8c83; }
:is(.sc-checkout, .sc-dialog) input[type=checkbox] {
  flex: none; width: 20px !important; height: 20px !important; margin: 0 !important; display: inline-grid !important; place-content: center;
  appearance: none !important; -webkit-appearance: none !important; position: static !important; opacity: 1 !important; visibility: visible !important;
  border: 1.5px solid var(--control); border-radius: 4px; background: #fff; cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
:is(.sc-checkout, .sc-dialog) input[type=checkbox]::before { content: ""; width: 10px; height: 6px; margin-top: -3px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) scale(0); transition: transform var(--t-fast); }
:is(.sc-checkout, .sc-dialog) input[type=checkbox]:checked { border-color: var(--ink); background: var(--ink); }
:is(.sc-checkout, .sc-dialog) input[type=checkbox]:checked::before { transform: rotate(-45deg) scale(1); }
@media (hover: hover) { :is(.sc-checkout, .sc-dialog) input[type=checkbox]:not(:checked):hover { border-color: var(--ink); } }
:is(.sc-checkout, .sc-dialog) input[type=checkbox]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sc-field-error, .suntc-quick-error { display: block; margin-top: 6px; color: var(--error-text); font-size: 13px; line-height: 1.4; }

/* ---- Modal window ---- */
.sc-dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: 0; border-radius: var(--r-card); overflow: auto; overscroll-behavior: contain;
  background: #fff; box-shadow: var(--sh-dialog); font-size: 16px; line-height: 1.5;
}
.sc-dialog *, .sc-dialog *::before, .sc-dialog *::after { box-sizing: border-box; }
.sc-dialog [hidden] { display: none !important; }
.sc-dialog::before { content: ""; position: sticky; top: 0; z-index: 2; display: block; height: 4px; background: var(--gold); }
.sc-dialog::backdrop { background: #1a1b1666; -webkit-backdrop-filter: blur(6px) saturate(.9); backdrop-filter: blur(6px) saturate(.9); }
@media (prefers-reduced-transparency: reduce) { .sc-dialog::backdrop { background: #1a1b16a6; -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-reduced-motion: no-preference) {
  .sc-dialog[open]::backdrop { animation: sc-backdrop-in 220ms ease-out both; }
  @keyframes sc-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
}
html[data-sc-dialog-open] { overflow: hidden; overscroll-behavior: none; }
html[data-sc-dialog-open] body { overflow: hidden !important; touch-action: none; }
html[data-sc-dialog-open] .sc-dialog { touch-action: pan-y; }
.sc-dialog-head { position: sticky; top: 4px; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 20px 20px 8px 24px; background: #fff; }
.sc-dialog-head h2 { margin: 0; padding: 0; font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; text-transform: none; color: inherit; }
.sc-dialog .sc-dialog-close { flex: 0 0 40px; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--r-ctl); background: var(--surface); color: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
@media (hover: hover) { .sc-dialog .sc-dialog-close:hover { background: var(--surface-2); } }
.sc-dialog-body { padding: 0 24px 24px; }
@media (prefers-reduced-motion: no-preference) {
  .sc-dialog[open] { animation: sc-dialog-in 180ms ease-out both; }
  @keyframes sc-dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
@media (max-width: 480px) {
  .sc-dialog, .sc-dialog.sc-issues { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-card) var(--r-card) 0 0; }
  .sc-dialog-head { padding: 16px 16px 8px; }
  .sc-dialog-body { padding: 0 16px max(20px, env(safe-area-inset-bottom)); }
  .sc-dialog-head h2 { font-size: 22px; }
}

/* ---- Problems dialog: a list of plain rows, red only in the numbers ---- */
.sc-issues { width: min(480px, calc(100vw - 24px)); }
#sc-issues-lead { margin: 0 0 var(--s-2); color: var(--ink-2); font-size: 15px; }
#sc-issues-list { margin: 0 0 var(--s-5); padding: 0; list-style: none; counter-reset: sc-issue; border-top: 1px solid var(--line); }
#sc-issues-list li { counter-increment: sc-issue; border-bottom: 1px solid var(--line); }
#sc-issues-list button, #sc-issues-list li:not(:has(button)) {
  position: relative; display: block; width: 100%; min-height: 48px; padding: 12px 32px 12px 36px;
  border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; line-height: 1.4; text-align: left; cursor: pointer;
}
#sc-issues-list button::before, #sc-issues-list li:not(:has(button))::before {
  content: counter(sc-issue); position: absolute; left: 4px; top: 13px; width: 20px; height: 20px;
  display: grid; place-items: center; border-radius: var(--r-pill); background: var(--error); color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
}
#sc-issues-list button::after { content: "›"; position: absolute; right: 8px; top: 50%; transform: translateY(-52%); color: var(--ink-2); font-size: 22px; line-height: 1; }
@media (hover: hover) { #sc-issues-list button:hover { background: var(--surface); } }
#sc-issues-list button:focus-visible { outline-offset: -2px; }
