/*
 * EGE-School front page (design B1, D42): hero with the exam/subject form, stats, subject
 * tiles, top schools, promos of the week (promo cards from promos.css), quotes, latest
 * materials (article cards from components.css). Loaded after page.css (dark hero) and
 * promos.css. Values from docs/design/b/B-home-desktop.dc.html and B-home-mobile.dc.html;
 * colours only from base.css tokens.
 */

/* The promo reveal toggles `hidden` (promo.js) on elements with a display. */
.es-home [hidden] {
  display: none !important;
}

/* ---------- hero ---------- */
.es-home-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-content: center;
  gap: 28px 40px;
  padding-top: 56px;
  padding-bottom: 88px;
}

.es-home-hero__inner > * {
  grid-column: 1;
  min-width: 0;
}

.es-home-hero__tag {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 30px;
  margin: 0;
  padding: 4px 14px;
  border-radius: var(--es-r-pill);
  background: color-mix(in srgb, var(--es-white) 12%, transparent);
  color: var(--es-acc);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.es-home-hero__title {
  margin: 0;
  color: var(--es-white);
  font-family: var(--es-font-display);
  font-size: clamp(36px, 5.4vw, 68px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.es-home-hero__hl {
  display: inline-block;
  padding: 0 0.2em;
  border-radius: 0.3em;
  background: var(--es-acc);
  color: var(--es-ink);
  transform: rotate(-2deg);
}

.es-home-hero__lead {
  max-width: 540px;
  margin: 0;
  color: var(--es-on-dark);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.5;
}

/* stickers: scattered on the right on desktop, a scrolling row on phones */
.es-home-stickers {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 4;
  align-self: center;
  height: 420px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.es-home-stickers__item {
  position: absolute;
}

.es-home-stickers__item--1 { top: 10px; left: 40px; transform: rotate(-6deg); }
.es-home-stickers__item--2 { top: 96px; right: 0; transform: rotate(5deg); }
.es-home-stickers__item--3 { top: 180px; left: 0; transform: rotate(3deg); }
.es-home-stickers__item--4 { top: 262px; right: 30px; transform: rotate(-4deg); }
.es-home-stickers__item--5 { top: 340px; left: 60px; transform: rotate(2deg); }

.es-home-sticker {
  display: inline-flex;
  align-items: center;
  height: 58px;
  padding: 0 26px;
  border: 2px solid var(--es-ink);
  border-radius: var(--es-r-pill);
  background: var(--chip, var(--es-subj-default));
  color: var(--es-ink);
  font-family: var(--es-font-display);
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.15s;
}

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

/* the form */
.es-home-find {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.es-home-find__exam {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.es-home-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-home-seg__opt {
  position: relative;
  display: inline-flex;
}

/* visually hidden, still focusable: the label span shows the state */
.es-home-seg__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.es-home-seg__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--es-r-pill);
  color: var(--es-white);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.es-home-seg__input:checked + .es-home-seg__label {
  background: var(--es-white);
  color: var(--es-ink);
}

.es-home-seg__input:not(:checked) + .es-home-seg__label:hover {
  color: var(--es-acc);
}

.es-home-seg__input:focus-visible + .es-home-seg__label {
  outline: 3px solid var(--es-acc);
  outline-offset: 2px;
}

.es-home-find__subject {
  display: flex;
  flex: 1 1 230px;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  height: 52px;
  padding: 0 6px 0 20px;
  border-radius: var(--es-r-pill);
  background: var(--es-white);
  color: var(--es-ink);
}

.es-home-find__subject:focus-within {
  outline: 3px solid var(--es-acc);
  outline-offset: 2px;
}

.es-home-find__label {
  flex: none;
  color: var(--es-muted);
  font-size: 13px;
  font-weight: 700;
}

.es-home-find__select {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 32px 0 0;
  border: 0;
  outline: 0;
  appearance: none;
  background: transparent 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") no-repeat right 10px center / 18px;
  color: var(--es-ink);
  font-family: var(--es-font-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.es-home-find__select:focus-visible {
  outline: 0;
}

/* ---------- sections ---------- */
.es-home {
  padding-bottom: clamp(48px, 7vw, 88px);
}

.es-home-section {
  padding-top: clamp(40px, 7vw, 88px);
}

.es-home-section--stats {
  padding-top: clamp(20px, 5vw, 72px);
}

.es-home-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 28px;
}

.es-home-section__title {
  margin: 0;
  color: var(--es-ink);
  font-family: var(--es-font-display);
  font-size: clamp(24px, 3.4vw, 40px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.es-home-section__more {
  color: var(--es-ink);
  font-weight: 800;
}

.es-home-section__more:hover {
  color: var(--es-link-h);
}

.es-home-section__all {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 28px auto 0;
}

/* ---------- stats ---------- */
.es-home-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--es-s-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.es-home-stat {
  display: flex;
  flex: 1 1 200px;
  flex-direction: column;
  gap: var(--es-s-1);
  padding: 26px;
  border-radius: var(--es-r-lg);
  background: var(--es-white);
  color: var(--es-ink);
}

.es-home-stat__num {
  font-family: var(--es-font-display);
  font-size: clamp(26px, 3.6vw, 44px);
  font-weight: 800;
  line-height: 1.1;
}

.es-home-stat__label {
  color: var(--es-muted-2);
  font-weight: 600;
}

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

.es-home-stat--acc .es-home-stat__label {
  color: var(--es-ink);
}

/* ---------- subject tiles ---------- */
.es-home-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.es-home-tiles__item--wide {
  grid-column: span 2;
}

.es-home-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  height: 100%;
  min-height: 170px;
  padding: 26px;
  border-radius: var(--es-r-lg);
  background: var(--chip, var(--es-subj-default));
  color: var(--es-ink);
  transition: transform 0.15s;
}

.es-home-tile--wide {
  min-height: 220px;
}

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

.es-home-tile__name {
  font-family: var(--es-font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.es-home-tile--wide .es-home-tile__name {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
}

.es-home-tile__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.es-home-tile__go {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--es-r-pill);
  background: var(--es-ink);
  color: var(--es-white);
}

/* ---------- top schools ---------- */
.es-home-sorts__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.es-home-sorts__list > li {
  flex: none;
}

.es-home-sorts .es-tag {
  white-space: nowrap;
}

.es-home-schools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.es-home-school {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 26px;
  border-radius: var(--es-r-lg);
  background: var(--es-white);
  color: var(--es-ink);
}

.es-home-school__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.es-home-school span.es-logo,
.es-home-quote__by span.es-logo {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--es-ground);
  color: var(--es-ink);
  font-family: var(--es-font-display);
  font-weight: 800;
  line-height: 1;
}

.es-home-school span.es-logo {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-size: 16px;
}

.es-home-quote__by span.es-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--es-r-sm);
  background: var(--es-white);
  font-size: 12px;
}

.es-home .es-logo__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.es-home-school__name {
  margin: 0;
  font-family: var(--es-font-display);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.es-home-school__name a {
  color: inherit;
}

.es-home-school__name a:hover {
  color: var(--es-link-h);
}

.es-home-school__line {
  margin: 4px 0 0;
  color: var(--es-muted);
  font-size: 14px;
  font-weight: 600;
}

.es-home-school__rating {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
}

.es-home-school__score {
  font-family: var(--es-font-display);
  font-size: clamp(32px, 3.6vw, 44px);
  font-weight: 800;
  line-height: 1;
}

.es-home-school__reviews {
  color: var(--es-muted-2);
  font-weight: 700;
}

a.es-home-school__reviews:hover {
  color: var(--es-link-h);
}

.es-home-school__price {
  margin: 0;
  font-weight: 700;
}

.es-home-school__act {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.es-home-school__site {
  flex: 1 1 auto;
}

.es-home-school__ad {
  margin: 0;
  color: var(--es-muted);
  font-size: 12px;
  line-height: 1.4;
}

/* ---------- promos of the week ---------- */
.es-home-promos {
  padding: clamp(24px, 4vw, 44px);
  border-radius: 40px;
  background: var(--es-acc);
}

.es-home-promos .es-home-section__head {
  margin-bottom: 24px;
}

.es-home-promos__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

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

.es-home-quote {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  margin: 0;
}

.es-home-quote__text {
  flex: 1;
  margin: 0;
  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;
  overflow-wrap: anywhere;
}

.es-home-quote__by {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.es-home-quote__by a {
  color: var(--es-ink);
}

.es-home-quote__by a:hover {
  color: var(--es-link-h);
}

/* ---------- materials ---------- */
.es-home-posts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.es-home-posts .es-post {
  min-height: 0;
  padding: 22px;
  border-radius: var(--es-r-md);
}

.es-home-posts .es-post__title {
  font-size: 17px;
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .es-home-schools,
  .es-home-posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .es-home-hero__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding-top: 16px;
    padding-bottom: 28px;
  }

  /* stickers: a row of small chips between the lead and the form */
  .es-home-stickers {
    display: flex;
    grid-column: 1;
    grid-row: auto;
    gap: 6px;
    height: auto;
    margin-inline: calc(-1 * var(--es-gutter));
    padding: 4px var(--es-gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .es-home-stickers::-webkit-scrollbar {
    display: none;
  }

  .es-home-stickers__item {
    position: static;
    flex: none;
  }

  .es-home-stickers__item--2,
  .es-home-stickers__item--4 {
    transform: rotate(2deg);
  }

  .es-home-stickers__item--1,
  .es-home-stickers__item--3,
  .es-home-stickers__item--5 {
    transform: rotate(-2deg);
  }

  .es-home-sticker {
    height: 30px;
    padding: 0 12px;
    border: 0;
    font-family: var(--es-font-text);
    font-size: 13px;
  }

  .es-home-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .es-home-quotes {
    grid-template-columns: minmax(0, 1fr);
  }

  /* promos scroll sideways inside the yellow block, the page does not */
  .es-home-promos__list {
    display: flex;
    margin-inline: calc(-1 * clamp(24px, 4vw, 44px));
    padding: 0 clamp(24px, 4vw, 44px) 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: clamp(24px, 4vw, 44px);
  }

  .es-home-promos__list > .es-promo-card {
    flex: 0 0 min(300px, 82%);
    scroll-snap-align: start;
  }
}

@media (max-width: 640px) {
  .es-home-find {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 16px;
    border-radius: var(--es-r-lg);
    background: color-mix(in srgb, var(--es-white) 8%, transparent);
  }

  .es-home-seg {
    display: flex;
  }

  .es-home-seg__opt {
    flex: 1;
  }

  .es-home-seg__label {
    width: 100%;
    padding: 0 12px;
  }

  .es-home-find__subject {
    flex: none;
    max-width: none;
    padding-left: 18px;
  }

  .es-home-find__label {
    font-size: 12px;
  }

  .es-home-find__submit {
    width: 100%;
  }

  .es-home-section__head {
    margin-bottom: 16px;
  }

  .es-home-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .es-home-stat {
    padding: 18px;
    border-radius: 24px;
  }

  .es-home-stat--acc {
    order: -1;
  }

  .es-home-stat__label {
    font-size: 13px;
    font-weight: 700;
  }

  .es-home-tiles {
    gap: 10px;
  }

  /* phones: the wide tile and six more, as in B-home-mobile */
  .es-home-tiles__item:nth-child(n + 8) {
    display: none;
  }

  .es-home-tile {
    gap: 16px;
    min-height: 112px;
    padding: 18px;
    border-radius: 24px;
  }

  .es-home-tile--wide {
    min-height: 112px;
  }

  .es-home-tile__name {
    font-size: 15px;
  }

  .es-home-tile--wide .es-home-tile__name {
    font-size: 24px;
  }

  .es-home-tile__meta {
    font-size: 13px;
  }

  .es-home-tile--wide .es-home-tile__meta {
    font-size: 14px;
  }

  .es-home-tile__go {
    width: 40px;
    height: 40px;
  }

  .es-home-sorts {
    width: 100%;
    min-width: 0;
  }

  .es-home-sorts__list {
    flex-wrap: nowrap;
    margin-inline: calc(-1 * var(--es-gutter));
    padding-inline: var(--es-gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .es-home-sorts__list::-webkit-scrollbar {
    display: none;
  }

  .es-home-schools {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  /* phones: the first three schools, as in B-home-mobile; «Весь рейтинг» follows */
  .es-home-school:nth-child(n + 4) {
    display: none;
  }

  .es-home-school {
    gap: 14px;
    padding: 20px;
  }

  .es-home-school__name {
    font-size: 18px;
  }

  .es-home-section__all {
    width: 100%;
    justify-content: center;
  }

  .es-home-promos {
    border-radius: var(--es-r-xl);
  }

  .es-home-promos__list > .es-promo-card {
    flex-basis: 88%;
  }

  /* the type label goes under a long school name instead of squeezing it */
  .es-home-promos .es-promo-card__head {
    flex-wrap: wrap;
  }

  .es-home-quote__text {
    padding: 20px;
    border-radius: 24px 24px 24px 6px;
    font-size: 16px;
  }

  .es-home-posts {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  /* phones: two promos, two quotes and three posts, as in B-home-mobile */
  .es-home-promos__list > .es-promo-card:nth-child(n + 3),
  .es-home-quote:nth-child(n + 3),
  .es-home-posts > .es-post:nth-child(n + 4) {
    display: none;
  }
}
