@font-face {
  font-family: 'Mahamir Magazine Yekan';
  src: url('./iranyekanx-medium.woff') format('woff');
  font-weight: 500;
  font-display: swap;
}

#main-content:has(> .mh-mag) { display: block; max-width: none; width: 100%; margin: 0; padding-inline: 0; }
.wd-page-content:has(.mh-mag) { padding-block-start: 0; }

.mh-mag {
  --navy: #071a2b;
  --paper: #fff;
  --muted: #36536a;
  --line: #cbdce8;
  --ice: #e9f5fb;
  --teal: #00666f;
  --accent: #22e5e8;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gap: clamp(18px, 2.25vw, 34px);
  direction: rtl;
  background: var(--paper);
  color: var(--navy);
  font: 500 1rem/1.85 'Mahamir Magazine Yekan', IRANYekanX, IRANYekan, sans-serif;
  text-align: start;
}

.mh-mag :is(h1, h2, h3, p, a, button, summary) { font-family: inherit; letter-spacing: normal; }
.mh-mag a:focus-visible, .mh-mag button:focus-visible, .mh-mag summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}

.mh-mag-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mh-mag-shell { width: min(calc(100% - 32px), 1136px); margin-inline: auto; }
.mh-mag-index { padding-block: clamp(14px, 2.5vw, 36px) clamp(28px, 5vw, 62px); }
.mh-mag-shell:has(.mh-mag-card:last-child:nth-child(1)) { max-width: 310px; }
.mh-mag-shell:has(.mh-mag-card:last-child:nth-child(2)) { max-width: 564px; }
.mh-mag-shell:has(.mh-mag-card:last-child:nth-child(3)) { max-width: 800px; }
.mh-mag-grid {
  --gutter: clamp(8px, 1vw, 14px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  align-items: start;
  gap: var(--gutter);
}
.mh-mag-grid--masonry { grid-auto-rows: 4px; row-gap: 0; }
.mh-mag-grid--masonry .mh-mag-card { grid-row-end: span var(--mh-mag-rows, 1); }
.mh-mag-grid:has(> :last-child:nth-child(2)) { grid-template-columns: 1.2fr 1fr; }
.mh-mag-card { min-width: 0; margin: 0; }
.mh-mag-card-link { display: block; color: var(--navy); text-decoration: none; }
.mh-mag-card:nth-child(4n+2) .mh-mag-card-link { padding-block-start: clamp(10px, 2vw, 26px); }
.mh-mag-media { position: relative; overflow: hidden; aspect-ratio: 1.25; background: var(--navy); }
.mh-mag-card:nth-child(4n+2) .mh-mag-media { aspect-ratio: .94; }
.mh-mag-card:nth-child(4n+3) .mh-mag-media { aspect-ratio: 1.65; }
.mh-mag-card:nth-child(4n+4) .mh-mag-media { aspect-ratio: .86; }
.mh-mag-media .mh-mag-photo, .mh-mag-image-fallback { display: block; width: 100%; height: 100%; object-fit: cover; }
.mh-mag-image-fallback { background: linear-gradient(140deg, #071a2b 42%, #06445a 42% 72%, #157994 72%); }
.mh-mag-arrow { position: absolute; inset-inline-end: 8px; inset-block-end: 8px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid #ffffffa6; background: #071a2bbd; color: #fff; }
.mh-mag-arrow::after { content: '↖'; line-height: 1; }
.mh-mag-caption { padding: 9px 2px 12px; border-bottom: 1px solid var(--line); }
.mh-mag-caption h2 { margin: 0; color: var(--navy); font-size: clamp(.88rem, 1.35vw, 1.18rem); line-height: 1.65; overflow-wrap: anywhere; text-wrap: pretty; }
.mh-mag-card-link:is(:hover,:focus-visible) h2 { color: var(--teal); }
.mh-mag-index-head { margin-block-start: clamp(22px, 3.5vw, 42px); }
@media (max-width: 600px) {
  .mh-mag-shell { width: calc(100% - 24px); }
  .mh-mag-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mh-mag-grid:has(> :only-child) { grid-template-columns: 1fr; }
  .mh-mag-caption { padding-block: 7px 9px; }
}
@media (prefers-reduced-motion: no-preference) {
  .mh-mag-photo { transition: transform .55s var(--ease); }
  .mh-mag-card-link:is(:hover,:focus-visible) .mh-mag-photo { transform: scale(1.045); }
  .mh-mag-card--entered .mh-mag-media { animation: mh-mag-unfold .65s var(--ease) backwards; animation-delay: var(--mh-mag-delay, 0ms); }
}
@keyframes mh-mag-unfold {
  from { clip-path: inset(10% 0 0); transform: translateY(10px); opacity: .6; }
  to { clip-path: inset(0); transform: none; opacity: 1; }
}
.mh-mag-topics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 clamp(12px, 2vw, 28px);
  margin-block-end: var(--gap);
  border-block: 1px solid var(--line);
}
.mh-mag-topics a {
  min-height: 46px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding-inline: 4px;
  color: var(--muted);
  font-size: .88rem;
  text-decoration: none;
}
.mh-mag-topics a[aria-current] { color: var(--navy); box-shadow: inset 0 -3px var(--teal); font-weight: 750; }
.mh-mag-topics a:is(:hover, :focus-visible) { color: var(--teal); }
.mh-mag-topics span { color: var(--teal); }

.mh-mag-about { max-width: 78ch; margin-block-start: 16px; border-block: 1px solid var(--line); color: var(--muted); }
.mh-mag-about summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 54px; cursor: pointer; color: var(--navy); font-weight: 750; scroll-margin-block-start: 112px; }
.mh-mag-about summary::-webkit-details-marker { display: none; }
.mh-mag-about summary::after {
  content: '';
  flex: 0 0 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(var(--teal), var(--teal)) center / 12px 2px no-repeat,
              linear-gradient(var(--teal), var(--teal)) center / 2px 12px no-repeat var(--ice);
}
.mh-mag-about[open] summary::after { background-size: 12px 2px, 0 0; }
.mh-mag-about :is(h2, h3) { color: var(--navy); margin-block: 24px 10px; font-size: clamp(1.12rem, 2vw, 1.55rem); }
.mh-mag-about p { overflow-wrap: anywhere; }
.mh-mag-about a { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.mh-mag-about figure { margin: 24px 0; }
.mh-mag-about img { display: block; width: 100%; max-width: 100%; height: auto; }
.mh-mag .pagination { margin-block-start: 30px; }
.mh-mag .nav-links { display: flex; flex-wrap: wrap; gap: 8px; }
.mh-mag .page-numbers, .mh-mag-more {
  min-inline-size: 44px;
  min-block-size: 44px;
  display: inline-grid;
  place-items: center;
  padding-inline: 12px;
  color: var(--navy);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.mh-mag .page-numbers.current, .mh-mag-more:is(:hover, :focus-visible) { color: var(--paper); background: var(--navy); }
.mh-mag-more { margin-block-start: 28px; cursor: pointer; }
.mh-mag-more[hidden] { display: none; }
.mh-mag-status { margin: 12px 0 0; color: var(--muted); }
.mh-mag-status:empty { margin: 0; }
