/* Najm legal site (najm-legal.web.app) — shared styles for the hub, the
   Privacy Policy and the Terms of Use. Brand: deep navy + Najm orange.

   The hub (index.html) shares this file. Everything that only the legal
   documents use (sidebar contents, section links, dark mode, stacked tables
   on phones) is scoped to `html.doc-page`, and every colour token keeps its
   original light value, so the hub renders exactly as before. */
:root {
  --primary-color: #1a237e;
  --primary-light: #3949ab;
  --primary-dark: #000051;
  --primary-tint: #eef0fb;
  --accent-color: #F57D1F;
  --accent-hover: #e65100;
  --accent-tint: #fff4ea;
  --bg-color: #f5f6fa;
  --card-bg: #ffffff;
  --text-primary: #1c1f2e;
  --text-secondary: #5f6475;
  --border-color: #e3e6ef;
  --success-color: #2e7d32;
  --success-tint: #edf7ee;
  --warning-color: #b45309;
  --warning-tint: #fff7e6;

  /* Role tokens (light values = the colours used before they existed). */
  --heading-color: var(--primary-color);
  --link-color: var(--primary-light);
  --accent-text: var(--accent-hover);
  --surface-subtle: #fcfcfe;
  --summary-border: #d9ddf3;
  --summary-end: #fff;
  --outline-border: #c9cdea;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --footer-bg: #fff;
  --header-accent-text: #ffd2ad;

  --font-family: "Cairo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Roboto, "Helvetica Neue", sans-serif;
  --shadow-sm: 0 1px 2px rgba(16, 24, 64, 0.06), 0 1px 3px rgba(16, 24, 64, 0.08);
  --shadow-md: 0 6px 18px rgba(16, 24, 64, 0.08);
  --shadow-lg: 0 18px 40px rgba(16, 24, 64, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

/* Legal documents follow the device's light/dark setting. */
html.doc-page {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  html.doc-page {
    --primary-tint: #1d2340;
    --accent-tint: #2b1d10;
    --bg-color: #0e1120;
    --card-bg: #161a2c;
    --text-primary: #e6e8f2;
    --text-secondary: #a7acc2;
    --border-color: #2a3050;
    --success-color: #7cc785;
    --success-tint: #13261a;
    --warning-color: #f0b35a;
    --warning-tint: #2a2110;

    --heading-color: #c9cefa;
    --link-color: #a3adff;
    --accent-text: #ffb27a;
    --surface-subtle: #12162a;
    --summary-border: #2e3560;
    --summary-end: #161a2c;
    --outline-border: #3a4170;
    --nav-bg: rgba(14, 17, 32, 0.92);
    --footer-bg: #12152a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  }
}

/* Reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.85;
  font-size: 1.02rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[lang="en"] body,
body[lang="en"] {
  line-height: 1.7;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-text);
  text-decoration: underline;
}

a:focus-visible,
.btn:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Typography */
h1, h2, h3, h4 {
  color: var(--heading-color);
  font-weight: 800;
  line-height: 1.35;
}

h1 { font-size: 2.1rem; margin-bottom: var(--spacing-sm); }
h2 { font-size: 1.4rem; margin-bottom: var(--spacing-md); }
h3 { font-size: 1.1rem; font-weight: 700; margin: var(--spacing-lg) 0 var(--spacing-sm); }

p { margin-bottom: var(--spacing-md); }
ul, ol { margin-bottom: var(--spacing-md); padding-inline-start: 1.4rem; }
li { margin-bottom: 6px; }
li::marker { color: var(--accent-color); }
strong { color: var(--text-primary); font-weight: 700; }

code, .ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

/* Long e-mail addresses and links may wrap instead of widening the page. */
html.doc-page .ltr {
  overflow-wrap: anywhere;
}

/* Layout */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
}

/* Skip link: hidden until it receives keyboard focus. */
.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -100px;
  z-index: 200;
  background: var(--primary-color);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
  color: #fff;
  text-decoration: none;
}

/* Top navigation */
.navbar {
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  padding-top: 12px;
  padding-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.brand {
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--heading-color);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand:hover { text-decoration: none; color: var(--heading-color); }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 10px rgba(26, 35, 126, 0.3);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
}

.nav-link:hover {
  color: var(--heading-color);
  background: var(--primary-tint);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  color: var(--heading-color);
  background: var(--primary-tint);
}

.nav-link.lang-switch {
  border: 1px solid var(--border-color);
}

.nav-link.nav-cta {
  background: var(--accent-color);
  color: #fff;
}

.nav-link.nav-cta:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Hero header */
.header {
  background:
    radial-gradient(circle at 85% 15%, rgba(245, 125, 31, 0.22), transparent 45%),
    linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #fff;
  padding: 56px 24px 64px;
  text-align: center;
}

.header h1 {
  color: #fff;
  font-size: 2.6rem;
}

.header .subtitle {
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.1rem;
  max-width: 640px;
  margin: 0 auto;
}

.doc-header {
  background:
    radial-gradient(circle at 12% 20%, rgba(245, 125, 31, 0.2), transparent 40%),
    linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #fff;
  padding: 48px 0 72px;
}

.doc-header h1 { color: #fff; }

.doc-header .eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--header-accent-text);
  margin-bottom: 6px;
}

.doc-header .lead {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.08rem;
  max-width: 680px;
  margin-bottom: var(--spacing-md);
}

.doc-header .lead a {
  color: var(--header-accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.doc-header .lead a:hover { color: #fff; }

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

/* The document card overlaps the header */
.doc-main {
  margin-top: -48px;
}

/* Summary + table of contents */
.summary {
  background: linear-gradient(180deg, var(--primary-tint), var(--summary-end));
  border: 1px solid var(--summary-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.summary h2 {
  font-size: 1.15rem;
  margin-bottom: var(--spacing-sm);
}

.summary ul { margin-bottom: 0; }

.toc {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
  background: var(--surface-subtle);
}

.toc h2 {
  font-size: 1.05rem;
  margin-bottom: var(--spacing-sm);
}

.toc ol {
  columns: 2;
  column-gap: var(--spacing-xl);
  margin: 0;
  padding-inline-start: 1.3rem;
}

.toc li {
  break-inside: avoid;
  font-size: 0.95rem;
}

.toc a { color: var(--text-primary); }
.toc a:hover { color: var(--accent-text); }

/* Collapsible contents (<details>) in the legal documents. */
.toc details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.toc details > summary::-webkit-details-marker { display: none; }

.toc details > summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(45deg);
  margin-top: -6px;
  transition: transform 0.2s ease;
}

.toc details:not([open]) > summary::after {
  transform: rotate(-45deg);
  margin-top: 0;
}

[dir="rtl"] .toc details:not([open]) > summary::after {
  transform: rotate(135deg);
}

.toc details > summary h2 { margin-bottom: 0; }
.toc details[open] > summary { margin-bottom: var(--spacing-sm); }

/* Document sections */
.doc-section {
  padding-top: var(--spacing-lg);
  margin-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

.doc-section:first-of-type {
  border-top: none;
  margin-top: 0;
}

.doc-section h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.doc-section h2 .num {
  flex: none;
  min-width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-text);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* "#" direct link next to each section title. */
.anchor-link {
  margin-inline-start: auto;
  flex: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0 6px;
  border-radius: 6px;
  opacity: 0.45;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.doc-section h2:hover .anchor-link,
.anchor-link:focus-visible {
  opacity: 1;
}

.anchor-link:hover {
  color: var(--accent-text);
  text-decoration: none;
  opacity: 1;
}

.doc-section h3 {
  color: var(--heading-color);
}

/* Data tables (what we collect / who sees what) */
.table-wrap {
  overflow-x: auto;
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: start;
  vertical-align: top;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--primary-tint);
  color: var(--heading-color);
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

html.doc-page td:first-child {
  width: 30%;
}

/* Notice boxes */
.notice {
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  margin: var(--spacing-md) 0;
  border-inline-start: 4px solid var(--primary-light);
  background: var(--primary-tint);
}

.notice p:last-child,
.notice ul:last-child { margin-bottom: 0; }

.notice-title {
  display: block;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--heading-color);
}

.notice.important {
  border-inline-start-color: var(--accent-color);
  background: var(--accent-tint);
}

.notice.important .notice-title { color: var(--accent-text); }

.notice.warning {
  border-inline-start-color: var(--warning-color);
  background: var(--warning-tint);
}

.notice.warning .notice-title { color: var(--warning-color); }

.notice.ok {
  border-inline-start-color: var(--success-color);
  background: var(--success-tint);
}

.notice.ok .notice-title { color: var(--success-color); }

/* Contact block */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.contact-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  background: var(--surface-subtle);
}

.contact-item strong { display: block; color: var(--heading-color); }

/* Operator identity block (who runs Najm). */
.operator {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-sm) var(--spacing-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  background: var(--surface-subtle);
}

.operator dt {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.operator dd {
  font-weight: 700;
  margin-bottom: 0;
}

/* Hub (index) cards */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--spacing-lg);
  margin-top: -40px;
  margin-bottom: var(--spacing-lg);
}

.hub-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.hub-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0;
}

.hub-sub {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-text);
  margin-top: -4px;
}

.hub-desc {
  flex: 1;
  margin-bottom: var(--spacing-sm);
}

.hub-desc p {
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.7;
}

.hub-desc p[lang="en"] {
  font-size: 0.9rem;
}

.hub-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-tint);
  color: var(--primary-color);
}

.hub-icon svg { width: 24px; height: 24px; }

.hub-card.download .hub-icon {
  background: var(--accent-tint);
  color: var(--accent-hover);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background-color: var(--accent-color);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.btn.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--outline-border);
}

.btn.btn-outline:hover {
  background: var(--primary-tint);
  color: var(--primary-color);
}

.lang-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.25);
}

.btn-outline .lang-tag { background: var(--primary-tint); }

/* Footer */
.footer {
  text-align: center;
  padding: var(--spacing-xl) 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--border-color);
  margin-top: var(--spacing-xl);
  background: var(--footer-bg);
}

.footer p { margin-bottom: var(--spacing-sm); }

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  padding: 0;
  margin-bottom: var(--spacing-sm);
}

.footer-links li { margin: 0; }

.back-to-top {
  display: inline-block;
  margin-top: var(--spacing-md);
  font-weight: 700;
  font-size: 0.92rem;
}

/* Legal documents on wide screens: contents in a sticky sidebar at the
   start side (right in Arabic, left in English), text column beside it. */
@media (min-width: 1100px) {
  html.doc-page .container {
    max-width: 1160px;
  }

  html.doc-page .doc-card {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    column-gap: 40px;
    align-items: start;
  }

  html.doc-page .doc-card > .toc {
    grid-column: 1;
    grid-row: 1 / span 2;
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    margin-bottom: 0;
    padding: var(--spacing-md);
  }

  html.doc-page .doc-card > .summary,
  html.doc-page .doc-card > .doc-body {
    grid-column: 2;
  }

  html.doc-page .doc-card > .summary { grid-row: 1; }
  html.doc-page .doc-card > .doc-body { grid-row: 2; }

  html.doc-page .toc ol {
    columns: 1;
    padding-inline-start: 1.2rem;
  }

  html.doc-page .toc li {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 8px;
  }
}

/* Responsive */
@media (max-width: 720px) {
  body { font-size: 1rem; }
  h1 { font-size: 1.7rem; }
  .header h1 { font-size: 2rem; }
  .header { padding: 40px 16px 56px; }
  .doc-header { padding: 32px 0 64px; }
  .card { padding: var(--spacing-lg) var(--spacing-md); }
  .container { padding: var(--spacing-md); }
  .toc ol { columns: 1; }
  .nav-links { width: 100%; }
  th, td { padding: 10px; }

  /* Legal documents: a static top bar leaves the whole screen for text. */
  html.doc-page { scroll-padding-top: 16px; }
  html.doc-page .navbar { position: static; }
  html.doc-page .nav-link { white-space: nowrap; }
  html.doc-page .doc-section h2 { font-size: 1.25rem; }
  html.doc-page .anchor-link { opacity: 0.6; }
}

/* Phones: two-column tables become stacked cards. */
@media (max-width: 600px) {
  html.doc-page table.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  html.doc-page table.stack,
  html.doc-page table.stack tbody,
  html.doc-page table.stack tr,
  html.doc-page table.stack td {
    display: block;
    width: 100%;
  }

  html.doc-page table.stack tr {
    border-bottom: 1px solid var(--border-color);
    padding: 12px 14px;
  }

  html.doc-page table.stack tr:last-child { border-bottom: none; }

  html.doc-page table.stack td {
    border-bottom: none;
    padding: 0;
  }

  html.doc-page table.stack td:first-child {
    color: var(--heading-color);
    margin-bottom: 4px;
  }
}

@media print {
  .navbar, .toc, .back-to-top, .nav-links, .skip-link, .anchor-link { display: none; }
  .doc-header, .header { background: none; color: #000; padding: 0; }
  .doc-header h1, .doc-header .lead, .chip { color: #000; }
  .doc-main { margin-top: 0; }
  .card { box-shadow: none; border: none; }
  html.doc-page .doc-card { display: block; }
}
