/* ============================================================
   نظام المواعيد والدور — Citizen site
   Official Syrian visual identity (frontend/public assets):
   Qomra Arabic type, burgundy + gold, state emblem, damask accents.
   Elderly-friendly: large type, big targets, strong contrast.
   ============================================================ */

@font-face {
  font-family: "Qomra Arabic";
  src: url("/public/fonts/itfQomraArabic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Qomra Arabic";
  src: url("/public/fonts/itfQomraArabic-Light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Qomra Arabic";
  src: url("/public/fonts/itfQomraArabic-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* --- Brand palette: Forest + Golden Wheat ------------------------------
     Forest      #428177   primary
     Forest deep #054239
     Forest ink  #002623
     Wheat       #edebe0   page ground
     Wheat gold  #b9a779
     Wheat deep  #988561
     The --burgundy-* names are kept for compatibility with the rules below,
     but the ramp is now Forest green, not burgundy. */
  --burgundy-950: #002623;   /* Forest ink */
  --burgundy-900: #04332c;
  --burgundy-800: #054239;   /* Forest deep */
  --burgundy-700: #0d5a4e;
  --burgundy-600: #428177;   /* Forest — primary */
  --burgundy-100: #dceae7;
  --burgundy-50: #edebe0;    /* Wheat */

  --gold: #b9a779;           /* Wheat gold */
  --gold-bright: #d3c69e;
  --gold-deep: #988561;      /* Wheat deep */
  --gold-soft: #f2eee0;
  --gold-line: #ddd6c0;

  --red: #b3452f;        /* flag red (danger), deepened for the new ground */
  --red-soft: #f7e4e0;

  --cream: #edebe0;      /* Wheat — warm ground */
  --paper: #faf8f1;

  --ink: #1b2624;
  --muted: #6b7a77;

  --card: #ffffff;
  --line: #e0ded2;

  --focus: #428177;
  --ok: #2f7d54;
  --ok-soft: #e4f1e8;
  --warn: #8a6412;
  --warn-soft: #f6efdc;

  --shadow: 0 6px 18px rgba(0, 38, 35, 0.12);
  --radius: 18px;

  --base: 20px;
  --sp: 8px;
  --maxw: 900px;
}

* { box-sizing: border-box; }

html {
  font-size: var(--base);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Qomra Arabic", "Noto Kufi Arabic", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  font-weight: 400;
  background:
    radial-gradient(1100px 420px at 88% -90px, #dceae7 0%, transparent 60%),
    radial-gradient(900px 380px at -10% 110%, #e8e2cf 0%, transparent 55%),
    var(--cream);
  color: var(--ink);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* damask calligraphy watermark (pt2.svg) across the viewport */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/public/pt2.svg") center / cover no-repeat;
  opacity: 0.045;
  pointer-events: none;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp) 1rem 3rem;
}

a { color: var(--burgundy-700); text-decoration-thickness: 2px; }
a:hover { color: var(--burgundy-600); }

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------- brand header ---------------- */
.site-header {
  background:
    linear-gradient(180deg, rgba(0, 38, 35, 0.22), rgba(0, 38, 35, 0.52)),
    linear-gradient(180deg, var(--burgundy-700), var(--burgundy-950));
  color: #fff;
  border-bottom: 3px solid var(--gold-deep);
  padding: 0.9rem 1rem;
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/public/pattern-lg.png") top / auto 100% repeat-x;
  opacity: 0.1;
  pointer-events: none;
}

.brand {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand .mark {
  width: 68px;
  height: 68px;
  flex: none;
  border-radius: 50%;
  background: rgba(237, 235, 224, 0.14);
  border: 2px solid var(--gold-bright);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 4px rgba(211, 198, 158, 0.20);
  overflow: hidden;
}

.brand .mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
}

.brand p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--gold-bright);
}

/* ---------------- components ---------------- */
.hero {
  text-align: center;
  padding: 2.5rem 0 1rem;
}

.hero .eyebrow {
  display: inline-block;
  background: var(--gold-soft);
  color: var(--burgundy-800);
  font-weight: 700;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  padding: 0.3rem 1.1rem;
  font-size: 0.95rem;
  margin-bottom: 1.1rem;
}

.hero h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  margin: 0 0 0.7rem;
  line-height: 1.35;
  color: var(--burgundy-950);
}

.hero p.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 40rem;
  margin: 0 auto;
}

/* giant landing buttons */
.cta-stack {
  display: grid;
  gap: 1.1rem;
  max-width: 620px;
  margin: 2.2rem auto 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-height: 3.5rem;
  padding: 0.9rem 1.6rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: 1.12rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--burgundy-700);
  color: #fff;
  box-shadow: var(--shadow);
  border-color: var(--gold-deep);
  font-size: 1.45rem;
  min-height: 4.6rem;
  padding: 1rem 2rem;
}
.btn-primary:hover { background: var(--burgundy-800); color: #fff; }
.btn-primary svg { width: 30px; height: 30px; }

.btn-secondary {
  background: var(--card);
  border-color: var(--burgundy-700);
  color: var(--burgundy-800);
}
.btn-secondary:hover { background: var(--burgundy-50); }

.btn-ghost {
  background: transparent;
  color: var(--burgundy-800);
}
.btn-ghost:hover { background: var(--burgundy-50); }

.btn-danger {
  background: var(--card);
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover { background: var(--red-soft); }

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold-deep);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
  margin: 1.4rem 0;
}

.card.no-shadow { box-shadow: none; background: var(--paper); }

.card h2, .card h3 { margin-top: 0; color: var(--burgundy-950); }

/* form */
.step {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--burgundy-950);
  margin: 0 0 1rem;
}

.step .num {
  width: 2.1rem;
  height: 2.1rem;
  flex: none;
  border-radius: 50%;
  background: var(--burgundy-700);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.field { margin: 1.1rem 0; }
.field label { display: block; font-weight: 700; margin-bottom: 0.4rem; }
.field .hint { color: var(--muted); font-size: 0.9rem; margin-top: 0.3rem; }

select, input[type="text"], input[type="tel"], input[type="number"] {
  width: 100%;
  min-height: 3.4rem;
  font: inherit;
  font-size: 1.15rem;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

select:hover, input:hover { border-color: var(--gold-deep); }
select:focus-visible, input:focus-visible { border-color: var(--focus); }

select option:checked { font-weight: 700; }

input::placeholder { color: #9aa8a3; }

/* segmented party-size chooser */
.seg {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.seg button {
  flex: 0 0 auto;
  min-width: 4rem;
  min-height: 3.4rem;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--burgundy-700);
  border-color: var(--burgundy-700);
  color: #fff;
}

/* ---------------- transaction rows (max 15 per visit) ---------------- */
.tx-counter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  margin: 0.9rem 0;
  font-weight: 700;
  font-size: 0.98rem;
}
.tx-counter strong { color: var(--burgundy-800); }
.tx-counter .tx-total { color: var(--burgundy-700); }

.tx-list { display: grid; gap: 0.6rem; }

.tx-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.tx-row select,
.tx-row input {
  min-height: 3rem;
  font-size: 1.05rem;
  padding: 0.4rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.tx-row .tx-amount { direction: ltr; text-align: right; }

.tx-del {
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--red);
  font-size: 1.1rem;
  cursor: pointer;
}
.tx-del:hover { background: var(--red-soft); border-color: var(--red); }

.tx-summary {
  background: var(--burgundy-50);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  margin: 1rem 0 0;
  font-weight: 700;
  text-align: center;
}

/* expected arrival window, before confirming and on the ticket */
.arrival-estimate {
  border: 1px dashed var(--gold-line);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  margin: 0.8rem 0 0;
  text-align: center;
  line-height: 1.8;
}
.arrival-estimate small { color: var(--muted); font-weight: 400; }
.ticket .arrival {
  margin: 0.9rem auto 0;
  padding: 0.6rem 1rem;
  max-width: 340px;
  background: var(--burgundy-50);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  font-size: 1.1rem;
}
.ticket .arrival-note { color: var(--muted); font-size: 0.85rem; margin: 0.4rem auto 0; max-width: 340px; }

/* transactions table on the ticket */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0 0;
  font-size: 0.98rem;
}
.items-table th,
.items-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.4rem;
}
.items-table thead th { background: var(--gold-soft); color: var(--burgundy-900); }
.items-table tfoot th { border-bottom: none; border-top: 2px solid var(--gold-deep); }
.items-table .ltr { direction: ltr; text-align: left; }

@media (max-width: 520px) {
  .tx-row { grid-template-columns: 1fr 1fr auto; font-size: 0.95rem; }
  .tx-row select, .tx-row input { font-size: 0.95rem; padding: 0.35rem 0.5rem; }
}

/* info row inside the type option */
.opt-info {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

/* alert */
.alert {
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  font-weight: 700;
  border: 2px solid transparent;
  display: none;
}
.alert[hidden] { display: none; }
.alert.show { display: block; }
.alert-error { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.alert-info { background: var(--gold-soft); border-color: var(--gold-deep); color: var(--burgundy-900); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

/* appointment ticket */
.ticket {
  border: 2px dashed var(--gold-deep);
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
  padding: 2rem 1.4rem;
}
.ticket .queue {
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 700;
  color: var(--burgundy-700);
  line-height: 1.05;
  letter-spacing: 1px;
}
.ticket .qlabel { color: var(--muted); font-weight: 700; font-size: 1rem; }
.ticket .queues {
  list-style: none;
  margin: 0.4rem auto 0;
  padding: 0;
  max-width: 360px;
  display: grid;
  gap: 0.45rem;
}
.ticket .queues li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
  background: var(--burgundy-50);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  padding: 0.45rem 0.8rem;
  font-weight: 700;
}
.ticket .queues .qnum { font-size: 1.4rem; color: var(--burgundy-700); }
.ticket .queues .qqty { color: var(--muted); font-size: 0.9rem; }
.ticket .code {
  display: inline-block;
  background: var(--burgundy-950);
  color: var(--gold-bright);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.4rem 1.4rem;
  border-radius: 999px;
  margin: 0.8rem 0;
  direction: ltr;
}
.ticket dl { display: grid; grid-template-columns: 1fr; gap: 0.4rem; margin: 1.2rem auto 0; max-width: 340px; text-align: right; }
.ticket dt { color: var(--muted); font-size: 0.95rem; }
.ticket dd { margin: 0; font-size: 1.15rem; font-weight: 700; }

.badge-status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.25rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
}
.badge-booked { background: var(--ok-soft); color: var(--ok); }
.badge-review { background: var(--warn-soft); color: var(--warn); }
.badge-cancelled, .badge-canceled { background: var(--red-soft); color: var(--red); }
.badge-completed { background: var(--gold-soft); color: var(--burgundy-800); }
.badge-no_show, .badge-no-show { background: var(--muted); color: #fff; }

/* status glossary */
.status-list { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.status-list li { display: flex; gap: 0.6rem; align-items: baseline; }

/* summary rows (lookup/booking detail) */
.summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  margin: 1rem 0;
}
.summary div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding-bottom: 0.5rem; }
.summary dt { font-weight: 700; color: var(--muted); }
.summary dd { margin: 0; font-weight: 700; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1.4rem;
}

/* footer */
.site-footer {
  background: var(--burgundy-950);
  color: var(--gold-bright);
  border-top: 3px solid var(--gold-deep);
  text-align: center;
  padding: 1.4rem 1rem;
  font-size: 0.95rem;
}
/* skip link */
.skip {
  position: absolute;
  inset-inline-start: -9999px;
  background: var(--red);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 10px 0;
  z-index: 50;
}
.skip:focus { inset-inline-start: 0; }

/* spinner */
.spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -0.15em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* hidden honeypot */
.honeypot {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  inset-inline-start: -9999px;
  white-space: nowrap;
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Print: the ticket card only.
   Keyed off `body.has-ticket`, set by app.js the moment a ticket is rendered. */
@media print {
  /* Print only the ticket.

     Keyed off `body.has-ticket`, a class app.js sets as soon as a ticket is
     rendered — NOT on the print button click, so Ctrl+P behaves the same.

     An earlier version used `body:has(.ticket)`. `:has()` is unsupported before
     Chrome 105 / Firefox 121 / Safari 15.4, and an unsupported selector makes
     the browser drop the whole rule silently — that is how the ticket ended up
     printing at half width, pushed to one side, with the site header still
     showing. A plain class works on every browser. */

  .no-print,
  #formAlert,
  .alert { display: none !important; }

  html, body { background: #fff !important; width: auto; height: auto; margin: 0; padding: 0; }

  body.has-ticket .site-header,
  body.has-ticket .site-footer,
  body.has-ticket main > [data-step],
  body.has-ticket main > .card:not([id]),
  body.has-ticket main > a,
  body.has-ticket noscript { display: none !important; }

  body.has-ticket,
  body.has-ticket main,
  body.has-ticket main *,
  body.has-ticket #resultCard,
  body.has-ticket #ticketCard {
    display: block !important;
    float: none !important;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    transform: none !important;
  }

  body.has-ticket .no-print,
  body.has-ticket #formAlert,
  body.has-ticket .alert { display: none !important; }

  body.has-ticket #resultCard,
  body.has-ticket #ticketCard {
    border: none !important; box-shadow: none !important;
    background: none !important; padding: 0 !important;
  }

  body.has-ticket .ticket {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid; break-inside: avoid;
    width: 100% !important; max-width: 100% !important;
    padding: 8mm 6mm;
    overflow: visible;
  }

  body.has-ticket .ticket .queue { font-size: 34pt !important; line-height: 1.05; }
  body.has-ticket .ticket .queues .qnum { font-size: 16pt !important; }
  body.has-ticket .ticket .code  { font-size: 15pt !important; }
  body.has-ticket .items-table  { font-size: 10pt !important; width: 100% !important; }
  body.has-ticket .ticket dl     { font-size: 11pt !important; }
  body.has-ticket * { overflow-wrap: break-word; word-break: break-word; }

  @page { size: A4 portrait; margin: 12mm; }
}

/* QR check-in (/checkin): one plain sentence, then the numbers */
.checkin-card { text-align: center; }
.checkin-wait { font-size: 1.25rem; font-weight: 700; color: var(--muted); margin: 1rem 0; }
.checkin-state { font-size: clamp(1.4rem, 5vw, 1.9rem); font-weight: 700; margin: 0.4rem 0 0.8rem; }
.checkin-state.ok { color: var(--ok); }
.checkin-state.staff { color: var(--burgundy-900); }
.checkin-card .ticket { margin-top: 0.6rem; padding: 1.2rem 1rem; }
.checkin-card .hint { color: var(--muted); margin: 0.8rem 0 0; }
