/* ==========================================================================
   Bustan's website. One file, no framework, no build step for the CSS.
   - Right-to-left by default; English works with the same rules because every
     direction-sensitive property is logical (inline-start/end, block-start/end).
   - Cascade layers fix the order of precedence, so nothing needs !important.
   - The look is the app's: warm paper, dark ink, one green for actions, gold for prices.
     Change it by editing tokens only; components never hard-code a colour or size.
   ========================================================================== */
@layer reset, tokens, base, layout, components, utilities;

/* Tajawal, the app's typeface, self-hosted (SIL OFL; see fonts/OFL-LICENSE.txt). A page downloads only the
   subsets and weights it uses: Arabic text pulls the Arabic files, Latin text the Latin ones. */
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/tajawal-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0897-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/tajawal-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/tajawal-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0897-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/tajawal-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/tajawal-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0897-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/tajawal-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("../fonts/tajawal-arabic-800-normal.woff2") format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+0870-088E,U+0890-0891,U+0897-08E1,U+08E3-08FF,U+200C-200E,U+2010-2011,U+204F,U+2E41,U+FB50-FDFF,U+FE70-FE74,U+FE76-FEFC; }
@font-face { font-family: "Tajawal"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("../fonts/tajawal-latin-800-normal.woff2") format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* --------------------------------------------------------------- reset */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, picture, svg, video { display: block; max-inline-size: 100%; block-size: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  [hidden] { display: none !important; }
  :where(ul, ol)[role="list"] { list-style: none; padding: 0; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  }
}

/* --------------------------------------------------------------- tokens */
@layer tokens {
  /* Colours: light values first; dark ones follow the device, or data-theme="light|dark" on <html>
     (the theme switch in app.js). The two ink values feed the brush sketches (ink.js). */
  :root {
    color-scheme: light dark;
    --bg: #E9E5DA;
    --surface: #FFFFFF;
    --surface-2: #F6F1E5;
    --text: #23201A;
    --muted: #5F5849;
    --line: #DDD3BE;
    --accent: #1B5E20;
    --accent-ink: #FFFFFF;
    --accent-soft: #E3EDD9;
    --gold: #8A6410;
    --danger: #B3261E;
    --ink-rgb: 24,25,32;
    --blue-rgb: 38,52,84;
    --focus: #2b8cff;

    --font: "Tajawal", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
    --leading: 1.8;            /* Arabic needs more line height than Latin */
    --step--1: clamp(.9rem, .87rem + .1vw, .96rem);
    --step-0:  clamp(1.0625rem, 1rem + .25vw, 1.15rem);
    --step-1:  clamp(1.25rem, 1.15rem + .5vw, 1.45rem);
    --step-2:  clamp(1.55rem, 1.3rem + 1.1vw, 2.1rem);
    --step-3:  clamp(2rem, 1.5rem + 2.4vw, 3.2rem);

    --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
    --space-5: 1.5rem; --space-6: 2rem;  --space-7: 3rem;   --space-8: 5rem;

    --radius: .75rem; --radius-sm: .375rem;
    --container: 70rem; --measure: 62ch;
    --ease: cubic-bezier(.2, .7, .2, 1); --fast: 150ms; --slow: 300ms;
  }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
      --bg: #0F120C;
      --surface: #171B13;
      --surface-2: #1F2419;
      --text: #ECE8DC;
      --muted: #A9A493;
      --line: #2C3324;
      --accent: #81C784;
      --accent-ink: #0F120C;
      --accent-soft: #1C2A1B;
      --gold: #DDB45F;
      --danger: #FF8A80;
      --ink-rgb: 228,224,212;
      --blue-rgb: 158,176,208;
  } }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0F120C;
    --surface: #171B13;
    --surface-2: #1F2419;
    --text: #ECE8DC;
    --muted: #A9A493;
    --line: #2C3324;
    --accent: #81C784;
    --accent-ink: #0F120C;
    --accent-soft: #1C2A1B;
    --gold: #DDB45F;
    --danger: #FF8A80;
    --ink-rgb: 228,224,212;
    --blue-rgb: 158,176,208;
  }
  :root[data-theme="light"] { color-scheme: light; }
  :root:lang(en) { --leading: 1.65; }
}

/* --------------------------------------------------------------- base */
@layer base {
  html { scroll-behavior: smooth; }
  body {
    background: var(--bg); color: var(--text);
    font-family: var(--font); font-size: var(--step-0); line-height: var(--leading);
    text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, h4 { line-height: 1.35; font-weight: 800; text-wrap: balance; }
  h1 { font-size: var(--step-3); } h2 { font-size: var(--step-2); } h3 { font-size: var(--step-1); }
  p, li { max-inline-size: var(--measure); text-wrap: pretty; }
  a { color: var(--accent); text-underline-offset: .25em; text-decoration-thickness: 1px; }
  a:hover { text-decoration-thickness: 2px; }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
  ::selection { background: var(--accent-soft); }
  /* Never letter-space or uppercase Arabic: it breaks letter joining. Latin-only labels opt in with .caps */
  :lang(en) .caps { text-transform: uppercase; letter-spacing: .06em; font-size: var(--step--1); }
  /* Embedded opposite-direction text (names, code, URLs) keeps its own direction */
  bdi, .ltr { unicode-bidi: isolate; }
  .ltr { direction: ltr; }
  /* Directional icons flip in RTL; neutral icons (search, close) don't use this class */
  [dir="rtl"] .icon-dir { transform: scaleX(-1); }
}

/* --------------------------------------------------------------- layout primitives */
@layer layout {
  .container { inline-size: min(100% - 2 * var(--space-4), var(--container)); margin-inline: auto; }
  .stack { display: flex; flex-direction: column; gap: var(--stack, var(--space-4)); }
  [data-gap="sm"] { --stack: var(--space-2); --cluster: var(--space-2); --grid-gap: var(--space-3); }
  [data-gap="lg"] { --stack: var(--space-5); --cluster: var(--space-4); --grid-gap: var(--space-6); }
  .cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster, var(--space-3)); }
  .grid { display: grid; gap: var(--grid-gap, var(--space-5));
          grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, 16rem)), 1fr)); }
  .section { padding-block: var(--space-8); }
  .section + .section { padding-block-start: 0; }
  .split { display: grid; gap: var(--space-6); align-items: center; }
  @media (min-width: 48rem) { .split { grid-template-columns: 1.1fr .9fr; } }
  /* grid children may shrink below their content: wide tables scroll inside .table-wrap instead of widening the page */
  .grid > *, .split > * { min-inline-size: 0; }
}

/* --------------------------------------------------------------- components */
@layer components {
  .skip-link { position: absolute; inset-inline-start: var(--space-4); inset-block-start: -10rem;
               background: var(--surface); padding: var(--space-2) var(--space-4); border-radius: var(--radius); z-index: 100; }
  .skip-link:focus { inset-block-start: var(--space-4); }

  /* header + navigation (mobile: toggle; desktop: inline) */
  .site-header { position: sticky; inset-block-start: 0; z-index: 50; background: var(--bg); border-block-end: 1px solid var(--line); }
  .site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-block-size: 4rem; }
  .brand { color: var(--accent); display: inline-flex; align-items: center; min-block-size: 2.75rem; }
  .brand svg { block-size: 2.1rem; inline-size: auto; }
  .nav { display: flex; align-items: center; gap: var(--space-2); }
  .nav a { color: var(--muted); text-decoration: none; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
           transition: color var(--fast), background var(--fast); }
  .nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
  .nav a.btn-primary, .nav a.btn-primary:hover { color: var(--accent-ink); background: var(--accent); }
  .nav-toggle { display: none; }
  @media (max-width: 47.99rem) {
    .nav-toggle { display: inline-grid; place-items: center; inline-size: 2.75rem; block-size: 2.75rem;
                  background: none; border: 1px solid var(--line); border-radius: var(--radius); }
    .nav { position: absolute; inset-inline: 0; inset-block-start: 100%; flex-direction: column; align-items: stretch;
           padding: var(--space-3) var(--space-4) var(--space-5); background: var(--bg); border-block-end: 1px solid var(--line);
           visibility: hidden; opacity: 0; translate: 0 -.5rem; transition: opacity var(--fast), translate var(--fast) var(--ease), visibility var(--fast); }
    .nav[data-open] { visibility: visible; opacity: 1; translate: 0 0; }
  }

  .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
         min-block-size: 2.75rem; padding-inline: var(--space-5); border-radius: var(--radius); border: 1px solid transparent;
         font-weight: 600; text-decoration: none; line-height: 1.2;
         transition: background var(--fast), color var(--fast), border-color var(--fast), transform var(--fast); }
  .btn:active { transform: translateY(1px); }
  .btn-primary { background: var(--accent); color: var(--accent-ink); }
  .btn-primary:hover { filter: brightness(.92); }
  .btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
  .btn-ghost:hover { background: var(--surface-2); }
  .btn[aria-busy="true"] { opacity: .7; pointer-events: none; }

  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); }
  .card h3 { margin-block-end: var(--space-2); }
  .card p { color: var(--muted); }

  .hero { padding-block: var(--space-8) var(--space-7); }
  .hero p { font-size: var(--step-1); color: var(--muted); }
  .hero .note, .note { font-size: var(--step--1); color: var(--muted); }
  .hero-plain { padding-block: var(--space-7) var(--space-5); }

  /* content pages */
  .prose { max-inline-size: calc(var(--measure) + 2 * var(--space-4)); }
  .prose img { border-radius: var(--radius); }
  /* tables scroll inside their box on phones, never widen the page */
  .table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .table { inline-size: 100%; border-collapse: collapse; font-size: var(--step--1); }
  .table th, .table td { padding: var(--space-3) var(--space-4); text-align: start; border-block-end: 1px solid var(--line); white-space: nowrap; }
  .table tr:last-child td { border-block-end: 0; }
  .table th { color: var(--muted); font-weight: 600; }
  .badge { display: inline-block; padding: 0 var(--space-2); border-radius: 999px; font-size: var(--step--1); background: var(--surface-2); color: var(--muted); }
  .badge[data-state="on"] { background: var(--accent-soft); color: var(--accent); }
  .site-footer { border-block-start: 1px solid var(--line); padding-block: var(--space-6); color: var(--muted); font-size: var(--step--1); }
  .site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4); }

  /* reveal on scroll: visible by default; JS adds .js-reveal only when motion is allowed */
  .js-reveal [data-reveal] { opacity: 0; translate: 0 1rem; transition: opacity var(--slow) var(--ease), translate var(--slow) var(--ease); }
  .js-reveal [data-reveal].is-visible { opacity: 1; translate: 0 0; }

}

/* --------------------------------------------------------------- the site's own components */
@layer components {
  .nav .icon-btn { display: inline-grid; place-items: center; inline-size: 2.75rem; block-size: 2.75rem; background: none; border: 0; border-radius: var(--radius-sm); color: var(--muted); }
  .nav .icon-btn:hover { color: var(--text); background: var(--surface-2); }
  .nav a[lang] { font-weight: 500; }
  @media (max-width: 61.99rem) and (min-width: 48rem) { .nav .nav-open { display: none; } }
  .field-error { color: var(--danger); font-size: var(--step--1); font-weight: 700; }

  /* brush sketches (ink.js): decorative, never take a tap */
  .ink { display: block; inline-size: 100%; aspect-ratio: 400 / 240; pointer-events: none; opacity: .9;
         -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14%, #000 86%, transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 14%, #000 86%, transparent 100%); }

  /* a quiet list of topics: a rule above each, no boxes */
  .topics { display: grid; gap: var(--space-5) var(--space-6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
  .topics > div { border-block-start: 2px solid var(--text); padding-block-start: var(--space-3); }
  .topics h3 { margin-block-end: var(--space-1); }
  .topics p { color: var(--muted); }
  .more { font-weight: 700; }

  .band { background: var(--surface-2); border-block: 1px solid var(--line); padding-block: var(--space-7); margin-block-end: var(--space-8); }
  .who h3 { color: var(--accent); }
  .who-price, .price { color: var(--gold); font-weight: 700; }
  .price-n { font-size: var(--step-3); font-weight: 800; line-height: 1.1; }
  .price-year { color: var(--muted); font-size: var(--step--1, .9rem); font-weight: 700; margin-block-start: 2px; }

  /* the three steps to start: a real sequence, so it is numbered */
  .steps { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); counter-reset: step; }
  .steps li { counter-increment: step; max-inline-size: none; }
  .steps li::before { content: counter(step); display: inline-grid; place-items: center; inline-size: 2.25rem; block-size: 2.25rem; border-radius: 50%;
                      background: var(--accent); color: var(--accent-ink); font-weight: 800; margin-block-end: var(--space-2); }
  .steps p { color: var(--muted); }

  .aside-note { border-inline-start: 4px solid var(--accent); padding-inline-start: var(--space-5); max-inline-size: 48rem; }

  /* features page: the group on the reading side, its features beside it */
  .feature-group { display: grid; gap: var(--space-5); }
  @media (min-width: 48rem) { .feature-group { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: var(--space-7); } }
  .feature-list li { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
                     padding-block: var(--space-3); border-block-end: 1px solid var(--line); max-inline-size: none; }
  .feature-list li:first-child { border-block-start: 1px solid var(--line); }
  .badge { white-space: nowrap; }

  /* plans */
  .plans { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); align-items: start; }
  .plans > *, .result-top > * { min-inline-size: 0; }
  .plan { display: flex; flex-direction: column; gap: var(--space-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); }
  .plan header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
  .plan-for { color: var(--muted); }
  .plan-people { font-weight: 700; }
  .plan-inc { font-size: var(--step--1); color: var(--muted); margin-block-start: var(--space-2); }
  .ticks { list-style: none; padding: 0; display: grid; gap: var(--space-2); margin-block: var(--space-2) var(--space-4); font-size: var(--step--1); }
  .ticks li { padding-inline-start: 1.5rem; position: relative; line-height: 1.6; }
  .ticks li::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--accent); font-weight: 800; }
  .plan .btn { margin-block-start: auto; }
  .table td, .table th[scope="row"] { white-space: normal; }
  .table th[scope="row"] { color: var(--text); }

  /* questions that open */
  .faq details { border-block-end: 1px solid var(--line); }
  .faq details:first-child { border-block-start: 1px solid var(--line); }
  .faq summary { cursor: pointer; font-weight: 700; padding-block: var(--space-4); min-block-size: 2.75rem; }
  .faq details p { color: var(--muted); padding-block-end: var(--space-4); }

  /* the plan finder */
  .finder { display: grid; gap: var(--space-5); max-inline-size: 36rem; }
  .finder fieldset { border: 0; padding: 0; display: grid; gap: var(--space-3); min-inline-size: 0; }
  .finder legend { font-size: var(--step-2); font-weight: 800; padding: 0; margin-block-end: var(--space-3); }
  .finder-count { color: var(--muted); font-size: var(--step--1); }
  .options { display: grid; gap: var(--space-3); }
  .option { display: flex; align-items: center; gap: var(--space-3); min-block-size: 3.5rem; padding: var(--space-3) var(--space-4); background: var(--surface);
            border: 1.5px solid var(--line); border-radius: var(--radius); font-weight: 700; cursor: pointer; transition: border-color var(--fast), background var(--fast); }
  .option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
  .option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
  .option input { inline-size: 1.25rem; block-size: 1.25rem; accent-color: var(--accent); flex: none; }
  .finder-result:focus { outline: none; }
  .result-top { display: grid; gap: var(--space-5); align-items: center; }
  @media (min-width: 48rem) { .result-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
  .result-top .plan { border: 2px solid var(--accent); }

  .contact { display: grid; gap: var(--space-4); }
  .contact dt { color: var(--muted); font-size: var(--step--1); }
  .contact dd { margin: 0; font-weight: 700; }
  .contact a { display: inline-flex; align-items: center; min-block-size: 2.75rem; }
  .site-footer a { color: inherit; display: inline-flex; align-items: center; min-block-size: 2.75rem; }
  [id] { scroll-margin-block-start: 5rem; }
}

/* --------------------------------------------------------------- utilities (few, on purpose) */
@layer utilities {
  /* Screen-reader-only text. Keep a positioned ancestor (header, .table-wrap, .field...) nearby: an absolute box inside
     an RTL scroller can otherwise land off-screen and widen the whole page. */
  .visually-hidden { position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .muted { color: var(--muted); }
  .center { text-align: center; margin-inline: auto; }
}

/* smooth page-to-page changes on same-origin links (ignored where unsupported) */
@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }
