:root {
  /* Hero */
  --deep: #092a1e;
  --gold: #c9b48f;
  --gold-soft: #e6d8bd;
  --sand: #f8f4ef;
  /* Page: Nusuk's light palette */
  --green: #1b8354;
  --green-strong: #14693f;
  --bronze: #806b4b;
  --bg: #fff;
  --soft: #f3f4f6;
  --paper: #fff;
  --ink: #1f2a37;
  --muted: #5d6673;
  --line: #e5e7eb;
  --danger: #b42318;
  --display: "El Messiri", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ticket-shadow: drop-shadow(0 1px 1px rgba(31, 42, 55, .1)) drop-shadow(0 8px 18px rgba(31, 42, 55, .09));
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, p { margin: 0; }
button, input { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.wrap { width: 100%; max-width: 640px; margin-inline: auto; padding-inline: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.code { font-family: var(--mono); font-weight: 500; letter-spacing: .02em; overflow-wrap: anywhere; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Hero */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: var(--sand);
  padding-block: 14px 76px;
  text-align: center;
  background: var(--deep);
}
.hero-photo {
  position: absolute;
  z-index: -1;
  inset: 0 0 auto;
  width: 100%;
  height: clamp(380px, 62svh, 560px);
  object-fit: cover;
  object-position: 50% 62%;
  -webkit-mask-image: linear-gradient(#000 62%, transparent);
  mask-image: linear-gradient(#000 62%, transparent);
  animation: drift 26s ease-in-out infinite alternate;
  transform-origin: 50% 62%;
}
@keyframes drift { to { transform: scale(1.09); } }
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 auto;
  height: clamp(380px, 62svh, 560px);
  background: linear-gradient(rgba(9, 42, 30, .72), rgba(9, 42, 30, .45) 30%, rgba(9, 42, 30, .45));
}
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: clamp(230px, calc(62svh - 170px), 400px); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 600 22px/1 var(--display); }
.brand img { border-radius: 10px; }
.lang {
  min-height: 44px; padding-block: 0; padding-inline: 16px 34px; cursor: pointer; color: inherit; font-size: 14px;
  -webkit-appearance: none; appearance: none;
  background: rgba(9, 42, 30, .35) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23f8f4ef' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid rgba(201, 180, 143, .45); border-radius: 999px; transition: border-color .15s;
}
[dir="rtl"] .lang { background-position: left 14px center; }
.lang-menu { position: relative; z-index: 2; }
.lang { display: inline-flex; align-items: center; gap: 8px; }
.flag { flex: none; width: 20px; height: 15px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.lang-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 170px; margin: 0; padding: 6px; list-style: none;
  background: var(--paper); border-radius: 12px; box-shadow: 0 14px 34px rgba(31, 42, 55, .25);
}
.lang-list button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 6px 10px; cursor: pointer;
  color: var(--ink); font-size: 14px; text-align: start; background: none; border: 0; border-radius: 8px;
}
.lang-list button:hover { background: var(--soft); }
.lang-list button[aria-selected="true"] { font-weight: 600; background: var(--sand); }
.lang:hover { border-color: var(--gold); }
h1 { font: 700 clamp(31px, 8.6vw, 46px)/1.3 var(--display); text-wrap: balance; }
.lead { max-width: 30em; margin: 12px auto 0; font-size: 17px; color: #d8d2c6; text-wrap: balance; }
.count {
  display: inline-block; margin: 18px 3px 0; padding: 4px 14px; color: var(--gold-soft); font-size: 14px; font-weight: 500;
  border: 1px solid rgba(201, 180, 143, .35); border-radius: 999px;
}
.hero h1, .hero .lead, .hero .count { animation: rise .7s cubic-bezier(.2, .7, .2, 1) backwards; }
.hero .lead { animation-delay: .12s; }
.hero .count { animation-delay: .24s; }
#today::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-inline-end: 7px; vertical-align: 1px;
  background: #5fe0a2; border-radius: 50%; animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(95, 224, 162, .7); } to { box-shadow: 0 0 0 9px rgba(95, 224, 162, 0); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px; cursor: pointer; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; transition: background-color .15s, border-color .15s, color .15s, transform .12s;
}
a.btn { text-decoration: none; }
.btn:active:not(:disabled), .tool:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.primary { color: #fff; background: var(--green); }
.primary:hover:not(:disabled) { background: var(--green-strong); }
.ghost { color: var(--ink); background: var(--paper); border-color: var(--line); }
.ghost:hover { border-color: var(--bronze); }
.small { min-height: 40px; font-size: 14px; }
.wide { width: 100%; }
.link {
  min-height: 44px; padding: 0; cursor: pointer; border: 0; background: none; color: var(--muted);
  font-size: 14px; text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: var(--ink); }

/* Layout */
.main { position: relative; z-index: 1; margin-top: -48px; display: grid; gap: 40px; padding-bottom: 64px; }
.section-title { font: 700 26px/1.3 var(--display); }

/* Add your code */
.dock {
  width: 100%; max-width: 640px; margin-inline: auto; padding: 18px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 34px rgba(31, 42, 55, .12);
}
.dock h2 { font-size: 18px; font-weight: 600; line-height: 1.4; }
.dock .hint { color: var(--muted); font-size: 14px; }
#add-form { display: flex; gap: 8px; margin-top: 10px; }
#code-input {
  flex: 1; min-width: 0; height: 50px; padding-inline: 14px; color: var(--ink); background: var(--soft);
  border: 1px solid transparent; border-radius: 10px; font-family: var(--mono); text-align: left; transition: border-color .15s, background-color .15s;
}
#code-input:focus { outline: 0; background: var(--paper); border-color: var(--green); }
#add-form .btn { min-height: 50px; }
#ts:not(:empty) { margin-top: 10px; }
.msg { margin-top: 8px; font-size: 14px; }
.msg:empty { display: none; }
.msg.error { color: var(--danger); }
.mine-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
#mine-code { font-size: 18px; }
#mine-add { min-height: 36px; margin-top: 4px; }

.note { display: grid; gap: 10px; max-width: 640px; width: 100%; margin-inline: auto; padding: 14px 16px; background: var(--sand); border-radius: 12px; font-size: 14px; }
.note .btn { justify-self: start; }

/* Helper progress */
.my-stats { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.keys { display: inline-flex; gap: 2px; }
.keys .icon { width: 18px; height: 18px; color: var(--line); transition: color .3s; }
.keys .icon.on { color: var(--bronze); }

/* Current code: a boarding pass */
.stage-pass { width: 100%; max-width: 820px; margin-inline: auto; }
/* The next tickets peek out from behind the current one */
.pass-stack { position: relative; isolation: isolate; }
#focus.has-next .pass-stack { padding-bottom: 20px; }
#focus.has-next .pass-stack::before, #focus.has-next .pass-stack::after {
  content: ""; position: absolute; height: 72px; background: var(--paper); border-radius: 0 0 16px 16px; filter: var(--ticket-shadow);
}
#focus.has-next .pass-stack::before { z-index: -1; inset-inline: 12px; bottom: 10px; background: #f6f1e8; }
#focus.has-next .pass-stack::after { z-index: -2; inset-inline: 26px; bottom: 0; background: #ece4d6; }
.pass { filter: var(--ticket-shadow); animation: deal .4s cubic-bezier(.2, .8, .2, 1); }
@keyframes deal { from { opacity: 0; transform: translateY(14px); } }
.pass-main { overflow: hidden; background: var(--paper); border-radius: 16px 16px 0 0; }
.pass-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px;
  color: #fff; background: var(--green);
}
.pass-brand { display: flex; align-items: center; gap: 8px; font: 700 18px/1 var(--display); }
.pass-kind { font-size: 13px; opacity: .9; }
.pass-route { display: flex; align-items: center; gap: 12px; padding: 20px 18px 4px; }
.stop { flex: none; }
.stop b { display: block; font: 700 38px/1.1 var(--display); letter-spacing: .02em; }
.stop span { display: block; color: var(--muted); font-size: 13px; }
.stop:last-child { text-align: end; }
.flight { position: relative; flex: 1; height: 24px; color: var(--bronze); }
.flight::before { content: ""; position: absolute; inset: 50% 0 auto; border-top: 2px dotted #cfc6b6; }
.flight .icon { position: absolute; top: 50%; left: 50%; width: 24px; height: 24px; padding: 2px; fill: currentColor; stroke: none; background: var(--paper); transform: translate(-50%, -50%); }
[dir="rtl"] .flight .icon { transform: translate(-50%, -50%) scaleX(-1); }
.pass-field { padding: 14px 18px 18px; }
.field-label { display: block; color: var(--muted); font-size: 13px; }
.pass-field .code { display: block; margin-top: 2px; color: var(--ink); font-size: clamp(27px, 8.6vw, 36px); line-height: 1.25; text-align: start; }
.pass-tear { position: relative; height: 22px; background: var(--paper); }
.pass-tear::before { content: ""; position: absolute; inset: 10px 18px auto; border-top: 2px dashed var(--line); }
.pass-tear {
  -webkit-mask-image: radial-gradient(circle at 0 50%, transparent 11px, #000 11.5px), radial-gradient(circle at 100% 50%, transparent 11px, #000 11.5px);
  mask-image: radial-gradient(circle at 0 50%, transparent 11px, #000 11.5px), radial-gradient(circle at 100% 50%, transparent 11px, #000 11.5px);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.pass-stub { display: grid; gap: 14px; padding: 6px 18px 18px; background: var(--paper); border-radius: 0 0 16px 16px; }
.barcode { display: block; width: 100%; height: 44px; fill: var(--ink); }
.pass .actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pass .btn { min-height: 52px; }
.pass.leaving { animation: fly .32s ease-in forwards; }
@keyframes fly { to { opacity: 0; transform: translateY(-30px) scale(.97); } }
.pass-note { margin-top: 12px; text-align: center; }
.pass-note p { padding: 12px 14px; color: var(--ink); font-size: 14px; font-weight: 500; text-wrap: balance; background: var(--sand); border-radius: 12px; }
.pass-note .link { min-height: 40px; font-size: 13px; }

.state { padding: 36px 20px; text-align: center; color: var(--muted); background: var(--soft); border-radius: 16px; }
.state:empty { display: none; }

.spark {
  position: fixed; z-index: 3; color: var(--bronze); font-size: 15px; line-height: 1; pointer-events: none;
  animation: spark .7s cubic-bezier(.15, .7, .3, 1) forwards;
}
@keyframes spark {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.6); }
  to { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.2) rotate(120deg); }
}

/* More codes: small tickets */
.more-codes { width: 100%; max-width: 820px; margin-inline: auto; }
.list-head { margin-bottom: 14px; }
.list { display: grid; gap: 12px; }
.mini { display: flex; filter: var(--ticket-shadow); transition: transform .15s; }
.mini:hover { transform: translateY(-2px); }
.mini.enter { animation: rise .45s cubic-bezier(.2, .7, .2, 1) backwards; }
.mini.leaving { animation: fly .3s ease-in forwards; }
.mini-main {
  flex: 1; min-width: 0; padding: 12px 14px; background: var(--paper);
  border-start-start-radius: 12px; border-end-start-radius: 12px;
}
.mini-main .code { display: block; font-size: 16px; line-height: 1.4; }
.mini-route { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.mini-route .icon { width: 13px; height: 13px; color: var(--bronze); fill: currentColor; stroke: none; }
[dir="rtl"] .mini-route .icon { transform: scaleX(-1); }
.mini-tear {
  position: relative; flex: none; width: 14px; background: var(--paper);
  -webkit-mask-image: radial-gradient(circle at 50% 0, transparent 7px, #000 7.5px), radial-gradient(circle at 50% 100%, transparent 7px, #000 7.5px);
  mask-image: radial-gradient(circle at 50% 0, transparent 7px, #000 7.5px), radial-gradient(circle at 50% 100%, transparent 7px, #000 7.5px);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.mini-tear::before { content: ""; position: absolute; inset: 10px auto 10px 6px; border-inline-start: 2px dashed var(--line); }
.mini-stub {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 8px; background: var(--paper);
  border-start-end-radius: 12px; border-end-end-radius: 12px;
}
[dir="rtl"] .mini-stub { padding: 10px 8px 10px 12px; }
.mini-stub .btn { min-height: 44px; padding: 6px 10px; font-size: 13.5px; }
.mini-stub .btn .icon { width: 17px; height: 17px; }
.mini-stub .copy { width: 44px; padding: 0; }
#more { margin-top: 14px; }
#empty-share { margin-top: 12px; }
.list-end { margin-top: 14px; padding: 16px; font-size: 15px; }

/* Codes already tried */
.history { width: 100%; max-width: 820px; margin-inline: auto; }
#history-more { margin-top: 12px; background: transparent; }
.history-count { display: inline-block; min-width: 26px; padding-inline: 8px; color: #fff; font: 600 14px/26px "IBM Plex Sans Arabic", sans-serif; text-align: center; background: var(--bronze); border-radius: 999px; }
.history .hint { margin-block: 4px 14px; color: var(--muted); font-size: 14px; }

/* Guide */
.closing { background: var(--sand); }
.guide { padding-block: 52px 44px; }
.guide h2 { font: 700 28px/1.3 var(--display); text-align: center; }
.steps { counter-reset: step; list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 24px; }
.steps li { position: relative; counter-increment: step; padding-inline-start: 56px; }
.steps li::before {
  content: counter(step);
  position: absolute; inset-inline-start: 0; top: 0;
  display: grid; place-items: center; width: 40px; height: 40px;
  color: var(--bronze); font-weight: 600; background: var(--paper); border: 1px solid #ddd2c0; border-radius: 50%;
}
.steps strong { display: block; font-size: 17px; font-weight: 600; line-height: 1.35; margin-bottom: 3px; }
.steps p { color: var(--muted); font-size: 15px; }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .2, 1); }
.reveal.in { opacity: 1; transform: none; }

/* Contact */
.contact { display: grid; gap: 20px; padding-block: 8px 52px; }
.contact h2 { font: 700 28px/1.3 var(--display); }
.contact-intro p { margin-top: 6px; color: var(--muted); font-size: 15px; }
#contact-form { display: grid; gap: 12px; padding: 18px; background: var(--paper); border: 1px solid #e8e0d4; border-radius: 16px; }
#contact-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
#contact-form input, #contact-form textarea {
  width: 100%; padding: 12px 14px; color: var(--ink); font: inherit; font-weight: 400; background: var(--soft);
  border: 1px solid transparent; border-radius: 10px; resize: vertical; transition: border-color .15s, background-color .15s;
}
#contact-form input { height: 48px; }
#contact-form input:focus, #contact-form textarea:focus { outline: 0; background: var(--paper); border-color: var(--green); }
[dir="rtl"] #contact-email { text-align: right; }
#contact-form .trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#ts-contact:empty { display: none; }
.msg.ok { color: var(--green-strong); }

/* Footer */
.foot { padding-block: 36px 28px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid #e8e0d4; }
.dua { color: var(--ink); font: 700 20px/1.6 var(--display); text-align: center; white-space: pre-line; text-wrap: balance; }
.foot .btn { display: flex; margin: 16px auto 0; }
.foot .hint { margin-top: 12px; text-align: center; }
.foot-bar {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin-top: 28px; padding-top: 16px; border-top: 1px solid #e8e0d4;
}
.dev { color: var(--ink); font-size: 14px; }
.dev a { color: var(--green-strong); font-weight: 600; }
.disclaimer { margin-top: 10px; font-size: 12.5px; line-height: 1.6; }
.credit { white-space: nowrap; }
.credit a { color: inherit; }

.toast {
  position: fixed; z-index: 2; inset-inline: 16px; bottom: max(16px, env(safe-area-inset-bottom)); max-width: 420px; margin-inline: auto;
  padding: 12px 16px; text-align: center; color: #fff; background: var(--ink); border-radius: 10px; box-shadow: 0 12px 30px rgba(31, 42, 55, .25);
}

@media (max-width: 350px) {
  #add-form { flex-direction: column; }
  .mini { flex-wrap: wrap; }
  .mini-tear { display: none; }
  .mini-main, .mini-stub { flex: 1 1 100%; border-radius: 12px; }
}

@media (min-width: 560px) {
  #contact-form { grid-template-columns: 1fr 1fr; }
  #contact-form .full { grid-column: 1 / -1; }
}

@media (min-width: 760px) {
  /* The pass turns sideways, like a real boarding pass */
  .pass { display: flex; }
  .pass-main { flex: 1; min-width: 0; border-radius: 0; border-start-start-radius: 16px; border-end-start-radius: 16px; }
  .pass-tear {
    flex: none; width: 22px; height: auto;
    -webkit-mask-image: radial-gradient(circle at 50% 0, transparent 11px, #000 11.5px), radial-gradient(circle at 50% 100%, transparent 11px, #000 11.5px);
    mask-image: radial-gradient(circle at 50% 0, transparent 11px, #000 11.5px), radial-gradient(circle at 50% 100%, transparent 11px, #000 11.5px);
  }
  .pass-tear::before { inset: 16px auto 16px 10px; border-top: 0; border-inline-start: 2px dashed var(--line); }
  .pass-stub {
    flex: none; width: 290px; align-content: center; padding: 18px; border-radius: 0;
    border-start-end-radius: 16px; border-end-end-radius: 16px;
  }
  .pass .actions { grid-template-columns: 1fr; }
  .barcode { height: 56px; }
  .list { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 900px) {
  /* Desktop hero: the portrait photo gets its own side so nothing is cropped away */
  .hero { padding-block: 14px 96px; text-align: start; }
  .hero .wrap { max-width: 1100px; }
  .hero-photo {
    inset: 0 0 0 auto;
    width: 52%;
    height: 100%;
    object-position: 50% 50%;
    -webkit-mask-image: linear-gradient(to left, #000 70%, transparent);
    mask-image: linear-gradient(to left, #000 70%, transparent);
  }
  [dir="rtl"] .hero-photo {
    inset: 0 auto 0 0;
    -webkit-mask-image: linear-gradient(to right, #000 70%, transparent);
    mask-image: linear-gradient(to right, #000 70%, transparent);
  }
  .hero::after { height: 100%; background: rgba(9, 42, 30, .35); }
  .topbar { margin-bottom: 96px; }
  .hero h1, .hero .lead { max-width: 46%; margin-inline: 0; }
  .hero .count { margin-inline: 0 6px; }


  .main { max-width: 1100px; }
  .closing .wrap { max-width: 1100px; }
  .guide { padding-block: 68px 60px; }
  .guide h2 { font-size: 34px; }
  .steps { grid-template-columns: repeat(3, 1fr); gap: 36px; margin-top: 40px; }
  .contact { grid-template-columns: 1fr 1.6fr; gap: 48px; align-items: start; padding-bottom: 68px; }
  .contact h2 { font-size: 34px; }
  .foot .wrap { max-width: 1100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .reveal { opacity: 1; transform: none; }
}
