/*
 * Theme glue: base element styles and mapping of WordPress core block markup
 * onto the design system. Values come only from tokens.css variables.
 */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body { margin: 0; font-family: var(--font-sans); color: var(--ink); background: var(--surface); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.sp-skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--yellow-500); color: var(--ink); padding: var(--space-10) var(--space-20); font-weight: 600; }
.sp-skip-link:focus { left: var(--space-20); }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Main content area */
.sp-main { display: block; }
.sp-page-head { padding-block: var(--space-40) var(--space-30); }

/* Core blocks in content (patterns and editor) mapped onto components */
.wp-block-button__link { /* = .sp-btn */
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-h);
  padding: 0 var(--space-40); border-radius: var(--radius-10); border: 1px solid transparent;
  background: var(--yellow-500); color: var(--ink); font-size: 16px; line-height: 1.07; font-weight: 600; text-decoration: none;
  transition: background-color var(--speed-hover) ease-in-out, color var(--speed-hover) ease-in-out;
}
.wp-block-button__link:hover { background: var(--yellow-400); }
.is-style-dark .wp-block-button__link { background: var(--ink); color: var(--on-dark); }
.is-style-dark .wp-block-button__link:hover { background: var(--surface); color: var(--ink); border-color: var(--ink); }
.wp-block-buttons { display: flex; flex-wrap: wrap; gap: var(--space-10); }
/* core/details = FAQ item (.sp-faq__item / .sp-faq__q) */
.wp-block-details { border-bottom: 1px solid var(--ink-700); }
.sp-faq > .wp-block-details:first-child, .sp-prose > .wp-block-details:first-of-type { border-top: 1px solid var(--ink-700); }
.wp-block-details > summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: var(--space-20);
  padding: var(--space-20) 0; font-size: 18px; line-height: 1.35; font-weight: 600;
}
.wp-block-details > summary::-webkit-details-marker { display: none; }
.wp-block-details > summary::after {
  content: "+"; flex: none; width: 30px; height: 30px; border-radius: var(--radius-pill); display: grid; place-items: center;
  font-weight: 400; font-size: 20px; line-height: 1; background: var(--yellow-500); color: var(--ink); transition: transform var(--speed-hover) ease-in-out;
}
.wp-block-details[open] > summary::after { transform: rotate(45deg); }
.wp-block-details > :not(summary) { margin: 0 0 var(--space-20); padding-right: 50px; font-size: 14px; line-height: 1.55; }
.sp-card .wp-block-buttons { margin-top: auto; padding-top: var(--space-20); }
.sp-card .wp-block-button__link { min-height: 43px; padding: 0 var(--space-20); font-size: 13px; font-weight: 500; width: 100%; }
/* core/table = Prose table (docs/DESIGN_SYSTEM.md §5 Prose): no cell borders from block-library, only the 1px line */
.sp-prose .wp-block-table { margin-inline: 0; overflow-x: auto; }
.sp-prose .wp-block-table table { border-collapse: collapse; }
.sp-prose .wp-block-table :is(th, td) { border: 0; border-bottom: 1px solid var(--line); }
.sp-prose .wp-block-table thead { border-bottom: 0; }
.sp-prose .wp-block-image figcaption { font-size: 13px; line-height: 1.55; color: var(--ink-700); }
.sp-prose mark { background: var(--yellow-500); color: var(--ink); padding: 0 .12em; }

/* Mobile sticky contact bar */
.sp-mobilebar { display: none; }
@media (max-width: 639px) {
  .sp-mobilebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: var(--space-10); align-items: center;
    padding: var(--space-10) var(--space-20) calc(var(--space-10) + env(safe-area-inset-bottom, 0px));
    background: var(--surface); box-shadow: var(--shadow-card);
  }
  .sp-mobilebar .sp-btn { flex: 1; }
  .sp-mobilebar img { width: 30px; height: 30px; display: block; }
  body { padding-bottom: 76px; }
}

/* wp_nav_menu() output inside the header and footer */
.sp-header__menu, .sp-footer__nav ul { display: flex; flex-wrap: nowrap; gap: var(--space-20); margin: 0; padding: 0; list-style: none; }
.sp-footer__nav ul { flex-wrap: wrap; margin-top: var(--space-30); }
.sp-footer__nav a { color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.55; font-weight: 600; }
.sp-header__menu .current-menu-item > a { box-shadow: inset 0 -3px 0 var(--yellow-500); }

/* Header submenu («Услуги»): a dropdown on desktop, an indented list in the mobile menu */
.sp-header__menu .sub-menu { margin: 0; padding: 0; list-style: none; }
.sp-header__menu .menu-item-has-children > a::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 2px 3px var(--space-10);
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg);
}
@media (min-width: 960px) {
  .sp-header__menu .menu-item-has-children { position: relative; }
  .sp-header__menu .sub-menu {
    position: absolute; top: calc(100% + var(--space-20)); left: calc(-1 * var(--space-30)); z-index: 11;
    display: grid; gap: var(--space-10); width: max-content; padding: var(--space-20) var(--space-30);
    background: var(--surface); border-radius: var(--radius-10); box-shadow: var(--shadow-card);
    visibility: hidden; opacity: 0; transition: opacity var(--speed-hover) ease-in-out, visibility var(--speed-hover) ease-in-out;
  }
  /* Invisible bridge so the pointer can travel from the link to the panel */
  .sp-header__menu .sub-menu::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--space-20); }
  .sp-header__menu .menu-item-has-children:hover > .sub-menu,
  .sp-header__menu .menu-item-has-children:focus-within > .sub-menu { visibility: visible; opacity: 1; }
  .sp-header__menu .sub-menu a { font-weight: 500; }
}
@media (max-width: 959px) {
  .sp-header__menu { flex-direction: column; gap: 0; }
  .sp-header__menu .sub-menu { padding-left: var(--space-20); }
  .sp-header__menu .sub-menu a { font-weight: 400; }
  .sp-header__menu .menu-item-has-children > a::after { display: none; }
}

/* Breadcrumbs from Rank Math / Yoast restyled like .sp-breadcrumbs */
.sp-breadcrumbs-wrap { margin: 0 0 var(--space-20); font-size: 13px; line-height: 1.55; font-weight: 300; }
.sp-breadcrumbs-wrap a { color: var(--ink); text-decoration: none; box-shadow: inset 0 -1px 0 var(--line); }
.sp-breadcrumbs-wrap a:hover { box-shadow: inset 0 -2px 0 var(--yellow-500); }
.sp-breadcrumbs-wrap .separator, .sp-breadcrumbs-wrap .breadcrumb_last { color: var(--ink-700); }

/* Lists of posts and forms inside sections */
.sp-section .sp-cards { margin-top: var(--space-40); }
.sp-contact .sp-form { width: 100%; max-width: none; }

/* Article meta line */
.sp-meta { display: flex; flex-wrap: wrap; gap: var(--space-20); margin: var(--space-15) 0 var(--space-40); font-size: 13px; line-height: 1.55; font-weight: 400; color: var(--ink-700); }
