/* ==========================================================================
   SHARED STYLES — Rakeezah Design System
   Used by all pages. Each page adds its own page-specific styles inline.
   ========================================================================== */

/* View Transitions — smooth crossfade between pages */
@view-transition { navigation: auto; }

/* ==========================================================================
   1. FONT FACES — Lyon Arabic (self-hosted)
   ========================================================================== */
@font-face {
  font-family: 'Lyon Arabic';
  src: url('fonts/lyon-arabic-text-regular.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lyon Arabic';
  src: url('fonts/lyon-arabic-text-semibold.otf') format('opentype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lyon Arabic';
  src: url('fonts/lyon-arabic-text-bold.otf') format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lyon Arabic';
  src: url('fonts/lyon-arabic-text-black.otf') format('opentype');
  font-weight: 900; font-style: normal; font-display: swap;
}

/* ==========================================================================
   2. CSS CUSTOM PROPERTIES
   ========================================================================== */
:root {
  --rgb-bg: 15, 14, 12;
  --rgb-text: 245, 240, 232;
  --rgb-accent: 217, 119, 6;

  --bg: rgb(var(--rgb-bg));
  --text: rgb(var(--rgb-text));
  --accent: rgb(var(--rgb-accent));
  --secondary: #16A34A;
  --accent-muted: rgba(var(--rgb-accent), 0.15);

  --font-family: 'Lyon Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-size: calc(1em + 0.8vw);
  --font-size-small: 75%;
  --line-height: calc(1.3em + 0.8vw);
  --spacing: 0.75em;
  --transition: 0.2s ease;

  /* z-index layers */
  --z-boundary: 101;
  --z-header: 104;
  --z-footer: 103;
  --z-underlay: 107;
  --z-nav: 108;
}

@media (min-width: 64em) {
  :root {
    --font-size: calc(1.15em + 0.8vw);
    --font-size-small: 65%;
    --line-height: 1.3em;
  }
}

/* ==========================================================================
   3. RESET
   ========================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
ul, ol, dl { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ==========================================================================
   4. BASE STYLES
   ========================================================================== */
html { font-size: 16px; }

body {
  background: var(--bg);
  color: rgba(var(--rgb-text), 0.85);
  font-family: var(--font-family);
  font-size: var(--font-size);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.3;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

::selection { background: rgba(var(--rgb-text), 0.15); }
strong, b { color: var(--text); font-weight: 700; }

/* Focus styles — keyboard accessibility (WCAG 2.4.7) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   5. FIXED HEADER (desktop nav)
   ========================================================================== */
.header {
  display: flex;
  justify-content: flex-end;
  inset-inline-start: 0;
  pointer-events: none;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: var(--z-header);
}
/* Default gradient for subpages (fully opaque at top) */
.header { background: linear-gradient(180deg, rgba(var(--rgb-bg), 1) 0, rgba(var(--rgb-bg), 0) 100%); }

.header .logo { order: 3; pointer-events: auto; }
.header .logo a img { filter: invert(1); }
.header ul {
  align-items: center;
  display: none;
  flex: 1;
  line-height: var(--line-height);
  order: 1;
  padding-inline-start: var(--spacing);
  padding-top: var(--spacing);
  pointer-events: auto;
}
.header ul li { font-size: var(--font-size-small); font-weight: 700; }
.header ul li a { padding: 0 0.5em; transition: text-decoration var(--transition); }

@media (min-width: 64em) {
  .header ul { display: flex; }
  .header ul li a:hover,
  .header ul li a:focus-visible { text-decoration: underline; text-underline-offset: 0.15em; }
}

/* ==========================================================================
   6. MOBILE NAV (37signals-style checkbox toggle)
   ========================================================================== */
.nav-active { display: none; }
.nav-active:checked ~ .nav-underlay { display: block; }
.nav-active:checked ~ .nav {
  background: var(--text);
  border-radius: 0 0 var(--spacing) var(--spacing);
  pointer-events: auto;
}
.nav-active:checked ~ .nav .nav__logo { display: block; }
.nav-active:checked ~ .nav .nav__options { display: flex; }
@media (min-width: 64em) {
  .nav-active:checked ~ .nav-underlay, .nav-active:checked ~ .nav { display: none; }
}
.nav-underlay {
  background: rgba(var(--rgb-bg), 0.8);
  display: none; height: 100%; inset-inline-start: 0;
  position: fixed; top: 0; width: 100%; z-index: var(--z-underlay);
}
@media (min-width: 64em) { .nav-underlay { display: none; } }
.nav {
  display: flex; flex-direction: column; inset-inline-start: 0;
  pointer-events: none; position: fixed; top: 0; width: 100%; z-index: var(--z-nav);
}
.nav__logo { display: none; position: absolute; inset-inline-end: 0; top: 0; }
/* .nav__logo a shares styles with .header .logo a above */
.header .logo a,
.nav__logo a { display: block; height: var(--line-height); margin-inline-end: var(--spacing); margin-top: var(--spacing); }
.header .logo a img,
.nav__logo a img { height: 100%; max-height: 100%; width: auto; }
.nav__toggle { display: flex; align-items: center; gap: 0.6em; margin-inline-start: var(--spacing); margin-top: var(--spacing); }
.nav__toggle label {
  align-items: center; cursor: pointer; display: flex;
  height: var(--line-height);
  pointer-events: auto;
}
/* Hamburger icon: two spans, 22px wide, 1.5px thick, 5px gap.
   X-transform: translateY = (gap + bar height) / 2 = (5 + 1.5) / 2 = 3.25px */
.hamburger {
  display: flex; flex-direction: column; justify-content: center;
  gap: 5px; width: 22px; height: 22px; cursor: pointer;
}
.hamburger span {
  display: block; height: 1.5px; width: 100%;
  background: var(--text); border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}
.nav-active:checked ~ .nav .hamburger span { background: var(--bg); }
.nav-active:checked ~ .nav .hamburger span:first-child { transform: translateY(3.25px) rotate(45deg); }
.nav-active:checked ~ .nav .hamburger span:last-child { transform: translateY(-3.25px) rotate(-45deg); }
.nav__options { display: none; flex-direction: column; padding: 0 var(--spacing); }
.nav__options ul { display: flex; flex: 1; flex-direction: column; line-height: var(--line-height); }
.nav__options ul li { font-weight: 700; }
.nav__options ul li a { color: var(--bg); }
.nav__options ul:last-child {
  border-top: 1px solid rgba(var(--rgb-bg), 0.1);
  margin-top: calc(var(--spacing) * 1.5);
  padding-bottom: calc(var(--spacing) * 1.5);
  padding-top: calc(var(--spacing) * 1.5);
}
.nav__options ul:last-child li { font-size: var(--font-size-small); line-height: var(--line-height); }
@media (min-width: 64em) { .nav { display: none; } }

/* ==========================================================================
   7. LANGUAGE TOGGLE
   ========================================================================== */
.lang-toggle {
  background: none; border: none;
  color: var(--text); font-family: var(--font-family);
  font-size: var(--font-size-small); font-weight: 600;
  opacity: 0.5; cursor: pointer;
  transition: opacity var(--transition);
  pointer-events: auto; padding: 0;
}
.lang-toggle:hover,
.lang-toggle:focus-visible { opacity: 1; }

/* Mobile: beside hamburger */
.lang-toggle--mobile {
  height: var(--line-height);
  display: flex; align-items: center;
}
.nav-active:checked ~ .nav .lang-toggle--mobile { color: var(--bg); }
@media (min-width: 64em) { .lang-toggle--mobile { display: none; } }

/* Desktop: inside <ul> as last <li>, styled as subtle pill */
.lang-toggle--desktop {
  display: none;
  border: 1px solid rgba(var(--rgb-text), 0.25);
  border-radius: 3px;
  padding: 0.15em 0.5em;
  margin-inline-start: 0.3em;
}
.lang-toggle--desktop:hover {
  border-color: rgba(var(--rgb-text), 0.6);
}
@media (min-width: 64em) { .lang-toggle--desktop { display: inline; } }

/* ==========================================================================
   8. ARTICLE LAYOUT — shared by all subpages
   ========================================================================== */
.article-hero {
  padding: 8rem 2rem 3rem;
  max-width: 800px;
  margin: 0 auto;
}
.article-hero h1 {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 1rem;
  color: var(--text);
}

.article-body {
  max-width: 65ch;
  margin: 0 auto;
  padding: 0 2rem 6rem;
  font-size: 1.1rem;
  line-height: 1.9;
}
.article-body h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin: 3rem 0 1rem;
}
.article-body h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.8rem;
}
.article-body p {
  margin-bottom: 1.5rem;
}

.article-footer {
  text-align: center;
  padding: 4rem 2rem;
  border-top: 1px solid rgba(var(--rgb-accent), 0.2);
}
.footer-link {
  display: inline-block;
  padding: 1rem 2rem; /* min 44px touch target */
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bg);
  background-color: var(--accent);
  border-radius: 4px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.footer-link:hover,
.footer-link:focus-visible {
  transform: scale(1.04);
  box-shadow: 0 0 40px rgba(var(--rgb-accent), 0.4); /* fallback for Safari < 16.2 */
}

.article-date {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(var(--rgb-text), 0.4);
  margin-bottom: 1.5rem;
}

@media (max-width: 64em) {
  .article-hero { padding: 6rem 1.5rem 2rem; }
  .article-hero h1 { font-size: 2.5rem; }
  .article-body { padding: 0 1.5rem 4rem; }
}

/* ==========================================================================
   9. ANIMATED PANEL SVGS
   ========================================================================== */
.panel-svg {
  position: absolute;
  inset-inline-end: 3%;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(300px, 32vw, 520px);
  height: auto;
  opacity: 0.25;
  mix-blend-mode: lighten;
  pointer-events: none;
}
@media (max-width: 64em) {
  .panel-svg { display: none; }
}

/* ==========================================================================
   10. REDUCED MOTION — respect user preference (WCAG 2.3.3)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  @view-transition { navigation: none; }
}
