:root {
  --background: #faf8f4;
  --surface: #fffefb;
  --foreground: #1c1a17;
  --muted: #ece6d8;
  --muted-foreground: #78705f;
  --border: #e5decd;
  --camel: #a75721;
  --success: #3b7955;
  --destructive: #a43d34;
  --radius: 0.75rem;
  color-scheme: light;
}

.dark {
  --background: #161410;
  --surface: #211e18;
  --foreground: #f2ede2;
  --muted: #27231c;
  --muted-foreground: #a89e8b;
  --border: color-mix(in srgb, #f2ede2 12%, transparent);
  --camel: #cc785c;
  --success: #6fa88a;
  --destructive: #f57e71;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-underline-offset: 0.22em; }
button, input, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--camel); outline-offset: 3px; }
.skip-link {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 100;
  transform: translateY(-180%);
  border-radius: 0.55rem;
  background: var(--foreground);
  color: var(--surface);
  padding: 0.45rem 0.8rem;
}
.skip-link:focus { transform: translateY(0); }

header[data-scrolled] {
  border-color: var(--border) !important;
  background: color-mix(in srgb, var(--surface) 92%, transparent) !important;
  backdrop-filter: blur(14px);
}

.legal-shell { min-height: 100svh; display: flex; flex-direction: column; }
.legal-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  border-block-end: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
}
.legal-nav, .legal-footer__inner {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.legal-nav { min-height: 4rem; }
.legal-nav__links, .legal-footer__links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1rem; }
.legal-nav a, .legal-footer a { font-size: 0.82rem; color: var(--muted-foreground); }
.legal-nav a[aria-current="page"] { color: var(--foreground); font-weight: 600; text-decoration-thickness: 2px; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; font-weight: 650; }
.brand svg { width: 2rem; height: 1.5rem; }
.theme-button {
  min-width: 2.25rem;
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--surface);
  color: var(--foreground);
  cursor: pointer;
}
.legal-main { width: min(100% - 2rem, 47rem); margin-inline: auto; padding-block: clamp(3rem, 7vw, 6rem); flex: 1; }
.legal-kicker { margin: 0 0 0.75rem; color: var(--camel); font-size: 0.75rem; font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; }
.legal-main h1 { margin: 0; max-width: 18ch; font-size: clamp(2.2rem, 7vw, 4.4rem); line-height: 1.08; letter-spacing: -0.035em; }
[dir="rtl"] .legal-main h1 { letter-spacing: 0; }
.legal-lede { margin-block: 1.3rem 0; max-width: 63ch; color: var(--muted-foreground); font-size: 1.05rem; }
.legal-updated { margin-block: 1.15rem 0; font-size: 0.78rem; color: var(--muted-foreground); }
.legal-section { border-block-start: 1px solid var(--border); padding-block: 2rem; }
.legal-section:first-of-type { margin-block-start: 3rem; }
.legal-section h2 { margin: 0 0 0.8rem; font-size: 1.15rem; line-height: 1.35; }
.legal-section p { margin: 0.7rem 0; }
.legal-section ul { margin-block: 0.8rem; padding-inline-start: 1.25rem; }
.legal-section li + li { margin-block-start: 0.45rem; }
.legal-note { border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); padding: 1rem 1.15rem; }
.legal-table-wrap { overflow-x: auto; margin-block: 1rem; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.legal-table th, .legal-table td { padding: 0.75rem; border-block-end: 1px solid var(--border); text-align: start; vertical-align: top; }
.legal-table th { color: var(--muted-foreground); font-weight: 600; }
.legal-footer { border-block-start: 1px solid var(--border); background: var(--surface); }
.legal-footer__inner { min-height: 5rem; flex-wrap: wrap; padding-block: 1rem; }
.legal-footer small { color: var(--muted-foreground); }

.consent-row { display: flex; align-items: flex-start; gap: 0.65rem; text-align: start; }
.consent-row input { width: 1rem; height: 1rem; margin-block-start: 0.3rem; accent-color: var(--camel); }
[data-form-status] { min-height: 1.5em; }
[data-form-status][data-kind="success"] { color: var(--success); }
[data-form-status][data-kind="error"] { color: var(--destructive); }
[data-turnstile] { min-height: 1px; display: flex; justify-content: center; }

.not-found { min-height: 100svh; display: grid; place-items: center; padding: 1.5rem; }
.not-found__card { width: min(100%, 42rem); border: 1px solid var(--border); border-radius: 1.2rem; background: var(--surface); padding: clamp(1.5rem, 6vw, 4rem); text-align: center; }
.not-found__code { margin: 0; color: var(--camel); font: 600 clamp(3.5rem, 14vw, 7rem)/1 ui-monospace, monospace; }
.not-found h1 { margin-block: 1rem 0.4rem; font-size: clamp(1.5rem, 5vw, 2.5rem); }
.not-found p { color: var(--muted-foreground); }
.not-found__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-block-start: 1.5rem; }
.not-found__links a { border: 1px solid var(--border); border-radius: 0.7rem; padding: 0.55rem 0.9rem; background: var(--background); text-decoration: none; }

@media (max-width: 48rem) {
  .legal-nav { align-items: flex-start; padding-block: 0.8rem; }
  .legal-nav__links { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
