/* ==========================================================================
   Rayed.Ai design system: tokens + components
   Concept: "one message, many rays". A request leaves one point and fans out
   to many pros; quotes travel back along the same rays. Night-ink grounds,
   a single saffron "ray" accent, cool porcelain paper. Bilingual EN / AR (RTL).
   ========================================================================== */

:root {
  /* Colour */
  --ink: #0D1230;          /* night ink: primary dark ground, text on light */
  --ink-2: #161C44;        /* raised dark surface */
  --ink-3: #252C5E;        /* hairlines / borders on dark */
  --porcelain: #F4F5FA;    /* light ground, text on dark */
  --paper: #FFFFFF;        /* cards on light ground */
  --mist: #A3A9CC;         /* secondary text on dark */
  --slate: #565D86;        /* secondary text on light */
  --line: #DFE2EF;         /* hairlines on light */
  --saffron: #FFB21A;      /* the ray: the only accent; fills, never small text on white */
  --saffron-ink: #8A5600;  /* saffron-family text that passes contrast on light */
  --saffron-wash: #FFF1D6; /* soft saffron tint on light */

  /* Type */
  --f-display: "Bricolage Grotesque", "Alexandria", system-ui, sans-serif;
  --f-body: "Instrument Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-ar-display: "Alexandria", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-ar-body: "IBM Plex Sans Arabic", "Alexandria", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Type scale (fluid, ~1.25 ratio) */
  --t-xs: 0.78rem;
  --t-sm: 0.9rem;
  --t-md: 1.05rem;
  --t-lg: clamp(1.2rem, 1.05rem + 0.6vw, 1.45rem);
  --t-xl: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
  --t-2xl: clamp(2.3rem, 1.4rem + 3.8vw, 4.4rem);
  --t-3xl: clamp(2.9rem, 1.5rem + 6vw, 6.6rem);

  /* Space, radius, motion */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
  --s-6: 2rem; --s-7: 3rem; --s-8: 4.5rem; --s-9: 7rem;
  --r-chip: 999px;
  --r-bubble: 20px;
  --r-card: 14px;
  --wrap: 72rem;
  --ease: cubic-bezier(.2,.7,.1,1);

  color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--porcelain);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--t-md);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-family: var(--f-ar-body); line-height: 1.8; }
img, svg { max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 3px; border-radius: 6px; }

/* Bilingual switch: every translatable string exists twice, one per language. */
html[lang="en"] [lang="ar"].t, html[lang="ar"] [lang="en"].t { display: none !important; }

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* ---------- Type roles ---------- */
.display {
  font-family: var(--f-display);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
  text-wrap: balance;
  margin: 0;
}
html[lang="ar"] .display { font-family: var(--f-ar-display); letter-spacing: 0; line-height: 1.2; font-weight: 800; }
.h2 {
  font-family: var(--f-display);
  font-weight: 750;
  font-size: var(--t-2xl);
  letter-spacing: -0.03em;
  line-height: 1;
  text-wrap: balance;
  margin: 0;
}
html[lang="ar"] .h2 { font-family: var(--f-ar-display); letter-spacing: 0; line-height: 1.25; font-weight: 700; }
.h3 { font-family: var(--f-display); font-weight: 700; font-size: var(--t-lg); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
html[lang="ar"] .h3 { font-family: var(--f-ar-display); letter-spacing: 0; }
.lede { font-size: var(--t-lg); line-height: 1.5; max-width: 34em; margin: 0; }
.label {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}
html[lang="ar"] .label { font-family: var(--f-ar-body); letter-spacing: 0; text-transform: none; font-size: var(--t-sm); font-weight: 600; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  --_bg: var(--saffron); --_fg: var(--ink);
  display: inline-flex; align-items: center; gap: 0.6em;
  min-height: 52px; padding: 0 1.4em;
  border-radius: var(--r-chip);
  background: var(--_bg); color: var(--_fg);
  font: 600 var(--t-md)/1 var(--f-body);
  text-decoration: none; border: 0; cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .2s;
  box-shadow: 0 0 0 0 rgba(255,178,26,0);
}
html[lang="ar"] .btn { font-family: var(--f-ar-body); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px -10px rgba(255,178,26,.65); }
.btn .arrow { transition: transform .25s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
html[dir="rtl"] .btn .arrow { transform: scaleX(-1); }
html[dir="rtl"] .btn:hover .arrow { transform: scaleX(-1) translateX(4px); }
.btn--ghost { --_bg: transparent; --_fg: currentColor; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn--ghost:hover { box-shadow: inset 0 0 0 1.5px currentColor; background: rgba(127,134,180,.12); }
.btn--ink { --_bg: var(--ink); --_fg: var(--porcelain); }
.btn--ink:hover { box-shadow: 0 10px 30px -12px rgba(13,18,48,.6); }

/* ---------- Brand lockup ---------- */
.lockup { display: inline-flex; align-items: center; gap: 0.55em; text-decoration: none; color: inherit; }
.lockup img { width: 2.1em; height: 2.1em; display: block; }
.wordmark {
  font-family: var(--f-display); font-weight: 800; font-size: 1.45em;
  letter-spacing: -0.04em; line-height: 1;
}
.wordmark .dot { color: var(--saffron); }
.wordmark-ar { font-family: var(--f-ar-display); font-weight: 800; font-size: 1.35em; line-height: 1; }

/* ---------- Chat components ---------- */
.thread { display: grid; gap: var(--s-3); }
.bubble {
  max-width: 82%;
  padding: 0.7em 1em;
  border-radius: var(--r-bubble);
  font-size: var(--t-sm);
  line-height: 1.5;
  position: relative;
}
.bubble--me {
  justify-self: end;
  background: var(--ink); color: var(--porcelain);
  border-end-end-radius: 6px;
}
.bubble--rayed {
  justify-self: start;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line);
  border-end-start-radius: 6px;
}
.bubble .who { display: block; font-size: var(--t-xs); font-weight: 600; color: var(--saffron-ink); margin-bottom: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-self: start; }
.chip {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .35em .85em; border-radius: var(--r-chip);
  font-size: var(--t-xs); font-weight: 600;
  background: var(--saffron-wash); color: var(--saffron-ink);
  border: 1px solid rgba(138,86,0,.18);
}
.chip--on { background: var(--saffron); color: var(--ink); border-color: transparent; }

.quote {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-3);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: .75em .9em;
  font-size: var(--t-sm);
}
.quote .avatar {
  width: 2.2em; height: 2.2em; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--porcelain);
  font-weight: 700; font-size: var(--t-xs);
}
.quote .meta { min-width: 0; }
.quote .name { font-weight: 600; display: block; }
.quote .sub { color: var(--slate); font-size: var(--t-xs); }
.quote .price { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quote--best { border-color: var(--saffron); box-shadow: 0 0 0 3px var(--saffron-wash); }
.quote--best .badge {
  grid-column: 1 / -1; justify-self: start;
  font-size: var(--t-xs); font-weight: 700; color: var(--saffron-ink);
}

/* ---------- Utility ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.band { padding-block: clamp(4rem, 2.5rem + 5vw, 7rem); }
.band--ink { background: var(--ink); color: var(--porcelain); }
.band--paper { background: var(--paper); }
.muted { color: var(--slate); }
.band--ink .muted { color: var(--mist); }
