/* ============================================================================
   Blog — журнал
   Uses only the tokens already defined in style.css :root. No new colours,
   no new typefaces: the journal has to read as the same site.
   Loaded after style.css on every page that needs it.
   ========================================================================== */

/* ── Journal strip on the home page ─────────────────────────────────────── */
.journal {
  padding: var(--section-y) 0;
  background: var(--bg-soft);
}
/* Guard: if any rule ever gives .journal a display value, [hidden] loses. */
.journal[hidden] {
  display: none;
}
.journal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
/* The strip is designed around three entries. One entry in a three-column
   track reads as an unfinished page, so the tracks follow the real count and
   a lone entry goes wide as a featured card instead. */
.journal-grid[data-count='1'] { grid-template-columns: minmax(0, 1fr); }
.journal-grid[data-count='2'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 769px) {
  .journal-grid[data-count='1'] .b-card {
    flex-direction: row;
    align-items: stretch;
  }
  .journal-grid[data-count='1'] .b-card-media {
    flex: 0 0 44%;
    aspect-ratio: auto;
    min-height: 320px;
    align-self: stretch;
  }
  /* Pinned to the frame. Left in flow, the image would fall back to its own
     intrinsic ratio and stretch the card to ~800px tall. */
  .journal-grid[data-count='1'] .b-card-media img {
    position: absolute;
    inset: 0;
  }
  .journal-grid[data-count='1'] .b-card-body {
    justify-content: center;
    padding: 34px 38px;
    gap: 14px;
  }
  .journal-grid[data-count='1'] .b-card-title { font-size: var(--fs-h3); }
}
.journal-more {
  margin-top: 48px;
  text-align: center;
}

/* ── Card (shared by the home strip and /blog) ──────────────────────────── */
.b-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.5s var(--easing), border-color 0.5s var(--easing),
    background 0.5s var(--easing);
}
.b-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent-line);
  background: var(--surface-2);
}
.b-card-media {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--surface-2);
}
.b-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  /* Same split as .gm-card img: `translate` tracks the scroll with no
     transition, `scale` carries the eased hover zoom. */
  translate: 0 var(--py, 0px);
  scale: var(--img-s, 1.08);
  transition: scale 0.9s var(--easing);
  will-change: translate;
}
.b-card:hover .b-card-media img {
  --img-s: 1.13;
}
.b-card-media.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}
.b-card-media.is-empty::after {
  content: '';
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
}
.b-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 24px 28px;
  flex: 1;
}
.b-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: var(--fs-overline);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.b-card-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.b-card-title {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}
.b-card-excerpt {
  font-size: var(--fs-caption);
  line-height: 1.6;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.b-card-foot {
  margin-top: auto;
  padding-top: 16px;
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.b-card-date {
  font-variant-numeric: tabular-nums;
}

/* ── /blog index ────────────────────────────────────────────────────────── */
.blog-page {
  padding: clamp(96px, 11vh, 132px) 0 var(--section-y);
  min-height: 60vh;
}
.blog-head {
  max-width: 720px;
  margin-bottom: 64px;
}
.blog-head .eyebrow {
  display: inline-block;
  font-size: var(--fs-overline);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.blog-head h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}
.blog-head p {
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--text-soft);
  max-width: 54ch;
}
.blog-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
.blog-empty {
  padding: 80px 0;
  text-align: center;
  color: var(--text-mute);
  font-size: var(--fs-body);
}

/* ── Post page ──────────────────────────────────────────────────────────── */
/* Editorial layout — no hero cover, just a compact header above the article.
   The cover image stays in metadata only (cards + og:image). The first body
   block of the article is the lead photo. */
.post-head {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(96px, 11vh, 132px) 32px clamp(28px, 4vw, 48px);
}
.post-head-inner {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.post-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-size: var(--fs-overline);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  text-decoration: none;
  transition: color .25s var(--easing);
}
.post-back:hover { color: var(--accent); }
.post-head h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.6vw, 44px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--text);
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.post-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.post-tags span {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--text-soft);
  font-size: var(--fs-overline);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Article body — a single readable column, magazine-width */
.post-body {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 24px) 32px var(--section-y);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text-soft);
}
.post-body .pb {
  margin-bottom: 34px;
}
.pb-heading {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 18px;
}
.pb-lead {
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--text);
  max-width: 54ch;
}
.pb-text {
  max-width: 68ch;
  white-space: pre-wrap;
}
.pb-rich {
  max-width: 68ch;
  /* Renders raw HTML for blocks that need inline links / anchors (SEO).
     No white-space:pre-wrap — the author controls whitespace themselves. */
}
.pb-rich a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: color .25s var(--easing), border-color .25s var(--easing);
}
.pb-rich a:hover {
  color: var(--text);
  border-bottom-color: var(--text-soft);
}
.pb-quote {
  margin: 44px 0;
  padding-left: 28px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-size: clamp(21px, 2.2vw, 28px);
  font-weight: 500;
  line-height: 1.34;
  letter-spacing: -0.01em;
  color: var(--text);
}
.pb-quote .pb-quote-author {
  display: block;
  margin-top: 14px;
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.pb-divider {
  height: 1px;
  margin: 48px 0;
  background: var(--line-strong);
  border: 0;
}
.pb-image-items {
  display: grid;
  gap: 16px;
}
.pb-image.layout-pair .pb-image-items {
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.pb-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-md);
  background: var(--surface);
}
.pb-image figcaption {
  margin-top: 12px;
  font-size: var(--fs-caption);
  line-height: 1.5;
  color: var(--text-mute);
}
/* Full-bleed: break out of the 720px column without breaking the layout */
.pb-image.layout-full {
  width: min(1100px, calc(100vw - 64px));
  margin-left: 50%;
  transform: translateX(-50%);
}

/* Prev / next */
.post-nav {
  border-top: 1px solid var(--line-soft);
  padding: 48px 0 var(--section-y);
}
.post-nav-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.4s var(--easing), background 0.4s var(--easing);
}
.post-nav a:hover {
  border-color: var(--accent-line);
  background: var(--surface);
}
.post-nav .pn-dir {
  font-size: var(--fs-overline);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.post-nav .pn-title {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.post-nav .is-next {
  text-align: right;
  align-items: flex-end;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .journal-grid,
  .blog-list {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .journal-grid,
  .blog-list {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .post-head {
    padding: 96px 20px 24px;
  }
  .post-body {
    padding: 8px 20px var(--section-y);
  }
  .pb-image.layout-full {
    width: calc(100vw - 40px);
  }
  .post-nav-inner {
    grid-template-columns: 1fr;
  }
  .post-nav .is-next {
    text-align: left;
    align-items: flex-start;
  }
  .pb-image.layout-pair .pb-image-items {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .b-card,
  .b-card-media img,
  .post-nav a {
    transition: none;
    animation-duration: 0.001ms;
    animation-iteration-count: 1;
  }
  .b-card:hover {
    transform: none;
  }
  .b-card:hover .b-card-media img {
    transform: none;
  }
}

/* ── Portfolio category page (/portfolio/c/<slug>) ─────────────────────────
   Reuses .blog-head for the header and .gm-card for each work, but the
   grid itself is its own: the homepage .grid-magazine is a 12-column
   masonry with per-card spans, which collapses into slivers when the
   cards come from a single category. A simple auto-fill grid with a
   fixed portrait ratio is steadier here. */

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-mute);
}
.crumbs a { color: var(--text-soft); text-decoration: none; transition: color .25s var(--easing); }
.crumbs a:hover { color: var(--accent); }
.crumbs span[aria-hidden] { color: var(--text-mute); opacity: .6; }

.cat-switch {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: -28px 0 40px;
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-soft);
  text-decoration: none;
  transition: border-color .25s var(--easing), color .25s var(--easing),
              background .25s var(--easing);
}
.cat-chip:hover { color: var(--text); border-color: var(--accent-line); }
.cat-chip.is-on {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(194, 100, 63, 0.12);
}
.cat-chip-n {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-mute);
}
.cat-chip.is-on .cat-chip-n { color: var(--accent); }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}
.cat-grid .gm-card { aspect-ratio: 3 / 4; }
.cat-grid .gm-card img { width: 100%; height: 100%; object-fit: cover; }

.cat-empty {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  color: var(--text-mute);
  padding: 40px 0;
}

@media (max-width: 620px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .cat-switch { margin-top: -16px; }
  .crumbs { margin-bottom: 18px; }
}
