/* hosting/public/shared/base.css
 *
 * What every balad.dev page shares: the shopfront (the warm plaster wall in
 * light, the app's stone in dark, and the canvas awning across the top, the
 * same one as the home page: /home/awning.webp moving in a slow wind, the still
 * frame for reduced motion; a page opts out with <body class="no-awning">),
 * the colour tokens (light and dark, the dark set chosen by
 * /shared/prefs.js), type per script, and the controls: buttons, fields, links, the error line, the loader and the
 * bottom sheet. Fonts follow the app: Nunito
 * Sans for English, Rubik for Hebrew, Alexandria for Arabic; amounts are
 * always Nunito Sans with Western digits.
 */

:root {
  --clay: #C96736;
  --clay-cta: #B95926;
  --clay-press: #A14C1F;
  --clay-text: #B95926;
  --canvas: #FFF6E3;  /* the plaster wall under the awning */
  --surface: #FFFFFF;
  --tint: #F7EDDC;    /* a warm block on the wall */
  --ink: #1B3A6B;     /* navy ink, as the home page and the posts */
  --muted: #5E6573;   /* 5.6:1 on the wall */
  --line: #EADFCC;
  --field: #848A95; /* 3:1 against white, the wall and tint (WCAG 1.4.11) */
  --awning-h: 104px;
  --awning-filter: none;
  --ok: #1E7F4F;
  --warn: #8A5100;
  --bad: #B3261E;
  --shade: rgba(150, 66, 24, 0.32);
  --seg-on: #FFFFFF;
  --switch-off: #848A95;
  --amount: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Dark: the app's stone ramp (COLOR_GUIDE.md "Dark mode: the stone ramp").
   /shared/prefs.js sets data-theme from the device or the visitor's pick. */
:root[data-theme="dark"] {
  --clay-text: #E58E5E;
  --canvas: #262624;
  --surface: #30302E;
  --tint: #353432;
  --ink: #F5F4EF;
  --muted: #B8B5AB;
  --line: #3E3D39;
  --field: #76746E;
  --ok: #5FC48E;
  --warn: #F0C36A;
  --bad: #FF8A80;
  --shade: rgba(70, 28, 10, 0.42);
  --seg-on: #44433F;
  --switch-off: #76746E;
  --awning-filter: brightness(.9);
}

/* The awning across the top of every page. */
body:not(.no-awning)::before {
  content: ""; display: block; height: var(--awning-h); filter: var(--awning-filter);
  background: url(/home/awning.webp) center top / auto 100% repeat-x;
}
@media (prefers-reduced-motion: reduce) { body:not(.no-awning)::before { background-image: url(/home/awning-still.webp); } }
@media (max-width: 600px) { :root { --awning-h: 78px; } }
@media print { body::before { display: none; } }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Alexandria", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html[lang="en"] body { font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.55; }
html[lang="he"] body { font-family: "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif; line-height: 1.6; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.lead { margin: 0 0 26px; font-size: 17px; }
.muted { color: var(--muted); }
p { margin: 0 0 12px; }
h2 { margin: 0 0 16px; font-size: 19px; line-height: 1.3; font-weight: 700; }
.center { text-align: center; }

/* Buttons: one slab shape, never a pill. */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 12px 18px; border: 0; border-radius: 14px;
  font-weight: 700; font-size: 17px; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer; transition: background-color .15s ease, transform .1s ease;
}
.btn svg { flex: none; width: 20px; height: 20px; }
.btn:active:not([disabled]) { transform: scale(0.985); }
.btn.primary {
  background: var(--clay-cta); color: #FFFFFF;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 8px 18px -10px rgba(185, 89, 38, 0.9);
}
.btn.primary:hover { background: var(--clay-press); }
.btn.secondary { background: var(--tint); color: var(--ink); }
.btn.danger { background: var(--bad); color: #FFFFFF; }
:root[data-theme="dark"] .btn.danger { color: #2A0B08; }
.btn[disabled] { cursor: default; opacity: 0.7; }
.btn[aria-busy="true"]::after {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite;
}
.note {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 12px 0 0; font-size: 13.5px; color: var(--muted); text-align: center;
}
.note svg { flex: none; width: 15px; height: 15px; }

.link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0;
  border: 0; background: none; cursor: pointer; text-decoration: none;
  color: var(--clay-text); font-weight: 600; font-size: 15px;
}
.link.quiet { color: var(--muted); }
.link.plain { color: var(--ink); }
.link.danger { color: var(--bad); }
.link svg { width: 18px; height: 18px; }
.links { display: flex; flex-wrap: wrap; gap: 4px 24px; }

/* Forms. */
.field { margin: 0 0 16px; }
.field label { display: block; margin: 0 0 8px; font-weight: 600; font-size: 15px; }
.field input {
  display: block; width: 100%; min-height: 56px; padding: 0 16px;
  border: 1.5px solid var(--field); border-radius: 14px; background: var(--surface);
  font-family: var(--amount); font-size: 19px; direction: ltr; text-align: start;
  transition: border-color .15s ease, box-shadow .15s ease;
}
html[dir="rtl"] .field input { text-align: right; }
.field input.code { text-align: center !important; letter-spacing: 0.4em; font-size: 24px; font-weight: 700; }
.field input:focus { outline: none; border-color: var(--clay-cta); box-shadow: 0 0 0 4px rgba(185, 89, 38, 0.18); }
.field input.bad { border-color: var(--bad); }
.error { display: flex; gap: 8px; align-items: flex-start; color: var(--bad); font-size: 15px; margin: 0 0 16px; }
.error svg { flex: none; width: 18px; height: 18px; margin-top: 3px; }
.okline { display: flex; gap: 8px; align-items: flex-start; color: var(--ok); font-size: 15px; font-weight: 600; margin: 16px 0 0; }
.okline svg { flex: none; width: 18px; height: 18px; margin-top: 3px; }

.loader {
  width: 34px; height: 34px; margin: 48px auto; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--clay-cta);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

:focus-visible { outline: 3px solid var(--clay-cta); outline-offset: 2px; }

/* A sheet rising from the bottom (a centred card on wide screens): the
   question before stopping or cancelling, and the card form. */
dialog.ask, dialog.paysheet {
  border: 0; margin: 0; inset: auto 0 0 0; width: 100%; max-width: 100%;
  padding: 26px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
}
dialog.ask[open], dialog.paysheet[open] { animation: rise .26s cubic-bezier(.2, .8, .2, 1); }
dialog.ask::backdrop, dialog.paysheet::backdrop { background: rgba(22, 14, 9, 0.48); }
dialog.ask p { font-size: 17px; margin: 0 0 22px; }
dialog.ask form { display: grid; gap: 10px; margin: 0; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (min-width: 640px) {
  dialog.ask, dialog.paysheet { inset: 0; margin: auto; max-width: 420px; height: fit-content; border-radius: 22px; padding: 28px; }
  dialog.paysheet { max-width: 460px; }
  dialog.ask[open], dialog.paysheet[open] { animation-name: pop; }
  @keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .loader, .btn[aria-busy="true"]::after { animation: spin 2.4s linear infinite !important; }
}
