/* ==========================================================================
   Placement-test site -- design system inherited from the course documents
   Navy #1F3864 / Orange #E36C0A / Turquoise #148F8F / DarkRed #C00000
   ========================================================================== */

:root {
  --navy: #1F3864;
  --navy-2: #2b4b81;
  --navy-ink: #16294a;
  --orange: #E36C0A;
  --orange-2: #ff8320;
  --teal: #148F8F;
  --red: #C00000;

  --bg: #f6f8fc;
  --card: #ffffff;
  --line: #dfe6f2;
  --text: #1b2537;
  --muted: #64708a;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 56, 100, .06), 0 8px 28px rgba(31, 56, 100, .09);
  --shadow-lg: 0 2px 6px rgba(31, 56, 100, .08), 0 24px 60px rgba(31, 56, 100, .16);
  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1526;
    --card: #16203a;
    --line: #26324f;
    --text: #e8edf7;
    --muted: #97a3bd;
    --navy: #cddcff;
    --navy-2: #a9c1f0;
    --navy-ink: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .34);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 24px 60px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Simplified Arabic", Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

.en, code {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-family: "Times New Roman", Georgia, serif;
  font-weight: 700;
  letter-spacing: .01em;
}

.hot { color: var(--red); font-weight: 700; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }

h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; color: var(--navy-ink); font-weight: 800; }
h1 { font-size: clamp(28px, 5vw, 46px); letter-spacing: -.01em; }
h2 { font-size: clamp(23px, 3.6vw, 33px); }
h3 { font-size: 20px; }
p  { margin: 0 0 1em; }

a { color: var(--teal); }

/* ------------------------------------------------------------------ nav -- */
header.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 18px; height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--navy-ink); text-decoration: none; font-size: 19px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--navy) 0%, var(--teal) 100%);
  color: #fff; font-size: 19px; line-height: 1;
}
.nav nav { margin-inline-start: auto; display: flex; gap: 22px; align-items: center; }
.nav nav a { color: var(--muted); text-decoration: none; font-size: 15.5px; font-weight: 600; }
.nav nav a:hover { color: var(--navy-ink); }
@media (max-width: 720px) { .nav nav a.hide-sm { display: none; } }

/* ---------------------------------------------------------------- button - */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 30px; border-radius: 999px; border: 0; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 17px; text-decoration: none;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-2) 100%);
  color: #fff; box-shadow: 0 6px 20px rgba(227, 108, 10, .32);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(227, 108, 10, .42); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: transparent; color: var(--navy-ink);
  border: 2px solid var(--line); box-shadow: none;
}
.btn.ghost:hover { border-color: var(--teal); color: var(--teal); box-shadow: none; }
.btn:disabled { filter: grayscale(1); opacity: .5; cursor: not-allowed; transform: none; }
.btn.wide { width: 100%; }

/* ----------------------------------------------------------------- hero -- */
.hero { padding: 68px 0 56px; text-align: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--teal); border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent);
  padding: 7px 16px; border-radius: 999px; font-size: 14.5px; font-weight: 700;
  margin-bottom: 22px;
}
.hero h1 { max-width: 15ch; margin-inline: auto; }
.hero h1 .accent { color: var(--orange); }
.hero .sub { font-size: clamp(17px, 2.3vw, 21px); color: var(--muted); max-width: 46ch; margin: 0 auto 32px; }
.hero .cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.trust { margin-top: 26px; color: var(--muted); font-size: 15px; display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.trust span { display: inline-flex; align-items: center; gap: 7px; }

/* ---------------------------------------------------------------- cards -- */
.grid { display: grid; gap: 20px; }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.card .ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 21px; margin-bottom: 14px;
  background: color-mix(in srgb, var(--teal) 13%, transparent);
}
.card h3 { margin-bottom: .35em; }
.card p { color: var(--muted); margin: 0; font-size: 16px; }

section { padding: 62px 0; }
section.alt { background: color-mix(in srgb, var(--navy) 5%, var(--bg)); }
.section-head { text-align: center; max-width: 620px; margin: 0 auto 42px; }
.section-head p { color: var(--muted); margin: 0; }

/* ------------------------------------------------------------- problem --- */
.pain { border-inline-start: 4px solid var(--red); }
.pain .ico { background: color-mix(in srgb, var(--red) 12%, transparent); }

/* --------------------------------------------------------------- steps --- */
.steps { counter-reset: s; display: grid; gap: 14px; }
.step {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 20px;
}
.step .n {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .step .n,
  :root:not([data-theme="light"]) .card .ico { color: #0e1526; }
}
.step h3 { margin: 0 0 2px; font-size: 17.5px; }
.step p { margin: 0; color: var(--muted); font-size: 15.5px; }

/* --------------------------------------------------------------- quiz ---- */
.quiz { padding: 34px 0 80px; }

.progress-wrap { max-width: 760px; margin: 0 auto 26px; }
.progress-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14.5px; color: var(--muted); font-weight: 700; margin-bottom: 9px;
}
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--teal), var(--orange));
  border-radius: 999px; transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 32px; max-width: 760px; margin: 0 auto;
}
.panel h2 { text-align: center; }
.panel > .lead { text-align: center; color: var(--muted); margin-bottom: 26px; }

/* ------------------------------------------------- interactive board ---- */
/* Square colours match chessdiag.py so the site and the printed course
   material read as one product. */
.board-wrap {
  width: 100%; max-width: 420px; margin: 0 auto 20px;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  border: 2px solid var(--navy);
  border-radius: 10px;
  overflow: hidden;
  direction: ltr;                 /* a1 stays bottom-left inside an RTL page */
  user-select: none;
  touch-action: manipulation;
}
.sq {
  position: relative;
  display: grid; place-items: center;
  cursor: pointer;
}
.sq.light { background: #EAF1FB; }
.sq.dark  { background: #A6BEE2; }

.piece {
  font-size: clamp(22px, 7.2vw, 40px);
  line-height: 1;
  pointer-events: none;
}
.piece.black { color: #1a1a1a; }
.piece.white {
  color: #ffffff;
  -webkit-text-stroke: 1.4px #1a1a1a;
  paint-order: stroke fill;
}

.coord {
  position: absolute; font-size: 9px; font-weight: 700;
  color: var(--navy); opacity: .65; pointer-events: none;
  font-family: "Times New Roman", serif;
}
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 3px; }

.sq.sel   { box-shadow: inset 0 0 0 4px var(--teal); }
.sq.from  { background: color-mix(in srgb, var(--orange) 55%, #EAF1FB); }
.sq.to    { background: color-mix(in srgb, var(--orange) 78%, #EAF1FB); }
.sq.bad   { box-shadow: inset 0 0 0 4px var(--red); }
.sq:hover:not(.sel) { filter: brightness(1.06); }

.turn-flag {
  text-align: center; font-size: 15px; font-weight: 800;
  margin: 0 0 10px; color: var(--muted);
}
.turn-flag .dot {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--navy); vertical-align: -2px; margin-inline-end: 6px;
}
.turn-flag .dot.w { background: #fff; }
.turn-flag .dot.b { background: #1a1a1a; }

.board {
  display: block; width: 100%; max-width: 380px; margin: 0 auto 22px;
  border-radius: 12px; border: 1px solid var(--line);
}

.qtext { font-size: 19px; font-weight: 700; text-align: center; margin: 0 0 22px; color: var(--navy-ink); }

.opts { display: grid; gap: 11px; }
.opt {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 16px 20px; border-radius: 13px; cursor: pointer;
  background: var(--bg); border: 2px solid var(--line);
  font: inherit; font-weight: 700; color: var(--text); text-align: start;
  transition: border-color .12s, background .12s, transform .08s;
}
.opt:hover:not(:disabled) { border-color: var(--teal); transform: translateX(-3px); }
.opt:disabled { cursor: default; }
.opt .key {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 14px; font-weight: 800; color: var(--muted);
}
.opt.right { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 11%, var(--card)); }
.opt.right .key { background: var(--teal); color: #fff; border-color: var(--teal); }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 9%, var(--card)); }
.opt.wrong .key { background: var(--red); color: #fff; border-color: var(--red); }

.explain {
  margin-top: 22px; padding: 20px 22px; border-radius: 13px;
  background: color-mix(in srgb, var(--navy) 6%, var(--card));
  border-inline-start: 4px solid var(--navy-2); font-size: 16.5px;
}
.explain .verdict { font-weight: 800; display: block; margin-bottom: 6px; font-size: 17px; }
.explain .verdict.good { color: var(--teal); }
.explain .verdict.bad { color: var(--red); }

/* --------------------------------------------------------- quiz extras -- */
.facts {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  color: var(--muted); font-size: 15px; font-weight: 700; margin-bottom: 22px;
}

.resume {
  background: color-mix(in srgb, var(--orange) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--orange) 40%, transparent);
  border-radius: 13px; padding: 18px; margin-bottom: 22px; text-align: center;
}
.resume p { margin: 0 0 12px; font-weight: 700; }
.resume-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.resume-btns .btn { padding: 11px 22px; font-size: 15.5px; }

.flash {
  margin-top: 16px; padding: 13px; border-radius: 11px; text-align: center;
  font-weight: 800; font-size: 17px;
}
.flash.good { background: color-mix(in srgb, var(--teal) 15%, var(--card)); color: var(--teal); }
.flash.bad  { background: color-mix(in srgb, var(--red) 12%, var(--card)); color: var(--red); }

.linkish {
  background: none; border: 0; padding: 0; font: inherit; font-size: 15.5px;
  color: var(--teal); text-decoration: underline; cursor: pointer;
}

.big-rating {
  text-align: center; font-size: clamp(52px, 13vw, 82px); font-weight: 800;
  line-height: 1.05; color: var(--orange); margin: 6px 0 10px;
  font-family: "Times New Roman", Georgia, serif; direction: ltr;
}

.stat-row { display: flex; gap: 14px; justify-content: center; margin: 22px 0; }
.stat {
  flex: 1; max-width: 170px; text-align: center; padding: 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.stat b { display: block; font-size: 21px; color: var(--navy-ink); }
.stat span { font-size: 14px; color: var(--muted); font-weight: 700; }

.promo {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-wrap: wrap; margin: 12px auto 0; padding: 12px;
  background: var(--card); border: 2px solid var(--teal); border-radius: 13px;
  max-width: 420px;
}
.promo-label { font-weight: 800; font-size: 15px; margin-inline-end: 4px; }
.promo-btn {
  width: 52px; height: 52px; border-radius: 10px; cursor: pointer;
  background: #EAF1FB; border: 2px solid var(--line);
  display: grid; place-items: center;
}
.promo-btn:hover { border-color: var(--teal); }
.promo-btn .piece { font-size: 30px; }

/* -------------------------------------------------------------- review -- */
.review-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; max-width: 760px; margin: 0 auto 18px;
}
.review-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; font-weight: 800; color: var(--navy-ink);
}
.review-head .d {
  background: color-mix(in srgb, var(--teal) 13%, transparent);
  color: var(--teal); padding: 4px 12px; border-radius: 999px; font-size: 14px;
}
.review-card .board-wrap { max-width: 300px; }
.review-ask { text-align: center; font-weight: 700; margin: 14px 0 8px; }
.review-ans { text-align: center; margin: 0 0 10px; }
.review-why { color: var(--muted); font-size: 15.5px; margin: 0; }

/* -------------------------------------------------------------- result --- */
.score-ring { display: grid; place-items: center; margin: 0 auto 8px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val { margin-top: -104px; text-align: center; font-weight: 800; }
.score-ring .val b { display: block; font-size: 40px; line-height: 1.1; color: var(--navy-ink); }
.score-ring .val span { font-size: 14px; color: var(--muted); font-weight: 700; }

.level-badge {
  display: block; text-align: center; font-size: 27px; font-weight: 800;
  color: var(--orange); margin: 6px 0 4px;
}

.breakdown { display: grid; gap: 10px; margin: 26px 0; }
.brow { display: flex; align-items: center; gap: 12px; font-size: 15.5px; }
.brow .nm { flex: none; width: 88px; font-weight: 700; color: var(--muted); }
.brow .bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.brow .bar i { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.brow .sc { flex: none; font-weight: 800; width: 46px; text-align: end; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.tags li {
  padding: 6px 13px; border-radius: 999px; font-size: 14.5px; font-weight: 700;
  background: color-mix(in srgb, var(--red) 10%, transparent); color: var(--red);
}
.tags li.ok { background: color-mix(in srgb, var(--teal) 12%, transparent); color: var(--teal); }

.rec {
  margin: 26px 0; padding: 22px; border-radius: 13px; text-align: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff;
}
.rec small { display: block; opacity: .78; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.rec strong { font-size: 22px; display: block; }

/* ---------------------------------------------------------------- form --- */
.field { margin-bottom: 15px; }
.field label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 16px; border-radius: 11px;
  border: 2px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px;
}
.field input:focus, .field select:focus { outline: 0; border-color: var(--teal); }
.field .err { color: var(--red); font-size: 14px; font-weight: 700; margin-top: 5px; display: none; }
.field.bad input { border-color: var(--red); }
.field.bad .err { display: block; }
.fineprint { font-size: 13.5px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* -------------------------------------------------------------- footer --- */
footer {
  border-top: 1px solid var(--line); padding: 34px 0;
  color: var(--muted); font-size: 15px;
}
footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
footer a { color: var(--muted); text-decoration: none; margin-inline-start: 18px; }
footer a:hover { color: var(--teal); }

/* ---------------------------------------------------------------- misc --- */
.center { text-align: center; }
.mt { margin-top: 26px; }
[hidden] { display: none !important; }

.fade { animation: fade .28s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .panel { padding: 22px 18px; border-radius: 14px; }
  .opt { padding: 14px 16px; }
  section { padding: 46px 0; }
  .hero { padding: 44px 0 40px; }
}
