/* Droid Arabic Naskh, hosted with the site (Apache 2.0). */
@font-face {
  font-family: "Droid Arabic Naskh";
  src: url("/fonts/DroidNaskh-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Droid Arabic Naskh";
  src: url("/fonts/DroidNaskh-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Every text colour reaches at least 4.5:1 against its background. */
:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --card: #ffffff;
  --hover: #f3efe6;
  --text: #1f2430;
  --muted: #5f6370;
  --line: #e4ded2;
  --edge: #8a8170;
  --accent: #1d4e6b;
  --focus: #c2410c;
  --facebook: #2f5ea8;
  --telegram: #17729f;
  --youtube: #b42a25;
  --chip: var(--bg);
  --on-accent: #fff;
  --on-accent-muted: #d6e2ea;
  --shadow: rgb(31 36 48 / 4%);
}

/* Chosen with the colour buttons at the top (theme.js); cream is the default. */
:root[data-theme="white"] {
  --bg: #ffffff;
  --hover: #f3f4f6;
  --line: #e3e5e9;
  --edge: #868b96;
  --chip: #f1f2f4;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141a26;
  --card: #1c2433;
  --hover: #243044;
  --text: #ece6d8;
  --muted: #a6adbb;
  --line: #2e3a4f;
  --edge: #6b7689;
  --accent: #8cc4e6;
  --focus: #fb923c;
  --chip: #141a26;
  --on-accent: #10151f;
  --on-accent-muted: #2a3a4a;
  --shadow: rgb(0 0 0 / 25%);
}

* { box-sizing: border-box; }

/* Jumps to a section stop below the sticky platform bar (its height comes from filter.js). */
html { scroll-padding-top: calc(var(--bar, 64px) + 12px); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* rem sizes follow the text size the reader set in the browser. */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Droid Arabic Naskh", "Noto Naskh Arabic", serif;
  font-size: 1.125rem;
  line-height: 1.8;
}

a { color: var(--accent); }

/* A clear ring around whatever the keyboard is on. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
main:focus { outline: none; }

/* Read by screen readers, not shown. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  top: 8px;
  inset-inline-start: 16px;
  z-index: 3;
  padding: 6px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.page-head {
  position: relative;
  padding: 24px 140px 4px;
  text-align: center;
}

/* The three colour buttons, in the top corner. */
.themes {
  position: absolute;
  top: 18px;
  inset-inline-end: 12px;
  display: flex;
  gap: 6px;
}
.theme {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.theme.cream { background: #f7f4ee; }
.theme.white { background: #ffffff; }
.theme.dark { background: #141a26; color: #ece6d8; }
.theme[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
h1 { margin: 0; font-size: 1.75rem; line-height: 1.5; color: var(--accent); }

/* The platform buttons stay at the top while scrolling. */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.filter::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.filter.facebook::before { background: var(--facebook); }
.filter.telegram::before { background: var(--telegram); }
.filter.youtube::before { background: var(--youtube); }
.filter:hover { background: var(--hover); }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.filter[aria-pressed="true"]::before { background: var(--on-accent); }
.filter .count { color: var(--muted); }
.filter[aria-pressed="true"] .count { color: var(--on-accent-muted); }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }

.contents, .section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px var(--shadow);
}
.contents h2, .section h2 { margin: 0 0 10px; font-size: 1.25rem; line-height: 1.6; }
.section h2 { padding-bottom: 8px; border-bottom: 2px solid var(--line); }

/* Each line of the contents is one link, its count included. */
.contents ol { list-style: none; margin: 0; padding: 0; }
.contents li { border-bottom: 1px dashed var(--line); }
.contents li:last-child { border-bottom: 0; }
/* No line under the last shown item when a filter hides the ones after it. */
.contents li:not(:has(~ li:not([hidden]))),
.links li:not(:has(~ li:not([hidden]))) { border-bottom: 0; }
.contents a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  text-decoration: none;
}
.contents a:hover { background: var(--hover); }
.contents a:hover .name { text-decoration: underline; }
.contents .name { flex: 1; }
.contents .count {
  flex: none;
  min-width: 2.5em;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}
.num { color: var(--muted); }

.links { list-style: none; margin: 0; padding: 0; }
.links li { border-bottom: 1px solid var(--line); }
.links li:last-child { border-bottom: 0; }
.links a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  text-decoration: none;
  min-width: 0;
}
.links a:hover { background: var(--hover); }
.links a:hover .url { text-decoration: underline; }

.badge {
  flex: none;
  min-width: 4.5em;
  text-align: center;
  font-size: 0.85rem;
  border-radius: 6px;
  padding: 0 8px;
  color: #fff;
}
.badge.facebook { background: var(--facebook); }
.badge.telegram { background: var(--telegram); }
.badge.youtube { background: var(--youtube); }

/* Long addresses are cut with "…"; the whole address is still the link. */
.url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--text);
  text-align: left;
}

.out {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: scaleX(-1);
}
.links a:hover .out { stroke: var(--accent); }

.top { margin: 10px 0 0; font-size: 0.9rem; }
.top a { text-decoration: none; }
.top a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

@media (max-width: 520px) {
  h1 { font-size: 1.35rem; }
  .page-head { padding: 10px 12px 4px; }
  /* On a phone the colour buttons sit on their own line above the title. */
  .themes { position: static; justify-content: flex-end; margin-bottom: 4px; }
  .filter-bar { padding: 8px 12px; }
  .filters { gap: 4px; }
  .filter { min-height: 40px; padding: 0 10px; gap: 6px; font-size: 0.9rem; }
  .filter::before { display: none; }
  main { padding: 16px 12px 32px; }
  .contents, .section { padding: 12px 14px; }
}

/* High-contrast modes (Windows): keep the chosen button and badges visible. */
@media (forced-colors: active) {
  .filter[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .filter[aria-pressed="true"] .count { color: HighlightText; }
  .badge { border: 1px solid; }
}

@media print {
  /* Printed in the default colours whatever was chosen on screen. */
  :root[data-theme] {
    color-scheme: light;
    --bg: #fff; --card: #fff; --text: #1f2430; --muted: #5f6370;
    --line: #e4ded2; --accent: #1d4e6b;
  }
  .skip, .themes, .filter-bar, .top, .out { display: none; }
  body { background: #fff; }
  .contents, .section { box-shadow: none; break-inside: avoid-page; }
  .url { white-space: normal; overflow-wrap: anywhere; }
}
