/* ===== مدونة أحمد عباس الملجمي ===== */
:root {
  --paper: #f7f3ec;
  --paper-2: #efe8dc;
  --ink: #1f2430;
  --ink-2: #4a4f5c;
  --muted: #7a7466;
  --line: #ddd3c2;
  --accent: #8a3b24;      /* بنّي محمّر: لون الطين والبن */
  --accent-2: #2f5d50;    /* أخضر قاتم */
  --serif: "Amiri", "Noto Naskh Arabic", serif;
  --body: "Noto Naskh Arabic", "Amiri", serif;
  --ui: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --wrap: 1080px;
  --measure: 40rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17191f; --paper-2: #1f222a; --ink: #ece6da; --ink-2: #c3bcae;
    --muted: #8f897c; --line: #333743; --accent: #d98a6a; --accent-2: #7fb3a3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 1.125rem; line-height: 1.9;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--ink); }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.4; font-weight: 700; margin: 0 0 .5em; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 1.5rem; }

/* ----- الرأس ----- */
.masthead { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 10; }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .9rem; flex-wrap: wrap; }
.brand { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; line-height: 1.3; }
.brand-name { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; }
.brand-tag { font-family: var(--ui); font-size: .8rem; color: var(--muted); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; font-family: var(--ui); font-size: .95rem; }
.nav a { color: var(--ink-2); text-decoration: none; padding: .35rem .7rem; border-radius: 6px; }
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--paper-2); }

/* ----- الواجهة ----- */
.hero { border-bottom: 1px solid var(--line); background:
  linear-gradient(var(--paper-2), var(--paper)); }
.hero-inner { padding-block: 4rem 3.5rem; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3.2rem); max-width: 26ch; margin-bottom: .6em; }
.hero p { max-width: var(--measure); color: var(--ink-2); margin: 0 0 1.2rem; }
.btn { display: inline-block; font-family: var(--ui); font-size: .95rem; padding: .55rem 1.2rem; border-radius: 6px;
  background: var(--accent); color: var(--paper); text-decoration: none; margin-inline-end: .5rem; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-quiet:hover { background: var(--paper-2); color: var(--ink); }

.section-label { font-family: var(--ui); font-size: .8rem; letter-spacing: 0; color: var(--muted); margin: 0 0 .75rem; font-weight: 600; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--ui); font-size: .9rem; }
.lead { padding-block: 3rem 2.5rem; border-bottom: 1px solid var(--line); }
.lead h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); max-width: 24ch; }
.lead h2 a, .card h3 a { color: var(--ink); text-decoration: none; }
.lead h2 a:hover, .card h3 a:hover { color: var(--accent); }
.lede { font-size: 1.2rem; color: var(--ink-2); max-width: var(--measure); }
.more { font-family: var(--ui); font-size: .95rem; text-decoration: none; font-weight: 500; }
.meta { font-family: var(--ui); font-size: .85rem; color: var(--muted); margin: 0 0 .5rem; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.kicker { color: var(--accent-2); font-weight: 600; text-decoration: none; font-family: var(--ui); font-size: .85rem; }

section.wrap:not(.lead):not(.page):not(.post) { padding-block: 2.5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 2.5rem; }
.card { padding-block: 1.25rem; border-top: 1px solid var(--line); }
.card h3 { font-size: 1.35rem; margin-bottom: .3em; }
.card p:not(.meta) { margin: 0; color: var(--ink-2); font-size: 1rem; line-height: 1.8; }

.project { border-top: 1px solid var(--line); }
.project h2 { font-size: 1.9rem; }
.project > p { max-width: var(--measure); color: var(--ink-2); }
.determinants { list-style: none; padding: 0; margin: 1.5rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem;
  counter-reset: d; font-family: var(--ui); }
.determinants li { counter-increment: d; border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; color: var(--muted); display: flex; flex-direction: column; }
.determinants li::before { content: counter(d); font-size: .75rem; }
.determinants li small { font-size: .75rem; }
.determinants .done { color: var(--ink); border-color: var(--accent-2); }
.determinants .done small { color: var(--accent-2); }
.determinants .current { color: var(--ink); border-color: var(--accent); border-style: dashed; }
.determinants .current small { color: var(--accent); }

/* ----- الصفحات الداخلية ----- */
.page { padding-block: 3rem 4rem; }
.page h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1.5rem 0; font-family: var(--ui); font-size: .9rem; }
.chips a { border: 1px solid var(--line); border-radius: 99px; padding: .2rem .9rem; text-decoration: none; color: var(--ink-2); }
.chips a:hover { border-color: var(--accent); color: var(--accent); }
.archive-group { margin-top: 2.5rem; }
.archive-group h2 { font-size: 1.4rem; color: var(--accent-2); }
.archive { list-style: none; padding: 0; margin: 0; }
.archive li { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.archive a { color: var(--ink); text-decoration: none; font-size: 1.15rem; }
.archive a:hover { color: var(--accent); }
.archive time { font-family: var(--ui); font-size: .85rem; color: var(--muted); white-space: nowrap; }

.group-title { font-size: 1.5rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.page > p { max-width: var(--measure); }
.study { padding: 1.25rem 0; border-bottom: 1px solid var(--line); max-width: 48rem; }
.study h3 { font-size: 1.3rem; margin: .4rem 0; }
.study p { margin: .3rem 0; color: var(--ink-2); font-size: 1.05rem; }
.study-meta { font-family: var(--ui); font-size: .9rem !important; color: var(--muted) !important; }
.status { font-family: var(--ui); font-size: .75rem; font-weight: 600; padding: .15rem .6rem; border-radius: 99px; background: var(--paper-2); color: var(--ink-2); }
.status-done { background: color-mix(in srgb, var(--accent-2) 15%, transparent); color: var(--accent-2); }
.status-current { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

.about-head { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; }
.about-head h1 { margin: 0; }
.about-head .lede { margin: .2rem 0 0; }
.portrait { border-radius: 50%; object-fit: cover; width: 160px; height: 160px; }
.avatar { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--paper); font-family: var(--ui); font-weight: 600; font-size: 1.5rem; flex: none; }
.avatar-lg { width: 160px; height: 160px; font-size: 4.5rem; }
.contact-list { list-style: none; padding: 0; margin: 2rem 0; max-width: 36rem; font-family: var(--ui); }
.contact-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.contact-list span { color: var(--muted); }
.contact-list .empty { color: var(--muted); }

/* ----- المقال ----- */
.post { padding-block: 3rem 4rem; }
.post-head { max-width: var(--measure); margin-inline: auto; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.post-head h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); margin-top: .3em; }
.prose { max-width: var(--measure); margin-inline: auto; }
.prose p { margin: 0 0 1.3em; }
.prose h2 { font-size: 1.6rem; margin-top: 1.8em; }
.prose h3 { font-size: 1.3rem; margin-top: 1.5em; }
.prose blockquote { margin: 1.5em 0; padding: .2em 1.2em; border-inline-start: 3px solid var(--accent); color: var(--ink-2); font-family: var(--serif); font-size: 1.25rem; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: 0 0 1.3em; }
.prose li { margin-bottom: .4em; }
.prose img { border-radius: 6px; margin-block: 1em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.post-foot { max-width: var(--measure); margin: 3rem auto 0; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.byline { display: flex; gap: 1rem; align-items: center; font-family: var(--ui); }
.byline img { border-radius: 50%; width: 56px; height: 56px; object-fit: cover; }
.byline div { display: flex; flex-direction: column; line-height: 1.5; }
.byline span { color: var(--muted); font-size: .9rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
.pager a { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; font-family: var(--serif); font-size: 1.1rem; line-height: 1.5; }
.pager a:hover { border-color: var(--accent); }
.pager small { font-family: var(--ui); font-size: .8rem; color: var(--muted); }
.pager-prev { text-align: left; }

/* ----- التذييل ----- */
.footer { border-top: 1px solid var(--line); margin-top: 2rem; font-family: var(--ui); font-size: .85rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding-block: 1.5rem; }
.footer p { margin: 0; }
.footer-links { display: flex; gap: 1rem; }
.footer a { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 1.06rem; }
  .masthead { position: static; }
  .nav { width: 100%; justify-content: space-between; flex-wrap: nowrap; font-size: .88rem; gap: 0; }
  .nav a { padding: .3rem .35rem; white-space: nowrap; }
  .hero-inner { padding-block: 2.5rem; }
  .archive li { flex-direction: column; gap: .1rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-prev { text-align: right; }
}
