/*
 * EGE-School components (design B): buttons, tags, chips, cards, post card,
 * rating badge, FAQ, breadcrumbs, pager, form fields, segment switch, prose.
 * Values come from docs/design/b mockups; colours only from base.css tokens.
 * Backgrounds: "dark" = ink (hero, footer), "light" = ground/white.
 */

/*
 * Dark context. Wrap a dark section (header, footer, hero) in .es-on-dark so
 * focus rings turn yellow: the global ring (--es-link-h on ink) is 2.3:1, the
 * yellow one is above 3:1. Light blocks inside a dark section (.es-card,
 * .es-faq, .es-post, or anything with .es-on-light) keep the violet ring.
 * layout.css uses .es-on-dark for the header, mega menu, footer and heroes.
 */
.es-on-dark :focus-visible {
  outline-color: var(--es-acc);
}

.es-on-dark .es-input:focus,
.es-on-dark .es-select:focus,
.es-on-dark .es-textarea:focus {
  outline-color: var(--es-acc);
}

.es-on-dark .es-on-light :focus-visible,
.es-on-dark .es-card :focus-visible,
.es-on-dark .es-faq :focus-visible,
.es-on-dark a.es-post:focus-visible,
.es-on-light :focus-visible {
  outline-color: var(--es-link-h);
}

/* form fields in light blocks inside a dark section: the :focus rules above are 0,3,0 */
.es-on-dark .es-on-light .es-input:focus,
.es-on-dark .es-on-light .es-select:focus,
.es-on-dark .es-on-light .es-textarea:focus,
.es-on-dark .es-card .es-input:focus,
.es-on-dark .es-card .es-select:focus,
.es-on-dark .es-card .es-textarea:focus {
  outline-color: var(--es-link-h);
}

/* ---------- buttons ---------- */
/* .es-btn is the shape (48px); add a colour variant and, optionally, a size. */
.es-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 2px solid transparent;
  border-radius: var(--es-r-pill);
  background: var(--es-acc);
  color: var(--es-ink);
  font-family: var(--es-font-text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.es-btn--sm {
  min-height: 44px;
  padding: 0 20px;
}

.es-btn--lg {
  min-height: 52px;
  padding: 0 26px;
  font-size: 16px;
}

.es-btn--xl {
  min-height: 56px;
  padding: 0 28px;
  font-size: 16px;
}

/*
 * Hover rules: :hover counts (0,2,0) and beats `a:hover`; the disabled guard is
 * inside :where() so it adds no specificity. Variant hovers come later and win
 * over this default by order. Never use :not() outside :where() on .es-btn.
 */
/* default hover (colour variants below override it) */
.es-btn:hover:where(:not([disabled]):not([aria-disabled='true'])) {
  background: var(--es-acc-h);
  color: var(--es-ink);
}

/* yellow accent */
.es-btn--acc {
  background: var(--es-acc);
  color: var(--es-ink);
}

.es-btn--acc:hover:where(:not([disabled]):not([aria-disabled='true'])) {
  background: var(--es-acc-h);
  color: var(--es-ink);
}

/* ink fill */
.es-btn--dark {
  background: var(--es-ink);
  color: var(--es-white);
  font-weight: 700;
}

.es-btn--dark:hover:where(:not([disabled]):not([aria-disabled='true'])) {
  background: var(--es-ink);
  color: var(--es-acc);
}

/* ink outline on a light background */
.es-btn--outline {
  background: transparent;
  border-color: var(--es-ink);
  color: var(--es-ink);
  font-weight: 700;
}

.es-btn--outline:hover:where(:not([disabled]):not([aria-disabled='true'])) {
  background: var(--es-ink);
  color: var(--es-white);
}

/* white outline on a dark background (inside .es-on-dark or any dark section) */
.es-btn--on-dark {
  background: transparent;
  border-color: color-mix(in srgb, var(--es-white) 50%, transparent);
  color: var(--es-white);
  font-weight: 700;
}

.es-btn--on-dark:focus-visible {
  outline-color: var(--es-acc);
}

.es-btn--on-dark:hover:where(:not([disabled]):not([aria-disabled='true'])) {
  background: transparent;
  border-color: var(--es-acc);
  color: var(--es-acc);
}

.es-btn[disabled],
.es-btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- tags, mini tags, subject chips ---------- */
/* Link hover for all tag kinds; modifiers below must stay more specific. */
a.es-tag:hover,
a.es-mini:hover,
a.es-chip:hover {
  color: var(--es-link-h);
}

/* Filter tag: white pill; --on = selected (ink). */
.es-tag {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--es-r-pill);
  background: var(--es-white);
  color: var(--es-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.es-tag--on {
  background: var(--es-ink);
  color: var(--es-white);
}

a.es-tag--on:hover {
  color: var(--es-acc);
}

/* Tag on a dark hero: translucent; --on = yellow. */
.es-tag--glass {
  height: 40px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--es-white) 12%, transparent);
  color: var(--es-white);
}

a.es-tag--glass:hover {
  color: var(--es-acc);
}

.es-tag--glass.es-tag--on {
  background: var(--es-acc);
  color: var(--es-ink);
}

a.es-tag--glass.es-tag--on:hover {
  color: var(--es-ink);
}

.es-tag--glass:focus-visible {
  outline-color: var(--es-acc);
}

/* Small label inside cards. */
.es-mini {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--es-r-pill);
  background: var(--es-ground);
  color: var(--es-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.es-mini--acc {
  background: var(--es-acc);
}

/* Subject chip: <span class="es-chip" style="--chip:#FFB8D9">. */
.es-chip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  height: 30px;
  padding: 0 14px;
  border-radius: var(--es-r-pill);
  background: var(--chip, var(--es-subj-default));
  color: var(--es-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

/* ---------- cards ---------- */
.es-card {
  padding: clamp(24px, 2vw, 28px);
  border-radius: var(--es-r-lg);
  background: var(--es-white);
  color: var(--es-ink);
}

.es-card--soft {
  background: var(--es-ground);
}

/* ---------- article card ---------- */
.es-posts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 900px) {
  .es-posts {
    grid-template-columns: minmax(0, 1fr);
  }
}

.es-post {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
  padding: 24px;
  border-radius: var(--es-r-lg);
  background: var(--es-white);
  color: var(--es-ink);
  transition: transform 0.15s;
}

a.es-post:hover {
  color: var(--es-ink);
  transform: translateY(-3px);
}

.es-post__title {
  font-family: var(--es-font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
}

.es-post__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  color: var(--es-muted);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- rating badge ---------- */
.es-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--es-ground);
  color: var(--es-ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.es-score--first {
  background: var(--es-acc);
}

/* ---------- FAQ ---------- */
.es-faq {
  border-radius: 24px;
  background: var(--es-white);
  color: var(--es-ink);
}

.es-faq + .es-faq {
  margin-top: 12px;
}

.es-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 26px;
  border-radius: 24px;
  font-size: 17px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.es-faq summary::-webkit-details-marker {
  display: none;
}

.es-faq summary::after {
  content: '+';
  content: '+' / '';
  flex: none;
  font-size: 22px;
  line-height: 1;
}

.es-faq[open] summary::after {
  content: '\2212';
  content: '\2212' / '';
}

.es-faq__a {
  padding: 0 26px 22px;
  color: var(--es-muted-2);
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- breadcrumbs ---------- */
/* Default: for the dark hero. .es-crumbs--light: for light backgrounds. */
.es-crumbs {
  font-size: 14px;
  color: var(--es-on-dark);
}

.es-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.es-crumbs li + li::before {
  content: '\203A';
  margin-right: 8px;
}

.es-crumbs a {
  color: var(--es-on-dark);
}

.es-crumbs a:hover {
  color: var(--es-acc);
}

.es-crumbs a:focus-visible {
  outline-color: var(--es-acc);
}

.es-crumbs [aria-current='page'] {
  color: var(--es-white);
}

.es-crumbs--light {
  color: var(--es-muted-2);
}

.es-crumbs--light a {
  color: var(--es-muted-2);
}

.es-crumbs--light a:hover {
  color: var(--es-link-h);
}

.es-crumbs--light a:focus-visible {
  outline-color: var(--es-link-h);
}

.es-crumbs--light [aria-current='page'] {
  color: var(--es-ink);
}

/* ---------- pager ---------- */
.es-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.es-pager a,
.es-pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 48px;
  padding: 0 4px;
  border-radius: var(--es-r-pill);
  background: var(--es-white);
  color: var(--es-ink);
  font-weight: 800;
  line-height: 1;
}

.es-pager a:hover {
  background: var(--es-acc);
  color: var(--es-ink);
}

.es-pager .on {
  background: var(--es-ink);
  color: var(--es-white);
}

.es-pager .gap {
  min-width: 24px;
  background: transparent;
  color: var(--es-muted);
}

/* ---------- form fields ---------- */
.es-input,
.es-select,
.es-textarea {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 2px solid var(--es-line);
  border-radius: 18px;
  background: var(--es-white);
  color: var(--es-ink);
  font-family: var(--es-font-text);
  font-size: 16px;
  line-height: 1.3;
}

.es-textarea {
  height: auto;
  min-height: 120px;
  padding: 14px 16px;
  resize: vertical;
}

.es-input::placeholder,
.es-textarea::placeholder {
  color: var(--es-muted);
  opacity: 1;
}

.es-input:hover,
.es-select:hover,
.es-textarea:hover {
  border-color: var(--es-muted);
}

.es-input:focus,
.es-select:focus,
.es-textarea:focus {
  border-color: var(--es-ink);
  outline: 3px solid var(--es-link-h);
  outline-offset: 2px;
}

.es-select {
  padding-right: 44px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231E1446' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-repeat: no-repeat;
  background-size: 18px;
}

.es-input[aria-invalid='true'],
.es-select[aria-invalid='true'],
.es-textarea[aria-invalid='true'] {
  border-color: var(--es-ink);
  border-style: dashed;
}

/* ---------- segment switch ---------- */
/* <div class="es-seg"> with a/button/span children; selected: .on, aria-pressed, aria-current. */
.es-seg {
  display: inline-flex;
  max-width: 100%;
  padding: 4px;
  border-radius: var(--es-r-pill);
  background: color-mix(in srgb, var(--es-white) 12%, transparent);
}

.es-seg > * {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--es-r-pill);
  background: transparent;
  color: var(--es-white);
  font-family: var(--es-font-text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.es-seg > .on,
.es-seg > [aria-pressed='true'],
.es-seg > [aria-current] {
  background: var(--es-white);
  color: var(--es-ink);
}

.es-seg > a:hover:not(.on):not([aria-current]) {
  color: var(--es-acc);
}

.es-seg > *:focus-visible {
  outline-color: var(--es-acc);
}

/* on a light background */
.es-seg--light {
  background: var(--es-white);
}

.es-seg--light > * {
  color: var(--es-ink);
}

.es-seg--light > .on,
.es-seg--light > [aria-pressed='true'],
.es-seg--light > [aria-current] {
  background: var(--es-ink);
  color: var(--es-white);
}

/* light variant: yellow hover/focus would vanish on white */
.es-seg--light > a:hover:not(.on):not([aria-current]) {
  color: var(--es-link-h);
}

.es-seg--light > *:focus-visible {
  outline-color: var(--es-link-h);
}

/* ---------- prose: article content (the_content) ---------- */
.es-prose {
  color: var(--es-article);
  font-size: 17px;
  line-height: 1.7;
}

@media (min-width: 641px) {
  .es-prose {
    font-size: 18px;
  }
}

.es-prose > :first-child {
  margin-top: 0;
}

.es-prose > :last-child {
  margin-bottom: 0;
}

.es-prose h2,
.es-prose h3,
.es-prose h4 {
  font-family: var(--es-font-display);
  font-weight: 800;
  color: var(--es-ink);
}

.es-prose h2 {
  margin: 40px 0 14px;
  font-size: clamp(22px, 1.1rem + 0.6vw, 26px);
  line-height: 1.15;
}

.es-prose h3 {
  margin: 32px 0 12px;
  font-size: clamp(18px, 1rem + 0.4vw, 21px);
  line-height: 1.25;
}

.es-prose h4 {
  margin: 24px 0 10px;
  font-size: 17px;
  line-height: 1.3;
}

.es-prose p,
.es-prose ul,
.es-prose ol,
.es-prose figure,
.es-prose blockquote,
.es-prose pre,
.es-prose table {
  margin: 0 0 16px;
}

/* Links in content; buttons inside content keep their own styles. */
.es-prose a:not(.es-btn):not(.wp-block-button__link) {
  color: var(--es-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.es-prose a:not(.es-btn):not(.wp-block-button__link):hover {
  color: var(--es-link-h);
  text-decoration-color: var(--es-acc);
}

.es-prose ul,
.es-prose ol {
  padding-left: 1.4em;
}

.es-prose li {
  margin-bottom: 6px;
}

.es-prose li > ul,
.es-prose li > ol {
  margin: 6px 0 0;
}

.es-prose li::marker {
  color: var(--es-muted);
  font-weight: 700;
}

.es-prose hr {
  margin: 32px 0;
  border: 0;
  border-top: 1px solid var(--es-line);
}

.es-prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--es-r-md);
}

.es-prose figure {
  max-width: 100%;
}

.es-prose figure img {
  margin-inline: auto;
}

.es-prose figcaption {
  margin-top: 8px;
  color: var(--es-muted-2);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.es-prose .aligncenter {
  margin-inline: auto;
}

@media (min-width: 641px) {
  .es-prose .alignleft {
    float: left;
    margin: 4px 24px 16px 0;
  }

  .es-prose .alignright {
    float: right;
    margin: 4px 0 16px 24px;
  }
}

.es-prose blockquote {
  padding: 24px;
  border-radius: var(--es-r-lg) var(--es-r-lg) var(--es-r-lg) 6px;
  background: var(--es-white);
  color: var(--es-ink);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.5;
}

.es-prose blockquote > :last-child {
  margin-bottom: 0;
}

.es-prose blockquote cite {
  display: block;
  margin-top: 10px;
  color: var(--es-muted-2);
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
}

.es-prose code,
.es-prose kbd,
.es-prose samp {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--es-line-2);
  color: var(--es-ink);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.es-prose pre {
  padding: 20px 24px;
  overflow-x: auto;
  border-radius: var(--es-r-md);
  background: var(--es-ink);
  color: var(--es-on-dark);
  font-size: 15px;
  line-height: 1.55;
}

.es-prose pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

/* tables: the block wrapper scrolls; a bare table scrolls by itself */
.es-prose .wp-block-table {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.es-prose .wp-block-table table {
  min-width: 520px;
  margin: 0;
}

.es-prose table {
  width: 100%;
  border-collapse: collapse;
  background: var(--es-white);
  font-size: 16px;
  line-height: 1.45;
}

.es-prose > table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.es-prose th,
.es-prose td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--es-line);
  text-align: left;
  vertical-align: top;
}

.es-prose th {
  background: var(--es-line-2);
  color: var(--es-ink);
  font-weight: 800;
}

.es-prose tr:last-child td {
  border-bottom: 0;
}

/* embeds: 16:9 */
.es-prose iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--es-r-md);
}

.es-prose .wp-block-embed__wrapper {
  position: relative;
}

.es-prose .wp-has-aspect-ratio iframe {
  position: absolute;
  inset: 0;
  height: 100%;
}

/* Fallback ratio when core block CSS is absent; specific ratios follow. */
.es-prose .wp-has-aspect-ratio .wp-block-embed__wrapper {
  aspect-ratio: 16 / 9;
}

.es-prose .wp-embed-aspect-21-9 .wp-block-embed__wrapper {
  aspect-ratio: 21 / 9;
}

.es-prose .wp-embed-aspect-18-9 .wp-block-embed__wrapper {
  aspect-ratio: 18 / 9;
}

.es-prose .wp-embed-aspect-4-3 .wp-block-embed__wrapper {
  aspect-ratio: 4 / 3;
}

.es-prose .wp-embed-aspect-1-1 .wp-block-embed__wrapper {
  aspect-ratio: 1 / 1;
}

.es-prose .wp-embed-aspect-9-16 .wp-block-embed__wrapper {
  aspect-ratio: 9 / 16;
}

/* ---------- ad slots (D43): code from «Настройки → Код и реклама» ---------- */
.es-ad {
  max-width: 100%;
  overflow: hidden;
  margin-block: var(--es-s-4);
}

.es-ad--header-top,
.es-ad--header-bottom {
  margin-inline: auto;
  text-align: center;
}

.es-ad--post-inline,
.es-ad--post-bottom {
  margin-block: var(--es-s-6);
}
