/* Kinlantern — warm, calm, readable. Mobile first. Logical properties for RTL. */

:root {
  --paper: #FBF7F1;
  --surface: #FFFFFF;
  --surface-2: #F3ECE2;
  --ink: #22303A;
  --ink-soft: #4B5963;
  --muted: #5F6C74;
  --line: #E4DBCD;
  --brand: #2A5D67;
  --brand-deep: #1E464E;
  --brand-tint: #E4EFF0;
  --accent: #9E4A22;
  --accent-light: #F4C98F;
  --accent-tint: #FBEEDD;
  --alert: #8A2434;
  --alert-tint: #F8E9EA;
  --focus: #B4610A;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(34, 48, 58, 0.06), 0 8px 24px rgba(34, 48, 58, 0.06);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-head: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --measure: 68ch;
}

html[lang="ar"] {
  --font-body: "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-head: "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --measure: 60ch;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-size: 1.125rem; line-height: 1.9; }

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

a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { color: var(--brand-deep); text-decoration-thickness: 2px; }

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

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; color: var(--ink); letter-spacing: -0.005em; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.85rem); margin-top: 1.6em; }
h3 { font-size: 1.15rem; margin-top: 1.4em; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { font-weight: 700; line-height: 1.5; letter-spacing: 0; }

p, ul, ol, dl { margin: 0 0 1em; }
ul, ol { padding-inline-start: 1.4em; }
li { margin-bottom: 0.45em; }
li > p { margin-bottom: 0.4em; }
strong { font-weight: 650; }

dfn {
  font-style: normal;
  font-weight: 600;
  color: var(--brand-deep);
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

.wrap { width: min(100% - 2rem, 1120px); margin-inline: auto; }
.muted { color: var(--muted); }
.plain { list-style: none; padding: 0; }

/* Skip link */
.skip-link { position: absolute; inset-inline-start: 1rem; top: -4rem; background: var(--ink); color: #fff; padding: 0.6rem 1rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 1rem; }

/* Crisis banner: persistent, top of every page */
.crisis { background: var(--alert); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.crisis-inner { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; align-items: center; padding: 0.4rem 0; font-size: 0.86rem; line-height: 1.3; }
.crisis-lead { font-weight: 600; }
@media (max-width: 480px) { .crisis-lead { display: none; } .crisis-inner { justify-content: center; } }
.crisis-item { color: #fff; text-decoration: none; white-space: nowrap; padding: 0.15rem 0; }
.crisis-item strong { font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.crisis-item:hover { color: #fff; }
.crisis-item:hover strong { text-decoration-thickness: 2px; }
.crisis :focus-visible { outline-color: #fff; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem 1rem; padding: 0.7rem 0; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; letter-spacing: 0.01em; }
html[lang="ar"] .brand-name { font-family: var(--font-body); }
.logo-mark { flex: none; }

.menu-toggle { display: inline-flex; align-items: center; gap: 0.5rem; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font: inherit; font-weight: 600; padding: 0.45rem 0.9rem; border-radius: 999px; cursor: pointer; }
.menu-icon { width: 18px; height: 2px; background: currentColor; position: relative; display: inline-block; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; inset-inline-start: 0; width: 18px; height: 2px; background: currentColor; }
.menu-icon::before { top: -6px; } .menu-icon::after { top: 6px; }
.menu-toggle[aria-expanded="true"] .menu-icon { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-icon::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }

.site-nav { display: none; flex-basis: 100%; padding: 0.5rem 0 0.75rem; border-top: 1px solid var(--line); }
.site-nav.open { display: block; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.nav-list a { display: block; padding: 0.55rem 0.5rem; text-decoration: none; font-weight: 600; color: var(--ink-soft); border-radius: var(--radius-sm); }
.nav-list a:hover { background: var(--surface-2); color: var(--ink); }
.nav-list a[aria-current="page"] { color: var(--brand-deep); background: var(--brand-tint); }

.lang-switch { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.lang-label { font-size: 0.85rem; color: var(--muted); }
.lang-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.lang-list a { display: inline-block; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font-weight: 600; font-size: 0.95rem; color: var(--ink-soft); background: var(--surface); }
.lang-list a:hover { border-color: var(--brand); color: var(--brand-deep); }
.lang-list a[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* The horizontal nav only appears once it genuinely fits. Spanish and Arabic
   labels run much longer than the English ones, so this breakpoint is set by the
   widest language, not by English. Below it, every language uses the menu. */
@media (min-width: 1100px) {
  .menu-toggle { display: none; }
  .site-nav { display: flex; flex-basis: auto; align-items: center; gap: 0.7rem; padding: 0; border: 0; margin-inline-start: auto; }
  .nav-list { flex-direction: row; gap: 0; flex-wrap: nowrap; }
  .nav-list a { padding: 0.4rem 0.45rem; font-size: 0.93rem; white-space: nowrap; }
  .lang-switch { margin: 0; padding: 0; border: 0; padding-inline-start: 0.9rem; border-inline-start: 1px solid var(--line); }
  .lang-list { flex-wrap: nowrap; }
  .lang-list a { padding: 0.25rem 0.6rem; font-size: 0.9rem; }
  .lang-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Hero + home */
.hero { background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%); border-bottom: 1px solid var(--line); }
.hero-inner { padding: 2.5rem 0 2.75rem; max-width: 46rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; font-weight: 700; color: var(--accent); margin-bottom: 0.75rem; }
html[lang="ar"] .eyebrow { letter-spacing: 0; text-transform: none; font-size: 0.95rem; }
.lede { font-size: 1.2rem; line-height: 1.55; color: var(--ink-soft); max-width: var(--measure); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.btn { display: inline-block; padding: 0.75rem 1.25rem; border-radius: 999px; font-weight: 650; text-decoration: none; border: 2px solid transparent; line-height: 1.2; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--brand-deep); border-color: var(--brand); }
.btn-ghost:hover { background: var(--brand-tint); }

.section { padding: 2.25rem 0 0.5rem; }
.section h2 { margin-top: 0; }
.section-intro { color: var(--ink-soft); max-width: var(--measure); margin-bottom: 1.25rem; }

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .card-grid { grid-template-columns: repeat(3, 1fr); } .card-grid-2 { grid-template-columns: repeat(2, 1fr); } }
.card { margin: 0; }
.card-link { display: flex; flex-direction: column; gap: 0.35rem; height: 100%; padding: 1.2rem 1.25rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform 120ms ease, border-color 120ms ease; }
.card-link:hover { transform: translateY(-2px); border-color: var(--brand); color: var(--ink); }
.card-kind { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--accent); }
html[lang="ar"] .card-kind { text-transform: none; letter-spacing: 0; font-size: 0.9rem; }
.card-title { font-family: var(--font-head); font-size: 1.25rem; font-weight: 650; line-height: 1.25; color: var(--brand-deep); }
html[lang="ar"] .card-title { line-height: 1.5; }
.card-text { color: var(--ink-soft); font-size: 0.97rem; }
.card-meta { margin-top: auto; padding-top: 0.5rem; font-size: 0.82rem; color: var(--muted); display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; background: var(--accent-tint); color: var(--accent); font-weight: 650; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem; }

.band { background: var(--brand-tint); margin-top: 2.5rem; padding: 2.25rem 0; }
.band h2 { margin-top: 0; }
.two-col { display: grid; gap: 2rem; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; gap: 3rem; } }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { position: relative; padding-inline-start: 2.6rem; margin-bottom: 0.9rem; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; inset-inline-start: 0; top: 0.1rem; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 0.95rem; }
.band .plain li { padding-inline-start: 1.5rem; position: relative; }
.band .plain li::before { content: "—"; position: absolute; inset-inline-start: 0; color: var(--accent); font-weight: 700; }

/* Article pages */
.page-head { padding: 2.25rem 0 1.25rem; max-width: 52rem; }
.page-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; font-size: 0.9rem; color: var(--muted); margin: 0.75rem 0 0; }

.article-layout { display: grid; gap: 1.5rem; align-items: start; padding-bottom: 1rem; }
@media (min-width: 1000px) { .article-layout { grid-template-columns: 250px minmax(0, 1fr); gap: 3rem; } }

.toc { font-size: 0.95rem; }
.toc-details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
.toc-details summary { font-weight: 700; cursor: pointer; font-family: var(--font-head); font-size: 1.05rem; color: var(--brand-deep); }
.toc-details ol { margin: 0.6rem 0 0; padding-inline-start: 1.3rem; }
.toc-details li { margin-bottom: 0.35rem; }
.toc-details a { text-decoration: none; color: var(--ink-soft); }
.toc-details a:hover, .toc-details a.active { color: var(--brand-deep); text-decoration: underline; }
.toc-details ol.letters { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.toc-details ol.letters a { display: inline-block; min-width: 2rem; text-align: center; padding: 0.2rem 0.4rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 600; }
@media (min-width: 1100px) {
  .toc { position: sticky; top: 3.4rem; }
  .toc-details summary { list-style: none; pointer-events: none; }
  .toc-details summary::-webkit-details-marker { display: none; }
}

/* Inline citation: a small numbered link to the source list at the foot of the
   page, so a reader can see that a claim is not ours without leaving the line. */
.cite { font-size: 0.68em; line-height: 0; vertical-align: super; margin-inline-start: 1px; white-space: nowrap; }
.cite a {
  text-decoration: none;
  color: var(--brand);
  background: var(--brand-tint);
  border-radius: 4px;
  padding: 0.18em 0.34em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cite a:hover, .cite a:focus-visible { background: var(--brand); color: #fff; }
.cite + .cite { margin-inline-start: 2px; }
.sources li:target { background: var(--accent-tint); border-radius: var(--radius-sm); padding: 0.2rem 0.4rem; margin-inline-start: -0.4rem; }
.urgent .cite a { color: var(--alert); background: #fff; }
.urgent .cite a:hover, .urgent .cite a:focus-visible { background: var(--alert); color: #fff; }
.help-backfire .cite a { background: var(--surface-2); }

.article { max-width: var(--measure); font-size: 1.09rem; }
html[lang="ar"] .article { font-size: 1.17rem; }
.article > p:first-child { font-size: 1.15rem; color: var(--ink-soft); }
.content-section { padding: 0.25rem 0 0.75rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.content-section h2 { margin-top: 1rem; }
.content-section:first-of-type h2 { margin-top: 0.4rem; }
.content-section ul li::marker { color: var(--accent); }

.help-backfire { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1.4rem 0.4rem; }
.help-backfire p strong:only-child { display: inline-block; margin-top: 0.75rem; padding: 0.15rem 0.7rem; border-radius: 999px; background: var(--brand-tint); color: var(--brand-deep); font-size: 0.95rem; }
.help-backfire p:has(> strong:only-child) + ul { margin-top: 0.5rem; }
.help-backfire p:nth-of-type(2) strong:only-child { background: var(--accent-tint); color: var(--accent); }

.urgent { background: var(--alert-tint); border: 1px solid #E9C9CE; border-radius: var(--radius); padding: 0.75rem 1.4rem 0.6rem; }
.urgent h2 { color: var(--alert); }
.urgent ul li::marker { color: var(--alert); }

.closing { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 1.5rem 1.6rem 1.25rem; margin: 2rem 0 1.5rem; }
.closing h2 { color: #fff; margin-top: 0; }
.closing p:last-child { margin-bottom: 0; }
.closing .btn-primary { background: #fff; color: var(--brand-deep); border-color: #fff; }
.closing .btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); color: var(--ink); }
.closing :focus-visible { outline-color: #fff; }

.crisis-block { background: var(--surface); border: 2px solid var(--alert); border-radius: var(--radius); padding: 1.1rem 1.4rem 0.75rem; margin: 1.5rem 0; }
.crisis-block h2 { margin-top: 0; font-size: 1.25rem; color: var(--alert); }
.crisis-list { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.crisis-list li { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; margin-bottom: 0.55rem; }
.crisis-list a { color: var(--alert); font-size: 1.05rem; }
.crisis-list span { color: var(--ink-soft); font-size: 0.95rem; }
.crisis-note { font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 0.4rem; }

.sources-block { margin-top: 2rem; padding-top: 1.25rem; border-top: 3px double var(--line); font-size: 0.97rem; }
.sources-block h2 { margin-top: 0; font-size: 1.35rem; }
.sources { padding-inline-start: 1.2em; }
.sources li { margin-bottom: 0.35rem; overflow-wrap: anywhere; }
.youth-note { background: var(--accent-tint); padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.95rem; }

.related { padding-top: 1.5rem; padding-bottom: 2rem; }

/* Glossary */
.glossary .letter-group { margin-bottom: 1.5rem; }
.glossary h2 { font-size: 1.6rem; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 0.25rem; }
.glossary dl { margin: 0; }
.glossary .term { padding: 0.65rem 0; border-bottom: 1px dashed var(--line); }
.glossary dt { font-weight: 700; color: var(--brand-deep); font-family: var(--font-head); font-size: 1.15rem; }
.glossary dd { margin: 0.2rem 0 0; color: var(--ink-soft); }

/* Footer */
.site-footer { margin-top: 3rem; background: var(--surface); border-top: 1px solid var(--line); font-size: 0.95rem; }
.footer-grid { display: grid; gap: 1.5rem; padding: 2rem 0 0.5rem; }
@media (min-width: 800px) { .footer-grid { grid-template-columns: 1.1fr 1fr; gap: 3rem; } }
.footer-brand { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-head); font-size: 1.3rem; }
.site-footer .crisis-block { margin: 0; }
.footer-bottom { padding: 0.75rem 0 1.75rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; }
.footer-bottom p { margin: 0; }

/* Root chooser / 404 */
.root-chooser { display: grid; place-items: center; min-height: 100vh; text-align: center; }
.chooser { padding: 3rem 0; }
.chooser h1 { font-size: 2.2rem; }
.chooser-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.chooser-list a { display: inline-block; padding: 0.8rem 1.5rem; border-radius: 999px; background: var(--brand); color: #fff; text-decoration: none; font-weight: 650; font-size: 1.1rem; }
.chooser section { margin: 1.5rem auto; max-width: 30rem; }

/* Print: keep it readable, drop chrome */
@media print {
  .site-header, .site-footer, .toc, .related, .skip-link { display: none !important; }
  .crisis { position: static; }
  body { background: #fff; }
  a { color: inherit; }
}
