/* JAM3AH tutor survey — one stylesheet. Brand tokens from BRAND.md only; logical properties throughout so the
   Arabic page mirrors automatically. The only physical-direction rules are the select chevrons, scoped by [dir]. */

:root {
  --navy: #2E3192;
  --red: #EF4136;
  --black: #000;
  --white: #fff;
  --lav: #E7E8F8;
  --lav-2: #F6F7FE;
  --navy-hover: #252873;
  --red-hover: #D8342A;
  --line: rgba(46, 49, 146, .25);
  --text: rgba(0, 0, 0, .85);
  --muted: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(46, 49, 146, .06), 0 10px 28px rgba(46, 49, 146, .08);
  --header-h: 64px;
  --radius: 16px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--white); -webkit-text-size-adjust: 100%; }
html:not([data-i18n-ready]) body { visibility: hidden; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  background: transparent;
}
/* The booklet's graduation-cap pattern (pages 9–12): the pre-tinted lavender tile, full-bleed behind everything.
   Section cards are opaque white, so it reads only in the gutters. */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background: url(/assets/pattern-tile.png) 0 0 / 150px auto repeat;
  opacity: .38;
}
main { flex: 1; }

html[lang=en] { font-family: Poppins, Montserrat, "Segoe UI", system-ui, sans-serif; }
html[lang=ar] { font-family: Tajawal, Almarai, "Noto Kufi Arabic", sans-serif; line-height: 1.7; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }

.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;
}

a { color: var(--navy); }

/* ---------- header ---------- */
#site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--white);
  border-block-end: 1px solid var(--lav);
}
.header-row { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { height: 40px; width: auto; display: block; }
#brand-name { color: var(--navy); font-weight: 700; font-size: 20px; line-height: 1; }
html[lang=en] #brand-name { text-transform: uppercase; letter-spacing: .12em; }
html[lang=ar] #brand-name { font-weight: 800; font-size: 22px; }

.lang-switch { display: inline-flex; border: 1.5px solid var(--navy); border-radius: 999px; overflow: hidden; background: var(--white); }
.lang-switch button {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: var(--white);
  color: var(--navy);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.lang-switch button[aria-pressed=true] { background: var(--navy); color: var(--white); }
.lang-switch button:focus-visible { outline: 2px solid var(--navy); outline-offset: -4px; }
#lang-en { font-family: Poppins, Montserrat, "Segoe UI", system-ui, sans-serif; }
#lang-ar { font-family: Tajawal, Almarai, "Noto Kufi Arabic", sans-serif; font-size: 16px; }

/* ---------- typography helpers (EN only: letter-spacing breaks Arabic joining) ---------- */
html[lang=en] .section-title,
html[lang=en] .hero h1,
html[lang=en] .btn-primary,
html[lang=en] .btn-on-navy,
html[lang=en] .footer-tagline { text-transform: uppercase; letter-spacing: .12em; }
html[lang=en] .section-num { letter-spacing: .08em; }

/* ---------- hero (navy cover moment, white lockup) ---------- */
.hero { background: var(--navy); color: var(--white); text-align: center; padding: 48px 0 60px; }
.hero-inner { max-width: 640px; }
#hero-logo { display: block; max-height: 200px; width: auto; max-width: 100%; margin: 0 auto 28px; filter: brightness(0) invert(1); }
.hero h1 { font-size: 30px; font-weight: 700; margin: 0 0 8px; line-height: 1.25; }
html[lang=ar] .hero h1 { font-weight: 800; font-size: 32px; }
.hero-sub { font-size: 18px; margin: 0; opacity: .92; }
.hero-body { font-size: 16px; line-height: 1.65; margin: 18px auto 28px; max-width: 560px; opacity: .88; }
.hero-link { color: var(--white); font-weight: 600; display: inline-block; margin-block-start: 8px; }
.thanks-mark { height: 96px; width: auto; display: block; margin: 0 auto 20px; filter: brightness(0) invert(1); }
.hero-thanks { padding: 64px 0 72px; }

.intro-card { position: relative; margin: -28px auto 32px; }
.intro-bullets { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.intro-bullets li { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; color: var(--text); }
.intro-bullets li::before {
  content: "✓";
  flex: 0 0 auto;
  color: var(--red);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.3;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--navy-hover); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--navy); }
.btn-secondary:hover:not(:disabled) { background: var(--lav-2); }
.btn-on-navy { background: var(--white); color: var(--navy); }
.btn-on-navy:hover { background: var(--lav); }
.btn-on-navy:focus-visible { outline-color: var(--white); }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-add { width: 100%; }

.btn-remove {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--white);
  color: var(--red);
  font-size: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.btn-remove:hover { border-color: var(--red); background: var(--lav-2); }
.btn-remove:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ---------- progress ---------- */
#progress {
  position: sticky;
  top: var(--header-h);
  z-index: 19;
  background: var(--white);
  border-block-end: 1px solid var(--lav);
  padding: 10px 0 8px;
}
.progress-track { height: 4px; background: var(--lav); border-radius: 2px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--navy); transition: width .3s ease; }
#progress-text { margin: 6px 0 0; font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---------- banners, alerts, toast ---------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--lav);
  color: var(--navy);
  font-weight: 500;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 20px 0 0;
}

.form-errors {
  background: var(--white);
  border: 1.5px solid var(--red);
  border-inline-start: 5px solid var(--red);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 20px 0 0;
  scroll-margin-block-start: 150px;
}
.form-errors-title { margin: 0 0 6px; color: var(--navy); font-weight: 600; }
#form-errors-list { margin: 0; padding-inline-start: 20px; }
#form-errors-list a { color: var(--navy); font-weight: 500; }

#toast {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 24px;
  z-index: 30;
  width: max-content;
  max-width: calc(100% - 40px);
  margin: 0 auto;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--navy);
  color: var(--white);
  font-weight: 500;
  font-size: 15px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

/* ---------- cards & sections ---------- */
.card { background: var(--white); border-radius: var(--radius); padding: 28px 28px 24px; box-shadow: var(--shadow); }
.section { margin-block-start: 20px; scroll-margin-block-start: 150px; }
.section-head { text-align: center; margin-block-end: 24px; }
.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--navy);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
}
.section-title { color: var(--red); font-size: 26px; font-weight: 700; line-height: 1.25; margin: 10px 0 0; }
html[lang=ar] .section-title { font-weight: 800; }

.helper { color: var(--muted); font-size: 15px; margin: 0 0 14px; }
.legend { background: var(--lav-2); color: var(--navy); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 500; margin: 0 0 22px; }
.sub-heading { margin: 26px 0 14px; font-size: 16px; }
.form-note { color: var(--muted); font-size: 14px; margin: 22px 0 14px; text-align: center; }
#submit-status { text-align: center; color: var(--navy); font-weight: 500; min-height: 1.5em; margin: 10px 0 0; }
#submit-status.is-error { color: var(--red-hover); }

/* ---------- fields ---------- */
.field { margin-block-end: 22px; scroll-margin-block-start: 150px; }
.field:last-child { margin-block-end: 0; }
.field > label, .label { display: block; color: var(--navy); font-weight: 600; font-size: 15px; margin-block-end: 8px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label-row .label { margin-block-end: 8px; }
.req { color: var(--red); text-decoration: none; border: 0; font-weight: 700; margin-inline-start: .25em; }
.opt { color: var(--muted); font-weight: 400; font-size: 13px; white-space: nowrap; }
.opt::before { content: "· "; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.field-error { color: var(--red-hover); font-size: 14px; font-weight: 600; margin: 8px 0 0; }
.scale-value { color: var(--muted); font-size: 14px; margin: 8px 0 0; min-height: 1.4em; }
.char-count { text-align: end; }
#style-count { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
#style-count.at-cap { color: var(--red-hover); }

input[type=text], input[type=tel], input[type=email], input[type=number], select, textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  text-align: start;
}
input::placeholder, textarea::placeholder { color: rgba(0, 0, 0, .38); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-color: var(--navy); }
textarea { min-height: 120px; resize: vertical; }
.input-number { max-width: 180px; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 44px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%232E3192' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  cursor: pointer;
}
[dir=ltr] select { background-position: right 16px center; }
[dir=rtl] select { background-position: left 16px center; }

.is-invalid > input, .is-invalid > select, .is-invalid > textarea { border-color: var(--red); }
.is-invalid > .chips .chip > span,
.is-invalid > .scale-row .pill > span,
.is-invalid > fieldset.scale .pill > span { border-color: var(--red); }

/* ---------- chips (single and multi select) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; position: relative; cursor: pointer; user-select: none; max-width: 100%; }
.chip > span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--navy);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.3;
  transition: background-color .12s, color .12s, border-color .12s;
}
.chip:hover > span { background: var(--lav-2); }
.chip input:checked + span { background: var(--navy); border-color: var(--navy); color: var(--white); }
.chip input:checked + span::before { content: "✓"; margin-inline-end: 8px; font-weight: 700; }
.chip input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }
.chip input:disabled + span { opacity: .45; cursor: not-allowed; }
.chip.is-capped { cursor: not-allowed; }
.shake { animation: shake .3s; }
@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- 1–5 scales ---------- */
fieldset.scale { display: flex; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; flex: 0 0 auto; }
.pill { display: inline-flex; cursor: pointer; user-select: none; }
.pill > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--navy);
  font-weight: 600;
  font-size: 16px;
  transition: background-color .12s, color .12s, transform .12s;
}
.pill:hover > span { background: var(--lav); }
.pill input:checked + span { background: var(--navy); border-color: var(--navy); color: var(--white); transform: scale(1.06); }
.pill input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }

.scale-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pole { flex: 1 1 0; min-width: 0; color: var(--muted); font-size: 14px; font-weight: 500; line-height: 1.3; }
.pole-left { text-align: start; }
.pole-right { text-align: end; }

.trait-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-block-end: 1px solid var(--lav); margin-block-end: 0; }
.trait-row:last-child { border-block-end: 0; }
.trait-name { color: var(--navy); font-weight: 600; font-size: 15px; flex: 1 1 0; }

/* ---------- repeatable subjects ---------- */
.subject-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-inline-start: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-block-end: 16px;
  scroll-margin-block-start: 150px;
}
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 12px; }
.subject-heading { margin: 0; color: var(--navy); font-size: 17px; font-weight: 700; }

/* ---------- footer ---------- */
#site-footer { margin-block-start: 48px; background: var(--white); border-block-start: 4px solid var(--red); box-shadow: inset 0 4px 0 var(--navy); padding: 28px 0 24px; }
.footer-inner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; color: var(--navy); }
.footer-mark { height: 28px; width: auto; }
.footer-text { color: var(--navy); font-weight: 600; text-decoration: none; }
.footer-tagline { color: var(--navy); font-size: 12px; font-weight: 600; opacity: .85; width: 100%; text-align: center; margin-block-start: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  #hero-logo { max-height: 140px; }
  .hero { padding: 36px 0 52px; }
  .hero h1 { font-size: 26px; }
  .card { padding: 22px 18px 20px; }
  .section-title { font-size: 24px; }
  .btn-add { width: 100%; }
}

@media (max-width: 480px) {
  .wrap { padding: 0 14px; }
  .card { padding: 20px 14px 18px; }
  .scale-row { flex-wrap: wrap; row-gap: 8px; }
  .scale-row .pole { flex: 1 1 40%; }
  .scale-row fieldset.scale { order: 3; flex: 1 1 100%; justify-content: center; }
  .trait-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .row-head { align-items: flex-start; }
  .lang-switch button { padding: 0 12px; }
  #brand-name { font-size: 18px; }
  .brand-mark { height: 34px; }
}
