/* ═══ الأساس: تصفيرٌ، وطباعةٌ، وعناصرُ عامّة ═══════════════ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--lh-snug);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--lh-tight);
  letter-spacing: -.01em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }
[hidden] { display: none !important; }   /* يسبق أيَّ display في المكوّنات */
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video, iframe { max-width: 100%; display: block; }
img { height: auto; }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

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

::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }

code, kbd { font-family: var(--font-mono); font-size: .86em; }

kbd {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .42em;
  box-shadow: 0 1px 0 var(--line);
}

/* ── تخطّي إلى المحتوى ── */
.skip {
  position: fixed;
  inset-inline-start: 50%;
  top: -100px;
  transform: translateX(50%);
  z-index: 999;
  background: var(--ink);
  color: var(--paper);
  padding: .7rem 1.3rem;
  border-radius: 0 0 var(--r-md) var(--r-md);
  transition: top var(--t-base);
}
.skip:focus { top: 0; }

/* ── نصٌّ لقارئ الشاشة وحده ── */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── شريطُ تقدّم القراءة ── */
.progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 60;
  pointer-events: none;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--spark));
  transition: width .1s linear;
}

/* ── حاويةُ العرض ── */
.shell {
  width: min(100% - (var(--pad) * 2), var(--shell));
  margin-inline: auto;
}

/* ── وضعُ القراءة الهادئ ── */
body.reading .masthead__nav,
body.reading .ticker,
body.reading .footer__grid,
body.reading .strip,
body.reading .prevnext,
body.reading .article__tags { display: none; }
body.reading .article__grid { grid-template-columns: minmax(0, 1fr); }
body.reading .toc { display: none; }
body.reading { --paper: var(--surface); }

/* ── الطباعة الورقيّة ── */
@media print {
  .masthead, .footer, .to-top, .tools, .sharebar, .toc,
  .progress, .strip, .prevnext, .ticker, .drawer, .finder { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .prose { max-width: none; }
  a::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
}
