/* ==========================================================================
   Persian Magazine — main stylesheet
   RTL-first. Everything is written with logical properties (inline-start/end)
   so the layout is direction-agnostic, but the design assumes Persian: a taller
   line-height than Latin type wants, and no letter-spacing (which breaks joined
   Arabic script).
   ========================================================================== */

/* ---------------------------------------------------------------- fonts ---
   Vazirmatn, self-hosted. No external font CDN: it is one less third-party
   request on every page, and it keeps the site independent of a network the
   audience may not reach quickly. */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------- tokens --- */

:root {
  --bg: #ffffff;
  --bg-alt: #f5f7f7;
  --surface: #ffffff;
  --text: #12171a;
  --muted: #5b6770;
  --border: #e2e6e7;
  --border-strong: #cdd4d5;

  --primary: #0d6e6e;
  --primary-ink: #0a5656;
  --primary-soft: #e6f2f2;
  --accent: #b8431a;
  --accent-soft: #fbeee8;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.05), 0 6px 20px -12px rgba(16, 24, 32, 0.18);
  --shadow-lg: 0 2px 6px rgba(16, 24, 32, 0.06), 0 22px 46px -24px rgba(16, 24, 32, 0.3);

  --wrap: 1220px;
  --gap: 26px;
  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 68px;
}

html[data-theme='dark'] {
  --bg: #0c1113;
  --bg-alt: #121a1d;
  --surface: #121a1d;
  --text: #e7edef;
  --muted: #98a5ac;
  --border: #222d31;
  --border-strong: #33424a;

  --primary: #53d3c8;
  --primary-ink: #8ce4dc;
  --primary-soft: #102a2c;
  --accent: #f0915c;
  --accent-soft: #2a1a12;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -14px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.5), 0 26px 50px -26px rgba(0, 0, 0, 0.8);
}

/* ---------------------------------------------------------------- reset --- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.85;
  font-feature-settings: 'ss01';
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

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

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

a:hover {
  color: var(--primary-ink);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

p {
  margin: 0 0 1.2em;
}

ul, ol {
  padding-inline-start: 1.4em;
}

button {
  font: inherit;
  color: inherit;
}

/* ------------------------------------------------------------- utilities --- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 20px;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  inset-block-start: -60px;
  inset-inline-start: 12px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: inset-block-start 0.2s ease;
}

.skip-link:focus {
  inset-block-start: 0;
  color: #fff;
}

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

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--primary-ink);
  border-color: var(--primary-ink);
  color: #fff;
}

.chip {
  display: inline-block;
  padding: 3px 11px;
  margin-block-end: 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.9;
}

.chip:hover {
  background: var(--primary);
  color: #fff;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.meta__sep {
  opacity: 0.55;
}

/* --------------------------------------------------------------- header --- */

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-block-end: 1px solid var(--border);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand img {
  max-height: 44px;
  width: auto;
}

.brand__link {
  display: flex;
  flex-direction: column;
  color: var(--text);
  line-height: 1.3;
}

.brand__name {
  font-size: 1.24rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.brand__desc {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}

.nav {
  flex: 1 1 auto;
  min-width: 0;
}

.nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__list li {
  margin: 0;
}

.nav__list a {
  display: block;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}

.nav__list a:hover,
.nav__list .current-menu-item > a,
.nav__list .current-cat > a,
.nav__list .current_page_item > a {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-alt);
  border-color: var(--border);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-toggle {
  display: none;
}

.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  display: block;
  width: 19px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.nav-toggle__bars {
  position: relative;
}

.nav-toggle__bars::before,
.nav-toggle__bars::after {
  content: '';
  position: absolute;
  inset-inline-start: 0;
}

.nav-toggle__bars::before {
  inset-block-start: -6px;
}

.nav-toggle__bars::after {
  inset-block-start: 6px;
}

.theme-toggle__moon {
  display: none;
}

html[data-theme='dark'] .theme-toggle__sun {
  display: none;
}

html[data-theme='dark'] .theme-toggle__moon {
  display: block;
}

.search-drawer {
  border-block-start: 1px solid var(--border);
  background: var(--bg-alt);
  padding-block: 16px;
}

/* ---------------------------------------------------------------- forms --- */

.search-form {
  display: flex;
  gap: 8px;
  max-width: 560px;
}

.search-form__input {
  flex: 1;
  padding: 11px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.search-form__submit {
  padding: 11px 22px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.search-form__submit:hover {
  background: var(--primary-ink);
}

/* --------------------------------------------------------------- layout --- */

.site-main {
  display: block;
  padding-block: 34px 60px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 46px;
  align-items: start;
}

.layout__main {
  min-width: 0;
}

.sidebar {
  position: sticky;
  /* --header-actual is set from the measured header; --header-h is the fallback
     for when JavaScript has not run or has been blocked. */
  inset-block-start: calc(var(--header-actual, var(--header-h)) + 20px);
}

body.no-sidebar .layout {
  grid-template-columns: minmax(0, 1fr);
}

/* ---------------------------------------------------------------- cards --- */

.cards {
  display: grid;
  gap: var(--gap);
}

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

.cards--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.card__media {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-alt);
  aspect-ratio: 16 / 9;
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .card__media img {
  transform: scale(1.035);
}

.card__title {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.65;
}

.card__title a {
  color: var(--text);
}

.card__title a:hover {
  color: var(--primary);
}

.card__excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.9;
}

.card__meta {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
}

/* the lead story: image and text side by side, stacked when narrow */
.card--lead {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 30px;
  align-items: center;
  padding-block-end: 4px;
}

.card--lead .card__media {
  aspect-ratio: 16 / 10;
}

.card--lead .card__title {
  font-size: clamp(1.5rem, 2.6vw, 2.15rem);
  line-height: 1.45;
  font-weight: 800;
}

.card--lead .card__excerpt {
  font-size: 1rem;
}

.card--list {
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.card--list .card__media {
  width: 92px;
  flex: 0 0 92px;
  aspect-ratio: 1;
}

.card--list .card__title {
  font-size: 0.95rem;
}

/* ----------------------------------------------------------- front page --- */

.front-lead {
  padding-block-end: 34px;
  margin-block-end: 34px;
  border-block-end: 1px solid var(--border);
}

.front-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  margin-block-start: 34px;
  padding-block-start: 34px;
  border-block-start: 1px solid var(--border);
}

.front-desk {
  margin-block-end: 46px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-block-end: 20px;
  padding-block-end: 12px;
  border-block-end: 2px solid var(--border);
}

.section-head__title {
  position: relative;
  margin: 0;
  padding-inline-start: 14px;
  font-size: 1.3rem;
  font-weight: 800;
}

.section-head__title::before {
  content: '';
  position: absolute;
  inset-block: 3px;
  inset-inline-start: 0;
  width: 4px;
  border-radius: 3px;
  background: var(--accent);
}

.section-head__more {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.section-head__more:hover {
  color: var(--primary);
}

/* --------------------------------------------------------------- archive --- */

.archive-head {
  margin-block-end: 26px;
  padding-block-end: 16px;
  border-block-end: 2px solid var(--border);
}

.archive-head__title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
}

.archive-head__desc {
  margin-block-start: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.pagination {
  margin-block-start: 40px;
}

.pagination ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding-inline: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
}

.pagination a.page-numbers:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .page-numbers.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

.pagination .dots {
  border-color: transparent;
}

/* ---------------------------------------------------------------- single --- */

.entry__header {
  max-width: 860px;
  margin-inline: auto;
  text-align: center;
  padding-block-end: 26px;
}

.entry__kicker {
  margin-block-end: 6px;
}

.entry__title {
  margin: 0 0 18px;
  font-size: clamp(1.6rem, 3.4vw, 2.5rem);
  font-weight: 900;
  line-height: 1.4;
}

.entry__header .meta {
  justify-content: center;
}

.entry__media {
  margin: 0 auto 34px;
  max-width: 1000px;
  padding-inline: 20px;
}

.entry__media img {
  width: 100%;
  border-radius: var(--radius);
}

.entry__media figcaption {
  margin-block-start: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.entry-content {
  font-size: 1.1rem;
  line-height: 2.05;
}

.entry-content > *:first-child {
  margin-block-start: 0;
}

.entry-content p {
  margin-block: 1.35em;
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
  margin-block: 1.9em 0.7em;
  line-height: 1.55;
}

.entry-content h2 {
  font-size: 1.42rem;
  padding-inline-start: 13px;
  border-inline-start: 4px solid var(--primary);
}

.entry-content h3 {
  font-size: 1.2rem;
}

.entry-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.entry-content ul,
.entry-content ol {
  margin-block: 1.3em;
}

.entry-content li {
  margin-block: 0.55em;
}

.entry-content blockquote {
  margin: 1.8em 0;
  padding: 4px 20px;
  border-inline-start: 4px solid var(--accent);
  background: var(--bg-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
  font-style: normal;
}

.entry-content img {
  border-radius: var(--radius-sm);
  margin-block: 1.6em;
}

.entry-content code {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-alt);
  font-family: var(--mono);
  font-size: 0.88em;
  direction: ltr;
  display: inline-block;
}

.entry-content pre {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  font-size: 0.86rem;
  line-height: 1.7;
}

.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 1.6em;
  font-size: 0.94rem;
}

.entry-content th,
.entry-content td {
  padding: 10px 13px;
  border: 1px solid var(--border);
  text-align: start;
}

.entry-content th {
  background: var(--bg-alt);
  font-weight: 700;
}

.entry-content hr {
  margin-block: 2.4em;
  border: 0;
  border-block-start: 1px solid var(--border);
}

.entry-content figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.entry__tags {
  margin-block-start: 30px;
  padding-block-start: 18px;
  border-block-start: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}

.entry__tags-label {
  font-weight: 600;
  color: var(--text);
}

/* attribution box: written into the content by the pipeline, styled here */
.pmag-source,
.source {
  margin-block: 30px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  font-size: 0.9rem;
  line-height: 1.9;
}

.pmag-source strong,
.source__label {
  display: block;
  margin-block-end: 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.pmag-source p {
  margin: 0 0 4px;
}

.pmag-source a,
.source__link {
  color: var(--primary);
  font-weight: 600;
}

.source__name {
  font-weight: 700;
  color: var(--text);
}

.source__title {
  display: block;
  margin-block: 3px 6px;
  color: var(--muted);
}

/* share + post nav */
.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-block-start: 26px;
  padding-block: 18px;
  border-block: 1px solid var(--border);
}

.share__label {
  color: var(--muted);
  font-size: 0.86rem;
}

.share__item {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
}

.share__item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-block-start: 30px;
}

.post-nav__item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}

.post-nav__item--next {
  text-align: end;
}

.post-nav__label {
  display: block;
  margin-block-end: 5px;
  color: var(--muted);
  font-size: 0.76rem;
}

.post-nav__item a {
  color: var(--text);
  font-weight: 600;
  font-size: 0.96rem;
  display: block;
}

.post-nav__item a:hover {
  color: var(--primary);
}

.related {
  margin-block-start: 42px;
}

/* -------------------------------------------------------------- comments --- */

.comments {
  margin-block-start: 46px;
  padding-block-start: 26px;
  border-block-start: 2px solid var(--border);
}

.comments__title {
  font-size: 1.2rem;
  font-weight: 800;
}

.comments__list {
  margin: 0 0 30px;
  padding: 0;
  list-style: none;
}

.comments__list ol.children {
  padding-inline-start: 24px;
  list-style: none;
}

.comment-body {
  padding: 16px 0;
  border-block-end: 1px solid var(--border);
}

.comment-author {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.92rem;
}

.comment-author img {
  border-radius: 50%;
}

.comment-metadata {
  margin-block: 4px 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.comment-content {
  font-size: 0.96rem;
  line-height: 1.95;
}

.comment-respond {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
}

.comment-reply-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.comment-form label {
  display: block;
  margin-block-end: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}

.comment-form input[type='text'],
.comment-form input[type='email'],
.comment-form input[type='url'],
.comment-form textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.comment-form .submit {
  padding: 11px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.comment-form .submit:hover {
  background: var(--primary-ink);
}

.comment-notes {
  color: var(--muted);
  font-size: 0.84rem;
}

/* --------------------------------------------------------------- sidebar --- */

.widget {
  margin-block-end: 32px;
  padding-block-end: 28px;
  border-block-end: 1px solid var(--border);
}

.widget:last-child {
  border-block-end: 0;
}

.widget__title {
  position: relative;
  margin-block-end: 16px;
  padding-inline-start: 12px;
  font-size: 1rem;
  font-weight: 800;
}

.widget__title::before {
  content: '';
  position: absolute;
  inset-block: 4px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}

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

.widget li {
  padding-block: 9px;
  border-block-end: 1px dashed var(--border);
  font-size: 0.92rem;
}

.widget li:last-child {
  border-block-end: 0;
}

.widget a {
  color: var(--text);
}

.widget a:hover {
  color: var(--primary);
}

.widget .cat-item a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.widget .count {
  color: var(--muted);
  font-size: 0.82rem;
}

/* Subcategories hang off their parent: indented, quieter, and with a rule that
   makes the hierarchy readable at a glance. */
.widget .cat-children {
  margin-block: 2px 8px;
  margin-inline-start: 4px;
  padding-inline-start: 12px;
  border-inline-start: 2px solid var(--border);
}

.widget .cat-children .cat-item {
  border-block-end: 0;
}

.widget .cat-children .cat-item a {
  padding-block: 3px;
  color: var(--muted);
  font-size: 0.85rem;
}

.widget .cat-children .cat-item a:hover {
  color: var(--primary);
}

.widget .cat-children .count {
  font-size: 0.76rem;
}

.widget-list__meta {
  display: block;
  margin-block-start: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.widget p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.95;
}

.tagcloud a {
  display: inline-block;
  margin: 0 0 6px 6px;
}

/* ---------------------------------------------------------------- footer --- */

.site-footer {
  margin-block-start: 40px;
  padding-block: 44px 26px;
  border-block-start: 1px solid var(--border);
  background: var(--bg-alt);
}

.footer-widgets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px;
  padding-block-end: 30px;
}

.footer-col .widget {
  border-block-end: 0;
  margin-block-end: 0;
  padding-block-end: 0;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-block-start: 22px;
  border-block-start: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
}

.footer-note {
  margin: 0;
}

.footer-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-nav__list a {
  color: var(--muted);
}

.footer-nav__list a:hover {
  color: var(--primary);
}

.to-top {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-start: 22px;
  z-index: 90;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1.1rem;
}

.to-top:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ----------------------------------------------------- empty and errors --- */

.empty-state,
.error-page {
  max-width: 640px;
  margin-inline: auto;
  padding-block: 60px;
  text-align: center;
}

.empty-state h1,
.empty-state h2,
.error-page h1 {
  font-size: 1.6rem;
  font-weight: 800;
}

.empty-state p,
.error-page p {
  color: var(--muted);
  line-height: 2;
}

.empty-state .search-form,
.error-page .search-form {
  margin: 24px auto;
  justify-content: center;
}

.error-page__code {
  margin: 0;
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  color: var(--primary-soft);
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 32px;
  }

  .cards--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card--lead {
    grid-template-columns: 1.2fr 1fr;
    gap: 22px;
  }
}

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }

  .nav {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 120;
    width: min(320px, 84vw);
    padding: 84px 22px 22px;
    background: var(--surface);
    border-inline-start: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    overflow-y: auto;
    visibility: hidden;
  }

  /* In RTL, inset-inline-end is the left edge, so the drawer lives on the left
     and translateX(-100%) slides it out of view. */
  .nav.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .nav__list {
    flex-direction: column;
    gap: 2px;
  }

  .nav__list a {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.42);
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  .nav-backdrop.is-open {
    opacity: 1;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
  }

  .sidebar {
    position: static;
  }

  .card--lead {
    grid-template-columns: minmax(0, 1fr);
  }

  .front-grid,
  .cards--2,
  .cards--3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-widgets {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-nav__item--next {
    text-align: start;
  }
}

@media (max-width: 520px) {
  .entry-content {
    font-size: 1.03rem;
  }

  .cards--2.front-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------------- print --- */

@media print {
  .site-header,
  .sidebar,
  .site-footer,
  .share,
  .post-nav,
  .related,
  .comments,
  .to-top {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .layout {
    display: block;
  }

  .entry-content {
    font-size: 12pt;
  }

  a::after {
    content: ' (' attr(href) ')';
    font-size: 9pt;
    color: #555;
  }
}
