/* ─────────────────────────────────────────────────────────────────────
   Public legal landing pages — Trust & Authority style.
   Used by /legal/privacy, /legal/terms, /legal/delete-account.
   Self-contained, framework-free; loads instantly for store reviewers.
   ───────────────────────────────────────────────────────────────────── */

@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=Cairo:wght@400;500;600;700&display=swap");

:root {
  /* Trust & Authority — navy + slate, optional warm accent only on CTA */
  --bg:        #F6F7FB;     /* page background — softer than slate-50 */
  --bg-elev:   #FFFFFF;     /* cards, header */
  --bg-mute:   #F1F5F9;     /* subtle wells */
  --border:    #E2E8F0;     /* hairlines */
  --border-strong: #CBD5E1;

  --fg:        #0F172A;     /* primary text — slate-900 */
  --fg-muted:  #475569;     /* secondary — slate-600, AAA on white */
  --fg-soft:   #64748B;     /* tertiary — slate-500 */

  --primary:   #1E3A8A;     /* navy 800 — authority */
  --primary-hover: #1E40AF;
  --primary-soft:  #EFF4FF; /* slightly bluer than EFF6FF */
  --link:      #1D4ED8;
  --link-hover:#1E40AF;

  --accent:    #B45309;     /* warm amber — sparingly on CTA only */
  --danger:    #B91C1C;
  --success:   #047857;

  /* Type scale (modular, 1.25 ratio) */
  --font-serif: "EB Garamond", "Source Serif Pro", "Times New Roman", Georgia, serif;
  --font-sans:  "Inter", "Cairo", "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-arabic: "Cairo", "Tajawal", "Inter", system-ui, sans-serif;

  /* Layout */
  --shell-width: 1180px;
  --content-width: 68ch;       /* ~65–75 char optimal line length */
  --toc-width: 240px;
  --gap: 48px;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);

  --duration: 200ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[lang="ar"] body,
[dir="rtl"] body {
  font-family: var(--font-arabic);
}

/* Subtle page wash — adds depth, never distracts */
body {
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(30, 58, 138, 0.06), transparent 55%),
    radial-gradient(900px 500px at 95% 8%, rgba(180, 83, 9, 0.04), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

::selection {
  background: var(--primary);
  color: #fff;
}

/* ─── Outer shell ─────────────────────────────────────────────────── */

.legal-root {
  max-width: var(--shell-width);
  margin: 0 auto;
  padding: 0 24px 96px;
}

/* ─── Sticky header / toolbar ─────────────────────────────────────── */

.legal-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 24px;
  margin: 0 -24px 40px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 19px;
  color: var(--fg);
  letter-spacing: -0.01em;
  user-select: none;
}

[lang="ar"] .legal-brand,
[dir="rtl"] .legal-brand {
  font-family: var(--font-arabic);
  font-weight: 700;
}

.legal-brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  padding: 2px;
  border: 1px solid var(--border);
}

.legal-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.legal-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--duration) var(--ease),
              background var(--duration) var(--ease);
  cursor: pointer;
}

.legal-nav a:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.legal-nav a[aria-current="page"] {
  color: var(--primary);
  font-weight: 600;
}

.legal-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--primary);
}

.legal-lang-switch {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  font-size: 13px;
}

[dir="rtl"] .legal-lang-switch {
  margin-left: 0;
  margin-right: 8px;
  padding-left: 0;
  padding-right: 12px;
  border-left: none;
  border-right: 1px solid var(--border);
}

.legal-lang-switch a {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── Two-column layout (article + ToC) ───────────────────────────── */

.legal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

@media (min-width: 1024px) {
  .legal-layout {
    grid-template-columns: minmax(0, 1fr) var(--toc-width);
  }
}

.legal-content {
  max-width: 820px;          /* keeps measure comfortable on wide screens */
  width: 100%;
  margin: 0 auto;
  min-width: 0;              /* prevent overflow inside grid */
}

@media (min-width: 1024px) {
  .legal-content { margin: 0; max-width: none; }
}

/* ─── Hero card (title + meta) ───────────────────────────────────── */

.legal-hero {
  margin-bottom: 40px;
  padding: 32px 36px 28px;
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.legal-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(30, 58, 138, 0.05), transparent 50%),
    linear-gradient(225deg, rgba(180, 83, 9, 0.03), transparent 60%);
  pointer-events: none;
}

.legal-hero > * { position: relative; }

.legal-hero h1,
.legal-content h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin: 12px 0 20px;
}

[lang="ar"] .legal-hero h1,
[dir="rtl"] .legal-hero h1 {
  font-family: var(--font-arabic);
  font-weight: 700;
  letter-spacing: -0.005em;
  font-size: clamp(28px, 3.6vw, 38px);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(30, 58, 138, 0.15);
}

.hero-badge svg { flex-shrink: 0; }

.hero-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 24px;
  margin-top: 12px;
}

.hero-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-left: 3px solid var(--primary);
  background: var(--bg-mute);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

[dir="rtl"] .hero-chip {
  border-left: none;
  border-right: 3px solid var(--primary);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.hero-chip-key {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-soft);
}

.hero-chip-value {
  font-size: 14.5px;
  color: var(--fg);
  font-weight: 500;
  word-break: break-word;
}

.hero-chip-value a {
  color: var(--link);
  text-decoration: none;
}

.hero-chip-value a:hover {
  text-decoration: underline;
}

/* ─── Article body ────────────────────────────────────────────────── */

.legal-article {
  max-width: var(--content-width);
}

@media (min-width: 1024px) {
  .legal-article { max-width: var(--content-width); margin: 0; }
}

.legal-article h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(22px, 2.4vw, 26px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 56px 0 16px;
  padding-top: 28px;
  position: relative;
  scroll-margin-top: 100px;  /* sticky-header offset for #anchor links */
}

.legal-article h2::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
}

[dir="rtl"] .legal-article h2::before {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, var(--primary), transparent);
}

.legal-article > h2:first-of-type {
  margin-top: 8px;
}

[lang="ar"] .legal-article h2,
[dir="rtl"] .legal-article h2 {
  font-family: var(--font-arabic);
  font-weight: 700;
  letter-spacing: 0;
}

.legal-article h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.4;
  color: var(--fg);
  margin: 28px 0 8px;
}

[lang="ar"] .legal-article h3,
[dir="rtl"] .legal-article h3 {
  font-family: var(--font-arabic);
  font-weight: 700;
}

.legal-article p {
  font-size: 16px;
  line-height: 1.75;
  color: var(--fg);
  margin: 0 0 18px;
}

.legal-article p + p {
  margin-top: 0;
}

.legal-article ul,
.legal-article ol {
  padding-left: 24px;
  margin: 8px 0 22px;
}

[dir="rtl"] .legal-article ul,
[dir="rtl"] .legal-article ol {
  padding-left: 0;
  padding-right: 24px;
}

.legal-article li {
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  margin: 0 0 8px;
}

.legal-article li::marker {
  color: var(--fg-soft);
  font-weight: 500;
}

.legal-article strong {
  font-weight: 600;
  color: var(--fg);
}

.legal-article code {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
  font-size: 13.5px;
  background: var(--bg-mute);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.legal-article a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(29, 78, 216, 0.35);
  transition: color var(--duration) var(--ease),
              text-decoration-color var(--duration) var(--ease);
}

.legal-article a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

/* ─── Table of Contents (desktop only, sticky) ────────────────────── */

.legal-toc {
  display: none;
  position: sticky;
  top: 110px;
  align-self: start;
  padding: 22px 8px 22px 20px;
  border-left: 1px solid var(--border);
  font-size: 13.5px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

[dir="rtl"] .legal-toc {
  padding: 22px 20px 22px 8px;
  border-left: none;
  border-right: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .legal-toc:not([hidden]) { display: block; }
}

.toc-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-soft);
  margin: 0 0 14px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc-step;
}

.toc-list li { counter-increment: toc-step; margin: 0; }

.toc-list a {
  display: block;
  padding: 7px 12px 7px 14px;
  margin-left: -1px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              background var(--duration) var(--ease);
}

[dir="rtl"] .toc-list a {
  padding: 7px 14px 7px 12px;
  margin-left: 0;
  margin-right: -1px;
  border-left: none;
  border-right: 2px solid transparent;
}

.toc-list a:hover {
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
}

.toc-list a[aria-current="true"] {
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

[dir="rtl"] .toc-list a[aria-current="true"] {
  border-right-color: var(--primary);
}

/* ─── Loading state ───────────────────────────────────────────────── */

.legal-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-soft);
  font-size: 14px;
  padding: 40px 4px;
}

.legal-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.legal-error {
  padding: 20px;
  border-radius: var(--radius);
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--danger);
  font-weight: 500;
}

/* ─── Form (delete account) ───────────────────────────────────────── */

.legal-form-content > h1 + p {
  font-size: 17.5px;
  color: var(--fg-muted);
  line-height: 1.65;
  margin-bottom: 28px;
  max-width: var(--content-width);
}

.legal-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  margin: 24px 0 36px;
  max-width: var(--content-width);
}

.legal-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.legal-form label > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legal-form input,
.legal-form textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.legal-form input:hover,
.legal-form textarea:hover { border-color: var(--border-strong); }

.legal-form input:focus,
.legal-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.legal-form textarea { resize: vertical; min-height: 96px; }

.legal-form button {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--duration) var(--ease),
              transform var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  min-height: 44px;
}

.legal-form button:hover:not([disabled]) {
  background: var(--primary-hover);
  box-shadow: var(--shadow);
}

.legal-form button:active:not([disabled]) { transform: translateY(1px); }

.legal-form button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.25);
}

.legal-form button[disabled] {
  background: var(--fg-soft);
  border-color: var(--fg-soft);
  cursor: not-allowed;
  opacity: 0.7;
}

.legal-form-step {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.legal-form-step[hidden] { display: none; }

.legal-link-button {
  align-self: flex-start;
  background: transparent !important;
  color: var(--link) !important;
  border: none !important;
  padding: 4px 0 !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: auto !important;
  box-shadow: none !important;
  cursor: pointer;
}

.legal-link-button:hover:not([disabled]) {
  background: transparent !important;
  color: var(--link-hover) !important;
  box-shadow: none !important;
}

.legal-link-button[disabled] {
  background: transparent !important;
  color: var(--fg-soft) !important;
}

.legal-form-status {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: background var(--duration) var(--ease);
}

.legal-form-status:empty { display: none; }

.legal-form-status.ok {
  color: var(--success);
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
}

.legal-form-status.error {
  color: var(--danger);
  background: #FEF2F2;
  border: 1px solid #FECACA;
}

.legal-muted {
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: var(--content-width);
}

/* Numbered procedure list on the delete-account page */
.legal-form-content ol {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
  max-width: var(--content-width);
}

.legal-form-content ol > li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  padding-top: 4px;
  padding-bottom: 4px;
  margin-bottom: 14px;
  font-size: 15px;
  line-height: 1.65;
}

[dir="rtl"] .legal-form-content ol > li {
  padding-left: 0;
  padding-right: 48px;
}

.legal-form-content ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  border: 1.5px solid rgba(30, 58, 138, 0.18);
}

[dir="rtl"] .legal-form-content ol > li::before { left: auto; right: 0; }

/* ─── Footer ──────────────────────────────────────────────────────── */

.legal-footer {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  color: var(--fg-soft);
  font-size: 13.5px;
  text-align: center;
}

.legal-footer p { margin: 4px 0; }

.legal-footer a {
  color: var(--fg-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--duration) var(--ease);
}

.legal-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ─── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .legal-root { padding: 0 16px 64px; }
  .legal-toolbar {
    margin: 0 -16px 28px;
    padding: 12px 16px;
    gap: 10px;
  }
  .legal-brand { font-size: 17px; }
  .legal-brand img { width: 28px; height: 28px; }
  .legal-nav { gap: 2px; }
  .legal-nav a { padding: 6px 8px; font-size: 13px; }

  .legal-hero { padding: 24px 22px 22px; border-radius: var(--radius); }
  .legal-hero h1 { font-size: 26px; margin: 10px 0 16px; }
  .hero-chips { gap: 10px; }
  .hero-chip { padding: 8px 12px; }

  .legal-article h2 { font-size: 19px; margin-top: 40px; }
  .legal-article h2::before { width: 40px; }
  .legal-article p, .legal-article li { font-size: 15.5px; }

  .legal-form { padding: 20px; }
  .legal-form button { width: 100%; align-self: stretch; justify-content: center; }
  .legal-form-content > h1 + p { font-size: 16px; }
}

@media (max-width: 420px) {
  .legal-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .legal-nav { width: 100%; }
  .legal-hero { padding: 20px 18px; }
}

/* ─── Reduced motion ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Focus rings (keyboard a11y) ─────────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Print — clean version for legal record ─────────────────────── */

@media print {
  body { background: #fff; }
  .legal-toolbar,
  .legal-footer,
  .legal-form,
  .legal-toc { display: none; }
  .legal-root { max-width: 100%; padding: 0; }
  .legal-content { max-width: 100%; }
  .legal-hero {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-bottom: 24pt;
  }
  .legal-hero::before, .hero-badge { display: none; }
  .hero-chips { display: block; columns: 2; column-gap: 24pt; }
  .hero-chip {
    background: none;
    border: none;
    border-left: 2pt solid var(--fg);
    padding: 4pt 8pt;
  }
  .legal-article { font-size: 11pt; }
  .legal-article h1 { font-size: 22pt; }
  .legal-article h2 { font-size: 14pt; padding-top: 18pt; margin-top: 18pt; }
  .legal-article h2::before { display: none; }
  .legal-article a { color: var(--fg); text-decoration: none; }
  .legal-article a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: var(--fg-muted);
  }
}
