:root {
  --red: #7a1f1a;
  --red-deep: #521410;
  --gold: #d9a441;
  --gold-soft: #f0d9a4;
  --gold-bright: #ffcc55;   /* readable gold on the dark-red header */
  --hero-bg: #5c1410;       /* darker red so white/gold text stands out */
  --sand: #f7efe1;
  --paper: #fffdf8;
  --ink: #2b1a12;
  --muted: #5f4b3c;         /* darker than before for readable secondary text */
  --line: #e6d6bc;
  --input-line: #d6bf99;    /* visible field borders */
  --error: #b42318;
  --ok: #1f7a4a;
  --radius: 14px;
  --font-body: 'Tajawal', system-ui, sans-serif;
  --font-display: 'Reem Kufi', 'Tajawal', serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--sand);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  color: #fff;
  text-align: center;
  padding: 60px 16px 116px;
  background-color: var(--hero-bg);
  /* Dark wash behind the text for strong contrast, then a faint 8-point Moroccan star pattern */
  background-image:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(0, 0, 0, .38), transparent 75%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23d9a441' stroke-opacity='.13' stroke-width='1.2'%3E%3Crect x='16' y='16' width='24' height='24'/%3E%3Crect x='16' y='16' width='24' height='24' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: auto, 56px 56px;
}
.hero::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 10px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 18px, var(--red-deep) 18px 24px);
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.edition {
  display: inline-block;
  margin: 0 0 24px;
  padding: 7px 22px;
  border: 1.5px solid var(--gold-bright);
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-weight: 700;
  font-size: clamp(16px, 4.2vw, 19px);
}
.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(55px, 15.6vw, 110px);
  line-height: 1.12;
  letter-spacing: .5px;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .45), 0 0 28px rgba(0, 0, 0, .45);
}
.hero h1 span {
  display: block;
  margin-top: 8px;
  color: var(--gold-bright);
}
.dates {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 0;
  padding: 11px clamp(14px, 4vw, 24px);
  white-space: nowrap;
  border-radius: 12px;
  background: var(--paper);
  color: var(--hero-bg);
  font-weight: 700;
  font-size: clamp(16px, 4.5vw, 22px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.dates svg { width: 22px; height: 22px; fill: var(--red); flex: none; }

/* ---------- Card / form ---------- */
.card {
  position: relative;
  max-width: 580px;
  margin: -64px auto 0;
  padding: 34px 26px 34px;
  background: var(--paper);
  border-radius: var(--radius);
  border-top: 5px solid var(--gold);
  box-shadow: 0 16px 40px rgba(82, 20, 16, .16), 0 1px 0 var(--line);
}
.card.narrow { margin-top: 48px; text-align: center; }
.card h2 {
  margin: 0;
  line-height: 1.3;
  font-family: var(--font-display);
  font-size: clamp(26px, 7vw, 32px);
  color: var(--red);
}
.lead { margin: 0 0 28px; color: var(--muted); font-size: 18px; line-height: 1.7; }
.ornament { display: flex; align-items: center; gap: 8px; margin: 12px 0 14px; }
.ornament span { width: 44px; height: 2px; border-radius: 2px; background: var(--gold); }
.ornament i { width: 9px; height: 9px; background: var(--gold); transform: rotate(45deg); }

.field { margin-bottom: 24px; }
.field > label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
}
.ico { width: 20px; height: 20px; margin-top: 3px; fill: var(--red); flex: none; }
input[type=text], input[type=tel], input[type=email] {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 18px; /* ≥16px stops iOS zoom */
  line-height: 1.4;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--input-line);
  border-radius: 12px;
  box-shadow: inset 0 1px 2px rgba(60, 30, 10, .06);
  transition: border-color .15s, box-shadow .15s;
}
input[dir=ltr] { text-align: left; letter-spacing: 1px; }
input::placeholder { color: #8f7c69; letter-spacing: 0; }
input:focus {
  outline: none;
  border-color: #b8801f;
  box-shadow: 0 0 0 4px rgba(217, 164, 65, .3);
}
input[aria-invalid=true] { border-color: var(--error); }

.check label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 500;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
}
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--red); flex: none; }

.err { margin: 8px 0 0; color: var(--error); font-size: 15px; font-weight: 500; line-height: 1.5; }
.err:empty { display: none; }
.err.general { margin-bottom: 12px; text-align: center; }

/* Visually hidden without pushing anything off-screen (an off-screen offset causes sideways scroll in RTL) */
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.btn {
  display: inline-block;
  padding: 12px 22px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  background: var(--red);
  cursor: pointer;
}
.btn.primary {
  width: 100%;
  margin-top: 6px;
  padding: 17px;
  border-radius: 12px;
  font-size: 21px;
  letter-spacing: .5px;
  background: linear-gradient(180deg, #9a2a22, var(--hero-bg));
  box-shadow: 0 8px 18px rgba(92, 20, 16, .28), inset 0 -3px 0 rgba(0, 0, 0, .22);
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .7; cursor: wait; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Success / notices ---------- */
.notice { text-align: center; padding: 8px 0; }
.notice.success h2 { color: var(--ok); }
.notice.error h2 { color: var(--error); }
.notice ul { text-align: right; color: var(--error); }
.tick {
  width: 72px; height: 72px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 38px;
  color: #fff;
  background: var(--ok);
}
.ref {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 16px;
  border-radius: 8px;
  background: var(--sand);
  font-weight: 700;
}
.ref:empty { display: none; }

.foot { text-align: center; padding: 28px 16px 36px; color: var(--muted); font-size: 14px; }

/* ---------- Admin ---------- */
.admin { padding: 24px 16px; }
.card.wide { max-width: 1320px; margin: 0 auto; }
.admin-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.admin-head h1 { margin: 0; font-family: var(--font-display); color: var(--red); font-size: 26px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stats div { flex: 1 1 140px; padding: 12px 16px; border-radius: 10px; background: var(--sand); color: var(--muted); }
.stats span { display: block; font-size: 28px; font-weight: 700; color: var(--ink); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { background: var(--sand); font-weight: 700; position: sticky; top: 0; }
td.empty { text-align: center; color: var(--muted); padding: 30px; }

@media (max-width: 420px) {
  .card { margin-left: 12px; margin-right: 12px; padding: 22px 16px 24px; }
}

/* ---------- Registration period ---------- */
.reg-period {
  display: table; /* own line, centered, shrink-to-fit */
  margin: 20px auto 0;
  padding: 7px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .4);
  color: #fff;
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 700;
}
.reg-period b { color: var(--gold-bright); }

/* ---------- QR identity ---------- */
.qr-box {
  display: inline-block;
  margin: 14px auto 6px;
  padding: 14px 14px 8px;
  background: #fff;
  border: 2px solid var(--gold);
  border-radius: 14px;
}
.qr-box img { display: block; width: 240px; height: 240px; max-width: 100%; image-rendering: pixelated; }
.qr-box .code { margin: 8px 0 0; font: 700 18px/1.2 ui-monospace, 'SFMono-Regular', Menlo, monospace; letter-spacing: 2px; color: var(--ink); }
.hint { color: var(--muted); font-size: 14px; }

/* ---------- Verify (QR scan) page ---------- */
.verify { text-align: center; }
.verified { display: inline-block; padding: 6px 16px; border-radius: 999px; background: var(--ok); color: #fff; font-weight: 700; }
.verify h1 { margin: 12px 0 8px; font-family: var(--font-display); color: var(--red); font-size: 28px; }
.details { margin: 0 0 6px; text-align: right; }
.details div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 700; }
.actions { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }

.hint-inline { font-weight: 500; font-size: 15px; color: var(--muted); white-space: nowrap; }
