/* Maroc-SaaS landing — self-hosted, no external CDNs/fonts. System font
   stack chosen for solid Arabic + Latin coverage without a webfont download.
   Uses CSS logical properties throughout so the SAME rules serve both
   dir="rtl" (ar) and dir="ltr" (fr/en/es) pages without duplication. */

:root {
  --teal-900: #0d3f3c;
  --teal-700: #146d66;
  --teal-500: #1f8c82;
  --terracotta-600: #c1602f;
  --terracotta-500: #d97a44;
  --brass-500: #b8923f;
  --brass-300: #e0c98a;
  --cream-50: #faf6ee;
  --cream-100: #f3ead9;
  --ink-900: #211d16;
  --ink-700: #4a4438;
  --ink-500: #6f6858;
  --white: #ffffff;
  --line: #e4dac2;
  --shadow: 0 12px 32px -18px rgba(13, 63, 60, 0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  /* -------------------------------------------------------- button tokens
     Owner-reported bug (2026-07-16, D46, both 390px + 1440px): teal/green
     buttons blended into the teal-tinted cream backgrounds; outline
     ("ghost") buttons nearly vanished. One token pass, verified against
     WCAG contrast math (see tests/leadbot_gate.mjs's computed-style
     assertions): every button below clears >=4.5:1 text contrast AND
     >=3:1 button-vs-page-background contrast at both viewports.
       - --btn-primary-bg (#0d3f3c, i.e. --teal-900) vs white text: 11.7:1
       - --btn-secondary-bg is a DARKENED terracotta (not --terracotta-500,
         which only clears 3.08:1 with white text -- fails AA); this ink
         darkens it to clear 5.8:1 text / 5.4:1 vs --cream-50.
       - --btn-ghost is no longer transparent-on-wash (unmeasurable/
         disappearing against the hero teal wash) -- solid opaque fill +
         2px border, same math as primary.
       - --btn-whatsapp is a dedicated darkened WhatsApp green (brighter
         brand green #25D366 only clears ~2:1) so it stays recognizable
         AND accessible. */
  --btn-primary-bg: var(--teal-900);
  --btn-primary-bg-hover: var(--teal-700);
  --btn-primary-text: var(--white);
  --terracotta-ink: #a8481f;
  --terracotta-ink-hover: #8a3a18;
  --btn-whatsapp-bg: #0b7a55;
  --btn-whatsapp-bg-hover: #086847;
  --shadow-btn: 0 10px 24px -10px rgba(13, 63, 60, 0.55), 0 2px 6px -1px rgba(13, 63, 60, 0.3);
  --font-sans:
    "Segoe UI", "Noto Naskh Arabic", "Geeza Pro", "Tahoma", system-ui,
    -apple-system, "Helvetica Neue", Arial, sans-serif;
  /* Display face for headings on the Latin-script pages (fr/en/es) — a
     serif carries the "official record" register of a court filing without
     resorting to a webfont. Arabic pages keep the sans stack throughout
     (see :lang(ar) override below): system Arabic serifs are unreliable
     across platforms, and Naskh-style sans reads more legible at heading
     sizes anyway. */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Naskh Arabic", var(--font-sans);
  --container: 1180px;
}

* { box-sizing: border-box; }
/* Explicit override: several elements toggled via the `hidden` attribute
   (.card-form, .chat-panel) also carry a class that sets `display` for
   their visible state, which otherwise beats the UA [hidden] rule in the
   cascade (author > UA at equal specificity). */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink-900);
  background: var(--cream-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; color: var(--teal-900); font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 1.5rem + 2vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.3rem); }
h3 { font-size: 1.2rem; font-family: var(--font-sans); letter-spacing: 0; }
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3 { font-family: var(--font-sans); letter-spacing: 0; }
p { margin: 0 0 1em; }
a { color: inherit; }
.wrap { max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }

.skip-link {
  position: absolute;
  inset-inline-start: -999px;
  top: 0;
  background: var(--teal-900);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  z-index: 200;
  border-end-end-radius: var(--radius-sm);
}
.skip-link:focus { inset-inline-start: 0; }

:focus-visible { outline: 3px solid var(--brass-500); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 246, 238, 0.92);
  backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 1.5rem; padding-block: 0.85rem; }
.brand { display: flex; align-items: center; gap: 0.65rem; text-decoration: none; font-weight: 800; font-size: 1.15rem; color: var(--teal-900); font-family: var(--font-display); }
:lang(ar) .brand { font-family: var(--font-sans); }
/* Signature mark: an eight-pointed zellige star — the union silhouette of
   two overlapping squares (one rotated 45°), the classic khatam
   construction the bg-zellige artwork is also built from. Pure CSS, no
   image request. */
.brand-mark { position: relative; width: 26px; height: 26px; flex: none; }
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; inset: 3px; background: var(--teal-700);
}
.brand-mark::after { transform: rotate(45deg); background: var(--brass-500); mix-blend-mode: multiply; }
.main-nav { display: flex; gap: 1.4rem; margin-inline-start: auto; flex-wrap: wrap; }
.main-nav a { text-decoration: none; font-weight: 600; color: var(--ink-700); font-size: 0.95rem; }
.main-nav a:hover { color: var(--teal-700); }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.lang-switch { display: flex; gap: 0.35rem; }
.lang-switch a {
  text-decoration: none; font-size: 0.82rem; font-weight: 700;
  padding: 0.3rem 0.55rem; border-radius: 999px; color: var(--ink-700);
  border: 1px solid var(--line);
}
.lang-switch a[aria-current="page"] { background: var(--teal-900); color: var(--white); border-color: var(--teal-900); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.7rem 1.4rem; border-radius: 999px; font-weight: 700;
  text-decoration: none; border: 2px solid transparent; cursor: pointer;
  font-size: 0.95rem; font-family: inherit; box-shadow: var(--shadow-btn);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-primary:hover { background: var(--btn-primary-bg-hover); }
/* Solid, darkened terracotta -- NOT --terracotta-500 (white text on it only
   clears 3.08:1, well under the 4.5:1 text minimum). */
.btn-secondary { background: var(--terracotta-ink); color: var(--white); }
.btn-secondary:hover { background: var(--terracotta-ink-hover); }
/* Was transparent-on-wash (the reported "nearly vanishes" bug, worst on the
   hero's teal-tinted background at 390px). Now an opaque fill + 2px border
   -- same solid-vs-background math as .btn-primary regardless of what's
   behind it. */
.btn-ghost { background: var(--white); color: var(--teal-900); border-color: var(--teal-900); box-shadow: 0 4px 14px -8px rgba(13, 63, 60, 0.3); }
.btn-ghost:hover { background: var(--teal-900); color: var(--white); }
.btn-whatsapp { background: var(--btn-whatsapp-bg); color: var(--white); gap: 0.5rem; }
.btn-whatsapp:hover { background: var(--btn-whatsapp-bg-hover); }
.btn-whatsapp svg { width: 1.1em; height: 1.1em; fill: currentColor; flex: none; }

/* ------------------------------------------------------------------ hero */
.hero { position: relative; overflow: clip; padding-block: 3.5rem 4.5rem; }
.hero-bg {
  position: absolute; inset: 0;
  background: radial-gradient(60% 60% at 80% 20%, rgba(184, 146, 63, 0.14), transparent),
    radial-gradient(50% 50% at 10% 90%, rgba(20, 109, 102, 0.12), transparent);
  z-index: -1;
}
.hero-inner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2.5rem; align-items: center; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; font-size: 0.8rem;
  color: var(--terracotta-600); margin-bottom: 0.6rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.eyebrow::before {
  content: ""; width: 8px; height: 8px; flex: none;
  background: var(--terracotta-600);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* section divider: a thin strip of the zellige artwork itself, the one
   recurring motif tying every section together. */
.zellige-divider {
  height: 10px;
  background-image: url("/img/bg-zellige-2.webp");
  background-repeat: repeat;
  background-size: 240px;
  opacity: 0.5;
}
.hero .lede { font-size: 1.1rem; color: var(--ink-700); max-width: 46ch; }
.hero-ctas { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 1.6rem; }
.hero-media img {
  border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; height: auto;
  aspect-ratio: 16 / 9; object-fit: cover;
}

/* -------------------------------------------------------------- features */
.features { padding-block: 3rem; }
.section-lede { color: var(--ink-700); max-width: 60ch; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.feature-card {
  background: var(--white); border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.feature-card img { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; height: auto; }
.feature-card h3, .feature-card p { padding-inline: 1.1rem; }
.feature-card h3 { margin-top: 1rem; }
.feature-card p { color: var(--ink-700); font-size: 0.95rem; padding-bottom: 1.1rem; }

/* --------------------------------------------------------------- pricing */
.pricing { position: relative; padding-block: 3.5rem; background: var(--cream-100); overflow: clip; }
.zellige-bg {
  position: absolute; inset: 0;
  background-image: url("/img/bg-zellige-1.webp");
  background-repeat: repeat;
  background-size: 420px;
  opacity: 0.12;
  z-index: 0;
}
.pricing .wrap { position: relative; z-index: 1; }
.pricing-tiers {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-top: 2rem;
  min-height: 3rem;
}
.pricing-status { color: var(--ink-700); }
.tier-card {
  background: var(--white); border-radius: var(--radius-md); padding: 1.6rem;
  border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.5rem;
}
.tier-card h3 { margin-bottom: 0.2rem; }
.tier-price { font-size: 1.7rem; font-weight: 800; color: var(--teal-900); }
.tier-price small { font-size: 0.9rem; font-weight: 600; color: var(--ink-500); }
.tier-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.85rem; color: var(--ink-700); margin: 0.4rem 0; }
.tier-meta span { background: var(--cream-100); border-radius: 999px; padding: 0.25rem 0.65rem; }
.tier-desc { color: var(--ink-700); font-size: 0.92rem; }

/* ------------------------------------------------------- invite/waitlist */
.invite, .waitlist { padding-block: 3.5rem; }
.waitlist { background: var(--white); }
.invite-inner, .waitlist-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start; }
.card-form {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.75rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem;
}
.waitlist .card-form { background: var(--cream-50); }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 700; font-size: 0.9rem; color: var(--ink-900); }
.field input, .field select {
  padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  font-size: 1rem; font-family: inherit; background: var(--cream-50); color: var(--ink-900);
}
.field input:focus, .field select:focus { border-color: var(--teal-700); background: var(--white); }
.field-hint { font-size: 0.8rem; color: var(--ink-500); margin: 0; }
.form-message { font-size: 0.9rem; font-weight: 600; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); margin: 0; }
.form-message[data-kind="error"] { background: #fbe4dd; color: #8f2f11; }
.form-message[data-kind="success"] { background: #e0f0e6; color: #1c5c34; }
.invite-success { text-align: center; }
.invite-success #invite-success-body { font-weight: 600; }

/* ------------------------------------------------------------------ footer */
.site-footer { background: var(--teal-900); color: var(--cream-100); padding-block: 2.5rem; margin-top: 2rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; align-items: center; }
.site-footer .brand-name { font-weight: 800; font-size: 1.05rem; }
.footer-tagline, .footer-rights { color: rgba(243, 234, 217, 0.75); font-size: 0.88rem; margin: 0.2rem 0 0; }

/* ------------------------------------------------------------- chat widget */
.chat-widget { position: fixed; inset-block-end: 1.25rem; inset-inline-end: 1.25rem; z-index: 300; }
.chat-toggle {
  display: flex; align-items: center; gap: 0.5rem; border: 2px solid var(--white); border-radius: 999px;
  background: var(--btn-primary-bg); color: var(--white); padding: 0.8rem 1.25rem; font-weight: 700;
  box-shadow: var(--shadow-btn); cursor: pointer; font-family: inherit; font-size: 0.92rem;
}
.chat-toggle:hover { background: var(--btn-primary-bg-hover); }
.chat-toggle-icon { width: 10px; height: 10px; border-radius: 50%; background: var(--brass-300); }

/* ------------------------------------------------------ chat nudge bubble
   Owner directive (LEAD-BOT-SPEC.md, D46): make the launcher visible/
   prominent via an auto-nudge after a few seconds -- localized, dismissible,
   not obnoxious (shown once per session, auto-hides itself too). */
.chat-nudge {
  position: absolute; inset-block-end: 4.25rem; inset-inline-end: 0;
  width: max-content; max-width: 220px; background: var(--white); color: var(--ink-900);
  border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0.75rem 2rem 0.75rem 0.9rem;
  box-shadow: var(--shadow-btn); font-size: 0.85rem; line-height: 1.4;
}
:lang(ar) .chat-nudge, [dir="rtl"] .chat-nudge { padding: 0.75rem 0.9rem 0.75rem 2rem; }
.chat-nudge p { margin: 0; }
.chat-nudge-dismiss {
  position: absolute; top: 0.35rem; inset-inline-end: 0.4rem; background: none; border: none;
  color: var(--ink-500); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0.2rem;
}
@media (prefers-reduced-motion: no-preference) {
  .chat-nudge { animation: fade-up 0.35s ease-out both; }
}

/* -------------------------------------------------------- WhatsApp float */
.whatsapp-float {
  position: fixed; inset-block-end: 6.25rem; inset-inline-end: 1.25rem; z-index: 299;
  display: flex; align-items: center; justify-content: center; width: 52px; height: 52px;
  border-radius: 50%; background: var(--btn-whatsapp-bg); color: var(--white);
  box-shadow: var(--shadow-btn); border: 2px solid var(--white);
}
.whatsapp-float:hover { background: var(--btn-whatsapp-bg-hover); }
.whatsapp-float svg { width: 26px; height: 26px; fill: currentColor; }

/* -------------------------------------------------------------- modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13, 20, 18, 0.55); z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card {
  position: relative; background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 1.75rem; max-width: 380px; width: 100%;
}
.modal-close {
  position: absolute; top: 0.75rem; inset-inline-end: 0.85rem; background: none; border: none;
  font-size: 1.4rem; line-height: 1; color: var(--ink-700); cursor: pointer;
}
.modal-card h3 { margin-top: 0; }
.modal-card .card-form { box-shadow: none; border: none; padding: 0; margin-top: 1rem; }
.chat-panel {
  position: absolute; inset-block-end: 4rem; inset-inline-end: 0;
  width: min(340px, 88vw); max-height: 70vh; background: var(--white);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-panel-header {
  background: var(--teal-900); color: var(--white); padding: 0.85rem 1rem; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
}
.chat-panel-header button { background: none; border: none; color: var(--white); font-size: 1.3rem; cursor: pointer; line-height: 1; }
.chat-panel-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; overflow-y: auto; }
.chat-messages { display: flex; flex-direction: column; gap: 0.5rem; max-height: 220px; overflow-y: auto; }
.chat-messages .msg { padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.9rem; background: var(--cream-100); }
.chat-messages .msg.from-user { background: var(--teal-900); color: var(--white); align-self: flex-end; }
.chat-messages .msg.typing { color: var(--ink-700); font-style: italic; opacity: 0.7; }
.chat-warming { font-size: 0.85rem; color: var(--ink-700); background: var(--cream-100); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; margin: 0; }
.chat-form, .chat-fallback-form { display: flex; gap: 0.5rem; }
.chat-form input, .chat-fallback-form input {
  flex: 1; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); border: 1.5px solid var(--line); font-family: inherit;
}
.chat-form button, .chat-fallback-form button {
  border: none; border-radius: var(--radius-sm); background: var(--teal-900); color: var(--white);
  padding: 0.55rem 0.9rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.chat-fallback-form { display: none; }
.chat-widget[data-chat-mode="fallback"] .chat-form { display: none; }
.chat-widget[data-chat-mode="fallback"] .chat-fallback-form { display: flex; }
.chat-widget[data-chat-mode="fallback"] #chat-messages { display: none; }

/* --------------------------------------------------------------- motion
   One orchestrated moment (hero enters on load) plus quiet hover feedback
   on interactive cards — nothing scattered, all gated behind
   prefers-reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy, .hero-media { animation: fade-up 0.7s ease-out both; }
  .hero-media { animation-delay: 0.12s; }
  @keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .feature-card, .tier-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
  .feature-card:hover, .tier-card:hover { transform: translateY(-4px); box-shadow: 0 18px 36px -18px rgba(13, 63, 60, 0.4); }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .hero-inner, .invite-inner, .waitlist-inner { grid-template-columns: 1fr; }
  .hero-media { order: -1; }
  .main-nav { display: none; }
}
@media (max-width: 480px) {
  .header-actions .btn-ghost { display: none; }
  .chat-panel { width: 92vw; }
}

/* -------------------------------------------------------- dark preference */
@media (prefers-color-scheme: dark) {
  :root {
    --cream-50: #16201e;
    --cream-100: #1c2725;
    --white: #21302c;
    --ink-900: #f2ecdd;
    --ink-700: #cfc6b0;
    --ink-500: #a89e88;
    --line: #35443f;
  }
  .site-header { background: rgba(22, 32, 30, 0.9); }
  h1, h2, h3 { color: var(--brass-300); }
  .field input, .field select { background: #16201e; color: var(--ink-900); }
}
