/* IBM Plex Sans Arabic, self-hosted (SIL Open Font License, see vendor/fonts/OFL.txt). */
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap; src: url("./vendor/fonts/ibm-plex-sans-arabic-400-arabic.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap; src: url("./vendor/fonts/ibm-plex-sans-arabic-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 700; font-display: swap; src: url("./vendor/fonts/ibm-plex-sans-arabic-700-arabic.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 700; font-display: swap; src: url("./vendor/fonts/ibm-plex-sans-arabic-700-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: dark;
  --ink: #f7f5f0;
  --muted: #cbc7d1;
  --accent: #f7f5f0;
  --accent-hover: #e7e3dc;
  --on-accent: #23212c;
  --selected: #403b4b;
  --line: #514b5d;
  --control-line: #807888;
  --page: #23212c;
  --paper: #2d2a38;
  --font: "IBM Plex Sans Arabic", Tahoma, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.23, 1, .32, 1);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--on-accent); }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.55 var(--font); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript { margin: 24px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.top { position: sticky; top: 0; z-index: 10; background: var(--page); border-bottom: 1px solid var(--line); }
.top-inner, main { margin-inline: auto; padding-inline: 24px; }
main { width: min(100%, 640px); }
.top-inner { display: flex; align-items: center; gap: 16px; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 10px; }
.identity { display: flex; justify-content: flex-start; }
#progress-head { flex: 1; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; font-size: 1.65rem; line-height: 1; color: var(--accent); font-weight: 700; }
/* The mark sits on the text baseline and stands as tall as the alef. */
.brand img { flex: none; width: .9em; height: .9em; }
@media (min-width: 840px) {
  .top-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px) minmax(0, 1fr); }
}
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; font-weight: 700; margin-bottom: 6px; }
.progress { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transform: scaleX(var(--completion, 0)); transform-origin: right; transition: transform 230ms var(--ease); }
main { padding-top: 30px; }
body:has(#survey:not([hidden]) #mosque-step:not([hidden])) { display: flex; flex-direction: column; min-height: 100dvh; }
main:has(#survey:not([hidden]) #mosque-step:not([hidden])) { display: flex; flex: 1; width: 100%; padding: 0; }
#survey { display: flex; flex-direction: column; }
.step { flex: 1; }
h1, p { margin: 0; }
h1 { font-size: clamp(1.72rem, 5vw, 2.55rem); line-height: 1.28; text-wrap: balance; }
h1:focus { outline: none; }
.eyebrow { width: fit-content; padding: 3px 10px; margin-bottom: 8px; border-radius: 6px; background: var(--selected); color: var(--accent); font-size: .84rem; font-weight: 700; }
.intro { margin: 7px 0 20px; color: var(--muted); }
#survey:has(#mosque-step:not([hidden])) { flex: 1; min-width: 0; min-height: calc(100svh - 163px); }
#mosque-step { display: flex; flex-direction: column; }
.map-controls, #mosque-step:not([hidden]) ~ .actions {
  width: min(100%, 720px);
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
}
.map-controls { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 10px; padding-block: 8px; }
#location-title { font-size: clamp(1.15rem, 4.5vw, 1.5rem); }
#mosque-picker, .map-tools, #manual-location { grid-column: 1 / -1; }
.map-tools { display: flex; align-items: center; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; }
.map-tools .text-button { font-size: .88rem; }
.map-tools .text-button:disabled { display: none; }
#mosque-step[data-proposal] :is(#mosque-picker, #manual-toggle, #manual-location, #location-status, #proposal-start) { display: none; }
#proposal-hint { margin: 4px 0; }
.proposal-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 10px; }
.proposal-fields label { font-size: .86rem; font-weight: 700; }
.proposal-fields :is(input, select) { margin-top: 3px; font-size: 16px; }
.proposal-fields:has(#proposal-type-field[hidden]) { grid-template-columns: minmax(0, 1fr); }
#proposal-district-field { grid-column: 1 / -1; }
.proposal-matches { display: grid; gap: 6px; max-height: min(220px, 34svh); overflow: auto; margin-bottom: 10px; scrollbar-width: thin; scrollbar-color: var(--control-line) transparent; }
.proposal-matches button { text-align: start; overflow-wrap: anywhere; }
#review-mosque { font-weight: 700; overflow-wrap: anywhere; }
#review-times { display: grid; gap: 6px; margin-block: 12px 20px; }
#review-times div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 46px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
#review-times dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#review-step:not([hidden]) ~ .actions .buttons { display: none; }
.proposal-pin { cursor: grab; }
.proposal-pin:active { cursor: grabbing; }
#location-status { margin: 0; }
#manual-location { margin-top: 0; }
.location-title { display: none; }
/* Changing city once a city is open: the choice takes the search row's place as a card
   under its button, instead of floating over the map and its controls. */
.map-controls:has(#mosque-picker:not([hidden])):has(#manual-location:not([hidden])) :is(#mosque-picker, .map-tools) { display: none; }
.map-controls:has(#mosque-picker:not([hidden])) #manual-location {
  margin-block: 2px 4px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.map-controls:has(#mosque-picker:not([hidden])) .location-title {
  display: block;
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
#manual-toggle[aria-expanded="true"] { background: var(--selected); border-color: var(--accent); }
#proposal-nearby-title { margin-bottom: 5px; }
@media (min-width: 740px) {
  .map-controls { width: min(100%, 1040px); grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 16px; }
  #mosque-picker { grid-column: 2; grid-row: 1; }
  #manual-toggle { grid-column: 3; }
}
.location { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; align-items: end; margin-top: 10px; }
.location label { font-size: .88rem; font-weight: 700; }
.location label { min-width: 0; }
button, input, select, textarea { font: inherit; }
button, select, input { min-height: 44px; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .62; cursor: default; }
input:not([type=radio]), select { width: 100%; color: var(--ink); background: var(--paper); border: 1px solid var(--control-line); border-radius: 10px; padding: 7px 11px; caret-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: 1; }
.primary, .secondary { border: 1px solid transparent; border-radius: 12px; padding: 8px 16px; font-weight: 700; touch-action: manipulation; transition: transform 140ms var(--ease), background-color 150ms ease; }
.primary { color: var(--on-accent); background: var(--accent); }
.secondary { color: var(--accent); background: var(--paper); border-color: var(--control-line); }
.primary:active, .secondary:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) {
  .primary:hover { background: var(--accent-hover); }
  .secondary:hover { background: var(--selected); }
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: .82rem; margin: 5px 0; }
.search { position: relative; }
.search-icon { position: absolute; inset-inline-start: 13px; inset-block-start: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input:not([type=radio]) { padding-inline-start: 41px; }
.results { position: absolute; inset: calc(100% + 4px) 0 auto; z-index: 5; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; max-height: min(300px, 42svh); overflow: auto; overscroll-behavior: contain; contain: paint; scrollbar-width: thin; scrollbar-color: var(--control-line) transparent; box-shadow: 0 12px 28px #0006; transform-origin: top center; }
.results button { width: 100%; background: var(--paper); text-align: start; border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; overflow-wrap: anywhere; }
.results button:focus-visible { background: var(--selected); outline-offset: -3px; }
@media (hover: hover) and (pointer: fine) { .results button:hover { background: var(--selected); } }
.results p { padding: 8px 12px; color: var(--muted); font-size: .86rem; }
.selection { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 8px 12px; overflow-wrap: anywhere; }
.selection img { flex: none; }
.selection-text { display: grid; gap: 2px; min-width: 0; }
.selection-text strong { line-height: 1.3; }
.selection-text span { color: var(--muted); font-size: .8rem; }
.map-stage { position: relative; contain: paint; display: flex; flex: 1 0 43svh; min-height: 240px; }
#map { flex: 1; min-width: 0; border-block: 1px solid var(--line); overflow: hidden; background: var(--paper); font-family: var(--font); }
.map-locate { position: absolute; inset-block-start: 10px; inset-inline-start: max(10px, env(safe-area-inset-right)); display: grid; place-items: center; width: 44px; padding: 0; }
.map-stage:has(> .map-start:not([hidden])) > .map-locate { display: none; }

/* Stand-in for the map until a place is known: one clear first step. */
.map-start {
  position: absolute; inset: 0; z-index: 4;
  display: grid; align-content: center; justify-items: center; gap: 6px;
  padding: 24px max(20px, env(safe-area-inset-left), env(safe-area-inset-right));
  text-align: center;
  border-block: 1px solid var(--line);
  background: radial-gradient(110% 75% at 50% 42%, var(--paper) 0%, var(--page) 72%);
}
.map-start-mark { display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 50%; background: var(--page); box-shadow: 0 8px 22px #0004; }
.map-start-text { max-width: 26ch; font-size: 1.08rem; font-weight: 700; text-wrap: balance; }
#start-note { margin: 0 0 12px; }
.map-start-locate { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: min(100%, 260px); min-height: 48px; }
#start-city { min-height: 44px; font-size: .9rem; }

#map-status { padding-inline: 16px; }
.selected-mosque-marker { width: 36px; height: 36px; border-radius: 50%; box-shadow: 0 0 0 4px #f7f5f05c; pointer-events: none; }
.maplibregl-marker.user-position { width: 14px; height: 14px; background: #65aaff; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 5px #65aaff45; pointer-events: none; }
.maplibregl-ctrl-group { display: grid; gap: 6px; background: transparent; }
.maplibregl-ctrl-group:not(:empty) { box-shadow: none; }
.maplibregl-ctrl-group button:is(:first-child, :last-child) { width: 44px; height: 44px; border: 1px solid var(--control-line); border-radius: 12px; background: var(--paper); }
.maplibregl-ctrl-group button:focus-visible { outline-offset: -4px; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
#map .maplibregl-ctrl-attrib { background: var(--paper); color: var(--ink); }
#map .maplibregl-ctrl-attrib a { color: var(--ink); }
#map .maplibregl-ctrl-attrib-button { filter: invert(1); }
#answers { border: 0; padding: 0; margin: 0; min-inline-size: 0; display: grid; gap: 7px; }
.choice { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.choice input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.choice span { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 700; transition: transform 140ms var(--ease), border-color 140ms ease, background-color 140ms ease; }
.choice span::after { content: ''; width: 19px; height: 19px; flex: 0 0 19px; border-radius: 50%; border: 1.5px solid var(--control-line); }
.choice span::before { content: ''; position: absolute; inset-inline-end: 17px; inset-block-start: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; background: var(--accent); transform: scale(.4); opacity: 0; transition: opacity 150ms ease, transform 200ms var(--ease); }
.choice input:checked + span { background: var(--selected); color: var(--accent); border-color: var(--accent); }
.choice input:checked + span::before { opacity: 1; transform: scale(1); }
.choice input:checked + span::after { border-color: var(--accent); }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice:active span { transform: scale(.99); }
@media (hover: hover) and (pointer: fine) {
  .choice:hover input:not(:checked) + span { border-color: var(--control-line); }
}
.custom-label { font-size: .86rem; font-weight: 700; }
.custom-label input { margin-top: 4px; }
.contact-field { margin-block: 16px 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
#review-step .contact-field { margin-block: 0 10px; }
.contact-field label { font-weight: 700; }
.contact-field label span { color: var(--muted); font-size: .85rem; }
.contact-field input { margin-top: 5px; font-size: 16px; }
.text-button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0 3px; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.actions { position: sticky; bottom: 0; z-index: 6; padding: 14px 0 max(12px, env(safe-area-inset-bottom)); margin-top: 12px; background: var(--page); }
#mosque-step:not([hidden]) ~ .actions { position: static; margin-top: 0; padding-top: 10px; }
#mosque-step:not([hidden]):not([data-proposal]) ~ .actions:not(:has(#selection:not([hidden]), #submit-status:not(:empty))) { display: none; }
#mosque-step[hidden] ~ .actions #selection { display: none; }
@media (min-width: 740px) {
  #mosque-step:not([hidden]) ~ .actions:has(#selection:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; align-items: center; }
  #mosque-step:not([hidden]) ~ .actions #selection { margin-bottom: 0; }
  #mosque-step:not([hidden]) ~ .actions #submit-status { grid-column: 1 / -1; grid-row: 1; }
}
.buttons { display: flex; gap: 9px; }
.buttons .primary { flex: 1; }
.buttons .back { min-width: 88px; min-height: 48px; }
.error { color: #ffafa6; font-size: .84rem; margin-bottom: 7px; }
.error:empty, .hint:empty { display: none; }
.preview-note { text-align: center; }
/* Busy buttons carry a small spinner beside their "جاري…" label. */
[aria-busy="true"]::before { content: ''; display: inline-block; width: .9em; height: .9em; margin-inline-end: 8px; vertical-align: -.1em; border: 2px solid currentColor; border-inline-start-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.success { text-align: center; display: grid; justify-items: center; align-content: center; width: min(100%, 470px); margin: clamp(10px, 5svh, 48px) auto 24px; padding: 28px 16px max(20px, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-radius: 24px; background: radial-gradient(ellipse at top, var(--selected), var(--paper) 62%); }
.success-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 15px; border: 1px solid var(--control-line); border-radius: 50%; color: var(--on-accent); background: var(--accent); }
.success .intro { max-width: 31ch; }
.success-mosque { overflow-wrap: anywhere; color: var(--accent); font-weight: 700; margin-bottom: 14px; }
.success .primary, .share-button, #share-message { width: min(100%, 310px); }
.share-button, .share-options, .social { display: flex; align-items: center; justify-content: center; gap: 8px; }
.share-button { margin-top: 8px; }
.share-options { gap: 16px; font-size: .88rem; }
.share-options a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); text-underline-offset: 4px; }
#share-message { color: var(--ink); background: var(--paper); border: 1px solid var(--control-line); border-radius: 10px; padding: 8px 11px; }
.social { margin-top: 10px; color: var(--muted); font-size: .82rem; }
.social a { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) { .social a:hover { background: var(--paper); } }
@media (max-width: 550px) {
  .top-inner, main { padding-inline: 16px; }
  main { padding-top: 21px; }
  .search input, .location select { font-size: 16px; }
}

/* Reduced motion keeps colour and opacity feedback but drops movement. */
@media (prefers-reduced-motion: reduce) {
  .primary, .secondary { transition-property: background-color; }
  .choice span { transition-property: border-color, background-color; }
  .choice span::before { transition-property: opacity; }
  .progress span { transition: none; }
  .primary:active, .secondary:active, .choice:active span { transform: none; }
  [aria-busy="true"]::before { animation-duration: 1.6s; }
  .results { transition: opacity 120ms ease; }
  @starting-style { .results { opacity: 0; } }
  .success:not([hidden]), .selection:not([hidden]), #review-step:not([hidden]), .map-start:not([hidden]) { animation: fade-in 160ms ease both; }
}
@media (prefers-reduced-motion: no-preference) {
  .success:not([hidden]), .selection:not([hidden]), #review-step:not([hidden]) { animation: confirm-entrance 240ms var(--ease) both; }
  #manual-location:not([hidden]),
  #mosque-step[data-proposal="name"] .map-controls,
  #mosque-step[data-proposal="name"] ~ .actions { animation: picker-entrance 280ms var(--ease) both; }
  #mosque-step[data-proposal="name"] ~ .actions { --picker-offset: 14px; }
  /* Results drop from the search box they belong to. */
  .results { transition: opacity 150ms var(--ease), transform 150ms var(--ease); }
  @starting-style { .results { opacity: 0; transform: translateY(-4px) scale(.98); } }
  /* First screen: the mark, the line and the actions arrive in one short cascade. */
  .map-start:not([hidden]) > * { animation: confirm-entrance 300ms var(--ease) both; }
  .map-start > :nth-child(2) { animation-delay: 45ms; }
  .map-start > :nth-child(3) { animation-delay: 80ms; }
  .map-start > :nth-child(4) { animation-delay: 115ms; }
  .map-start > :nth-child(5) { animation-delay: 150ms; }
  .map-start:is([data-state="locating"], [data-state="loading"]) .map-start-mark img { animation: breathe 1.1s ease-in-out infinite alternate; }
  /* Success: the badge settles, then the tick draws itself. */
  .success:not([hidden]) .success-mark { animation: mark-in 320ms var(--ease) both; }
  .success:not([hidden]) .success-mark path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: tick-draw 360ms 150ms var(--ease) forwards; }
  @keyframes picker-entrance {
    from { opacity: 0; transform: translateY(var(--picker-offset, -10px)); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes confirm-entrance {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes mark-in {
    from { opacity: 0; transform: scale(.9); }
    to { opacity: 1; transform: scale(1); }
  }
  @keyframes tick-draw { to { stroke-dashoffset: 0; } }
  @keyframes breathe { from { opacity: 1; } to { opacity: .45; } }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
