/* ==========================================================================
   Base: tokens, reset, typography, container, buttons, accessibility helpers.
   Direction-neutral (logical properties) so it serves RTL and LTR languages.
   ========================================================================== */

:root {
  /* Green: brand */
  --green-900: #3F5226;
  --green-800: #4E6330;
  --green-700: #56702E;
  --green-600: #66803A;
  --green-500: #7A9648;
  --green-400: #9AB26A;
  --green-300: #B5C493;
  --green-200: #C9D6A8;
  --green-150: #DCE5C6;
  --green-100: #E5EBD7;
  --green-75:  #E8EEDB;
  --green-50:  #F1F4EA;
  --green-25:  #F7F9F2;
  --green-10:  #FBFCF8;

  /* Ink: text */
  --ink-900: #23241F;
  --ink-800: #2B2B2B;
  --ink-700: #3D3E39;
  --ink-500: #5A5B55;
  --ink-400: #6B6B66;
  --ink-300: #8A8C82;
  --ink-200: #A8A9A3;
  --ink-150: #C9CAC4;

  /* Lines and neutral surfaces */
  --line-100: #E7E8E1;
  --line-150: #E5E8DC;
  --line-200: #E1E4D7;
  --line-300: #D9DCCF;
  --line-50:  #EEEFE9;
  --surface: #FFFFFF;

  /* Footer */
  --dark-900: #2B2B2B;
  --dark-800: #383836;
  --dark-700: #4A4A45;

  --danger: #B3261E;

  /* Fonts (Arabic interface overrides below) */
  --font-sans: 'Janna', system-ui, sans-serif;
  --font-display: var(--font-sans);
  --font-hadith: system-ui, sans-serif;

  /* Layout */
  --container: 1200px;
  --gutter: 15px;
  --header-offset: 92px;

  /* Radii and shadows */
  --radius-card: 18px;
  --shadow-card: 0 12px 32px -16px rgba(78, 99, 48, 0.18);
  --shadow-card-hover: 0 18px 40px -14px rgba(78, 99, 48, 0.2);
  --shadow-menu: 0 24px 60px -22px rgba(35, 36, 31, 0.34);
  --shadow-modal: 0 28px 80px rgba(35, 36, 31, 0.24);
  --focus-ring: 0 0 0 4px rgba(201, 214, 168, 0.3);
}

.lang-ar {
  --font-sans: 'Thmanyah Sans', 'Janna', sans-serif;
  --font-display: 'Thmanyah Serif Display', 'Amiri', serif;
  --font-hadith: 'Noto Naskh Arabic', 'Janna', serif;
}
.lang-fa { --font-sans: 'Farsi', 'Janna', sans-serif; }

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-offset);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink-700);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
main { flex: 1 0 auto; display: block; }
main:focus { outline: none; }

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
/* Sprite icons inherit the text colour; shapes with an explicit fill keep it. */
svg { flex-shrink: 0; fill: currentColor; }

a {
  color: var(--green-800);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s, background-color .2s, border-color .2s, box-shadow .2s, transform .2s;
}
a:hover { color: var(--green-900); }

h1, h2, h3, h4, h5, h6, p, ol, ul, dl, dd, figure, blockquote { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.4; color: var(--ink-900); }

input, select, button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
fieldset { margin: 0; padding: 0; border: 0; }

[hidden] { display: none !important; }

/* Arabic text inside non-Arabic pages and vice versa */
.rtl { direction: rtl; text-align: right; }
.ltr { direction: ltr; text-align: left; }

/* --------------------------------------------------------------------------
   Accessibility helpers
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 2000;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--green-800);
  color: #FFFFFF;
  font-weight: 700;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; color: #FFFFFF; outline: 3px solid #FFFFFF; outline-offset: 2px; }

:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
a:focus-visible { border-radius: 4px; }

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

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.display-title {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink-900);
  text-wrap: balance;
}

.tabular { font-variant-numeric: tabular-nums; }

/* Inline SVG icon from the sprite: sized by the font, coloured by currentColor */
.icon { width: 1em; height: 1em; fill: currentColor; }
.icon--stroke { fill: none; stroke: currentColor; }

/* Chevron (rotates when its control is expanded) */
.chevron { fill: none; color: currentColor; transition: transform .2s ease; }
[aria-expanded="true"] > .chevron,
[aria-expanded="true"] .chevron,
.is-open > .chevron { transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, color .2s, transform .2s;
}
.btn:disabled { cursor: not-allowed; opacity: .6; }
.btn svg { width: 16px; height: 16px; }

.btn--primary { background: var(--green-600); border-color: var(--green-600); color: #FFFFFF; }
.btn--primary:hover { background: var(--green-700); border-color: var(--green-700); color: #FFFFFF; }

.btn--outline { background: var(--surface); border-color: var(--line-300); color: var(--green-800); }
.btn--outline:hover { border-color: var(--green-400); background: var(--green-50); color: var(--green-900); }

.btn--soft { background: var(--green-50); border-color: var(--green-150); color: var(--green-800); }
.btn--soft:hover { border-color: var(--green-400); color: var(--green-900); }

.btn--sm { min-height: 40px; padding: 0 16px; border-radius: 10px; font-size: 14px; }
.btn--block { width: 100%; }

/* Square bordered icon button */
.icon-btn {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line-100);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-700);
  cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--green-400); background: var(--green-25); color: var(--ink-700); }
.icon-btn svg { width: 18px; height: 18px; }

/* Transparent close button */
.close-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-700);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { background: var(--green-50); color: var(--green-900); }

/* Button that reads as an inline link */
.link-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green-800);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--green-600); }

/* Search input with a leading icon */
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--green-200);
  border-radius: 12px;
  background: var(--green-25);
  color: var(--green-600);
  transition: border-color .2s, background-color .2s, box-shadow .2s;
}
.search-field:focus-within { border-color: var(--green-600); background: var(--surface); box-shadow: var(--focus-ring); }
.search-field svg { width: 18px; height: 18px; }
.search-field input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 42px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-900);
  font-size: 15px;
}
.search-field input::placeholder { color: var(--ink-300); opacity: 1; }

/* Form controls */
.input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line-300);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-900);
  font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--green-600); box-shadow: var(--focus-ring); outline: none; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.7; }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, .15); }

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
/* Elements that exist only on paper */
.print-only { display: none !important; }

@media print {
  @page { margin: 14mm 12mm 16mm; }
  *, *::before, *::after {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    animation: none !important;
    transition: none !important;
  }
  html { scroll-padding-top: 0; }
  body { display: block; min-height: 0; background: #FFFFFF; color: #000000; }
  .no-print,
  .site-header,
  .site-footer,
  .skip-link,
  .smart-assistant,
  .modal,
  #toast-container,
  .breadcrumb { display: none !important; }
  .print-only { display: block !important; }
  .container { max-width: none; padding-inline: 0; }
  a { color: inherit; text-decoration: none; }
  h1, h2, h3 { break-after: avoid; }
  img, svg, li, blockquote, figure { break-inside: avoid; }
  p { orphans: 3; widows: 3; }

  .print-brand {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12pt;
    margin-bottom: 12pt;
    padding-bottom: 8pt;
    border-bottom: 2px solid var(--green-600);
    color: var(--ink-500);
    font-size: 9pt;
  }
  .print-brand img { width: auto; height: 32pt; }
  .print-source {
    margin-top: 14pt;
    padding-top: 8pt;
    border-top: 1px solid var(--line-200);
    color: var(--ink-500);
    font-size: 8.5pt;
    overflow-wrap: anywhere;
  }
}
