/* Global styles (loaded without blocking render). First-viewport layout lives in critical.css. */

/* ---------- Mobile menu ---------- */
.site-menu { width: min(420px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 16px var(--gutter) 28px; border: 0; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-3); }
[dir='rtl'] .site-menu { margin: 0 auto 0 0; }
.site-menu::backdrop { background: rgba(27, 42, 34, .38); backdrop-filter: blur(2px); }
.site-menu[open] { display: flex; flex-direction: column; gap: 22px; animation: menu-in .32s var(--ease-out); }
@keyframes menu-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
[dir='rtl'] .site-menu[open] { animation-name: menu-in-rtl; }
@keyframes menu-in-rtl { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.site-menu__top { display: flex; align-items: center; justify-content: space-between; }
.site-menu__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.site-menu__list a { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-family: var(--font-display); font-size: 1.35rem; }
.site-menu__list a[aria-current='page'] { color: var(--green); }
.site-menu__list svg { width: 20px; height: 20px; color: var(--green-3); }
[dir='rtl'] .site-menu__list svg { transform: scaleX(-1); }
.site-menu__cta { width: 100%; }
.site-menu__label { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.site-menu__label svg { width: 18px; height: 18px; }
.site-menu__langs ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 10px 0 0; }
.site-menu__langs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; }
.site-menu__langs a[aria-current='true'] { border-color: var(--green); color: var(--green); background: var(--green-tint); }
.nav-nojs { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-block: 8px 12px; }
.nav-nojs a { min-height: 44px; display: inline-flex; align-items: center; }
html:not(.js) .menu-btn { display: none; }

/* ---------- Footer ---------- */
.site-footer { margin-top: clamp(56px, 8vw, 104px); background: var(--green); color: #e7efe9; }
.site-footer a { color: #fff; }
.site-footer .brand { color: #fff; }
.site-footer__grid { display: grid; gap: 36px; padding-block: clamp(40px, 6vw, 72px) 32px; grid-template-columns: 1fr; }
.site-footer__brand p { margin: 14px 0 20px; max-width: 38ch; color: #cfdcd3; }
.site-footer__brand .btn { --b-bg: var(--gold); --b-bd: var(--gold); --b-fg: #1b2a22; color: var(--b-fg); }
.site-footer__brand .btn:hover { --b-bg: #d8ad52; --b-bd: #d8ad52; }
.site-footer__col h2 { font-family: var(--font-text); font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-soft); margin-bottom: 12px; }
.site-footer__col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.site-footer__col a { display: inline-flex; align-items: center; min-height: 40px; text-decoration: none; color: #e7efe9; }
.site-footer__col a:hover { color: #fff; text-decoration: underline; }
.site-footer__base { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-block: 20px 32px; border-top: 1px solid rgba(255, 255, 255, .14); font-size: .88rem; color: #bfd0c5; }
.site-footer__langs { display: flex; gap: 12px; list-style: none; margin: 0; padding: 0; }
.site-footer :focus-visible { outline-color: var(--gold); }
@media (min-width: 40rem) { .site-footer__grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 64rem) { .site-footer__grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }

/* ---------- Sections & shared blocks ---------- */
.section { padding-block: clamp(48px, 7vw, 96px); }
.section--tint { background: var(--paper-2); }
.section--tight { padding-block: clamp(32px, 5vw, 56px); }
.section-head { max-width: 62ch; margin-bottom: clamp(24px, 4vw, 40px); }
.section-head h2 { font-size: var(--step-3); }
.section-head p { margin-top: 12px; color: var(--ink-2); font-size: var(--step-1); }
.section-head--center { margin-inline: auto; text-align: center; }
.muted { color: var(--ink-2); }
.small { font-size: var(--step--1); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--green-tint); color: var(--green); font-size: .8rem; font-weight: 650; }
.pill--gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill--example { background: var(--gold-soft); color: var(--gold-ink); letter-spacing: .04em; text-transform: uppercase; font-size: .72rem; font-weight: 750; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; text-decoration: none; min-height: 44px; }
.link-arrow svg { width: 18px; height: 18px; transition: transform .3s var(--ease-out); }
.link-arrow:hover svg { transform: translateX(3px); }
[dir='rtl'] .link-arrow svg { transform: scaleX(-1); }
.stack > * + * { margin-top: 1em; }

/* ---------- Example challenge card (hero) ---------- */
.ex-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-3); padding: 18px 18px 16px; }
.ex-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ex-card h2 { font-size: 1.15rem; line-height: 1.2; }
.ex-card__sub { margin-top: 4px; font-size: .9rem; color: var(--ink-2); }
.ex-card dl { margin: 14px 0 0; display: grid; gap: 10px; }
.ex-card dl > div { display: grid; grid-template-columns: 34px 1fr; gap: 0 10px; align-items: start; }
.ex-card dt { grid-column: 2; font-size: .75rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.ex-card dd { grid-column: 2; margin: 0; font-weight: 600; line-height: 1.35; }
.ex-card__icon { grid-row: 1 / span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--green-tint); color: var(--green); }
.ex-card__icon--gold { background: var(--gold-soft); color: var(--gold-ink); }
.ex-card__icon svg { width: 19px; height: 19px; }

/* ---------- Cards / tiles ---------- */
.tiles { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .tiles--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 56rem) { .tiles--3 { grid-template-columns: repeat(3, 1fr); } .tiles--4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 72rem) { .tiles--4 { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-l); color: var(--ink); text-decoration: none; transition: border-color .25s, box-shadow .35s var(--ease-out), transform .35s var(--ease-out); }
a.tile:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.tile h3 { font-size: 1.3rem; }
.tile p { color: var(--ink-2); }
.tile .link-arrow { margin-top: auto; color: var(--green); min-height: 32px; }
.tile__mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--green-tint); color: var(--green); }
.tile__mark svg { width: 22px; height: 22px; }
.tile__mark--gold { background: var(--gold-soft); color: var(--gold-ink); }

/* ---------- Prose (guides) ---------- */
.article-layout { display: grid; gap: 40px; padding-bottom: 24px; }
@media (min-width: 64rem) { .article-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 64px; } .article-aside { order: 2; } }
.article-aside { align-self: start; }
@media (min-width: 64rem) { .article-aside { position: sticky; top: calc(var(--header-h) + 24px); } }
.prose { max-width: var(--measure); font-size: clamp(1.03rem, 1rem + .2vw, 1.12rem); line-height: 1.7; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 { font-size: var(--step-3); margin-top: 2em; scroll-margin-top: calc(var(--header-h) + 20px); }
.prose h3 { font-size: var(--step-2); margin-top: 1.6em; scroll-margin-top: calc(var(--header-h) + 20px); }
.prose h4 { font-family: var(--font-text); font-weight: 700; font-size: 1.05rem; margin-top: 1.4em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: .6em; }
.prose ul, .prose ol { padding-inline-start: 1.35em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--green-3); }
.prose strong { font-weight: 700; color: var(--ink); }
.prose blockquote { margin-inline: 0; padding: 14px 18px; border-radius: var(--radius); background: var(--paper-2); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2em; }
.prose .answer { padding: 18px 20px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-size: 1.08em; }
.prose .answer p + p { margin-top: .6em; }
.prose .note, .prose .example { padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); }
.prose .example { background: #fffaf0; border-color: #e8d6ad; }
.prose .example::before { content: 'Illustrative example'; display: block; margin-bottom: 6px; font-size: .74rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-ink); }
html[lang='ar'] .prose .example::before { content: 'مثال توضيحي'; letter-spacing: 0; }
html[lang='es'] .prose .example::before { content: 'Ejemplo ilustrativo'; }
html[lang='fr'] .prose .example::before { content: 'Exemple illustratif'; }
.prose .note { background: var(--green-tint); border-color: #c9d8cc; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.table-wrap:focus-visible { outline-offset: 2px; }
.prose table, table.data { width: 100%; border-collapse: collapse; font-size: .95em; line-height: 1.45; }
.prose th, .prose td, table.data th, table.data td { padding: 12px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose thead th, table.data thead th { background: var(--paper-2); font-weight: 700; font-size: .9em; }
.prose tr:last-child td, table.data tr:last-child td { border-bottom: 0; }
.prose td:first-child { font-weight: 600; }
.prose a { font-weight: 550; }
.prose code { font-size: .92em; background: var(--paper-2); padding: .1em .35em; border-radius: 4px; }

.toc { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--card); }
.toc h2 { font-family: var(--font-text); font-size: .8rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 7px 0; color: var(--ink-2); text-decoration: none; line-height: 1.35; font-size: .95rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.toc li:last-child a { border-bottom: 0; }
.toc a:hover, .toc a.is-active { color: var(--green); }
.toc details summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.toc details summary::-webkit-details-marker { display: none; }
.toc details summary svg { width: 18px; height: 18px; transition: transform .25s; }
.toc details[open] summary svg { transform: rotate(180deg); }
.aside-cta { margin-top: 16px; padding: 18px; border-radius: var(--radius-l); background: var(--green); color: #fff; }
.aside-cta p { color: #d9e6dc; font-size: .95rem; margin: 6px 0 14px; }
.aside-cta h2 { font-size: 1.2rem; color: #fff; }
.aside-cta .btn { --b-bg: var(--gold); --b-bd: var(--gold); --b-fg: #1b2a22; width: 100%; }
.aside-cta .btn:hover { --b-bg: #d8ad52; --b-bd: #d8ad52; }

.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 16px; font-size: .92rem; color: var(--ink-2); }
.byline a { color: var(--ink); }
.byline span + span::before { content: '·'; margin-inline-end: 14px; color: var(--line-2); }

.next-step { margin-top: 48px; display: grid; gap: 16px; padding: clamp(20px, 4vw, 32px); border-radius: var(--radius-l); background: var(--paper-2); border: 1px solid var(--line); }
@media (min-width: 48rem) { .next-step { grid-template-columns: 1fr auto; align-items: center; } }
.next-step h2 { font-size: var(--step-2); }
.next-step p { margin-top: 6px; color: var(--ink-2); }

.sources { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); font-size: .93rem; color: var(--ink-2); }
.sources h2 { font-family: var(--font-text); font-size: .85rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.sources ol { padding-inline-start: 1.2em; margin: 0; }
.sources li + li { margin-top: 8px; }

.related { margin-top: 40px; }
.related h2 { font-size: var(--step-2); margin-bottom: 16px; }

/* ---------- Reveal (one-shot, content visible by default) ---------- */
.will-reveal { opacity: 0; transform: translateY(18px); }
.will-reveal.is-in { opacity: 1; transform: none; transition: opacity .7s var(--ease-out), transform .8s var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .will-reveal { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast { position: fixed; inset-inline: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 90; margin-inline: auto; width: fit-content; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow-3); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .25s, transform .3s var(--ease-out); }
.toast:empty { display: none; }
.toast.is-on { opacity: 1; transform: none; }

/* ---------- Ads (only rendered when configured) ---------- */
.ad-slot { margin-block: 40px; padding: 10px 0 0; min-height: 300px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ad-slot__label { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); text-align: center; margin-bottom: 8px; }
.ad-slot--inFeed { min-height: 220px; margin-block: 0; border: 1px dashed var(--line-2); border-radius: var(--radius-l); padding: 12px; }
.ad-slot--multiplex { min-height: 380px; }
.ad-slot__box { display: grid; place-items: center; min-height: 250px; background: repeating-linear-gradient(45deg, var(--paper-2) 0 10px, var(--paper) 10px 20px); color: var(--ink-3); font-weight: 650; border-radius: var(--radius); }

/* ---------- Forms (shared by tools) ---------- */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label, .field legend { font-weight: 650; }
.field .hint { font-size: .9rem; color: var(--ink-2); }
.input, .select, .textarea { width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: var(--radius); background: #fff; color: var(--ink); transition: border-color .2s, box-shadow .2s; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.input[aria-invalid='true'] { border-color: var(--clay); }
.error-text { color: var(--clay); font-weight: 600; font-size: .92rem; }
::placeholder { color: #8b8f86; opacity: 1; }

/* Choice chips (checkbox / radio cards) */
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.choice { position: relative; display: flex; align-items: flex-start; gap: 10px; min-height: 56px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; transition: border-color .2s, background-color .2s, box-shadow .2s; }
.choice:hover { border-color: var(--line-2); }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice__box { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border: 1.5px solid var(--line-2); border-radius: 6px; background: #fff; transition: background-color .2s, border-color .2s; }
.choice__box svg { width: 16px; height: 16px; color: #fff; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .25s var(--ease-out); }
.choice--radio .choice__box { border-radius: 999px; }
.choice__text strong { display: block; font-weight: 650; line-height: 1.3; }
.choice__text span { display: block; font-size: .88rem; color: var(--ink-2); margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--green); background: #f3f7f2; box-shadow: inset 0 0 0 1px var(--green); }
.choice:has(input:checked) .choice__box { background: var(--green); border-color: var(--green); }
.choice:has(input:checked) .choice__box svg { opacity: 1; transform: none; }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Accordion (details) ---------- */
.acc { border-top: 1px solid var(--line); }
.acc details { border-bottom: 1px solid var(--line); }
.acc summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 14px 4px; cursor: pointer; list-style: none; font-family: var(--font-display); font-size: var(--step-1); }
.acc summary::-webkit-details-marker { display: none; }
.acc summary svg { flex: none; width: 22px; height: 22px; color: var(--green-3); transition: transform .3s var(--ease-out); }
.acc details[open] summary svg { transform: rotate(180deg); }
.acc .acc__body { padding: 0 4px 22px; max-width: var(--measure); color: var(--ink-2); }
.acc .acc__body > * + * { margin-top: .8em; }

/* ---------- Misc ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--green-tint); color: var(--ink); }
.notice svg { flex: none; width: 22px; height: 22px; color: var(--green); margin-top: 1px; }
.notice--warn { background: var(--clay-tint); }
.notice--warn svg { color: var(--clay); }
.kbd { font-size: .85em; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; background: #fff; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--paper-2); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 3px solid var(--paper-2); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
html { scrollbar-color: var(--line-2) var(--paper-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .skip, .ad-slot, .toast, .no-print { display: none !important; }
  body { background: #fff; }
}

/* ---------- Rule sheet (examples, builder preview, print) ---------- */
.rulesheet { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-2); overflow: hidden; }
.rulesheet__head { display: flex; justify-content: space-between; gap: 16px; padding: 20px 22px 16px; border-bottom: 1px dashed var(--line-2); background: linear-gradient(#fffcf6, #fbf6ec); }
.rulesheet__title { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.15; margin-top: 8px; }
.rulesheet__meta { margin-top: 4px; font-size: .9rem; color: var(--ink-2); }
.rulesheet__seal { flex: none; width: 52px; height: 52px; color: var(--gold); }
.rulesheet__body { padding: 6px 22px 20px; display: grid; gap: 0; }
.rulesheet__group { padding: 14px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.rulesheet__group:last-of-type { border-bottom: 0; }
.rulesheet__group h3 { display: flex; align-items: center; gap: 8px; font-family: var(--font-text); font-size: .78rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.rulesheet__group h3 svg { width: 18px; height: 18px; }
.rulesheet__group--paused h3 { color: var(--green); }
.rulesheet__group--allowed h3 { color: var(--green-3); }
.rulesheet__group--exceptions h3, .rulesheet__group--limits h3 { color: var(--gold-ink); }
.rulesheet__group ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.rulesheet__group li { position: relative; padding-inline-start: 18px; line-height: 1.4; }
.rulesheet__group li::before { content: ''; position: absolute; inset-inline-start: 2px; top: .62em; width: 7px; height: 7px; border-radius: 2px; background: var(--line-2); }
.rulesheet__group--paused li::before { background: var(--green); }
.rulesheet__group--allowed li::before { border-radius: 999px; background: var(--green-3); }
.rulesheet__intent { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--gold-soft); color: var(--ink); font-style: italic; }
.rulesheet__intent span { display: block; font-style: normal; font-size: .74rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-ink); margin-bottom: 2px; }
.rulesheet--compact .rulesheet__group li { font-size: .95rem; }
