/**
 * KHEDMA.MA - Public Theme & Google AdSense Core Stylesheet
 * Optimized for Core Web Vitals (CLS: 0, LCP < 1.2s, FID < 50ms)
 * Breakpoints:
 * - Mobile: < 640px
 * - Small Tablet: 640px - 767px
 * - Tablet / iPad: 768px - 1024px
 * - Laptop / Desktop: > 1024px
 */

:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-light: #eff6ff;
  --gold-accent: #f59e0b;
  --text-dark: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-light: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-md: 8px;
  --radius-lg: 12px;
  --max-w: 1200px;
  --touch-target: 44px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-body);
  font-size: clamp(1rem, 1.2vw, 1.125rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.container {
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(16px, 3vw, 24px);
  padding-right: clamp(16px, 3vw, 24px);
  width: 100%;
}

/* -------------------------------------------------------------
   GOOGLE ADSENSE COMPLIANT AD CONTAINERS (ZERO CLS)
   Aspect-ratio and min-height reservations prevent layout shifts
------------------------------------------------------------- */
.ad-placement-wrapper {
  margin: 20px auto;
  text-align: center;
  background: #fdfdfd;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  overflow: hidden; /* Prevents oversized creatives from breaking viewport */
  clear: both;
}

.ad-compliance-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 6px;
  text-align: center;
}

.ad-unit-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  overflow: hidden;
}

/* Header Slot: 90px on Desktop, 50px on Mobile */
.ad-slot-header {
  max-width: 970px;
  min-height: 90px;
  width: 100%;
}

/* In-Article Slot: 250px reservation for fluid/rectangle units */
.ad-slot-in-article {
  max-width: 728px;
  min-height: 250px;
  margin: 32px auto;
  width: 100%;
}

/* Sidebar Slot: 300x250 or 300x600 reservation */
.ad-slot-sidebar {
  max-width: 300px;
  min-height: 250px;
  margin: 16px auto;
  width: 100%;
}

/* -------------------------------------------------------------
   SITE HEADER & RESPONSIVE NAVIGATION
------------------------------------------------------------- */
.site-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 99;
  box-shadow: var(--shadow-sm);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo-img {
  height: clamp(34px, 5vw, 44px);
  width: auto;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-main-title {
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-main-title span {
  color: var(--primary);
}

.brand-tagline {
  font-size: clamp(0.68rem, 1.2vw, 0.72rem);
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mobile Hamburger Toggle (Public) */
.nav-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  background: #f1f5f9;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: #0f172a;
  cursor: pointer;
  padding: 0;
}

/* Main Navigation Bar */
.main-nav-bar {
  background: #0d1527;
  transition: all 0.25s ease;
}

.nav-links-wrap {
  display: flex;
  list-style: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.nav-links-wrap li a {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  min-height: var(--touch-target);
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.nav-links-wrap li a:hover,
.nav-links-wrap li a.active {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

/* -------------------------------------------------------------
   BREADCRUMBS
------------------------------------------------------------- */
.breadcrumb-nav {
  padding: 14px 0;
  font-size: clamp(0.78rem, 1.5vw, 0.85rem);
  color: var(--text-muted);
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.breadcrumb-separator {
  color: #cbd5e1;
}

.breadcrumb-active {
  color: var(--text-body);
  font-weight: 600;
}

/* -------------------------------------------------------------
   PAGE LAYOUT: MAIN + SIDEBAR
------------------------------------------------------------- */
.layout-split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 36px;
  margin: 24px 0 60px 0;
}

/* -------------------------------------------------------------
   HERO / BANNER
------------------------------------------------------------- */
.hero-banner {
  background: linear-gradient(135deg, #0d1527 0%, #1e293b 100%);
  color: #ffffff;
  padding: clamp(36px, 6vw, 56px) clamp(16px, 4vw, 32px);
  border-radius: var(--radius-lg);
  margin: 16px 0 32px 0;
  text-align: center;
}

.hero-title {
  font-size: clamp(1.75rem, 4vw + 1rem, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  color: #cbd5e1;
  max-width: 680px;
  margin: 0 auto 24px auto;
  line-height: 1.5;
}

/* -------------------------------------------------------------
   ARTICLE CARDS GRID
------------------------------------------------------------- */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.post-card-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.post-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.post-cat-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

.post-reading-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.post-card-title {
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
}

.post-card-title a {
  color: var(--text-dark);
}
.post-card-title a:hover {
  color: var(--primary);
}

.post-card-excerpt {
  font-size: 0.92rem;
  color: var(--text-body);
  line-height: 1.55;
  margin-bottom: 16px;
  flex-grow: 1;
}

.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------
   SINGLE ARTICLE VIEW (post.php)
------------------------------------------------------------- */
.article-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 40px);
}

.article-header {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 20px;
}

.article-title {
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-dark);
  letter-spacing: -0.02em;
  margin: 12px 0 16px 0;
}

.author-byline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.author-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-light);
}

.author-name {
  font-weight: 700;
  color: var(--text-dark);
  font-size: 0.95rem;
}

.author-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.article-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #1e293b;
}

.article-body h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.45rem);
  font-weight: 700;
  color: #0f172a;
  margin: 32px 0 14px 0;
  letter-spacing: -0.01em;
}

.article-body h3 {
  font-size: clamp(1.1rem, 2vw, 1.2rem);
  font-weight: 700;
  margin: 24px 0 10px 0;
}

.article-body p {
  margin-bottom: 18px;
}

.article-body ul, .article-body ol {
  margin: 16px 0 20px 24px;
}

.article-body li {
  margin-bottom: 8px;
}

.author-bio-box {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 36px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------
   FAQ ACCORDION & LISTS
------------------------------------------------------------- */
.faq-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
}

.faq-item-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-question-btn {
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  min-height: var(--touch-target);
  background: none;
  border: none;
  font-size: clamp(0.92rem, 1.5vw, 1.02rem);
  font-weight: 700;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.faq-answer-body {
  padding: 0 20px 18px 20px;
  color: var(--text-body);
  font-size: 0.95rem;
  line-height: 1.65;
  border-top: 1px solid #f1f5f9;
  padding-top: 14px;
}

/* -------------------------------------------------------------
   SIDEBAR WIDGETS
------------------------------------------------------------- */
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-bottom: 24px;
}

.widget-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
}

/* -------------------------------------------------------------
   FOOTER
------------------------------------------------------------- */
.site-footer {
  background-color: #0d1527;
  color: #94a3b8;
  padding: 48px 0 24px 0;
  margin-top: 60px;
}

.footer-columns-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

.footer-col h4 {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-col ul a {
  color: #94a3b8;
  font-size: 0.88rem;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}
.footer-col ul a:hover {
  color: #ffffff;
}

.footer-bottom-bar {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 24px;
  text-align: center;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.6;
}

/* =============================================================
   PUBLIC RESPONSIVE BREAKPOINTS
============================================================= */

/* 1. Tablet & iPad (768px - 1024px) */
@media (max-width: 1024px) {
  .layout-split {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .footer-columns-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-mobile-toggle {
    display: inline-flex;
  }

  /* Slide-down mobile nav bar */
  .main-nav-bar {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .main-nav-bar.nav-open {
    max-height: 500px;
  }

  .nav-links-wrap {
    flex-direction: column;
    white-space: normal;
    padding: 12px 0;
  }

  .nav-links-wrap li a {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
}

/* 2. Small Tablet / Large Mobile (640px - 767px) */
@media (max-width: 767px) {
  .ad-slot-header {
    min-height: 50px;
    max-width: 320px;
  }

  .posts-grid {
    grid-template-columns: 1fr;
  }

  .footer-columns-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* 3. Mobile (< 640px) */
@media (max-width: 639px) {
  .brand-tagline {
    display: none; /* keeps header clean on mobile */
  }

  .admin-access-link span {
    display: none;
  }

  .ad-placement-wrapper {
    margin: 16px auto;
    padding: 8px 6px;
  }

  .hero-banner form {
    flex-direction: column;
  }

  .hero-banner form button {
    width: 100%;
    min-height: var(--touch-target);
  }
}
