/* ==========================================================================
   The Islamic Software Licenses — islamiclicense.org
   Illuminated-manuscript editorial: ivory paper, emerald ink, gold leaf,
   madder rubrication for restrictions. No frameworks.
   ========================================================================== */

:root {
  --paper: #f6efe1;
  --paper-deep: #eee3cb;
  --paper-edge: #e3d4b4;
  --ink: #1e2a24;
  --ink-soft: #47554d;
  --emerald: #14594a;
  --emerald-deep: #0d3f34;
  --gold: #a9822f;
  --gold-bright: #c9a44f;
  --gold-pale: #e6d5a8;
  --madder: #8c352a;
  --madder-soft: #f3e2dc;

  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Source Serif 4", "Georgia", serif;
  --font-arabic: "Amiri", serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;

  --measure: 46rem;
  --wide: 72rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--paper);
  /* faint laid-paper grain */
  background-image:
    repeating-linear-gradient(0deg, rgba(30, 42, 36, 0.018) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% -20%, rgba(201, 164, 79, 0.10), transparent 60%);
}

::selection { background: var(--gold-pale); color: var(--emerald-deep); }

/* ---------- girih star band ---------------------------------------------- */

.girih {
  height: 14px;
  background-color: var(--emerald-deep);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='14' viewBox='0 0 28 14'%3E%3Cg fill='none' stroke='%23c9a44f' stroke-width='1'%3E%3Cpath d='M7 0 L14 7 L7 14 L0 7 Z'/%3E%3Cpath d='M21 0 L28 7 L21 14 L14 7 Z'/%3E%3Ccircle cx='7' cy='7' r='2'/%3E%3Ccircle cx='21' cy='7' r='2'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- header / nav -------------------------------------------------- */

header.site {
  border-bottom: 1px solid var(--paper-edge);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 2rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--emerald-deep);
  text-decoration: none;
}
.brand .star { color: var(--gold); }

nav.primary { margin-left: auto; display: flex; gap: 1.4rem; }
nav.primary a {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
  transition: color 160ms ease, border-color 160ms ease;
}
nav.primary a:hover { color: var(--emerald); border-color: var(--gold-bright); }
nav.primary a[aria-current="page"] { color: var(--emerald-deep); border-color: var(--gold); }

/* ---------- hero ----------------------------------------------------------- */

.hero {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 5rem 1.5rem 3.5rem;
  text-align: center;
}

.bismillah {
  font-family: var(--font-arabic);
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 1.75rem;
  animation: rise 700ms ease-out both;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 600;
  line-height: 1.08;
  color: var(--emerald-deep);
  letter-spacing: -0.015em;
  animation: rise 700ms ease-out 120ms both;
}

.hero .kicker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--madder);
  margin-bottom: 1.1rem;
  animation: rise 700ms ease-out 60ms both;
}

.hero .lede {
  max-width: 38rem;
  margin: 1.6rem auto 0;
  font-size: 1.2rem;
  color: var(--ink-soft);
  animation: rise 700ms ease-out 220ms both;
}

.hero .actions {
  margin-top: 2.4rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  animation: rise 700ms ease-out 320ms both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bismillah, .hero h1, .hero .kicker, .hero .lede, .hero .actions { animation: none; }
}

/* ---------- buttons -------------------------------------------------------- */

.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 0.7rem 1.6rem;
  border-radius: 2px;
  text-decoration: none;
  border: 1px solid var(--emerald-deep);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(13, 63, 52, 0.18); }
.btn.solid { background: var(--emerald-deep); color: var(--paper); }
.btn.solid:hover { background: var(--emerald); }
.btn.ghost { color: var(--emerald-deep); background: transparent; }

/* ---------- honesty banner ------------------------------------------------- */

.honesty {
  max-width: var(--measure);
  margin: 0 auto 3.5rem;
  padding: 1.1rem 1.5rem;
  border: 1px solid var(--gold-pale);
  border-left: 4px solid var(--madder);
  background: var(--madder-soft);
  font-size: 0.98rem;
  color: var(--ink);
}
.honesty strong { color: var(--madder); }

/* ---------- ornamental divider --------------------------------------------- */

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--measure);
  margin: 3.5rem auto;
  color: var(--gold);
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--gold-pale);
}
.divider span { font-size: 1.1rem; letter-spacing: 0.5em; }

/* ---------- license chooser cards ------------------------------------------ */

.chooser {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.chooser h2, .section-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 600;
  color: var(--emerald-deep);
  text-align: center;
  margin-bottom: 0.6rem;
}
.chooser .sub {
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 2.5rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 1.4rem;
}

.card {
  position: relative;
  background: #fbf7ec;
  border: 1px solid var(--paper-edge);
  border-top: 3px solid var(--gold);
  padding: 1.8rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 0 rgba(30, 42, 36, 0.05);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(13, 63, 52, 0.12); }

.card .spdx {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--emerald-deep);
  margin-bottom: 0.7rem;
}
.card p { font-size: 0.95rem; color: var(--ink-soft); flex: 1; }
.card ul {
  list-style: none;
  margin: 1rem 0 1.3rem;
  font-size: 0.9rem;
}
.card ul li { padding: 0.28rem 0 0.28rem 1.4rem; position: relative; }
.card ul li::before { content: "✦"; position: absolute; left: 0; color: var(--gold); font-size: 0.7rem; top: 0.55rem; }
.card ul li.no { color: var(--madder); }
.card ul li.no::before { content: "✕"; color: var(--madder); }
.card .btn { text-align: center; }

.card.featured { border-top-color: var(--madder); }
.card.featured .spdx { color: var(--madder); }

/* ---------- comparison table ------------------------------------------------ */

.compare { max-width: var(--wide); margin: 0 auto; padding: 1rem 1.5rem 4rem; overflow-x: auto; }

table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  background: #fbf7ec;
  border: 1px solid var(--paper-edge);
}
table.matrix th, table.matrix td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--paper-edge);
  text-align: center;
}
table.matrix th {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--emerald-deep);
  background: var(--paper-deep);
}
table.matrix td:first-child, table.matrix th:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
}
table.matrix .yes { color: var(--emerald); font-weight: 700; }
table.matrix .no  { color: var(--madder); font-weight: 700; }

/* ---------- prose pages (FAQ, how-to-apply, license bodies) ----------------- */

main.prose {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 5rem;
}

main.prose > h1, article.license > h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  color: var(--emerald-deep);
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

main.prose h2, article.license h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--emerald-deep);
  margin: 2.6rem 0 0.9rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--gold-pale);
}
main.prose h3, article.license h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin: 1.8rem 0 0.6rem;
}

main.prose p, article.license p { margin-bottom: 1rem; }
main.prose ul, main.prose ol, article.license ul, article.license ol { margin: 0 0 1rem 1.4rem; }
main.prose li, article.license li { margin-bottom: 0.35rem; }

main.prose a, article.license a { color: var(--emerald); text-decoration-color: var(--gold-bright); text-underline-offset: 3px; }
main.prose a:hover, article.license a:hover { color: var(--emerald-deep); }

/* Quranic / scriptural quotation — gilded */
blockquote {
  font-family: var(--font-arabic);
  font-size: 1.18rem;
  font-style: italic;
  color: var(--emerald-deep);
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, rgba(201, 164, 79, 0.10), transparent 70%);
  padding: 0.9rem 1.3rem;
  margin: 1.4rem 0;
}
blockquote p { margin: 0; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-deep);
  border: 1px solid var(--paper-edge);
}
code { padding: 0.1em 0.4em; border-radius: 2px; }
pre {
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  margin: 1.2rem 0;
  line-height: 1.55;
}
pre code { background: none; border: none; padding: 0; }

/* ---------- license article specifics ---------------------------------------- */

.license-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border: 1px solid var(--paper-edge);
  background: var(--paper-deep);
  padding: 0.8rem 1.1rem;
  margin: 1.4rem 0 2.2rem;
}
.license-meta strong { color: var(--emerald-deep); }
.license-meta a { color: var(--madder); }

/* rubricated restriction sections (Sections 4–5): red-ink manuscript warnings */
article.license .rubric {
  border-top-color: var(--madder);
  color: var(--madder);
}
article.license .rubric-block h3 { color: var(--madder); }

.toc {
  border: 1px solid var(--paper-edge);
  background: #fbf7ec;
  padding: 1.2rem 1.5rem;
  margin: 0 0 2.5rem;
  font-size: 0.92rem;
}
.toc strong {
  font-family: var(--font-display);
  color: var(--emerald-deep);
  display: block;
  margin-bottom: 0.5rem;
}
.toc ol { margin: 0 0 0 1.2rem; columns: 2; column-gap: 2.5rem; }
@media (max-width: 40rem) { .toc ol { columns: 1; } }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--emerald); }

/* ---------- FAQ -------------------------------------------------------------- */

details.faq {
  border: 1px solid var(--paper-edge);
  background: #fbf7ec;
  margin-bottom: 0.9rem;
}
details.faq summary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  color: var(--emerald-deep);
  padding: 1rem 1.3rem;
  cursor: pointer;
  list-style: none;
  position: relative;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "✦";
  position: absolute;
  right: 1.2rem;
  color: var(--gold);
  transition: transform 200ms ease;
}
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq .answer { padding: 0 1.3rem 1.2rem; color: var(--ink-soft); }
details.faq .answer p { margin-bottom: 0.7rem; }

/* ---------- footer ------------------------------------------------------------ */

footer.site {
  margin-top: 2rem;
  background: var(--emerald-deep);
  color: var(--gold-pale);
  font-size: 0.9rem;
}
.footer-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.6rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 2rem;
}
footer.site h4 {
  font-family: var(--font-display);
  color: var(--paper);
  margin-bottom: 0.7rem;
  font-size: 1rem;
}
footer.site a { color: var(--gold-bright); text-decoration: none; }
footer.site a:hover { text-decoration: underline; }
footer.site ul { list-style: none; }
footer.site li { margin-bottom: 0.35rem; }
.footer-legal {
  border-top: 1px solid rgba(201, 164, 79, 0.25);
  padding: 1.2rem 1.5rem 1.6rem;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(230, 213, 168, 0.75);
}

/* ---------- utility ------------------------------------------------------------ */

.small { font-size: 0.85rem; color: var(--ink-soft); }
.center { text-align: center; }

/* ==========================================================================
   Notice generator (how-to-apply page) — form, inputs, and output blocks
   ========================================================================== */

.generator-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
  margin: 1.6rem 0 2rem;
  padding: 1.3rem 1.5rem;
  border: 1px solid var(--paper-edge);
  background: var(--paper-deep);
}

.generator-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.generator-form label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--emerald-deep);
}

.generator-form select,
.generator-form input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  padding: 0.5rem 0.6rem;
}

.generator-form select:focus,
.generator-form input:focus {
  outline: 2px solid var(--gold-bright);
  outline-offset: 1px;
}

.btn.ghost.small {
  font-size: 0.82rem;
  padding: 0.4rem 1rem;
  margin: -0.6rem 0 1.6rem;
}

/* ==========================================================================
   RTL support (Arabic pages) — overrides scoped to [dir="rtl"], set on <html>
   for content/ar/*.md output. Structure and specificity mirror the LTR rules
   above; only direction-sensitive properties are touched.
   ========================================================================== */

[dir="rtl"] body {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  line-height: 1.9;
}

/* Honesty banner: accent border moves from left edge to right edge */
[dir="rtl"] .honesty {
  border-left: 1px solid var(--gold-pale);
  border-right: 4px solid var(--madder);
}

/* Blockquote: accent border and gilded gradient mirror to the right */
[dir="rtl"] blockquote {
  border-left: none;
  border-right: 3px solid var(--gold);
  background: linear-gradient(270deg, rgba(201, 164, 79, 0.10), transparent 70%);
}

/* License chooser card list markers: bullet and indent flip to the right */
[dir="rtl"] .card ul li { padding: 0.28rem 1.4rem 0.28rem 0; }
[dir="rtl"] .card ul li::before { left: auto; right: 0; }

/* License metadata strip and table of contents: right-aligned reading order */
[dir="rtl"] .license-meta { text-align: right; }
[dir="rtl"] .toc { text-align: right; }
[dir="rtl"] .toc ol { margin: 0 1.2rem 0 0; }

/* Identifiers and code stay LTR even inside an RTL page */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] .spdx {
  direction: ltr;
  text-align: left;
}
