/* SchoolUp blog — public reading view
   Manrope for structure, Source Serif 4 for reading. Both carry Latin + Cyrillic,
   which the uz/ru mix needs. */

:root {
  --ink: #0e1526;
  --ink-soft: #34405a;
  --muted: #5d6b84;
  --paper: #ffffff;
  --wash: #f2f5fc;
  --rule: #e3e8f2;
  --brand: #2f6bff;
  --brand-dark: #1f4fd4;

  --measure: 42rem;
  --radius: 14px;
  --gap: 12px;

  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 4px; }

/* ---------------------------------------------------------------- chrome */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 22px 20px 8px;
  font-family: var(--sans);
}

.masthead__brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--brand);
  text-decoration: none;
}

.masthead__channel {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.masthead__channel:hover { color: var(--brand); }

.preview-bar {
  background: #fff7e0;
  border-bottom: 1px solid #f0dfae;
  color: #7a5b12;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  text-align: center;
}

.progress { position: sticky; top: 0; height: 2px; background: transparent; z-index: 20; }
.progress__bar { display: block; height: 100%; width: 0; background: var(--brand); transition: width 90ms linear; }

/* ---------------------------------------------------------------- article */

.post {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 20px 20px 0;
}

.post__title {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(30px, 6vw, 42px);
  line-height: 1.14;
  letter-spacing: -0.025em;
  margin: 18px 0 0;
}

.post__lead {
  font-size: 20px;
  color: var(--ink-soft);
  margin: 14px 0 0;
}

.post__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.post__author { font-style: normal; }
.post__author a { color: var(--ink); text-decoration: none; }
.post__author a:hover { color: var(--brand); }

.post__date::before { content: "·"; margin-right: 10px; color: var(--rule); }

.post__cover { margin: 26px 0 0; }
.post__cover img { border-radius: var(--radius); width: 100%; }

.post__body { padding: 4px 0 40px; }

.post__body > * { margin: 22px 0; }
.post__body > *:first-child { margin-top: 26px; }

.post__body h3,
.post__body h4 {
  font-family: var(--sans);
  letter-spacing: -0.018em;
  line-height: 1.28;
  margin: 40px 0 -6px;
}
.post__body h3 { font-size: 25px; font-weight: 800; }
.post__body h4 { font-size: 20px; font-weight: 700; color: var(--ink-soft); }

.post__body ul, .post__body ol { padding-left: 1.3em; }
.post__body li { margin: 8px 0; }

.post__body blockquote {
  margin-inline: 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--brand);
  color: var(--ink-soft);
  font-size: 20px;
}
.quote__cite { display: block; margin-top: 8px; font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--muted); }

.post__body pre {
  background: var(--wash);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.55;
}
.post__body code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.post__body :not(pre) > code {
  background: var(--wash);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 0.88em;
}

.post__body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 40px auto;
  width: 80px;
}

/* ---------------------------------------------------------------- media */

.caption {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 10px;
  text-align: center;
}

.figure { margin: 26px 0; }
.figure img { border-radius: var(--radius); width: 100%; }

/* Grid lives here, not in the HTML structure — Instant View stacks the same
   figures in one column and this rule simply does not apply there. */
.gallery {
  display: grid;
  gap: var(--gap);
  margin: 26px 0;
}
.gallery--row[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.gallery--row[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
.gallery--row[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
.gallery--col { grid-template-columns: 1fr; }

.gallery__item { margin: 0; }
.gallery__img {
  border-radius: var(--radius);
  width: 100%;
  background: var(--wash);
}
.gallery__item .caption { margin-top: 8px; font-size: 13px; }
.caption--group { margin-top: -12px; }

/* Full-bleed galleries read better than cramped thumbnails on wide screens. */
@media (min-width: 900px) {
  .gallery--row[data-cols="3"],
  .gallery--row[data-cols="4"] {
    width: min(100vw - 40px, 62rem);
    margin-inline: calc(50% - min(50vw - 20px, 31rem));
  }
}

@media (max-width: 620px) {
  .gallery--row[data-cols="3"],
  .gallery--row[data-cols="4"] { grid-template-columns: repeat(2, 1fr); }
}

.embed { margin: 26px 0; }
.embed__frame {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  display: block;
}
.embed--video {
  aspect-ratio: var(--ratio, 16 / 9);
}
.embed--video .embed__frame { height: 100%; aspect-ratio: var(--ratio, 16 / 9); }
/* site.js replaces the height with the one the embed reports, so the post is
   never cropped. The transition keeps that correction from snapping. */
.embed--telegram .embed__frame {
  background: var(--wash);
  min-height: 220px;
  transition: height 0.18s ease;
}

/* ---------------------------------------------------------------- lightbox */

/* site.js adds .zoomable and builds .lightbox at runtime. Instant View runs no
   scripts and has its own image viewer, so none of this reaches Telegram. */

.zoomable { cursor: zoom-in; }

.has-lightbox { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 22, 0.97);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.lightbox.is-open { opacity: 1; }
.lightbox[hidden] { display: none; }

.lightbox__stage {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  /* Without this the flex item refuses to shrink below the picture's natural
     width and a wide screenshot hangs off the right edge of a phone. */
  min-width: 0;
}

.lightbox__img {
  max-width: min(100%, 1400px);
  max-height: 82vh;
  width: auto;
  border-radius: 10px;
  cursor: zoom-out;
  object-fit: contain;
}

.lightbox__meta {
  font-family: var(--sans);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lightbox__count { font-size: 13px; color: rgba(255, 255, 255, 0.45); }

.lightbox__btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: var(--sans);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lightbox__btn:hover { background: rgba(255, 255, 255, 0.24); }

.lightbox__close { top: 18px; right: 18px; font-size: 17px; }
.lightbox__nav { top: 50%; transform: translateY(-50%); font-size: 30px; }
.lightbox__nav--prev { left: 18px; }
.lightbox__nav--next { right: 18px; }

/* One image in the post: nothing to page through. */
.lightbox--single .lightbox__nav { display: none; }

@media (max-width: 620px) {
  .lightbox { padding: 12px; }
  .lightbox__img { max-height: 74vh; }
  .lightbox__nav { top: auto; bottom: 18px; transform: none; }
  .lightbox__nav--prev { left: 24px; }
  .lightbox__nav--next { right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox { transition: none; }
}

/* ---------------------------------------------------------------- cta */

.cta { text-align: center; }

.cta__link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border-radius: 10px;
  padding: 13px 26px;
  text-decoration: none;
  transition: background 140ms ease;
}
.cta__link:hover { background: var(--brand-dark); color: #fff; }

/* ---------------------------------------------------------------- foot */

.post__foot {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 30px 20px 60px;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-family: var(--sans);
}

.post__subscribe {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 11px 22px;
}
.post__subscribe:hover { border-color: var(--brand); }

.post__copyright { color: var(--muted); font-size: 13px; margin: 18px 0 0; }

/* ---------------------------------------------------------------- feed */

.feed { max-width: var(--measure); margin: 0 auto; padding: 24px 20px 40px; }

.feed__title {
  font-family: var(--sans);
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 12px 0 6px;
}
.feed__sub { color: var(--muted); font-size: 17px; margin: 0 0 30px; }

.feed__list { list-style: none; margin: 0; padding: 0; }

.card + .card { border-top: 1px solid var(--rule); }

.card__link {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 20px 0;
  text-decoration: none;
  color: inherit;
}
.card__link:hover .card__title { color: var(--brand); }

.card__thumb { flex: 0 0 108px; }
.card__thumb img { border-radius: 10px; aspect-ratio: 4 / 3; object-fit: cover; }

.card__text { display: block; }
.card__date { display: block; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); }
.card__title { display: block; font-family: var(--sans); font-size: 21px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.28; margin-top: 5px; }
.card__preview { display: block; color: var(--muted); font-size: 16px; margin-top: 6px; }

.feed__empty { padding: 50px 0; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- status */

.status { max-width: 30rem; margin: 0 auto; padding: 14vh 20px; text-align: center; font-family: var(--sans); }
.status__code { font-size: 60px; font-weight: 800; color: var(--brand); margin: 0; letter-spacing: -0.03em; }
.status__title { font-size: 26px; font-weight: 800; margin: 6px 0 10px; }
.status__text { color: var(--muted); margin: 0 0 26px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.feed__hint { font-size: 14px; margin-top: 10px; }
.feed__hint code { background: var(--wash); border-radius: 5px; padding: 2px 6px; font-size: 13px; }
