/* =========================================================
   Tamɣrabit v4 — minimal
   One typeface, one accent colour, thin lines, lots of space.
   ========================================================= */
:root {
  --bg: #fbfaf7;
  --ink: #1c1a18;
  --muted: #6e6862;
  --line: #e6e1d9;
  --soft: #f3f0ea;
  --accent: #9c3a1e;          /* henna, used sparingly */

  --sans: "Noto Sans", system-ui, sans-serif;
  --arabic: "Noto Naskh Arabic", serif;
  --tifinagh: "Noto Sans Tifinagh", "Noto Sans", sans-serif;

  --measure: 78ch;
  --wide: 960px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1.0625rem/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
[lang="ar"] { font-family: var(--arabic); }
[lang="zgh"] { font-family: var(--tifinagh); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 2.6rem); font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 12px; z-index: 10; background: var(--bg); padding: 8px 12px; }

.container { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 20px; }

/* ---------- Header / footer ---------- */
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 24px; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .9375rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 6px; }

.site-footer { border-top: 1px solid var(--line); margin-top: 96px; }
.footer-inner { max-width: var(--wide); margin: 0 auto; padding: 28px 20px; text-align: right; font-size: .875rem; color: var(--muted); }
.footer-inner .brand img { width: 20px; height: 20px; }
.footer-inner .brand-name { font-size: .9375rem; }
.footer-tagline { margin: 0; }

/* ---------- Home ---------- */
.home { min-height: 100vh; display: grid; place-items: center; }
.home-main { text-align: center; padding: 48px 20px; }
.home-logo { width: 56px; height: 56px; margin: 0 auto 20px; }
.home-title { font-size: clamp(2.4rem, 8vw, 3.4rem); }
.home-tagline { margin: 8px 0 40px; color: var(--muted); display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.home-tagline .sep { color: var(--line); }
.doors { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.door {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 22px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--ink); text-decoration: none; font: 500 1rem/1 var(--sans); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.door.tamazight { font-family: var(--tifinagh); }
.door:hover { border-color: var(--ink); }
.door-cta svg { width: 16px; height: 16px; display: block; }

/* ---------- Blog list ---------- */
.masthead { padding: 72px 0 24px; }
.masthead-grid { max-width: var(--measure); }
.lead { color: var(--muted); margin: 12px 0 0; }
.section-head { max-width: var(--measure); margin: 40px auto 0; }
.section-head h2 { font-size: .9375rem; font-weight: 600; color: var(--muted); }
.masthead .container, .post-list { max-width: var(--wide); }
.post-list { list-style: none; margin: 8px 0 0; padding: 0; }
.post-list li { border-bottom: 1px solid var(--line); }
.post-row { display: grid; grid-template-columns: 110px 1fr; gap: 24px; padding: 24px 0; color: var(--ink); text-decoration: none; }
.post-row .date { color: var(--muted); font-size: .875rem; padding-top: 4px; font-variant-numeric: tabular-nums; }
.post-row h3 { font-size: 1.25rem; transition: color .15s; }
.post-row p { margin: 6px 0 0; color: var(--muted); }
.post-row:hover h3 { color: var(--accent); }
.read-more { display: none; }
.empty { padding: 32px 0; color: var(--muted); }
@media (max-width: 560px) {
  .post-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Article ---------- */
article.container, .page-wrap { max-width: calc(var(--measure) + 40px); }
.article-head { padding: 72px 0 0; }
.kicker { margin: 10px 0 0; color: var(--muted); font-size: .875rem; }
.article-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; margin-top: 32px; }
.prose { margin-top: 32px; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.2em; }
.prose h2 { margin: 2.2em 0 .6em; }
.prose h3 { margin: 1.8em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose li ol, .prose li ul { margin: .4em 0 0; }
.prose strong { font-weight: 700; }
.prose .source { margin-top: 3em; padding-top: 16px; border-top: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 40px; font-size: .9375rem; text-decoration: none; }
.back-link svg { width: 16px; height: 16px; }

/* Tables: plain lines, may be wider than the text but never the screen */
.table-figure {
  width: min(820px, 100vw - 40px);
  margin: 2em 0 2em calc(50% - min(410px, 50vw - 20px));
  overflow-x: auto;
}
.table-figure table { margin: 0 auto; border-collapse: collapse; font-size: .9375rem; line-height: 1.5; }
.table-figure th { font-weight: 600; color: var(--muted); font-size: .8125rem; letter-spacing: .04em; border-bottom: 1px solid var(--ink); }
.table-figure th, .table-figure td { padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table-figure td[lang="ar"] { font-size: 1.05rem; }
.table-figure figcaption { margin-top: 10px; text-align: center; font-size: .875rem; color: var(--muted); }

/* ---------- Lḥuṛuf page ---------- */
main.container { max-width: calc(var(--measure) + 40px); }
.page-head { padding: 72px 0 0; }
.page-head .arabic-title { margin: 6px 0 0; color: var(--muted); font-size: 1.3rem; }
.toc { margin-top: 24px; }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: .9375rem; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent); }
.chapter { margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line); }
.chapter-title { margin-bottom: .8em; }
.chapter > .prose { margin-top: 0; }
.chapter-lead { color: var(--muted); margin: 0 0 24px; }

.letter-group { margin-top: 28px; }
.letter-group h3 { font-size: .9375rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.letters { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.tile { height: 100%; display: flex; flex-direction: column; align-items: center; padding: 14px 6px; background: var(--soft); border-radius: 6px; text-align: center; }
.tile .glyph { font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.tile .glyph sup { font-size: .45em; color: var(--accent); }
.tile .sound { color: var(--muted); font-size: 1.1rem; line-height: 1.5; }
.tile .word { font-size: .9375rem; margin-top: 4px; }
.tile .word-ar { color: var(--muted); font-size: .9rem; }
.tile.special .glyph { color: var(--accent); }
.footnote { margin: 12px 0 0; font-size: .875rem; color: var(--muted); }

.convert { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.convert li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.convert .from { color: var(--muted); min-width: 52px; }
.convert .arrow { color: var(--line); }
.convert .to { font-weight: 700; font-size: 1.15rem; }

@media (max-width: 480px) {
  .site-nav ul { gap: 16px; }
  .masthead, .article-head, .page-head { padding-top: 48px; }
}

/* ---------- Tamazight blog ---------- */
.tamazight-blog h1, .tamazight-blog h2, .tamazight-blog h3 { letter-spacing: 0; }
.tamazight-blog .prose { font-size: 1.125rem; line-height: 1.9; }

/* Embedded map: wider than the text, never wider than the screen */
.map-embed {
  width: min(960px, 100vw - 40px);
  margin: 2em 0 2em calc(50% - min(480px, 50vw - 20px));
}
.map-embed iframe { display: block; width: 100%; height: min(620px, 75vh); border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.map-embed figcaption { margin-top: 10px; font-size: .875rem; color: var(--muted); text-align: center; }