/* =====================================================================
   a.w.e — Unit Economics tools  (layers on top of css/styles.css)
   Uses the shared design tokens (--indigo, --pink, --surface, --font …).
   ===================================================================== */

/* visually hidden but announced by screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- page shell + animated spark background ---- */
.tool-main { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 96px var(--pad-x, 24px) 40px; }
.tool-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.tool-bg .spark { position: absolute; }
.tool-bg .spark--t1 { width: 22px; height: 22px; top: 14%; left: 8%;  animation-delay: 0s, -.2s; }
.tool-bg .spark--t2 { width: 15px; height: 15px; top: 22%; left: 88%; animation-delay: -2.4s, -.8s; animation-duration: 8.5s, 2.6s; }
.tool-bg .spark--t3 { width: 13px; height: 13px; top: 46%; left: 4%;  animation-delay: -4.1s, -1.6s; animation-duration: 6s, 3.8s; }
.tool-bg .spark--t4 { width: 18px; height: 18px; top: 62%; left: 92%; animation-delay: -1.2s, -2.2s; animation-duration: 9s, 2.9s; }
.tool-bg .spark--t5 { width: 12px; height: 12px; top: 78%; left: 12%; animation-delay: -3.3s, -.4s;  animation-duration: 7.5s, 3.3s; }
.tool-bg .spark--t6 { width: 16px; height: 16px; top: 86%; left: 80%; animation-delay: -5s, -1.1s;   animation-duration: 8s, 2.4s; }
.tool-bg .spark--t7 { width: 12px; height: 12px; top: 34%; left: 50%; animation-delay: -2.1s, -1.9s; animation-duration: 8.2s, 3.1s; }
.tool-bg .spark--t8 { width: 20px; height: 20px; top: 6%;  left: 62%; animation-delay: -6s, -.6s;    animation-duration: 9.4s, 2.7s; }
.tool-bg .spark { opacity: .5; }
[data-theme="dark"] .tool-bg .spark { opacity: .7; }

/* ---- short headline ---- */
.tool-hero { text-align: center; max-width: 760px; margin: 0 auto 34px; }
.tool-hero .eyebrow { justify-content: center; }
.tool-hero__title { font-size: clamp(30px, 5vw, 50px); font-weight: 900; line-height: 1.16; letter-spacing: -.01em; color: var(--text); }
/* Arabic needs looser lines and no negative tracking, or connected script and
   descenders collide between the two lines */
html[lang="ar"] .tool-hero__title { line-height: 1.45; letter-spacing: 0; font-weight: 800; }
.tool-hero__title .g {
  /* inline-block + vertical padding: the gradient box otherwise stops at the
     baseline and clips Arabic descenders/dots into transparency */
  display: inline-block; padding: .06em 0 .16em;
  background-image: var(--grad-indigo); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
html[lang="ar"] .tool-explain h2,
html[lang="ar"] .consult__intro h2 { line-height: 1.5; }
.tool-hero__sub { margin-top: 15px; color: var(--text-dim); font-size: 18px; line-height: 1.75; }

/* ---- the calculator card ---- */
.uecard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow); padding: 30px; position: relative;
}
.ue-grid { display: grid; grid-template-columns: 330px 1fr; gap: 30px; align-items: start; }
.ue-inputs { display: grid; gap: 16px; }
.ue-inputs__title, .ue-results__title {
  font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 2px;
}

.ue-field { display: grid; gap: 7px; }
.ue-field > label { font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.ue-input { position: relative; }
.ue-input input {
  width: 100%; font-family: inherit; font-size: 17px; font-weight: 700; color: var(--text);
  background: var(--bg-soft); border: 1.5px solid var(--border-2); border-radius: 12px;
  padding: 12px 15px; padding-inline-end: 56px; transition: border-color .18s var(--ease);
}
[data-theme="dark"] .ue-input input { background: var(--bg); }
.ue-input input:focus { outline: none; border-color: var(--pink); }
.ue-input .unit {
  position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--text-faint); pointer-events: none;
}

/* ---- KPI stat cards ---- */
.kpigrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.statcard {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 15px; padding: 15px 14px 14px;
  display: flex; flex-direction: column;   /* labels on one line, numbers bottom-aligned across the row */
  min-width: 0;
}
[data-theme="dark"] .statcard { background: var(--bg); }
.statcard__label {
  font-size: 11.5px; font-weight: 600; color: var(--text-dim); line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;   /* never wrap to a second line */
}
.statcard__num {
  font-size: clamp(20px, 2.2vw, 27px); font-weight: 900; color: var(--text); line-height: 1;
  margin-top: auto; padding-top: 10px;      /* pushes every number onto the same baseline */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* the scorecard's "weakest lever" prints a name — smaller so it stays on one line */
.statcard__num--text { font-size: clamp(14px, 1.4vw, 18px); }
/* Arabic labels run longer than English, so ease them down a touch */
html[lang="ar"] .statcard__label { font-size: 11px; }
/* a trailing unit ("شهر" / "mo") is set smaller so the number stays the hero
   and never crowds its box */
.statcard__num .u { font-size: .58em; font-weight: 700; opacity: .72; margin-inline-start: .22em; }
.statcard__num.pulse { animation: statPulse .22s var(--ease); }
@keyframes statPulse { 0% { transform: scale(1); } 50% { transform: scale(1.09); } 100% { transform: scale(1); } }

/* ---- the constraint panel: the single accent per view ---- */
.constraint {
  margin-top: 16px; border-radius: 20px; padding: 26px 28px 24px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(115deg, #3E14C8 0%, #7B3FE4 48%, #DD0A9A 100%);
  box-shadow: 0 22px 50px -24px rgba(80,20,190,.6);
}
.constraint__eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; opacity: .82; }
.constraint__name { font-size: clamp(24px, 3.2vw, 34px); font-weight: 900; line-height: 1.1; margin: 6px 0 12px; }
.constraint__rec { font-size: 15.5px; line-height: 1.75; opacity: .96; max-width: 62ch; }
.constraint__spark { position: absolute; width: 120px; height: 120px; top: -30px; inset-inline-end: -24px; background: rgba(255,255,255,.14); -webkit-mask: var(--star) center/contain no-repeat; mask: var(--star) center/contain no-repeat; }

.ue-note { margin-top: 14px; font-size: 12.5px; color: var(--text-faint); line-height: 1.6; text-align: center; }

/* ---- definitions / why it helps ---- */
.tool-explain { margin-top: 46px; }
.tool-explain h2 { font-size: clamp(23px, 3vw, 32px); font-weight: 900; text-align: center; color: var(--text); margin-bottom: 8px; }
.tool-explain__lead { text-align: center; color: var(--text-dim); font-size: 17px; line-height: 1.8; max-width: 640px; margin: 0 auto 30px; }
.defgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.defcard { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 22px 20px; box-shadow: var(--card-shadow); }
.defcard h3 { font-size: 16px; font-weight: 800; color: var(--indigo); margin-bottom: 7px; }
[data-theme="dark"] .defcard h3 { color: #C9BEF5; }
.defcard p { font-size: 14.5px; line-height: 1.75; color: var(--text-dim); }

/* ---- free-consultation block ---- */
.consult { margin-top: 50px; }
.consult__card {
  background: linear-gradient(120deg, #EFE9FB 0%, #F7EBF5 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px 34px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center;
}
[data-theme="dark"] .consult__card { background: linear-gradient(120deg, var(--bg-soft), var(--bg)); }
/* grid items default to min-width:auto, and <input>/<textarea> carry an intrinsic
   width — without this the card refuses to shrink and blows the page out sideways
   on phones. Same fix as the partner-logo grid. */
.consult__card > *,
.consult__card .form > *,
.consult__card .form__row > *,
.consult__card .field > * { min-width: 0; }
.consult__intro .eyebrow { margin-bottom: 14px; }
.consult__intro h2 { font-size: clamp(24px, 3.2vw, 34px); font-weight: 900; line-height: 1.25; color: var(--text); margin-bottom: 12px; }
.consult__intro p { color: var(--text-dim); font-size: 16px; line-height: 1.8; max-width: 420px; }
.consult__ok {
  display: none; text-align: center; padding: 8px 0;
  font-weight: 800; font-size: 17px; color: var(--text); line-height: 1.7; white-space: pre-line;
}
.consult__ok.is-visible { display: block; }
.consult__ok .star { width: 42px; height: 42px; background: var(--grad-btn); margin: 0 auto 12px; display: block; }

/* ---- simplified tool nav ---- */
.nav__inner--tool { grid-template-columns: auto 1fr auto; }

/* ---- sliders ---- */
.ue-field--slider .ue-slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ue-slider-val { font-size: 19px; font-weight: 900; color: var(--indigo); direction: ltr; }
[data-theme="dark"] .ue-slider-val { color: #C9BEF5; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: var(--border-2); }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--border-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad-btn); border: 3px solid var(--surface); margin-top: -9px;
  box-shadow: 0 5px 14px -4px rgba(221,10,154,.7); transition: transform .15s var(--ease);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--indigo);
  border: 3px solid var(--surface); box-shadow: 0 5px 14px -4px rgba(221,10,154,.7);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--pink); outline-offset: 2px; }

/* ---- chart card ---- */
.chartcard {
  margin-top: 18px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px 18px 12px; color: var(--text);
}
[data-theme="dark"] .chartcard { background: var(--bg); }
.chartcard__title { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.chartgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chartgrid .chartcard { margin-top: 0; }
.chartcard__legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 8px; }
.chartcard__legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.chartcard__legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* verdict callout (price tool etc.) */
.callout {
  margin-top: 16px; border-radius: 16px; padding: 18px 20px; font-size: 15.5px; line-height: 1.7;
  font-weight: 600; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border-2); border-inline-start: 4px solid var(--indigo);
}
[data-theme="dark"] .callout { background: var(--bg); }
.callout--warn { border-inline-start-color: var(--pink); }
.callout--good { border-inline-start-color: #22C55E; }
.callout strong { color: var(--indigo); font-weight: 900; }
[data-theme="dark"] .callout strong { color: #C9BEF5; }

/* tools hub */
.hubgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.hubcard {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px 22px; box-shadow: var(--card-shadow);
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.hubcard:hover { transform: translateY(-3px); border-color: var(--pink); }
.hubcard .star { width: 26px; height: 26px; background: var(--grad-btn); margin-bottom: 12px; }
.hubcard h3 { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 7px; }
.hubcard p { font-size: 14px; line-height: 1.7; color: var(--text-dim); }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .ue-grid { grid-template-columns: 1fr; gap: 22px; }
  .kpigrid { grid-template-columns: repeat(2, 1fr); }
  .chartgrid { grid-template-columns: 1fr; }
  .defgrid { grid-template-columns: 1fr; }
  .hubgrid { grid-template-columns: 1fr 1fr; }
  .consult__card { grid-template-columns: 1fr; gap: 26px; padding: 30px 22px; }
}
@media (max-width: 560px) {
  .tool-main { padding-top: 88px; }
  .uecard { padding: 22px 16px; }
  .hubgrid { grid-template-columns: 1fr; }
  .kpigrid { gap: 10px; }
  .statcard { padding: 13px 12px 12px; }
  .constraint { padding: 22px 20px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .tool-bg .spark { animation: none !important; }
  .statcard__num.pulse { animation: none !important; }
}
