/* ==========================================================================
   Learnio DS on learnio.ru: a thin layer over assets/css/learnio-ds.css (task 01a1f408, W2a; docs/design-system.md).
   The bundle (printed first) holds the --l-* tokens for light and dark, the faces and the .l-* components. This sheet,
   printed after style.css and the product sheets (inc/design-system.php, priority 40), only maps the site's own
   markup onto them:
     1. legacy --ds-* names as aliases of --l-* (no values here: the DS switches them for dark)
     2. type roles: Artegra for page titles and marketing headings, Inter for the rest
     3. buttons
     4. fields: inputs, selects, text areas
     5. checkbox, radio, switch (18 px, r6, 1.5 px field edge: the one DS design)
     6. choice row: control + label + description, the whole row clickable
   Classes pages (body.learnio-oblako) have their own sheet with stronger selectors; nothing here targets them.
   ========================================================================== */

/* 1. Legacy names --------------------------------------------------------- */
:root {
  --ds-accent: var(--l-accent);
  --ds-accent-hover: var(--l-accent-hover);
  --ds-on-accent: var(--l-on-accent);
  --ds-surface: var(--l-surface);
  --ds-surface-2: var(--l-surface-2);
  /* Edge of an empty field, checkbox or radio: 3:1 against the surface (WCAG 1.4.11). */
  --ds-field: var(--l-field);
  --ds-field-hover: var(--l-field-hover);
  --ds-text: var(--l-text);
  --ds-muted: var(--l-muted);
  --ds-focus: var(--l-focus);
  --ds-ring: var(--l-ring);
  --ds-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E");
  --ds-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M4 8h8'/%3E%3C/svg%3E");
  --ds-ease: var(--l-ease);
  --ds-dur: var(--l-dur);
}

/* 2. Type roles ------------------------------------------------------------ */
/* Page titles, the home hero and the marketing section titles: Artegra Sans Extended.
   User content (a material, a child's name) stays Inter 700 even as the page title. */
main h1:not([data-learnio-user-content]),
.home-page h2,
.articles-hero h1,
.learnio-article-products__title,
.learnio-404 h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
main h1[data-learnio-user-content],
main div:has(> .learnio-profile-action-kicker) > h1,
body.single-product main h1.product_title {
  font-family: var(--font-text);
  font-weight: 700;
}
/* Artegra is about a fifth wider than the old face: titles get one step smaller so lines break as before. */
:root {
  --h1-size: 36px;
  --h2-size: 26px;
}
@media (max-width: 767.98px) {
  :root {
    --h1-size: 28px;
    --h2-size: 22px;
  }
}
.library-header h1,
.articles-hero h1 {
  font-size: var(--h1-size);
  line-height: 1.12;
}
.article-single-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.15;
}
.home-page > .stats > .stat h2 {
  font-family: var(--font-display);
}
/* Card titles, panel titles, labels and body copy: Inter. */
:is(h3, h4, h5, h6),
.material-title,
.article-title,
.filters h2 {
  font-family: var(--font-text);
}

/* 3. Buttons --------------------------------------------------------------- */
:is(.primary-button, .ghost-button, .link-button, .wp-block-button__link, .wp-element-button, .woocommerce .button, .woocommerce button.button) {
  border-radius: var(--radius-pill);
  font-family: var(--font-text);
  font-weight: 600;
  letter-spacing: 0;
  transition: background-color var(--ds-dur) var(--ds-ease), border-color var(--ds-dur) var(--ds-ease),
    color var(--ds-dur) var(--ds-ease), box-shadow var(--ds-dur) var(--ds-ease), transform 100ms var(--ds-ease);
}
:is(.primary-button, .ghost-button, .wp-block-button__link, .woocommerce .button):not(:disabled):active {
  transform: scale(0.97);
}
:is(.primary-button, .ghost-button, .link-button, .wp-block-button__link, .woocommerce .button):focus-visible {
  outline: 2px solid var(--ds-focus);
  outline-offset: 2px;
}
:is(.primary-button, .ghost-button, .wp-block-button__link, .woocommerce .button):is(:disabled, [aria-disabled="true"]) {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* 4. Fields ---------------------------------------------------------------- */
/* One field everywhere (the DS .l-input): --l-control high (40, 44 on phones and touch), pill, 1 px --l-field edge,
   surface fill; a text area is r12 and grows. A read-only field looks like any other. The scope list includes the
   ЛК content (#profileContent) and the checkout, and the long :not() chain lifts this above the older per-page field
   rules (some start with an id), so a page never needs its own height, border or radius for a field. */
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="color"]):not([type="image"]):not([type="reset"]):not(.qty),
  select
):not([data-l-free]) {
  box-sizing: border-box;
  height: var(--l-control);
  min-height: var(--l-control);
  padding: 0 var(--l-s-4);
  border: 1px solid var(--l-field);
  border-radius: var(--l-r-pill);
  background-color: var(--l-surface);
  color: var(--l-text);
  font-family: var(--font-text);
  font-size: var(--l-fs-md);
  line-height: 1.3;
}
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) input[type="search"]:not([data-l-free]) {
  padding-inline-start: 40px; /* room for the magnifier */
}
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) select:not([data-l-free]) {
  padding-inline: var(--l-s-4) 40px;
}
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) textarea:not([data-l-free]) {
  box-sizing: border-box;
  height: auto;
  min-height: 96px;
  padding: 10px var(--l-s-4);
  border: 1px solid var(--l-field);
  border-radius: var(--l-r-sm);
  background-color: var(--l-surface);
  color: var(--l-text);
  font-family: var(--font-text);
  font-size: var(--l-fs-md);
  line-height: var(--l-lh);
}
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) :is(input, select, textarea):not([data-l-free]):hover:not(:focus):not(:disabled):not([aria-invalid="true"]) {
  border-color: var(--l-field-hover);
}
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) :is(input, select, textarea)[aria-invalid="true"]:not([data-l-free]) {
  border-color: var(--l-danger);
}
html body :is(main, #profileContent, #profileRoot, .learnio-modal, .learnio-auth-modal, .filters, .woocommerce) :is(input, select, textarea):not([data-l-free]):focus-visible {
  border-color: var(--ds-focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--ds-ring);
}

/* 5. Checkbox, radio, switch ----------------------------------------------- */
/* Visible native controls of the site (opt-in by container, so the chip toggles of the filters and the
   tile radios of sign-up and «Оформление», which hide their input, are not touched).
   html body + !important: older rules here set width 100% on every form input of a modal. */
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input:is([type="checkbox"], [type="radio"]) {
  appearance: none !important;
  -webkit-appearance: none !important;
  position: relative !important;
  display: inline-block !important;
  flex: 0 0 auto !important;
  width: 18px !important;
  min-width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1.5px solid var(--ds-field) !important;
  border-radius: var(--radius-check) !important;
  background: var(--ds-surface) center / 12px 12px no-repeat !important;
  box-shadow: none !important;
  outline: none !important;
  cursor: pointer;
  vertical-align: top;
  transition: background-color var(--ds-dur) var(--ds-ease), border-color var(--ds-dur) var(--ds-ease), box-shadow var(--ds-dur) var(--ds-ease);
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input[type="radio"] {
  border-radius: 50% !important;
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input:is([type="checkbox"], [type="radio"]):hover:not(:disabled) {
  border-color: var(--ds-field-hover) !important;
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input[type="checkbox"]:is(:checked, :indeterminate) {
  border-color: var(--ds-accent) !important;
  background-color: var(--ds-accent) !important;
  background-image: var(--ds-check) !important;
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input[type="checkbox"]:indeterminate {
  background-image: var(--ds-dash) !important;
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input[type="radio"]:checked {
  border-color: var(--ds-accent) !important;
  box-shadow: inset 0 0 0 4px var(--ds-surface) !important;
  background-color: var(--ds-accent) !important;
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input:is([type="checkbox"], [type="radio"]):focus-visible {
  outline: 2px solid var(--ds-focus) !important;
  outline-offset: 2px !important;
}
html body :is(
  .learnio-choice, .learnio-profile-choice, .learnio-distribution-choice, .learnio-marketing-consent,
  .learnio-parent__item, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox,
  .woocommerce-terms-and-conditions-wrapper, .woocommerce-form-login__rememberme
) > input:is([type="checkbox"], [type="radio"]):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* Switch: a checkbox with role="switch" inside a choice row. 36 × 18 track, 12 px thumb. */
html body .learnio-choice > input[type="checkbox"][role="switch"] {
  width: 36px !important;
  min-width: 36px !important;
  border-radius: var(--radius-pill) !important;
  background: var(--ds-field) !important;
  border-color: var(--ds-field) !important;
}
html body .learnio-choice > input[type="checkbox"][role="switch"]::after {
  content: "";
  position: absolute;
  top: 1.5px;
  left: 1.5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--l-shadow-sm);
  transition: transform var(--ds-dur) var(--ds-ease);
}
html body .learnio-choice > input[type="checkbox"][role="switch"]:checked {
  background: var(--ds-accent) !important;
  border-color: var(--ds-accent) !important;
}
html body .learnio-choice > input[type="checkbox"][role="switch"]:checked::after {
  transform: translateX(18px);
}
@media (prefers-reduced-motion: reduce) {
  html body .learnio-choice > input[type="checkbox"][role="switch"]::after { transition: none; }
}

/* 6. Choice row ------------------------------------------------------------ */
/* <label class="learnio-choice"><input type="checkbox"><span><strong>Label</strong><small>Description</small></span></label>
   Control in an 18 px column, 12 px gap, label 15/600, description 13 muted under it; the row is the click target. */
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice) {
  display: grid !important;
  grid-template-columns: 18px minmax(0, 1fr) !important;
  align-items: start !important;
  column-gap: 12px !important;
  row-gap: 0 !important;
  width: calc(100% + 24px);
  margin: 0 -12px !important;
  padding: 12px !important;
  border: 0 !important;
  border-radius: var(--radius-sm) !important;
  background: transparent !important;
  color: var(--ds-text) !important;
  font-family: var(--font-text) !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  line-height: 1.35 !important;
  cursor: pointer;
  transition: background-color var(--ds-dur) var(--ds-ease);
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice):hover {
  background: var(--ds-surface-2) !important;
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice) > input {
  margin-top: 0 !important;
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice) > span {
  display: grid !important;
  gap: 2px !important;
  min-width: 0;
  padding-top: 0;
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice) > span > strong {
  display: block;
  color: var(--ds-text) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 20px !important;
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice) > span > small {
  display: block;
  color: var(--ds-muted) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 1.45 !important;
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice) a {
  color: var(--ds-focus) !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}
html body :is(.learnio-choice, .learnio-profile-choice, .learnio-distribution-choice):has(> input:disabled) {
  cursor: not-allowed;
}
/* Single-line consent rows (sign-up, checkout, «Запомнить меня»): the box sits on the first text line. */
html body :is(.learnio-marketing-consent, .learnio-auth-consent, .inline-toggle, .woocommerce-form__label-for-checkbox, .woocommerce-form-login__rememberme) {
  display: flex !important;
  gap: 12px !important;
  align-items: flex-start !important;
  cursor: pointer;
}
html body :is(.learnio-marketing-consent, .learnio-auth-consent, .woocommerce-form__label-for-checkbox) > input {
  margin-top: 1px !important;
}

/* Profile «Настройки профиля» block of the edit dialog: title, one muted line, then the rows. */
html body .learnio-profile-preferences {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--l-border);
}
html body .learnio-profile-preferences__head {
  display: grid;
  gap: 4px;
  margin: 0 0 8px;
}
html body .learnio-profile-preferences__head h4 {
  margin: 0;
  color: var(--ds-text);
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
html body .learnio-profile-preferences__head p,
html body .learnio-profile-preferences__consents {
  margin: 0;
  color: var(--ds-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
}
html body .learnio-profile-preferences__consents {
  padding: 4px 0 8px 30px;
}
html body .learnio-profile-preferences__consents a {
  color: var(--ds-focus);
  text-decoration: underline;
  text-underline-offset: 2px;
}
html body .learnio-profile-author-choice {
  padding-left: 32px;
}

/* 7. WooCommerce blocks (cart / checkout built from blocks) -------------------- */
.wc-block-components-text-input :is(input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"]),
.wc-block-components-combobox .wc-block-components-combobox-control input.components-combobox-control__input,
.wc-blocks-components-select .wc-blocks-components-select__select {
  border-radius: var(--radius-pill) !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
}
.wc-block-components-text-input label,
.wc-blocks-components-select .wc-blocks-components-select__label {
  left: 19px !important;
}
.wc-block-components-textarea {
  border-radius: var(--radius-sm) !important;
}
.wc-block-components-button:not(.is-link) {
  border-radius: var(--radius-pill) !important;
  font-family: var(--font-text);
  font-weight: 600;
}
.wc-block-components-checkout-place-order-button,
.wc-block-cart__submit-button {
  background: var(--ds-accent) !important;
  color: var(--ds-on-accent) !important;
}
.wc-block-components-checkout-place-order-button:hover,
.wc-block-cart__submit-button:hover {
  background: var(--ds-accent-hover) !important;
}
.wp-block-woocommerce-checkout-order-summary-block,
.wc-block-components-sidebar .wc-block-components-panel,
.wc-block-components-notice-banner {
  border-radius: var(--card-radius) !important;
}
.wc-block-components-checkbox .wc-block-components-checkbox__input[type="checkbox"] {
  border-radius: var(--radius-check);
}
.wc-block-components-checkbox .wc-block-components-checkbox__input[type="checkbox"]:checked {
  border-color: var(--ds-accent);
  background: var(--ds-accent);
}
.wc-block-components-checkbox .wc-block-components-checkbox__input[type="checkbox"]:checked + .wc-block-components-checkbox__mark {
  fill: var(--l-on-accent);
}

/* 8. Dialog forms: label 14/600 above the field, the field gap from the label 6. */
html body .learnio-modal .upload-form > label,
html body .learnio-modal .upload-form .form-grid > label {
  font-size: 14px !important;
  font-weight: 600 !important;
  gap: 6px !important;
}

/* 9. Review fixes (wave 3 design review) ------------------------------------ */
/* Placeholders read as hints, not as typed values: muted, regular weight, in both themes
   (the profile dialog inherited the 700 label weight and, in dark, a colour close to the value). */
html body :where(main, .learnio-modal, .learnio-auth-modal) :is(input, textarea)::placeholder {
  color: var(--ds-muted) !important;
  font-weight: 400 !important;
  opacity: 1;
}
/* Profile dialogs: one shrinkable column, so on 320 px the form never gets wider than the dialog. */
html body.learnio-profile-context :is(#profileSettingsModal, #balanceTopupModal, #withdrawModal) .learnio-modal-dialog {
  grid-template-columns: minmax(0, 1fr) !important;
}
/* Profile dialog select: the same chevron as the library filters, not the browser arrow. */
html body.learnio-profile-context #profileSettingsModal select:not([multiple]):not([size]) {
  appearance: none !important;
  -webkit-appearance: none !important;
  padding-right: 40px !important;
  background-image: var(--chevron) !important;
  background-repeat: no-repeat !important;
  background-position: right 16px center !important;
  background-size: 12px 8px !important;
}
/* «Просмотр корзины» in a WooCommerce notice: a real pill with padding, accent text, centred on the row. */
.wc-block-components-notice-banner > .wc-block-components-notice-banner__content .wc-forward {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  height: auto !important;
  padding: 0 18px !important;
  border-radius: var(--radius-pill) !important;
  color: var(--ds-focus) !important;
  font-weight: 600;
  white-space: nowrap;
  opacity: 1 !important;
}
/* Profile sign-in gate («Войти / Регистрация»): brand ink and muted text instead of browser black. */
#authGate h2 {
  color: var(--tk-fg-blue);
}
#authGate p {
  color: var(--ds-muted);
}

/* 10. Wave 3 leftovers (wave 4, task 01a1f417) ------------------------------ */
/* Article title next to the picture (5 + 7 columns): one step smaller, so a long Artegra title takes three or four
   lines at 1280, not nine. html body: style.css is printed again after this sheet (learnio-style-hotfix-direct). */
html body .article-single-shell .article-single-title {
  font-size: clamp(24px, 2.4vw, 32px);
}
html body .article-single-shell:has(> .article-single-thumb) .article-single-title {
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.15;
}
/* Typed values in dialog forms read as content, not as labels: regular 500 under the 600 label.
   The id in :is() matches nothing; it only lifts the rule over the #profileSettingsModal ones of style.css. */
html body :is(.learnio-modal, #learnioAnyModal) .learnio-modal-dialog :is(
  input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="url"],
  input[type="search"], input[type="tel"], input[type="date"], select, textarea
) {
  font-weight: 500 !important;
}

/* Article title next to the picture: the picture takes the height of the row (4:3 stays its minimum), so both cards
   end on the same line. */
@media (min-width: 768px) {
  html body .article-single-shell > .article-single-thumb { align-self: stretch; }
}
