/* TopSchoolHub theme layer (task 5.1): WordPress glue on top of the design system
   (tokens.css + components.css are copied from design/system unchanged except the font path).
   Only layout pieces the system does not cover live here; reads tokens only. */

/* ===== Page shell ===== */
.site-main { display: block; min-height: 50vh; }
.site-main:focus { outline: none; }
/* Sticky header (task 9.3): stays on top while scrolling; anchors land below it. */
html { scroll-padding-top: calc(var(--header-h) + var(--s-4)); }
.site-header { position: sticky; top: 0; z-index: 40; }
body.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .site-header { top: 46px; } }
@media (max-width: 600px) { body.admin-bar .site-header { top: 0; } } /* the admin bar scrolls away there */
.chips--sticky { top: var(--header-h); }
.nav__link[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--c-mint); }
.site-header__logo[aria-current="page"] { box-shadow: none; }
.site-footer__brand p { margin: 0; max-width: 300px; }
.crumbs + .page-head, .crumbs + h1 { padding-top: var(--s-2); }

/* ===== Editor content (trust pages, intros) ===== */
.entry-content > :first-child { margin-top: 0; }
.entry-content h2 { margin-top: var(--s-7); }
.entry-content h3 { margin-top: var(--s-6); }
.entry-content img { border-radius: var(--r-md); }
.entry-content table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.entry-content th, .entry-content td { padding: 10px 12px; border-bottom: 1px solid var(--c-line); text-align: left; }
.entry-content blockquote { margin: var(--s-5) 0; padding: var(--s-3) var(--s-4); border-left: 3px solid var(--c-brand-2);
  background: var(--c-surface); color: var(--c-ink-2); }
.alignleft { float: left; margin: 0 var(--s-5) var(--s-3) 0; }
.alignright { float: right; margin: 0 0 var(--s-3) var(--s-5); }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.wp-caption-text, figcaption { font-size: var(--fs-sm); color: var(--c-muted); }

/* ===== Internal link blocks (plugin LinkBlock: .box.tsh-links > h2 + ul.links) ===== */
.link-blocks { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); margin-top: var(--s-7); }
@media (min-width: 760px) { .link-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .link-blocks { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.link-blocks .box { margin: 0; }
.tsh-links .links a { text-decoration: none; }
.tsh-links .links a:hover { text-decoration: underline; }

/* ===== Plain lists of posts ===== */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list h2 { font-size: var(--fs-lg); }

/* ===== Hero (home) ===== */
.hero__overline { color: var(--c-on-brand-muted); }
.hero + .section { padding-top: var(--s-7); }
.home__stats { padding-top: var(--s-5); }

/* ===== 404 ===== */
.not-found { padding: var(--s-9) 0 var(--s-4); max-width: var(--w-prose); }
.not-found__code { margin: 0 0 var(--s-2); font-size: clamp(3.5rem, 2rem + 8vw, 6rem); font-weight: var(--fw-heavy);
  line-height: 1; color: var(--c-brand-2); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ===== Fallback route template of the plugin (until tsh/*.php templates exist) ===== */
.tsh-route { padding-bottom: var(--s-7); }
.tsh-route .tsh-ranking { padding-left: 1.4em; }
.tsh-route .tsh-ranking__item { padding: var(--s-2) 0; border-bottom: 1px solid var(--c-line); }

@media print {
  .site-header, .site-footer, .skip-link, .sticky-cta, .chips { display: none; }
}

/* ===== Ranking pages (task 5.2: tsh/seo-page.php) ===== */
.ranking { padding-bottom: var(--s-7); }
.page-head__lead { margin: 0; }
.stats { margin: 0; }
.stat dd { margin: 0; }
.ranking__intro { margin: var(--s-3) 0 var(--s-2); max-width: var(--w-prose); }
.ranking__aside .box + .box { margin-top: var(--s-4); }
.box__note { margin: var(--s-2) 0 0; }
.places { list-style: none; margin: 0; padding: 0; }
.places .dest-card { height: 100%; }
.facts { display: grid; gap: var(--s-3); margin: 0; }
.facts > div { padding: var(--s-3) var(--s-4); background: var(--c-soft); border-radius: var(--r-md); }
.facts dt { font-weight: var(--fw-bold); }
.facts dd { margin: 4px 0 0; color: var(--c-ink-2); }
.tbl th[scope="row"] { font-weight: var(--fw-semibold); }

/* Filter form (plugin FilterForm, design-system fields) */
.tsh-filters { display: grid; gap: var(--s-3); margin: var(--s-4) 0; padding: var(--s-3) 0;
  border-top: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); }
.tsh-filters__fields { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-items: end; }
.tsh-filters__check label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--c-ink); }
.tsh-filters__check input { width: 18px; height: 18px; accent-color: var(--c-brand-2); }
.tsh-filters__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.tsh-filters__found { margin: 0; font-size: var(--fs-sm); color: var(--c-muted); }
.tsh-filters__chips { list-style: none; margin: 0; padding: 0; }

/* ===== School profile (task 5.3: tsh/school.php) ===== */
.profile { padding-bottom: var(--s-6); }
.profile__closed { margin: var(--s-3) 0 0; }
.profile-head__title { margin: 0 0 6px; }
.profile-head__meta { margin: 0; }
.profile-head__meta a { color: inherit; }
.profile-head__verified { color: var(--c-success); font-weight: var(--fw-semibold); }
.profile-head__cta { display: flex; flex-wrap: wrap; gap: var(--s-2); }
@media (min-width: 1000px) { .profile-head__cta { max-width: 360px; justify-content: flex-end; } }
.profile__stats { margin: var(--s-4) 0 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.profile__lead { margin: var(--s-5) 0 0; max-width: var(--w-prose); }
.profile__main > .section:first-child { padding-top: var(--s-5); }
.profile__bars { max-width: 520px; margin-bottom: var(--s-3); }
.profile__aside { padding-top: var(--s-5); }
.profile__price { margin: 0; font-size: var(--fs-md); }
.profile__price b { font-size: 1.5rem; }
.profile__others { list-style: none; margin: 0; padding: 0; }
.profile__others .meta { margin: 0; }
.profile__data { margin: 0; line-height: 1.7; }
.reviews { list-style: none; margin: 0; padding: 0; }
.review { padding: var(--s-4) 0; border-bottom: 1px solid var(--c-line); }
.review:first-child { padding-top: 0; }
.review__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; font-size: var(--fs-sm); color: var(--c-muted); }
.review__meta b { color: var(--c-ink); font-size: 1rem; }
.review__title { margin: var(--s-2) 0 0; font-size: 1rem; }
.review__body { margin: var(--s-2) 0 0; max-width: var(--w-prose); }
.reviews__more { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-4); }
.map { display: grid; gap: var(--s-2); align-content: center; min-height: 120px; padding: var(--s-3);
  border-radius: var(--r-md); background: var(--c-soft); }
.map__address { margin: 0; }
.map__load { justify-self: start; }
.map.is-loaded { padding: 0; background: none; }
.map.is-loaded .map__address { padding: 0 2px; }
.map__canvas { height: 260px; border-radius: var(--r-md); overflow: hidden; }
.profile + .sticky-cta, .profile .sticky-cta { margin: var(--s-5) calc(-1 * var(--gutter)) 0; }

/* ===== Byline: "Last updated · Reviewed by" (task 5.4, ТЗ 8.9) ===== */
.byline { margin: var(--s-2) 0 0; color: var(--c-muted); }
.byline a { color: inherit; }

/* ===== Prices pages (task 5.4, ТЗ 7.5) ===== */
.prices, .guide, .search-page { padding-bottom: var(--s-7); }
.prices-table tbody + tbody { border-top: 2px solid var(--c-line); }
.prices-table .prices-table__school th { background: var(--c-surface); font-weight: var(--fw-bold); }
.prices-table__pos { margin-right: 6px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.prices-table__hourly { display: block; margin-top: 2px; font-weight: 400; color: var(--c-muted); }
.prices-table .muted { color: var(--c-muted); }
@media (max-width: 759px) {
  .prices-table .prices-table__school { display: block; background: var(--c-surface); }
  .prices-table .prices-table__school th { background: none; }
}

/* ===== Guides (task 5.4) ===== */
.guide__single { max-width: var(--w-prose); }
.guide__body h2 { scroll-margin-top: var(--s-5); }
.toc h2 { margin: 0 0 var(--s-2); font-size: var(--fs-md); }
.toc ol { margin: 0; padding-left: 1.3em; }
.toc li + li { margin-top: 4px; }

/* ===== Search (task 5.4, ТЗ 3.4) ===== */
.search--simple { box-shadow: none; padding: 0; background: transparent; }
@media (min-width: 760px) { .search--simple { grid-template-columns: minmax(0, 1fr) auto; align-items: end; max-width: 640px; } }
.hero .search--simple { padding: 10px; background: var(--c-bg); box-shadow: var(--sh-3); }
.not-found .search--simple { margin: var(--s-4) 0; }
.search-page .search--simple { margin: var(--s-3) 0 var(--s-2); }
.search-results { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--c-line); }
.search-results li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--c-line); }
.search-results a { font-weight: var(--fw-semibold); }
.search-results .small { color: var(--c-muted); }

/* ===== Cookie banner (task 5.4) ===== */
.cookie-banner { position: fixed; inset: auto 0 0 0; z-index: 50; padding: var(--s-3) 0; background: var(--c-bg);
  border-top: 1px solid var(--c-line); box-shadow: var(--sh-3); }
.cookie-banner[hidden] { display: none; }
.cookie-banner__inner { display: grid; gap: var(--s-3); align-items: center; }
@media (min-width: 760px) { .cookie-banner__inner { grid-template-columns: minmax(0, 1fr) auto; } }
.cookie-banner__title { margin: 0 0 4px; font-size: var(--fs-md); }
.cookie-banner p { margin: 0; }
.cookie-banner__actions { display: flex; gap: var(--s-2); }
.cookie-banner__actions .btn { flex: 1 1 auto; }
.site-footer__link { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.site-footer__link[hidden] { display: none; }

/* ===== Contact form (plugin shortcode [tsh_contact_form], task 9.2) ===== */
.contact-form { max-width: 560px; margin: var(--s-5) 0; }
.contact-form__form { display: grid; gap: var(--s-4); }
.contact-form__form textarea.input { min-height: 160px; resize: vertical; font: inherit; }
.contact-form__form .field label { font-size: var(--fs-sm); color: var(--c-ink); }
.field__error { font-size: var(--fs-sm); color: var(--c-danger, #b42318); }
.contact-form [aria-invalid="true"] { border-color: var(--c-danger, #b42318); }
.contact-form__hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact-form__form p { margin: 0; }

/* ===== Mega menu by region (task 9.3): sport → region tabs → countries → places =====
   Phones: one accordion inside the drawer (regions, then countries). Desktop: region tabs in a row
   (flex order puts every head before the panels), countries in columns, places under a country.
   Without JS the panels are never shown (the header has no .js), all links stay in the HTML. */
.mega__regions { display: block; }
.mega__region-head { margin: 0; font-size: var(--fs-base); }
.mega__tab { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: var(--s-3) var(--s-2); border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.15); background: none; color: inherit; text-align: left; cursor: pointer;
  font: var(--fw-semibold) var(--fs-base) / 1.2 var(--font-sans); }
.mega__tab::after, .mega__expand::after { content: ""; width: 7px; height: 7px; margin: -4px 2px 0 auto; border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform var(--t-fast); }
.mega__expand::after { margin: -3px 0 0 6px; }
.mega__tab[aria-expanded="true"]::after, .mega__expand[aria-expanded="true"]::after { transform: translateY(3px) rotate(-135deg); }
.mega__tab::before { content: attr(data-count); order: 1; font-size: var(--fs-xs); font-weight: var(--fw-medium); opacity: 0.75; font-variant-numeric: tabular-nums; }
.mega__tab::after { order: 2; }
.site-header.js .mega__region:not(.is-open), .site-header.js .mega__places:not(.is-open) { display: none; }
.mega__region { padding: 0 var(--s-2) var(--s-3); }
.mega__countries, .mega__places { list-style: none; margin: 0; padding: 0; }
.mega__country { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-2); }
.mega__country > .mega__places { flex-basis: 100%; }
.mega__country-link { flex: 1; padding: 9px 0; color: inherit; font-weight: var(--fw-semibold); text-decoration: none; }
a.mega__country-link:hover, .mega__places a:hover { text-decoration: underline; }
.mega__expand { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: 40px; font-size: var(--fs-xs);
  padding: 0 var(--s-2); border: 0; border-radius: var(--r-sm); background: none; color: inherit; cursor: pointer; }
.mega__expand:hover { background: rgba(255, 255, 255, 0.12); }
.mega__places { margin: 0 0 var(--s-2) 2px; padding-left: var(--s-3); border-left: 2px solid rgba(255, 255, 255, 0.25); }
.mega__places a { display: block; padding: 7px 0; color: inherit; text-decoration: none; }
.mega__foot { margin: var(--s-2) 0 0; padding: var(--s-3) var(--s-2) 0; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.mega__foot .mega__all { color: inherit; }
@media (max-width: 759px) {
  /* The open drawer scrolls inside the sticky header instead of running off the screen. */
  .site-header.js.is-open .nav { max-height: calc(100vh - var(--header-h)); max-height: calc(100dvh - var(--header-h));
    overflow-y: auto; overscroll-behavior: contain; }
  .mega__inner { padding: 0 0 var(--s-3); }
}
@media (min-width: 760px) {
  .mega { max-height: calc(100vh - var(--header-h) - var(--s-6)); overflow-y: auto; overscroll-behavior: contain; }
  .mega__inner { display: block; }
  .mega__regions { display: flex; flex-wrap: wrap; gap: 0 var(--s-1); border-bottom: 0; }
  .mega__region-head { order: 0; }
  .mega__region { order: 1; flex-basis: 100%; padding: var(--s-5) 0 0; border-top: 1px solid var(--c-line); }
  .mega__tab { width: auto; padding: var(--s-2) var(--s-3); border: 0; border-bottom: 3px solid transparent; color: var(--c-muted); }
  .mega__tab:hover { color: var(--c-brand); }
  .mega__tab[aria-expanded="true"] { color: var(--c-brand); border-bottom-color: var(--c-brand-2); }
  .mega__tab::after { display: none; }
  .mega__countries { columns: 4 190px; column-gap: var(--s-6); }
  .mega__country { break-inside: avoid; }
  .mega__country-link { color: var(--c-ink); padding: 6px 0; }
  .mega__expand { min-height: 32px; min-width: 40px; color: var(--c-muted); }
  .mega__expand:hover { background: var(--c-soft); color: var(--c-brand); }
  .mega__places { border-left-color: var(--c-line); }
  .mega__places a { padding: 4px 0; color: var(--c-ink-2); }
  .mega__foot { margin-top: var(--s-5); padding: var(--s-4) 0 0; border-top-color: var(--c-line); }
  .mega__foot .mega__all { color: var(--c-brand-2); }
}

/* ===== Home: Scoreboard (task 9.3, design concept B) ===== */
.home-block { padding: var(--s-7) 0 0; }
.home-block:last-of-type { padding-bottom: var(--s-7); }
.home-block h2 { margin: 0 0 var(--s-4); }
.home-block__more { margin: var(--s-4) 0 0; }
.home-dest .cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s-4); }
.tabs[hidden] { display: none; }
.tabs [role="tab"] { padding: 7px 14px; border: 1px solid var(--c-line); border-radius: var(--r-pill); background: var(--c-bg);
  color: var(--c-ink); font: var(--fw-semibold) var(--fs-sm) / 1.2 var(--font-sans); cursor: pointer; }
.tabs [role="tab"]:hover { border-color: var(--c-brand-2); color: var(--c-brand); }
.tabs [role="tab"][aria-selected="true"] { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }
.tab-panel + .tab-panel { margin-top: var(--s-6); }
.tabs-ready .tab-panel + .tab-panel { margin-top: 0; }
.tabs-ready .tab-panel__title { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tab-panel__title { font-size: var(--fs-md); margin: 0 0 var(--s-3); }
.home-top .tbl td:first-child { width: 2.5em; color: var(--c-muted); }
.home-top .tbl a { font-weight: var(--fw-bold); color: var(--c-ink); text-decoration: none; }
.home-top .tbl a:hover { color: var(--c-brand-2); text-decoration: underline; }
.home-top .tbl .price small { display: block; font-weight: 400; color: var(--c-muted); }
.home-score { display: grid; gap: var(--s-5); }
@media (min-width: 900px) { .home-score { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; gap: var(--s-7); } }
.home-score .bars li { grid-template-columns: minmax(150px, 320px) 1fr 40px; }
.home-score__base { margin: 0 0 var(--s-3); }
/* Desktop: every home block spans the same width as the "Highest-rated schools" table (.wrap). */
.hero .search--simple { max-width: none; }
.hero h1, .hero p { max-width: none; }
.home-about { padding: var(--s-7) 0; }
.home-about .prose { max-width: none; }
.home-about .prose > :first-child { margin-top: 0; }
@media (max-width: 599px) {
  .home-score .bars li { grid-template-columns: minmax(0, 1fr) 70px 36px; font-size: var(--fs-sm); }
}
/* Phones: the "Highest-rated schools" table becomes stacked rows (no sideways scrolling). */
@media (max-width: 599px) {
  .home-top .tbl--wide { min-width: 0; }
  .home-top .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .home-top .tbl tr { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 2px 10px; padding: 12px; border-bottom: 1px solid var(--c-line); }
  .home-top .tbl tbody tr:last-child { border-bottom: 0; }
  .home-top .tbl td { padding: 0; border: 0; }
  .home-top .tbl td:nth-child(1) { grid-row: 1 / span 3; width: auto; text-align: left; }
  .home-top .tbl td:nth-child(2) { grid-column: 2; grid-row: 1; }
  .home-top .tbl td:nth-child(3), .home-top .tbl td:nth-child(4) { grid-column: 2; font-size: var(--fs-sm); color: var(--c-muted); }
  .home-top .tbl td:nth-child(5) { grid-column: 3; grid-row: 1; text-align: right; }
  .home-top .tbl td:nth-child(6) { grid-column: 3; grid-row: 2 / span 2; }
}
