/* ==========================================================================
   SPL Walaa — Design System
   Tokens, fonts, base typography, utilities.
   Prototype design system for Sharjah Public Library (not an official brand).
   ========================================================================== */

/* ---------- Local fonts (bundled, no CDN) ---------- */
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2"); font-weight: 300 800; font-display: swap; }

:root {
  /* Brand */
  --navy-900: #35093F;
  --navy-800: #4E1162;
  --navy-700: #5B1770;
  --navy-600: #6A2080;
  --indigo-700: #6E1280;
  --indigo-600: #87189D;
  --indigo-500: #A23DB8;
  --indigo-100: #F1E2F5;
  --indigo-50:  #F9F3FB;
  --gold-700: #8F6A1E;
  --gold-600: #B98A33;
  --gold-500: #D8A84E;
  --gold-200: #F2DFB8;
  --gold-100: #FAF1DF;
  --ivory: #F8F7F2;
  --ivory-2: #F1EFE6;
  --white: #FFFFFF;

  /* Neutrals */
  --text: #202A38;
  --text-2: #4A5565;
  --text-3: #697586;
  --text-4: #8A94A3;
  --border: #E4E8EF;
  --border-2: #D3D9E3;
  --surface: #FFFFFF;
  --surface-2: #F6F7FA;
  --surface-3: #EEF1F5;
  --canvas: #F4F5F8;

  /* Semantic */
  --success: #21865B;  --success-bg: #E7F4EE; --success-bd: #BFE2D0;
  --warning: #9A6A12;  --warning-ico: #C58A23; --warning-bg: #FBF2E1; --warning-bd: #F0DAAE;
  --error: #C84646;    --error-bg: #FBEAEA;   --error-bd: #F1C6C6;
  --info: #87189D;     --info-bg: #F3E8F6;    --info-bd: #DDC3E4;
  --neutral-bg: #EEF1F5;

  /* Tier colours (defaults; admin can change) */
  --tier-reader: #6B5F74;
  --tier-silver: #8C8696;
  --tier-gold: #B98A33;

  /* Type */
  --font-sans: "Plex", "Plex Arabic", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Plex Arabic", "Plex", "Segoe UI", Tahoma, "Geeza Pro", "Arial", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs-base: 0.9375rem; /* 15 */
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 3rem;

  /* Space (4px scale) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px; --s10: 72px;

  /* Shape */
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(16, 30, 54, .06);
  --shadow-sm: 0 1px 2px rgba(16, 30, 54, .06), 0 2px 6px rgba(16, 30, 54, .05);
  --shadow: 0 2px 4px rgba(16, 30, 54, .05), 0 8px 24px rgba(16, 30, 54, .08);
  --shadow-lg: 0 12px 40px rgba(16, 30, 54, .18);
  --focus: 0 0 0 3px rgba(135, 24, 157, .35);

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html[lang="ar"] body { font-family: var(--font-ar); line-height: 1.7; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--indigo-600); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4, h5 { margin: 0; color: var(--navy-800); line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s5) 0; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--gold-200); color: var(--navy-900); }

.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; font-variation-settings: "opsz" 72; }
html[lang="ar"] .display { font-family: var(--font-ar); letter-spacing: 0; font-weight: 700; }

/* Focus */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--indigo-600); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 1000;
  background: var(--navy-800); color: #fff; padding: 10px 16px; border-radius: var(--r);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* ---------- Utilities ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.mono, .ltr-id { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.ltr-id, .num { direction: ltr; unicode-bidi: isolate; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.end { text-align: end; }
.gold { color: var(--gold-700); }
.success-text { color: var(--success); }
.error-text { color: var(--error); }
.warning-text { color: var(--warning); }

.row { display: flex; align-items: center; gap: var(--s3); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s5); }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); } .gap-4 { gap: var(--s4); } .gap-6 { gap: var(--s6); }
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); } .mt-6 { margin-top: var(--s6); }
.mb-2 { margin-bottom: var(--s2); } .mb-4 { margin-bottom: var(--s4); }
.ms-auto { margin-inline-start: auto; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.grid { display: grid; gap: var(--s5); }
.grid-2 { display: grid; gap: var(--s5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--s5); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--s5); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-side-main { display: grid; gap: var(--s5); grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.span-2 { grid-column: span 2; }

/* Icons */
.ico { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.9; }
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }
.ico-xl { width: 28px; height: 28px; }
/* Directional icons flip in RTL; neutral icons (QR, clock, check) do not */
html[dir="rtl"] .ico.flip-rtl { transform: scaleX(-1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
