@layer reset, base, components, utilities, rtl;

/* ============================================================
   Fonts — self-hosted woff2 in /fonts/. Latin faces load on
   first paint; the Arabic face has a unicode-range so the
   browser only fetches it once an Arabic glyph is rendered.
   ============================================================ */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-v9-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-v9-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-v20-latin-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-v20-latin-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-v20-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Readex Pro";
  src: url("fonts/readex-pro-v27-arabic_latin-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Readex Pro";
  src: url("fonts/readex-pro-v27-arabic_latin-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

@keyframes rule-fill {
  from { background-size: 0% 100%; }
  to { background-size: 100% 100%; }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  img, picture, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
}

@layer base {
  :root {
    /* color */
    --bg: #fbfaf6;
    --bg-sink: #f1eee6;
    --ink: #15201a;
    --ink-soft: #535a52;
    --brand: #0e5c3b;
    --brand-press: #0a3f29;
    --signal: #d98a1f;
    --signal-ink: #9a5e0f;
    --hairline: #e2decf;

    /* type */
    --font-display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --step--1: clamp(0.8rem, 0.77rem + 0.14vw, 0.875rem);
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
    --step-1: clamp(1.1rem, 1.03rem + 0.32vw, 1.3rem);
    --step-2: clamp(1.35rem, 1.15rem + 0.95vw, 1.9rem);
    --step-3: clamp(2rem, 1.55rem + 2vw, 3rem);
    --step-4: clamp(2.8rem, 2rem + 4vw, 5rem);

    /* space */
    --space-1: 0.5rem;
    --space-2: 0.75rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.5rem;
    --space-6: 4rem;
    --section-y: clamp(3rem, 2rem + 5vw, 5.5rem);

    /* layout */
    --radius: 10px;
    --radius-sm: 6px;
    --wrap: 1080px;
    --nav-h: 64px;
    /* --nav-break: 900px (used literally in the media queries below) */
  }

  html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 1rem); }

  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.65;
  }

  /* film grain — inline SVG, no request, not animated */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 140px 140px;
  }

  h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.1;
    text-wrap: balance;
  }
  h1 { font-size: var(--step-4); letter-spacing: -0.03em; line-height: 1.02; margin-bottom: var(--space-3); }
  h2 { font-size: var(--step-3); letter-spacing: -0.02em; margin-bottom: var(--space-3); }
  h3 { font-size: var(--step-1); margin-bottom: var(--space-1); }
  p { line-height: 1.65; text-wrap: pretty; }
  a { color: inherit; }

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

@layer components {
  .wrap { width: min(100% - 2.4rem, var(--wrap)); margin-inline: auto; }

  .eyebrow {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: var(--step--1);
    font-weight: 500;
    color: var(--signal-ink);
    margin-bottom: var(--space-4);
  }

  /* ---- progress rule (the signature) — native scroll-driven ---- */
  .rule {
    height: 2px;
    margin-bottom: var(--space-5);
    background-color: var(--hairline);
    background-image: linear-gradient(to right, var(--signal), var(--signal));
    background-repeat: no-repeat;
    background-size: 0% 100%;
    animation: rule-fill linear both;
    animation-timeline: view();
    animation-range: entry 8% cover 38%;
  }
  @supports not (animation-timeline: view()) {
    .rule { background-size: 100% 100%; animation: none; }
  }

  /* ---- buttons ---- */
  .btn {
    display: inline-block;
    padding: 0.85rem 1.5rem;
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.98rem;
    border: 1px solid var(--brand);
    transition: transform 0.12s ease, background 0.12s ease;
  }
  .btn:hover { background: var(--brand-press); border-color: var(--brand-press); transform: translateY(-1px); }
  .btn--ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
  .btn--ghost:hover { background: var(--bg-sink); }
  .btn--light { background: #fff; color: var(--brand-press); border-color: #fff; }
  .btn--light:hover { background: var(--bg-sink); border-color: var(--bg-sink); }
  .btn--sm { padding: 0.55rem 1.1rem; font-size: 0.9rem; }
  .btn--full { display: block; text-align: center; margin-top: auto; }

  /* ---- skip link ---- */
  .skip-link {
    position: absolute;
    inset-inline-start: var(--space-3);
    top: var(--space-3);
    z-index: 100;
    padding: 0.6rem 1rem;
    background: var(--brand);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform 0.15s ease;
  }
  .skip-link:focus { transform: none; }

  /* ---- nav ---- */
  .nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--hairline);
  }
  @supports not (backdrop-filter: blur(1px)) {
    .nav { background: var(--bg); }
  }
  .nav__inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--nav-h); }
  .brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    text-decoration: none;
  }
  .nav__menu { display: flex; align-items: center; gap: 1.4rem; }
  .nav__menu a { text-decoration: none; font-size: 0.95rem; font-weight: 500; }
  .nav__menu a:hover { color: var(--signal-ink); }

  .nav__toggle {
    display: none;
    min-height: 38px;
    background: none;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
  }

  /* ---- hero ---- */
  .hero { padding-block: clamp(3rem, 2rem + 6vw, 6.5rem); }
  .hero__inner { display: grid; gap: var(--space-5); align-items: start; }
  .hero__body { min-width: 0; }
  .lede {
    font-size: var(--step-1);
    color: var(--ink-soft);
    max-width: 42ch;
    text-wrap: pretty;
  }
  .hero__cta { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: var(--space-4) 0 var(--space-5); }
  .hero__media {
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    background:
      radial-gradient(circle at 30% 22%, #cdd8bf, transparent 55%),
      linear-gradient(150deg, var(--brand) 0%, var(--brand-press) 60%, #08281a 100%);
  }
  .hero__media img { width: 100%; height: 100%; object-fit: cover; }

  .stats {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    border-top: 1px solid var(--hairline);
    padding-top: var(--space-4);
  }
  .stats strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
  .stats span {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--ink-soft);
  }
  .stats li::after {
    content: "";
    display: block;
    height: 2px;
    margin-top: var(--space-2);
    background: linear-gradient(to right, var(--signal) 55%, var(--hairline) 0);
  }

  /* ---- sections ---- */
  .section { padding-block: var(--section-y); }
  .section--alt { background: var(--bg-sink); }
  .section__lede { color: var(--ink-soft); max-width: 46ch; margin-bottom: var(--space-5); text-wrap: pretty; }

  .grid { display: grid; gap: var(--space-4); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }

  /* ---- steps (method + testimonials: hairline editorial rows, not cards) ---- */
  .steps { border-top: 1px solid var(--hairline); }
  .step {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
    padding-block: var(--space-4);
    border-bottom: 1px solid var(--hairline);
  }
  .step__num {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--ink-soft);
  }
  .step__num::after {
    content: "";
    width: 2.4rem;
    height: 2px;
    background: linear-gradient(to right, var(--signal) var(--seg, 33%), var(--hairline) 0);
  }
  .step:nth-of-type(2) .step__num::after { --seg: 66%; }
  .step:nth-of-type(3) .step__num::after { --seg: 100%; }
  .step > div { min-width: 0; }
  .step p { color: var(--ink-soft); max-width: 62ch; }
  .step cite {
    display: block;
    margin-top: var(--space-2);
    font-family: var(--font-mono);
    font-style: normal;
    font-size: var(--step--1);
    color: var(--ink-soft);
  }
  .step blockquote p {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--step-1);
    line-height: 1.4;
    color: var(--ink);
    max-width: 58ch;
    hanging-punctuation: first;
  }
  @media (min-width: 40rem) {
    .step:has(.step__num) {
      grid-template-columns: 8rem 1fr;
      gap: var(--space-5);
      align-items: start;
    }
    .step__num { padding-top: 0.3rem; }
  }

  /* ---- tiers ---- */
  .tiers { align-items: stretch; }
  .tier {
    display: flex;
    flex-direction: column;
    background: transparent;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: var(--space-5);
  }
  .tier--featured {
    background: var(--bg);
    border-color: var(--brand);
    box-shadow: 0 18px 40px -24px rgba(14, 92, 59, 0.4);
  }
  .tier__flag {
    display: inline-block;
    align-self: flex-start;
    background: var(--signal);
    color: #2a1a05;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
  }
  .tier__price {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    margin: 0.2rem 0 var(--space-2);
  }
  .tier__price .amt {
    font-family: var(--font-display);
    font-size: 2.4rem;
    color: var(--ink);
    font-weight: 700;
  }
  .tier__for { font-size: 0.95rem; color: var(--ink-soft); }
  .tier__list { list-style: none; padding: 0; margin: var(--space-3) 0 var(--space-4); }
  .tier__list li {
    padding-block: 0.5rem;
    padding-inline-start: 1.6rem;
    border-top: 1px solid var(--hairline);
    position: relative;
    font-size: 0.95rem;
  }
  .tier__list li::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0.95rem;
    width: 0.7rem;
    height: 0.4rem;
    border-inline-start: 2px solid var(--signal-ink);
    border-bottom: 2px solid var(--signal-ink);
    transform: rotate(-45deg);
  }
  .tier__note {
    margin-top: var(--space-2);
    font-size: var(--step--1);
    color: var(--signal-ink);
  }

  .pay-note { margin-top: var(--space-4); font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-soft); }
  .pay-note__todo { display: block; color: var(--signal-ink); font-size: 0.78rem; margin-top: 0.2rem; }

  /* ---- about ---- */
  .about { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: var(--space-6); align-items: center; }
  .about__photo {
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    background:
      radial-gradient(circle at 30% 25%, #cdd8bf, transparent 55%),
      linear-gradient(150deg, var(--brand) 0%, var(--brand-press) 60%, #08281a 100%);
  }
  .about__photo img { width: 100%; height: 100%; object-fit: cover; }
  .about__text p + p { margin-top: var(--space-3); }
  .creds { list-style: none; padding: 0; margin-block: var(--space-4); display: flex; flex-wrap: wrap; gap: 0.6rem; }
  .creds li {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--bg-sink);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.85rem;
  }
  .section--alt .creds li { background: var(--bg); }

  /* ---- faq ---- */
  .faq { max-width: 46rem; }
  .faq details { border-top: 1px solid var(--hairline); padding: var(--space-3) 0; }
  .faq details:last-of-type { border-bottom: 1px solid var(--hairline); }
  .faq summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
  }
  .faq summary::-webkit-details-marker { display: none; }
  .faq summary::after { content: "+"; color: var(--signal-ink); font-size: 1.3rem; line-height: 1; }
  .faq details[open] summary::after { content: "\2013"; }
  .faq details p { margin-top: var(--space-2); color: var(--ink-soft); }

  /* ---- cta band ---- */
  .cta-band {
    background: var(--brand-press);
    color: #fff;
    text-align: center;
    padding-block: clamp(3rem, 2rem + 4vw, 4.5rem);
  }
  .cta-band p { color: color-mix(in srgb, #fff 80%, transparent); margin-top: var(--space-2); }
  .cta-band .btn--light { margin-top: var(--space-3); }

  /* ---- footer ---- */
  .footer { background: var(--ink); color: #fff; padding-block: var(--space-5); }
  .footer__inner { display: flex; flex-direction: column; gap: 0.3rem; }
  .footer .brand { color: #fff; }
  .footer a { color: #fff; }
  .footer__fine { font-family: var(--font-mono); font-size: 0.78rem; color: color-mix(in srgb, #fff 58%, transparent); margin-top: var(--space-2); }

  /* ---- video facade (dormant until a [data-yt] element exists) ---- */
  .video-card { display: grid; gap: var(--space-2); }
  .video-card > span { font-family: var(--font-mono); font-size: var(--step--1); color: var(--ink-soft); }
  .video-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    border: 0;
    padding: 0;
    border-radius: var(--radius);
    background-size: cover;
    background-position: center;
    cursor: pointer;
  }
  .video-embed::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 4rem;
    height: 4rem;
    border-radius: 999px;
    background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center / 45% no-repeat;
  }
  .video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: inherit; }
}

@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  #results, #faq { content-visibility: auto; contain-intrinsic-size: 0 900px; }

  /* --nav-break: 900px */
  @media (min-width: 56.25rem) {
    .hero__inner { grid-template-columns: 1.15fr 0.85fr; }
  }

  @media (max-width: 56.24rem) {
    .grid--3 { grid-template-columns: 1fr; }
    .about { grid-template-columns: 1fr; gap: var(--space-4); }
    .hero__media, .about__photo { width: min(100%, 22rem); margin-inline: auto; }
    .nav__toggle { display: block; }
    .nav__menu {
      position: absolute;
      inset-inline: 0;
      top: var(--nav-h);
      flex-direction: column;
      align-items: stretch;
      gap: 0;
      background: var(--bg);
      border-bottom: 1px solid var(--hairline);
      padding: 0.5rem 1.2rem 1.2rem;
      display: none;
    }
    .nav__menu.is-open { display: flex; }
    .nav__menu a { padding: 0.8rem 0; border-top: 1px solid var(--hairline); }
    .nav__menu .btn { margin-top: 0.8rem; text-align: center; }
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .btn:hover { transform: none; }
    .rule { background-size: 100% 100%; animation: none; }
  }

  @media (forced-colors: active) {
    body::after { display: none; }
    .rule, .stats li::after, .step__num::after { forced-color-adjust: none; }
  }
}

@layer rtl {
  [dir="rtl"] body {
    font-family: "Readex Pro", "Inter", system-ui, sans-serif;
    line-height: 1.8;
  }
  [dir="rtl"] h1,
  [dir="rtl"] h2,
  [dir="rtl"] h3,
  [dir="rtl"] .stats strong,
  [dir="rtl"] .tier__price .amt,
  [dir="rtl"] .step blockquote p {
    font-family: "Readex Pro", "Inter", system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: 0;
  }
  [dir="rtl"] h1 { font-size: var(--step-3); line-height: 1.35; }

  /* The mono label face (--font-mono) has no Arabic — fall the RTL labels back to
     Readex Pro, and drop letter-spacing (Arabic is cursive, spacing breaks joining). */
  [dir="rtl"] .eyebrow,
  [dir="rtl"] .nav__toggle,
  [dir="rtl"] .tier__flag,
  [dir="rtl"] .tier__price,
  [dir="rtl"] .stats span,
  [dir="rtl"] .step cite,
  [dir="rtl"] .creds li,
  [dir="rtl"] .pay-note,
  [dir="rtl"] .footer__fine,
  [dir="rtl"] .video-card > span {
    font-family: "Readex Pro", "Inter", system-ui, sans-serif;
    letter-spacing: normal;
  }
  [dir="rtl"] .tier__list li::before { transform: rotate(45deg) scaleX(-1); }
}
