/* Projects section: /projects/ (2a), /projects/education/ (2b), /projects/<slug>/ (1d).
   Page-scoped under .pj — nothing here leaks into base.html. Sizes are px on purpose:
   the site root font-size scales with the viewport, the design does not. */
/* Кнопки скоупим под .pj: preflight Tailwind CDN ([type=button] {padding:0; background:transparent}) подключается позже и иначе перебивает их. */

.pj {
  --ink: #1b1b1b;
  --paper: #f3f1ec;
  --stripe-a: #e3e0d9;
  --stripe-b: #ebe8e2;
  --blue: #3b82f6;
  --red: #ef4444;
  --red-ink: #b4231b;          /* countdown on paper (contrast-safe red) */
  --link: #93c5fd;
  --muted-d: rgba(255,255,255,.6);
  --body-d: rgba(255,255,255,.82);
  --line-d: rgba(255,255,255,.12);
  --muted-l: #5b5852;
  --body-l: #33312d;
  --line-l: rgba(27,27,27,.15);
  --pad: clamp(20px, 3.9vw, 56px);
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --sticky-top: 120px;         /* under the fixed site header */
  font-family: 'Inter', sans-serif;
  padding-top: 120px;
  min-height: calc(100vh - 400px);
}
.pj--dark  { background: var(--ink); color: #fff; }
.pj--light { background: linear-gradient(var(--ink) 0 120px, var(--paper) 120px); color: var(--ink); }
.pj *, .pj *::before, .pj *::after { box-sizing: border-box; }
.pj a { color: inherit; text-decoration: none; }
.pj button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.pj :focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.pj-wrap { max-width: 1440px; margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }
.pj-mono { font-family: var(--mono); }
.pj-label { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.pj-crumbs { font-family: var(--mono); font-size: 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.pj--dark .pj-crumbs { color: rgba(255,255,255,.55); }
.pj--light .pj-crumbs { color: var(--muted-l); }
.pj-crumbs [aria-current] { color: inherit; }
.pj--dark .pj-crumbs [aria-current] { color: #fff; }
.pj--light .pj-crumbs [aria-current] { color: var(--ink); }
.pj-crumbs a:hover { color: var(--blue); }

/* ---------- Page head (2a, 2b) ---------- */
.pj-head { border-bottom: 2px solid currentColor; }
.pj-head__in { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px 48px; flex-wrap: wrap; padding-top: 64px; padding-bottom: 40px; }
.pj-h1 { margin: 0; font-size: clamp(56px, 8.4vw, 120px); line-height: .9; font-weight: 900; letter-spacing: -.05em; }
.pj-head__intro { margin: 0 0 10px; max-width: 420px; font-size: 18px; line-height: 1.5; color: var(--body-l); text-wrap: pretty; }

.pj-tabs { display: flex; flex-wrap: wrap; gap: 12px 28px; padding-bottom: 10px; }
.pj-tab { padding-bottom: 6px; font-size: 16px; border-bottom: 2px solid transparent; transition: border-color .15s; }
.pj-tab:hover { border-bottom-color: rgba(255,255,255,.35); }
.pj-tab.is-active { font-weight: 700; border-bottom-color: var(--red); }
.pj-tab__n { font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,.55); }

/* ---------- Education band on /projects/ (2a) ---------- */
.pj-band { background: var(--paper); color: var(--ink); }
.pj-band__in { display: grid; grid-template-columns: 180px minmax(0,1fr) auto; gap: 16px 40px; align-items: center; padding-top: 28px; padding-bottom: 28px; }
.pj-band__tag { display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 13px; }
.pj-band__tag b { font-weight: 400; text-transform: uppercase; letter-spacing: .12em; }
.pj-countdown { font-family: var(--mono); font-size: 13px; color: var(--red-ink); }
.pj-band__event { display: flex; gap: 12px 28px; align-items: baseline; flex-wrap: wrap; }
.pj-band__date { font-size: 48px; line-height: .9; font-weight: 900; letter-spacing: -.04em; white-space: nowrap; }
.pj-band__title { font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; text-wrap: pretty; }
.pj-band__title small { font-size: 16px; font-weight: 400; color: var(--muted-l); }
.pj-btn-ink { display: inline-block; padding: 14px 20px; background: var(--ink); color: #fff !important; font-size: 15px; font-weight: 600; white-space: nowrap; transition: background .15s; }
.pj-btn-ink:hover { background: #000; }

/* ---------- Brief spread (2a list + 2b upcoming event) ---------- */
.pj-brief { border-bottom: 1px solid var(--line-d); }
.pj--light .pj-brief { border-bottom-color: var(--line-l); }
.pj-brief__in { display: grid; grid-template-columns: minmax(0,7fr) minmax(0,5fr); gap: 32px 48px; padding-top: 48px; padding-bottom: 48px; }
.pj-brief--flip .pj-brief__in { grid-template-columns: minmax(0,5fr) minmax(0,7fr); }
.pj-brief--flip .pj-brief__media { order: 2; }
.pj-brief__media { aspect-ratio: 4/3; overflow: hidden; background: rgba(255,255,255,.05); }
.pj--light .pj-brief__media, .pj-ph { background: repeating-linear-gradient(135deg, var(--stripe-a) 0 12px, var(--stripe-b) 12px 24px); }
.pj-brief__media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
a.pj-brief__in:hover .pj-brief__media img { transform: scale(1.02); }
a.pj-brief__in:hover .pj-brief__h { color: var(--blue); }
.pj-brief__text { display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.pj-brief__top { display: flex; flex-direction: column; gap: 20px; }
.pj-brief__kicker { font-family: var(--mono); font-size: 14px; color: var(--muted-d); }
.pj--light .pj-brief__kicker { color: var(--muted-l); }
.pj-brief__h { margin: 0; font-size: clamp(32px, 3.9vw, 56px); line-height: 1; font-weight: 800; letter-spacing: -.035em; text-wrap: pretty; transition: color .15s; }
.pj-brief__lede { margin: 0; font-size: 20px; line-height: 1.55; color: var(--body-d); text-wrap: pretty; }
.pj--light .pj-brief__lede { color: var(--body-l); }

.pj-facts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); border-top: 1px solid currentColor; }
.pj-facts > div { padding: 16px 16px 0; display: flex; flex-direction: column; gap: 6px; border-left: 1px solid rgba(255,255,255,.15); }
.pj--light .pj-facts > div { border-left-color: var(--line-l); }
.pj-facts > div:first-child { padding-left: 0; border-left: 0; }
.pj-facts > div:last-child { padding-right: 0; }
.pj-facts .pj-label { color: rgba(255,255,255,.55); }
.pj--light .pj-facts .pj-label { color: var(--muted-l); }
.pj-facts__v { font-size: 18px; font-weight: 600; }

.pj-program { display: flex; flex-direction: column; border-top: 1px solid var(--line-l); margin: 0; padding: 0; list-style: none; }
.pj-program li { display: grid; grid-template-columns: 40px 1fr; padding: 10px 0; border-bottom: 1px solid var(--line-l); font-size: 16px; }
.pj-program span { font-family: var(--mono); font-size: 13px; color: var(--muted-l); }
.pj-btn-big { align-self: flex-start; padding: 16px 24px; background: var(--ink); color: #fff !important; font-size: 16px; font-weight: 600; }
.pj-btn-big:hover { background: #000; }

.pj-listfoot { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 40px; padding-bottom: 80px; }
.pj-listfoot a { font-size: 16px; color: rgba(255,255,255,.7); border-bottom: 1px solid rgba(255,255,255,.25); }
.pj-listfoot a:hover { color: #fff; border-bottom-color: var(--blue); }
.pj-listfoot span { font-family: var(--mono); font-size: 14px; color: rgba(255,255,255,.5); }
.pj-pages { display: flex; gap: 8px; font-family: var(--mono); font-size: 14px; }
.pj-pages a, .pj-pages span { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-d); }
.pj-pages [aria-current] { background: #fff; color: var(--ink); border-color: #fff; }
.pj-pages a:hover { border-color: var(--blue); }

/* ---------- Education page (2b) ---------- */
.ed-next { display: flex; gap: 14px; align-items: baseline; padding-top: 40px; }
.ed-next b { font-family: var(--mono); font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .12em; }
.pj--light .pj-brief__in { padding-top: 24px; padding-bottom: 56px; }
.ed-archive-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; padding-top: 48px; padding-bottom: 24px; }
.ed-archive-head h2 { margin: 0; font-size: 40px; line-height: 1; font-weight: 800; letter-spacing: -.03em; }
.ed-archive-head span { font-family: var(--mono); font-size: 13px; color: var(--muted-l); }
.ed-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 48px 32px; padding-bottom: 72px; }
.ed-card { display: flex; flex-direction: column; gap: 14px; }
.ed-card__cover { aspect-ratio: 4/3; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.ed-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-card__cover span { font-family: var(--mono); font-size: 13px; color: var(--muted-l); }
.ed-card__meta { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted-l); padding-top: 4px; border-top: 1px solid var(--ink); }
.ed-card__title { font-size: 26px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; text-wrap: pretty; }
a.ed-card:hover .ed-card__title { color: #1d4ed8; }
.ed-card__place { font-size: 15px; color: var(--muted-l); }
.ed-empty { padding: 40px 0 72px; font-size: 18px; color: var(--muted-l); }
.pj-ctabar { background: var(--ink); color: #fff; }
.pj-ctabar__in { display: flex; justify-content: space-between; align-items: center; gap: 24px 32px; flex-wrap: wrap; padding-top: 40px; padding-bottom: 40px; }
.pj-ctabar__in > span { font-size: 24px; font-weight: 600; }
.pj .pj-pill-red { display: inline-block; padding: 14px 22px; border-radius: 999px; background: var(--red) !important; color: var(--ink) !important; font-weight: 700 !important; font-size: 15px !important; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; transition: background .15s; }
.pj .pj-pill-red:hover { background: #f87171 !important; }

/* ---------- Case page (1d) ---------- */
.pd-head { display: flex; flex-direction: column; gap: 28px; padding-top: 48px; padding-bottom: 40px; }
.pd-h1 { margin: 0; max-width: 1100px; font-size: clamp(44px, 7.2vw, 104px); line-height: .92; font-weight: 800; letter-spacing: -.05em; text-wrap: balance; }
.pd-meta { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border-top: 1px solid var(--line-d); border-bottom: 1px solid var(--line-d); }
.pd-meta > div { padding: 18px 24px; display: flex; flex-direction: column; gap: 6px; border-left: 1px solid var(--line-d); }
.pd-meta > div:first-child { padding-left: 0; border-left: 0; }
.pd-meta .pj-label { color: var(--blue); }
.pd-meta__v { font-size: 18px; }
a.pd-meta__v:hover { color: var(--blue); }

.pd-mosaic { display: grid; gap: 12px; grid-template-columns: minmax(0,2fr) minmax(0,1fr) minmax(0,1fr); grid-template-rows: 260px 260px; }
.pd-mosaic--n1 { grid-template-columns: 1fr; grid-template-rows: 520px; }
.pd-mosaic--n2 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); grid-template-rows: 520px; }
.pd-mosaic--n3 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.pj .pd-tile { position: relative; display: block; width: 100%; height: 100%; border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.05); cursor: zoom-in; }
.pd-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.pd-tile:hover img { transform: scale(1.02); }
.pd-tile:first-child { grid-row: span 2; }
.pd-mosaic--n1 .pd-tile:first-child, .pd-mosaic--n2 .pd-tile:first-child { grid-row: auto; }
.pd-mosaic--n4 .pd-tile:nth-child(4) { grid-column: span 2; }
.pd-tile__all { position: absolute; right: 14px; bottom: 14px; padding: 8px 14px; border-radius: 999px; background: rgba(27,27,27,.85); color: #fff; font-family: var(--mono); font-size: 13px; }

.pd-body { display: grid; grid-template-columns: 240px minmax(0,1fr) 340px; gap: 56px; align-items: start; padding-top: 72px; padding-bottom: 72px; }
.pd-toc { position: sticky; top: var(--sticky-top); display: flex; flex-direction: column; border-top: 1px solid var(--line-d); }
.pd-toc a { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-d); font-size: 17px; color: var(--muted-d); transition: color .15s; }
.pd-toc a:hover, .pd-toc a.is-active { color: #fff; }
.pd-toc a span { font-family: var(--mono); font-size: 13px; color: var(--blue); padding-top: 3px; }
.pd-article { display: flex; flex-direction: column; gap: 56px; max-width: 720px; min-width: 0; }
.pd-step { scroll-margin-top: calc(var(--sticky-top) + 16px); }
.pd-step__h { margin: 0 0 20px; font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--blue); text-transform: uppercase; letter-spacing: .12em; }
.pd-step:first-child .rt > p:first-child { font-size: 26px; line-height: 1.45; font-weight: 500; letter-spacing: -.01em; color: #fff; }
.pd-cta { display: flex; justify-content: space-between; align-items: center; gap: 20px 24px; flex-wrap: wrap; padding: 28px 32px; border-radius: 20px; border: 1px solid rgba(239,68,68,.5); }
.pd-cta > span { font-size: 22px; font-weight: 600; }
.pd-aside { position: sticky; top: var(--sticky-top); display: flex; flex-direction: column; gap: 28px; }
.pd-aside__group { display: flex; flex-direction: column; gap: 12px; }
.pd-aside .pj-label { font-size: 13px; color: var(--blue); }
.pd-kb { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); transition: border-color .15s; }
.pd-kb:hover { border-color: rgba(59,130,246,.5); }
.pd-kb b { font-size: 17px; line-height: 1.35; font-weight: 500; }
.pd-kb span { font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,.5); }
.pd-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-pills a { padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.2); font-size: 14px; transition: border-color .15s; }
.pd-pills a:hover { border-color: var(--blue); }
.pd-nav { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line-d); }
.pd-nav a { padding: 40px var(--pad); display: flex; flex-direction: column; gap: 10px; }
.pd-nav a:first-child { border-right: 1px solid var(--line-d); }
.pd-nav a:last-child { align-items: flex-end; text-align: right; }
.pd-nav span { font-family: var(--mono); font-size: 14px; color: rgba(255,255,255,.55); }
.pd-nav b { font-size: 28px; font-weight: 600; }
.pd-nav a:hover b { color: var(--blue); }

/* Rich text (CKEditor output after |sanitize) — one style for list + case page */
.rt { font-size: 19px; line-height: 1.7; color: rgba(255,255,255,.85); word-break: break-word; text-wrap: pretty; }
.rt > :first-child { margin-top: 0 !important; }
.rt > :last-child { margin-bottom: 0 !important; }
.rt p { margin: 0 0 1.1em; }
.rt h1, .rt h2, .rt h3, .rt h4, .rt h5, .rt h6 { color: #fff; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; margin: 1.4em 0 .6em; }
.rt h1, .rt h2 { font-size: 28px; } .rt h3 { font-size: 23px; } .rt h4, .rt h5, .rt h6 { font-size: 19px; }
.rt a { color: var(--link); border-bottom: 1px solid rgba(147,197,253,.4); }
.rt a:hover { border-bottom-color: var(--link); }
.rt strong, .rt b { color: #fff; font-weight: 600; }
.rt ul, .rt ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.rt li { margin-bottom: .5em; }
.rt ul li::marker { color: var(--blue); }
.rt ol li::marker { font-family: var(--mono); font-size: .8em; color: var(--blue); }
.rt blockquote { margin: 1.4em 0; padding: 4px 0 4px 24px; border-left: 2px solid var(--blue); color: #fff; font-size: 21px; }
.rt img { max-width: 100%; height: auto; border-radius: 16px; }
.rt figure { margin: 1.4em 0; }
.rt figcaption { margin-top: 8px; font-family: var(--mono); font-size: 13px; color: rgba(255,255,255,.55); }
.rt table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 16px; display: block; overflow-x: auto; }
.rt th, .rt td { padding: 10px 12px; border-bottom: 1px solid var(--line-d); text-align: left; vertical-align: top; }
.rt th { font-family: var(--mono); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.6); }
.rt code { font-family: var(--mono); font-size: .85em; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.08); }
.rt pre { overflow-x: auto; padding: 16px; border-radius: 12px; background: rgba(255,255,255,.05); }
.rt pre code { padding: 0; background: none; }
.rt details { margin: 1.1em 0; padding: 12px 16px; border: 1px solid var(--line-d); border-radius: 12px; }
.rt summary { cursor: pointer; color: #fff; font-weight: 600; }
.rt hr { border: 0; border-top: 1px solid var(--line-d); margin: 2em 0; }
.rt span[style*="color"] { color: inherit !important; }

/* Lightbox (case page) */
.pd-lb { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 24px; }
.pd-lb.is-open { display: flex; }
.pd-lb img { max-width: min(92vw, 1600px); max-height: 80vh; object-fit: contain; border-radius: 8px; }
.pd-lb__bar { display: flex; gap: 16px; align-items: center; font-family: var(--mono); font-size: 13px; color: rgba(255,255,255,.7); max-width: 92vw; }
.pj .pd-lb__btn { position: absolute; width: 48px; height: 48px; border-radius: 999px; background: rgba(255,255,255,.1) !important; color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.pj .pd-lb__btn:hover { background: rgba(255,255,255,.2) !important; }
.pd-lb__close { top: 20px; right: 20px; } .pd-lb__prev { left: 20px; top: 50%; } .pd-lb__next { right: 20px; top: 50%; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .pd-body { grid-template-columns: minmax(0,1fr) 300px; }
  .pd-toc { display: none; }
}
@media (max-width: 1024px) {
  .pj-brief__in, .pj-brief--flip .pj-brief__in { grid-template-columns: 1fr; }
  .pj-brief--flip .pj-brief__media { order: 0; }
  .pj-band__in { grid-template-columns: 1fr; }
  .pj-band__in .pj-btn-ink { justify-self: start; }
  .ed-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pd-body { grid-template-columns: 1fr; gap: 48px; }
  .pd-aside { position: static; }
}
@media (max-width: 768px) {
  .pj-head__in { padding-top: 40px; padding-bottom: 28px; }
  .pj-brief__in { padding-top: 32px; padding-bottom: 32px; }
  .pj-brief__lede { font-size: 18px; }
  .pj-facts { grid-auto-flow: row; grid-template-columns: 1fr; }
  .pj-facts > div { padding: 12px 0 !important; border-left: 0 !important; border-bottom: 1px solid var(--line-d); }
  .pj--light .pj-facts > div { border-bottom-color: var(--line-l); }
  .pd-meta { grid-template-columns: 1fr 1fr; }
  .pd-meta > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .pd-meta > div:nth-child(n+3) { border-top: 1px solid var(--line-d); }
  .pd-mosaic, .pd-mosaic--n1, .pd-mosaic--n2, .pd-mosaic--n3 { grid-template-columns: 1fr; grid-template-rows: none; }
  .pd-tile { aspect-ratio: 4/3; height: auto; }
  .pd-tile:first-child { grid-row: auto; }
  .pd-tile:not(:first-child) { display: none; }
  .pd-tile:first-child .pd-tile__all { display: inline-block; }
  .pd-step:first-child .rt > p:first-child { font-size: 22px; }
  .rt { font-size: 18px; }
  .pd-nav { grid-template-columns: 1fr; }
  .pd-nav a:first-child { border-right: 0; border-bottom: 1px solid var(--line-d); }
  .pd-nav a:last-child { align-items: flex-start; text-align: left; }
  .pd-nav b { font-size: 22px; }
}
@media (max-width: 640px) {
  .ed-grid { grid-template-columns: 1fr; }
  .pj-band__date { font-size: 36px; }
  .pj-band__title { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .pj *, .pj *::before, .pj *::after { transition: none !important; }
}
