/*!
 * Meyar Almoallem — Privacy Policy page stylesheet (standalone, dedicated to privacy.html)
 * Vanilla CSS, no build step, no framework. Source of truth for content:
 * PRIVACY_POLICY.md — this file only styles the rendered markup, never the words.
 */

/* ------------------------------------------------------------------ */
/* 1. Fonts                                                            */
/* ------------------------------------------------------------------ */

@font-face {
  font-family: "Tajawal";
  src: url("../fonts/Tajawal-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Tajawal";
  src: url("../fonts/Tajawal-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Tajawal";
  src: url("../fonts/Tajawal-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Variable.woff2") format("woff2-variations"), url("../fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ */
/* 2. Design tokens                                                    */
/* ------------------------------------------------------------------ */

:root {
  --primary: #1565d8;
  --primary-600: #1155ba;
  --primary-700: #0d3e8f;
  --primary-50: #eaf1fd;

  --green: #43a047;
  --green-50: #e7f6e8;
  --orange: #fb8c00;
  --orange-50: #fff2e1;
  --purple: #8e24aa;

  --ink: #1a2233;
  --ink-soft: #48566b;
  --muted: #5b6b82;
  --line: rgba(26, 34, 51, 0.1);
  --surface: #ffffff;
  --bg: #f6f8fc;

  --font-ar: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-en: "Inter", "Segoe UI", Tahoma, Arial, sans-serif;

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 3px rgba(26, 34, 51, 0.07);
  --shadow-sm: 0 6px 18px rgba(26, 34, 51, 0.08);
  --shadow-md: 0 14px 36px rgba(26, 34, 51, 0.12);

  --header-h: 68px;
  --toolbar-h: 52px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

@media (prefers-contrast: more) {
  :root {
    --muted: #3d4a5c;
    --line: rgba(26, 34, 51, 0.24);
  }
}

/* ------------------------------------------------------------------ */
/* 3. Reset & base                                                     */
/* ------------------------------------------------------------------ */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ar);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
  min-height: 100vh;
}

[lang="en"] {
  font-family: var(--font-en);
}

img {
  max-width: 100%;
  display: block;
}

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

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 0.6em;
}

p {
  margin: 0 0 1em;
}

ul,
ol {
  margin: 0 0 1em;
  padding-inline-start: 1.4em;
}

button {
  font-family: inherit;
}

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

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -48px;
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  z-index: 1200;
  transition: top 0.15s var(--ease);
}

.skip-link:focus {
  top: 12px;
}

/* ------------------------------------------------------------------ */
/* 4. Reading progress bar                                             */
/* ------------------------------------------------------------------ */

.progress-track {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 1100;
  background: transparent;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  transition: width 0.1s linear;
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar {
    transition: none;
  }
}

/* ------------------------------------------------------------------ */
/* 5. Header                                                           */
/* ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-block: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  flex: none;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.page-title p {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-title .divider {
  color: var(--line);
}

.page-title .en-cap {
  font-family: var(--font-en);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.updated-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-50);
  color: var(--green);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex: none;
}

.updated-badge svg {
  width: 14px;
  height: 14px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: none;
}

.main-nav a {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 14.5px;
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.main-nav a:hover,
.main-nav a:focus-visible {
  color: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
}

.main-nav a[aria-current="page"] {
  color: var(--primary);
  border-color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.icon-btn[aria-expanded="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  position: relative;
  transition: transform 0.2s var(--ease);
}

.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
}

.nav-toggle span::before {
  top: -7px;
}

.nav-toggle span::after {
  top: 7px;
}

/* ---- Search panel ---- */

.search-panel {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 0;
}

.search-panel[hidden] {
  display: none;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  max-width: 640px;
  margin-inline: auto;
}

.search-field svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: none;
}

.search-field input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  outline: none;
  min-width: 0;
}

.search-status {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}

.search-nav {
  display: flex;
  gap: 4px;
  flex: none;
}

.search-nav button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-nav button:hover,
.search-nav button:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

mark[data-search-mark] {
  background: #ffe699;
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

mark[data-search-mark].is-current {
  background: var(--orange);
  color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* 6. Toolbar (reading time + utilities)                               */
/* ------------------------------------------------------------------ */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-block: 16px;
  color: var(--muted);
  font-size: 13.5px;
}

.reading-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.reading-meta svg {
  width: 15px;
  height: 15px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* 7. Layout                                                           */
/* ------------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  align-items: start;
  padding-bottom: 100px;
}

/* ---- TOC ---- */

.toc-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.toc-sidebar > summary {
  cursor: pointer;
  list-style: none;
  padding: 18px 20px;
  font-weight: 700;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
}

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

.toc-sidebar > summary .chevron {
  transition: transform 0.2s var(--ease);
  color: var(--muted);
}

.toc-sidebar[open] > summary .chevron {
  transform: rotate(180deg);
}

.toc-body {
  padding: 20px;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
}

.toc-group-label {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

.toc-group-label:first-child {
  margin-top: 0;
}

.toc-body ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.toc-body a {
  display: block;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 8px;
  line-height: 1.4;
}

.toc-body a:hover,
.toc-body a:focus-visible {
  background: var(--bg);
  color: var(--primary);
}

.toc-body a.is-active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* 8. Document article                                                 */
/* ------------------------------------------------------------------ */

.doc {
  min-width: 0;
}

.lang-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 48px;
}

.doc-hero {
  margin-bottom: 8px;
  padding-bottom: 28px;
  border-bottom: 2px solid var(--primary-50);
}

.doc-hero h1 {
  font-size: clamp(24px, 3vw, 32px);
  color: var(--primary);
}

.doc-hero p {
  margin-bottom: 12px;
}

.doc-hero blockquote {
  margin: 0;
}

.doc-section {
  padding-top: 40px;
  scroll-margin-top: calc(var(--header-h) + var(--toolbar-h) + 20px);
}

.doc-section h2 {
  font-size: 20px;
  color: var(--primary);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.doc-section p,
.doc-section li {
  color: var(--ink);
  font-size: 15.5px;
}

.doc-section strong {
  color: var(--ink);
  font-weight: 700;
}

.doc-section code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--primary-50);
  color: var(--primary-700);
  padding: 0.15em 0.45em;
  border-radius: 6px;
  direction: ltr;
  unicode-bidi: embed;
}

.doc-section pre {
  background: var(--ink);
  color: #fff;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  direction: ltr;
}

.doc-section pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.doc-section ul li {
  margin-bottom: 8px;
}

.doc-section ul ul,
.doc-section ol ol {
  margin-top: 8px;
}

.doc-section blockquote {
  background: var(--primary-50);
  border-inline-start: 4px solid var(--primary);
  padding: 16px 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--primary-700);
  font-weight: 500;
  margin: 0 0 1em;
}

[dir="rtl"] .doc-section blockquote {
  border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.doc-section hr.doc-hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent 70%);
  margin: 32px 0 0;
}

/* ---- Tables ---- */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.2em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.doc-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

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

.doc-section thead th {
  background: var(--bg);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.doc-section tbody tr:last-child th,
.doc-section tbody tr:last-child td {
  border-bottom: none;
}

.doc-section tbody tr:hover {
  background: var(--bg);
}

/* Card-style stacked table for narrow screens */
@media (max-width: 640px) {
  .doc-section table,
  .doc-section thead,
  .doc-section tbody,
  .doc-section th,
  .doc-section td,
  .doc-section tr {
    display: block;
  }

  .doc-section thead {
    display: none;
  }

  .doc-section tr {
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }

  .doc-section tr:last-child {
    border-bottom: none;
  }

  .doc-section td {
    border: none;
    padding: 6px 0;
    display: flex;
    gap: 8px;
  }

  .doc-section td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    flex: none;
    min-width: 40%;
  }
}

/* ---- Language divider ---- */

.lang-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 40px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lang-divider::before,
.lang-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ------------------------------------------------------------------ */
/* 9. Back to top                                                      */
/* ------------------------------------------------------------------ */

.back-to-top {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), background-color 0.2s var(--ease);
  z-index: 500;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--primary-600);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* ------------------------------------------------------------------ */
/* 10. Footer                                                          */
/* ------------------------------------------------------------------ */

.site-footer {
  background: linear-gradient(180deg, var(--ink), #0b1730);
  color: rgba(255, 255, 255, 0.75);
  padding: 48px 0 26px;
  font-size: 14px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.footer-brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.footer-meta {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.footer-meta strong {
  color: rgba(255, 255, 255, 0.88);
}

.footer-meta a {
  color: inherit;
}

.footer-meta a:hover,
.footer-meta a:focus-visible {
  color: #fff;
}

.footer-nav {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-nav a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 13.5px;
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: #fff;
}

.footer-bottom {
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.5);
}

/* ------------------------------------------------------------------ */
/* 11. Responsive                                                      */
/* ------------------------------------------------------------------ */

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    position: static;
    margin-bottom: 24px;
  }

  .toc-sidebar > summary {
    display: flex;
  }

  .toc-body {
    max-height: 50vh;
  }

  .toc-sidebar:not([open]) .toc-body {
    display: none;
  }

  .lang-block {
    padding: 32px 24px;
  }

  .page-title .en-cap {
    display: none;
  }
}

@media (max-width: 720px) {
  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 20px 20px;
    box-shadow: var(--shadow-md);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
  }

  .main-nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .main-nav a {
    padding: 14px 4px;
    border-bottom: 1px solid var(--line);
  }

  .nav-toggle {
    display: block;
  }

  .updated-badge {
    display: none;
  }

  .lang-block {
    padding: 26px 18px;
    border-radius: var(--radius-md);
  }

  .back-to-top {
    bottom: 16px;
    inset-inline-end: 16px;
    width: 44px;
    height: 44px;
  }
}

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

  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------ */
/* 12. Print                                                           */
/* ------------------------------------------------------------------ */

@media print {
  .site-header,
  .site-footer,
  .toc-sidebar,
  .toolbar,
  .back-to-top,
  .progress-track,
  .skip-link {
    display: none !important;
  }

  .layout {
    display: block;
    padding: 0;
  }

  .lang-block {
    box-shadow: none;
    border: none;
    padding: 0;
    page-break-after: always;
  }

  .doc-section {
    break-inside: avoid;
  }

  .table-wrap {
    break-inside: avoid;
  }

  body {
    background: #fff;
  }

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