/* ===========================================================================
   Sherif platforms — one brand, one stylesheet.
   Canonical source: ~/Projects/sherif-brand/sherif-brand.css

   Framework-free on purpose. The platforms are not built the same way — React
   (Areeb, VyaTrip, Lybance, Afriqiyah, Arabian Barber), Liquid (Lastricks),
   plain HTML/Express (Social Agent, Sherif HQ, lycloud), PHP/cPanel (bs.ly) —
   so anything that needed a build step could not be shared. Custom properties
   and plain classes work in all of them, and in an email client's webview.

   HOW TO ADOPT (one line, nothing else to change):
       <link rel="stylesheet" href="/brand/sherif-brand.css">
   Then use the tokens instead of literal colours. Existing CSS keeps working;
   this file sets no opinionated resets beyond box-sizing and tap behaviour.

   WHY THESE VALUES. The palette was not chosen by eye. #D4AF37 gold on white
   is about 1.9:1 contrast — unreadable as text — so there are deliberately
   TWO golds: a dark brass for words (4.97:1 on the cream page, passes WCAG AA)
   and the bright one for decoration only. Every text pair below was measured.
   =========================================================================== */

:root {
  /* ---- brand ---------------------------------------------------------- */
  --sh-gold:            #8A6514;   /* words and solid buttons — AA on cream */
  --sh-gold-hover:      #6F5110;
  --sh-gold-bright:     #C19A2E;   /* fills, rules, icon washes — NOT text */
  --sh-gold-light:      #E8C85A;   /* only on dark sections */
  --sh-gold-wash:       #FBF4E2;   /* faint tint for highlight panels */

  /* ---- surfaces ------------------------------------------------------- */
  --sh-page:            #FAF7F2;   /* warm off-white, not grey */
  --sh-surface:         #FFFFFF;   /* cards */
  --sh-highlight:       #F3EDE3;   /* alternating bands, hovers */
  --sh-line:            #E7DFD2;   /* hairlines */
  --sh-dark:            #17140F;   /* deliberate dark sections: hero, footer */
  --sh-darker:          #0F0D0A;

  /* ---- text ----------------------------------------------------------- */
  --sh-ink:             #1C1815;   /* body — 13.6:1 on the page */
  --sh-ink-soft:        #6E6559;   /* secondary — 4.6:1, still AA */
  --sh-ink-faint:       #8A8175;   /* 3.1:1 — large text or non-essential only */
  --sh-on-dark:         #F6F1E8;   /* body text on the dark sections */
  --sh-on-dark-soft:    #B9AF9F;

  /* ---- state ---------------------------------------------------------- */
  --sh-good:            #1F7A4C;
  --sh-warn:            #8A5A08;
  --sh-bad:             #A32020;
  --sh-info:            #1F5C8A;
  --sh-good-wash:       #ECF7F0;
  --sh-warn-wash:       #FDF4E3;
  --sh-bad-wash:        #FBECEC;
  --sh-info-wash:       #EAF2F8;

  /* ---- type ----------------------------------------------------------- */
  /* Cairo carries Arabic and Latin in one family, which is why every Sherif
     platform uses it: an Arabic/English page should not change typeface when
     it changes language. */
  --sh-font: 'Cairo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sh-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* A 1.2 scale from 16px. Steps, not arbitrary sizes, so two platforms side
     by side cannot drift a pixel apart. */
  --sh-text-xs:   0.75rem;
  --sh-text-sm:   0.875rem;
  --sh-text-base: 1rem;
  --sh-text-lg:   1.125rem;
  --sh-text-xl:   1.375rem;
  --sh-text-2xl:  1.75rem;
  --sh-text-3xl:  2.25rem;
  --sh-text-4xl:  3rem;

  --sh-leading-tight: 1.2;
  --sh-leading:       1.55;   /* body: comfortable for Arabic, which sits taller */

  /* ---- spacing: a 4px grid ------------------------------------------- */
  --sh-1: 4px;   --sh-2: 8px;   --sh-3: 12px;  --sh-4: 16px;
  --sh-5: 20px;  --sh-6: 24px;  --sh-8: 32px;  --sh-10: 40px;
  --sh-12: 48px; --sh-16: 64px; --sh-20: 80px;

  --sh-radius-sm: 6px;
  --sh-radius:    10px;
  --sh-radius-lg: 16px;
  --sh-radius-pill: 999px;

  /* Shadows warm rather than neutral — a grey shadow on a cream page reads
     as dirt. */
  --sh-shadow-sm: 0 1px 2px rgba(42, 33, 18, .06);
  --sh-shadow:    0 2px 8px rgba(42, 33, 18, .08);
  --sh-shadow-lg: 0 10px 30px rgba(42, 33, 18, .12);

  /* ---- layout --------------------------------------------------------- */
  --sh-content-max: 1200px;
  --sh-tap: 44px;              /* Apple HIG minimum touch target */
  --sh-safe-t: env(safe-area-inset-top, 0px);
  --sh-safe-b: env(safe-area-inset-bottom, 0px);
  --sh-safe-l: env(safe-area-inset-left, 0px);
  --sh-safe-r: env(safe-area-inset-right, 0px);
}

/* ===========================================================================
   PER-PLATFORM BRAND COLOUR — read this before adopting the sheet.

   These are different businesses, not one product. An audit of the live sites
   on 2026-12-05 found nine different theme colours:

     Arabian Barber ....... #8A6514  brass      (barber.cloud.bs.ly)
     Areeb Pharmacy ....... #3D6359  green      (areebpharmacy.ly)
     VyaTrip .............. #071A3A  navy       (vyatrip.com)
     Lybance .............. #0B1826  dark navy  (lybance.com)
     Al Taaj Stables ...... #0E0E0E  black      (altaajstables.ly)
     Al-Basma Al-Haditha .. #0D9488  teal       (albasmaalhaditha.ly)
     Bahr Al-Rimal ........ #0F172A  slate      (baheralremal.ly)
     lycloud .............. #0C1424  (cloud.bs.ly)
     bs.ly ................ #071330  (bs.ly)
     Sherif Pharmacy ...... none set (sherifpharmacy.ly)

   That is NOT a bug to flatten. A pharmacy should not look like a barbershop,
   and a travel agency's navy is its identity. What should be shared is the
   SYSTEM — layout, spacing, type scale, touch targets, iPad behaviour, focus
   rings, RTL, accessibility — with the brand colour swapped per platform.

   So: adopt this sheet, then override the four accent tokens and nothing else.

       <link rel="stylesheet" href="/brand/sherif-brand.css">
       <style>
         :root {
           --sh-gold:        #3D6359;   /* your brand colour, AA on white */
           --sh-gold-hover:  #2F4E46;   /* ~15% darker */
           --sh-gold-bright: #5C8C7E;   /* decorative fills only, never text */
           --sh-gold-wash:   #EEF4F2;   /* faint tint for panels */
         }
       </style>

   The token is called --sh-gold for historical reasons (it began on the
   barbershop). Treat it as "the brand accent".

   ONE HARD RULE: --sh-gold is used for TEXT, so it must reach 4.5:1 against
   white. Check before you paste. #D4AF37 gold is about 1.9:1 and is unreadable
   as text, which is why the barbershop carries two golds and the bright one is
   banned from words. Every platform above except Sherif Pharmacy already has
   a dark enough accent; keep it, and only pick a darker shade if it fails.

   Each platform should also set, to match its own page background:
       <meta name="theme-color" content="...">     and in manifest.json
       "theme_color" / "background_color"
   A theme colour that disagrees with the page tints the browser chrome a
   different shade from the page, and background_color is the launch splash —
   the barbershop flashed near-black #0d0f12 before a cream page until
   2026-12-05.
   =========================================================================== */

/* ===========================================================================
   Base
   =========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

.sh, .sh-page {
  font-family: var(--sh-font);
  font-size: var(--sh-text-base);
  line-height: var(--sh-leading);
  color: var(--sh-ink);
  background: var(--sh-page);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Dark sections. Scoped, so a dark hero cannot leak its colours into the page. */
.sh-on-dark { background: var(--sh-dark); color: var(--sh-on-dark); }
.sh-on-dark h1, .sh-on-dark h2, .sh-on-dark h3 { color: #fff; }
.sh-on-dark a { color: var(--sh-gold-light); }
.sh-on-dark .sh-muted { color: var(--sh-on-dark-soft); }

.sh-muted { color: var(--sh-ink-soft); }
.sh-faint { color: var(--sh-ink-faint); }

h1,h2,h3,h4 { line-height: var(--sh-leading-tight); margin: 0 0 var(--sh-3); font-weight: 700; }
h1 { font-size: var(--sh-text-3xl); letter-spacing: -.01em; }
h2 { font-size: var(--sh-text-2xl); }
h3 { font-size: var(--sh-text-xl); }

/* Focus must be visible and must not be the only cue. Removing outlines is the
   single most common accessibility regression, so it is set once, here. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--sh-gold);
  outline-offset: 2px;
  border-radius: var(--sh-radius-sm);
}

/* ===========================================================================
   Components
   =========================================================================== */
.sh-container { width: 100%; max-width: var(--sh-content-max); margin-inline: auto;
  padding-inline: max(var(--sh-4), var(--sh-safe-l)); }

.sh-card {
  background: var(--sh-surface);
  border: 1px solid var(--sh-line);
  border-radius: var(--sh-radius-lg);
  padding: var(--sh-5);
  box-shadow: var(--sh-shadow-sm);
}
.sh-card-tight { padding: var(--sh-4); border-radius: var(--sh-radius); }

.sh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sh-2);
  min-height: var(--sh-tap); min-width: var(--sh-tap);
  padding: var(--sh-3) var(--sh-5);
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--sh-radius);
  cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
}
.sh-btn:active { transform: translateY(1px); }
.sh-btn[disabled], .sh-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.sh-btn-primary { background: var(--sh-gold); color: #fff; box-shadow: var(--sh-shadow-sm); }
.sh-btn-primary:hover { background: var(--sh-gold-hover); }
.sh-btn-secondary { background: var(--sh-surface); color: var(--sh-ink); border-color: var(--sh-line); }
.sh-btn-secondary:hover { background: var(--sh-highlight); }
.sh-btn-ghost { background: transparent; color: var(--sh-gold); }
.sh-btn-ghost:hover { background: var(--sh-gold-wash); }
.sh-btn-danger { background: var(--sh-bad); color: #fff; }

.sh-input, .sh-select, .sh-textarea {
  width: 100%; min-height: var(--sh-tap);
  padding: var(--sh-3) var(--sh-4);
  font: inherit; color: var(--sh-ink);
  background: var(--sh-surface);
  border: 1px solid var(--sh-line); border-radius: var(--sh-radius);
}
.sh-input:focus, .sh-select:focus, .sh-textarea:focus { border-color: var(--sh-gold); }
/* 16px minimum, or iOS zooms the whole page the moment the field is tapped. */
@supports (-webkit-touch-callout: none) {
  .sh-input, .sh-select, .sh-textarea { font-size: max(16px, var(--sh-text-base)); }
}
.sh-label { display: block; font-size: var(--sh-text-sm); font-weight: 600;
  color: var(--sh-ink-soft); margin-bottom: var(--sh-1); }

.sh-badge {
  display: inline-flex; align-items: center; gap: var(--sh-1);
  padding: 2px var(--sh-2); border-radius: var(--sh-radius-pill);
  font-size: var(--sh-text-xs); font-weight: 700; white-space: nowrap;
}
.sh-badge-good { background: var(--sh-good-wash); color: var(--sh-good); }
.sh-badge-warn { background: var(--sh-warn-wash); color: var(--sh-warn); }
.sh-badge-bad  { background: var(--sh-bad-wash);  color: var(--sh-bad); }
.sh-badge-info { background: var(--sh-info-wash); color: var(--sh-info); }

/* Figures. Tabular numerals so a column of money lines up and does not shimmer
   as it updates. */
.sh-figure { font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  font-weight: 700; letter-spacing: -.01em; }
.sh-figure-lg { font-size: var(--sh-text-3xl); }
.sh-money::before { content: "£"; opacity: .6; margin-inline-end: 1px; }
.sh-neg { color: var(--sh-bad); }

.sh-table { width: 100%; border-collapse: collapse; font-size: var(--sh-text-sm); }
.sh-table th { text-align: start; font-weight: 700; color: var(--sh-ink-soft);
  padding: var(--sh-3); border-bottom: 1px solid var(--sh-line); white-space: nowrap; }
.sh-table td { padding: var(--sh-3); border-bottom: 1px solid var(--sh-line); }
.sh-table tbody tr:hover { background: var(--sh-highlight); }
.sh-table .num { text-align: end; font-variant-numeric: tabular-nums; }

/* ===========================================================================
   RTL. Every Sherif platform is bilingual, so direction is a first-class
   concern, not a patch. The rules above use logical properties
   (padding-inline, text-align: start/end) which flip by themselves — these are
   only for the few things that cannot.
   =========================================================================== */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .sh-money::before { margin-inline-end: 0; margin-inline-start: 1px; }

/* ===========================================================================
   LAYOUT — phone, iPad, desktop

   The iPad sizes that matter, in CSS pixels:
     iPad mini / 9th gen portrait .... 768 x 1024
     iPad Air / Pro 11" portrait ..... 820-834 x 1180
     iPad Pro 12.9" portrait ......... 1024 x 1366
     the same devices landscape ...... 1024 / 1180 / 1366 wide

   The trap is that an iPad in landscape is as wide as a laptop, so a plain
   `min-width: 1024px` desktop rule catches it and hands a touch device a
   mouse-sized interface. These blocks therefore key off BOTH width and
   `pointer: coarse`, so an iPad gets the roomy two-pane layout with big
   targets while a 1024px laptop window gets the dense one.
   =========================================================================== */

/* --- phone first --------------------------------------------------------- */
.sh-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh;
  min-height: 100dvh; /* dvh: the iOS toolbar no longer crops the last row */ }
.sh-sidebar { display: none; }
.sh-main { padding: var(--sh-4); padding-bottom: calc(var(--sh-16) + var(--sh-safe-b)); }

/* A phone gets a bottom bar, which is where a thumb actually is. */
.sh-tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: var(--sh-2) var(--sh-2) calc(var(--sh-2) + var(--sh-safe-b));
  background: var(--sh-surface); border-top: 1px solid var(--sh-line);
}
.sh-tabbar a { flex: 1; min-height: var(--sh-tap); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  font-size: var(--sh-text-xs); color: var(--sh-ink-soft); text-decoration: none; }
.sh-tabbar a[aria-current="page"] { color: var(--sh-gold); font-weight: 700; }

.sh-grid { display: grid; gap: var(--sh-4); grid-template-columns: 1fr; }
.sh-stats { display: grid; gap: var(--sh-3); grid-template-columns: repeat(2, 1fr); }

/* --- iPad portrait and up (768px) --------------------------------------- */
@media (min-width: 768px) {
  .sh-main { padding: var(--sh-6); }
  .sh-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sh-5); }
  .sh-stats { grid-template-columns: repeat(4, 1fr); }
  h1 { font-size: var(--sh-text-4xl); }
}

/* --- iPad: the real two-pane layout ------------------------------------
   820px catches iPad Air/Pro portrait and every iPad in landscape. The
   sidebar becomes permanent, so navigation stops eating a tap. */
@media (min-width: 820px) {
  .sh-shell { grid-template-columns: 248px 1fr; }
  .sh-sidebar {
    display: flex; flex-direction: column; gap: var(--sh-1);
    padding: var(--sh-5) var(--sh-3);
    padding-top: calc(var(--sh-5) + var(--sh-safe-t));
    padding-inline-start: max(var(--sh-3), var(--sh-safe-l));
    background: var(--sh-surface); border-inline-end: 1px solid var(--sh-line);
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  }
  .sh-sidebar a {
    display: flex; align-items: center; gap: var(--sh-3);
    min-height: var(--sh-tap); padding: var(--sh-2) var(--sh-3);
    border-radius: var(--sh-radius); color: var(--sh-ink);
    text-decoration: none; font-weight: 600; font-size: var(--sh-text-sm);
  }
  .sh-sidebar a:hover { background: var(--sh-highlight); }
  .sh-sidebar a[aria-current="page"] { background: var(--sh-gold-wash); color: var(--sh-gold); }
  .sh-tabbar { display: none; }
  .sh-main { padding-bottom: var(--sh-10); }
}

/* --- a touch device this wide is an iPad, not a laptop -------------------
   Roomier rows, bigger targets, no hover-only affordances. */
@media (min-width: 820px) and (pointer: coarse) {
  :root { --sh-tap: 48px; }
  .sh-table th, .sh-table td { padding: var(--sh-4) var(--sh-3); }
  .sh-table { font-size: var(--sh-text-base); }
  .sh-btn { padding: var(--sh-3) var(--sh-6); }
  .sh-grid { gap: var(--sh-6); }
  /* A hover that hides something is unusable with a finger: show it always. */
  .sh-hover-only { opacity: 1 !important; }
}

/* --- iPad Pro 12.9" and desktop ----------------------------------------- */
@media (min-width: 1180px) {
  .sh-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .sh-shell { grid-template-columns: 276px 1fr; }
}
@media (min-width: 1366px) {
  .sh-main { padding: var(--sh-8); }
}

/* --- split view / slide over -------------------------------------------
   iPadOS can hand an app a third of the screen. Narrow is a WIDTH question,
   never a device question, which is why these are plain width rules and why
   nothing above tests the user agent. */
@media (min-width: 768px) and (max-width: 819px) {
  .sh-stats { grid-template-columns: repeat(2, 1fr); }
}

/* --- installed to the home screen -------------------------------------- */
@media (display-mode: standalone) {
  /* No browser chrome to fall back on, so the app owns the safe areas. */
  .sh-sidebar { padding-top: calc(var(--sh-6) + var(--sh-safe-t)); }
  .sh-main { padding-top: calc(var(--sh-4) + var(--sh-safe-t)); }
  /* Text selection on a tap-and-hold looks broken in a standalone app. */
  .sh-shell { -webkit-user-select: none; user-select: none; }
  .sh-input, .sh-textarea, .sh-selectable { -webkit-user-select: text; user-select: text; }
}

/* ===========================================================================
   Respect the user's settings
   =========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Receipts and reports. A printed report must say what it is and when it was
   run, or it is worthless as a record. */
@media print {
  .sh-sidebar, .sh-tabbar, .sh-no-print { display: none !important; }
  .sh, .sh-page { background: #fff; }
  .sh-card { box-shadow: none; border-color: #999; break-inside: avoid; }
  .sh-table { font-size: 11pt; }
}
