/* ============================================================
   style.css — Fikr Magazine Core Design System
   Classic Arabic Broadsheet / Newspaper Theme - "Journal Papier Arabe"
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Cairo:wght@300;400;600;700;800&family=Noto+Naskh+Arabic:wght@400;500;600;700&family=Readex+Pro:wght@200;300;400;500;600;700&display=swap');

/* ---- CSS VARIABLES ---- */
:root {
  /* Paper & Ink Palette */
  --paper: #EFECE4;          /* Soft, vintage newsprint color */
  --paper-dark: #E5E2DA;     /* Editorial slightly darker warm paper */
  --ink: #2B2B2B;            /* Deep charcoal/ink black */
  --ink-mid: #2B2B2B;        /* Readable dark charcoal for paragraphs */
  --ink-light: #4A4A4A;      /* Muted dark grey for meta details */
  --ink-faint: #A09D94;      /* Soft beige-gray for editorial separation borders */

  /* Accent */
  --accent: #800020;         /* Bordeaux red classic */
  --accent-hover: #5d0016;
  --accent-emerald: #0f5257; /* Dark Emerald green for dynamic categories */
  --accent-gold: #b8860b;
  --accent-gold-light: #d4a017;

  /* Category Palette */
  --cat-ideas: #8e44ad;
  --cat-economy: #2c3e50;
  --cat-tech: #2980b9;
  --cat-history: #d35400;

  /* Surface */
  --surface: #fdfbf7;        /* Match the cream background */
  --surface-warm: #fcfaf2;

  /* Layout */
  --container-width: 1240px;
  --header-height: 80px;   /* masthead + nav */

  /* Typography */
  --font-serif: 'Amiri', 'Georgia', serif;
  --font-sans: 'Readex Pro', 'Cairo', 'Segoe UI', sans-serif;
  --font-body: 'Noto Naskh Arabic', 'Amiri', serif;

  /* Effects */
  --shadow-sm: 0 1px 3px rgba(26,26,26,0.05);
  --shadow-md: 0 4px 12px rgba(26,26,26,0.08);
  --shadow-lg: 0 8px 28px rgba(26,26,26,0.1);
  --transition: all 0.25s ease;
  --border-radius: 2px;      /* Sharp newspaper edges */
  --border-rule: 1px solid #1a1a1a; /* Fine black line */
  --border-rule-dark: 2px solid #1a1a1a;
}

/* ---- RESET & BASE ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  overflow-anchor: none;
}

body {
  background-color: #C4BAA0; /* dark surround — looks like a desk around the newspaper */
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.8;
  direction: rtl;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--paper-dark); }
::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-light); }

/* ---- TYPOGRAPHY ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

p { margin-bottom: 1.25rem; }

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

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

/* ---- LAYOUT ---- */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.25rem; /* Base padding */
}

@media (max-width: 600px) {
  .container { padding: 0 0.75rem; } /* Optimized for mobile screens */
}
@media (max-width: 360px) {
  .container { padding: 0 0.5rem; } /* Ultra-compact for small phones like iPhone SE */
}

.main-content {
  margin-top: 0; /* sticky header no longer needs offset */
  min-height: calc(100vh - 80px);
  padding-bottom: 4rem;
  overflow-x: hidden;
  /* Newspaper page: paper texture + page-edge shadows */
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(
      transparent 0px,
      transparent 26px,
      rgba(43,43,43,0.028) 26px,
      rgba(43,43,43,0.028) 27px
    );
  box-shadow:
    -8px 0 24px rgba(0,0,0,0.18),
     8px 0 24px rgba(0,0,0,0.18),
     0 6px 20px rgba(0,0,0,0.1);
  position: relative;
}
/* Left/Right page-edge darkening effect */
.main-content::before,
.main-content::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  pointer-events: none;
  z-index: 1;
}
.main-content::before {
  right: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.06), transparent);
}
.main-content::after {
  left: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
}


/* ---- SITE HEADER (Global Navigation) ---- */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: var(--paper);
  border-bottom: var(--border-rule-dark);
}

.masthead-top {
  background: var(--surface);
  padding: 0.75rem 0 0.5rem;
  border-bottom: 1px solid var(--ink-faint);
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.masthead-date {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--ink-light);
  letter-spacing: 0.02em;
  min-width: 160px;
}

.masthead-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  gap: 0.5rem;
}

.site-logo {
  height: 80px;
  width: auto;
  transition: transform 0.2s;
  display: block;
}

.masthead-logo:hover .site-logo {
  transform: scale(1.02);
}

.logo-main {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
  transition: color 0.2s;
}

.masthead-logo:hover .logo-main { color: var(--accent); }

.logo-sub {
  font-size: 0.68rem;
  letter-spacing: 0.25em;
  color: var(--ink-light);
  text-transform: uppercase;
  font-family: var(--font-sans);
  margin-top: 2px;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 160px;
  justify-content: flex-start;
}

/* ---- MAIN NAV ---- */
.main-nav {
  background: var(--ink);
  padding: 0;
}

.main-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0;
}

.nav-links a {
  display: block;
  padding: 0.65rem 1.1rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  color: #d4cfc8;
  letter-spacing: 0.02em;
  transition: background 0.2s, color 0.2s;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-bottom-color: var(--accent-gold);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.2rem;
  border-radius: var(--border-radius);
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139,26,26,0.3);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink-faint);
}
.btn-outline:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.btn-gold {
  background: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}
.btn-gold:hover {
  background: var(--accent-gold-light);
  border-color: var(--accent-gold-light);
}

/* ---- EDITORIAL DIVIDERS ---- */
.rule-double {
  border: none;
  border-top: 4px double var(--ink);
  margin: 0;
}

.rule-single {
  border: none;
  border-top: var(--border-rule);
  margin: 0;
}

.section-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.section-rule__label {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.section-rule__line {
  flex: 1;
  height: 1px;
  background: var(--ink-faint);
}

.section-rule__color-bar {
  width: 40px;
  height: 3px;
  border-radius: 2px;
}

.section-rule__link {
  font-size: 0.8rem;
  color: var(--ink-light);
  white-space: nowrap;
  font-family: var(--font-sans);
}

.section-rule__link:hover { color: var(--accent); }

/* ---- POST CARDS ---- */
.post-card {
  background: var(--surface);
  border: var(--border-rule);
  transition: box-shadow 0.25s, transform 0.25s;
  display: flex;
  flex-direction: column;
  height: 100%;
}

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

.post-card__img-link { display: block; overflow: hidden; }

.post-card__img-wrap {
  position: relative;
  padding-top: 62%;
  overflow: hidden;
}

.post-card__img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.post-card:hover .post-card__img-wrap img { transform: scale(1.05); }

.post-card__img-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(26,17,8,0.5) 0%, transparent 60%);
}

.post-card__section {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-sans);
  color: #fff;
  letter-spacing: 0.05em;
}

.post-card__body {
  padding: 1.1rem 1.25rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 3px solid var(--ink);
}

.post-card__title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.4;
  margin-bottom: 0.6rem;
  flex: 1;
}

.post-card__title a { color: var(--ink); }
.post-card__title a:hover { color: var(--accent); }

.post-card__title--lg { font-size: 1.6rem; }

.post-card__excerpt {
  font-size: 0.9rem;
  color: var(--ink-light);
  line-height: 1.6;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-light);
  border-top: var(--border-rule);
  padding-top: 0.65rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.post-card__author { font-weight: 600; }
.post-card__sep { color: var(--ink-faint); }

/* Featured card variant */
.post-card--featured {
  flex-direction: row;
  align-items: stretch;
}

.post-card--featured .post-card__img-link {
  flex: 0 0 45%;
}

.post-card--featured .post-card__img-wrap {
  padding-top: 0;
  height: 100%;
  min-height: 220px;
}

.post-card--featured .post-card__body {
  flex: 1;
}

/* ---- POST ROW (compact list) ---- */
.post-row {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 0.9rem 0;
  border-bottom: var(--border-rule);
}

.post-row:last-child { border-bottom: none; }

.post-row__img-link {
  flex: 0 0 80px;
}

.post-row__img-link img {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 2px;
}

.post-row__body { flex: 1; }

.post-row__section {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.2rem;
}

.post-row__title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.post-row__title a { color: var(--ink); }
.post-row__title a:hover { color: var(--accent); }

.post-row__date {
  font-size: 0.72rem;
  color: var(--ink-light);
}

/* ---- GRID ---- */
.grid { display: grid; gap: 1.5rem; }
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 992px) {
  .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--ink-mid);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--ink-faint);
  border-radius: var(--border-radius);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: rtl;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,26,26,0.12);
}

textarea.form-control { min-height: 130px; resize: vertical; }
select.form-control { appearance: none; cursor: pointer; }

/* ---- STATUS BADGES ---- */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 700;
}
.status-draft     { background: #e9e5dd; color: #5c4a2e; }
.status-pending   { background: #fef3c7; color: #92400e; }
.status-revision  { background: #dbeafe; color: #1e40af; }
.status-published { background: #dcfce7; color: #166534; }
.status-rejected  { background: #fee2e2; color: #991b1b; }
.status-archived  { background: #f1f5f9; color: #475569; }

/* ---- TOAST ---- */
.fikr-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 2rem;
  border-radius: 2px;
  font-size: 0.9rem;
  z-index: 9999;
  transition: transform 0.35s ease;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
}
.fikr-toast--show { transform: translateX(-50%) translateY(0); }
.fikr-toast--error { background: var(--accent); }

/* ---- MOBILE MENU BUTTON ---- */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.mobile-menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* ---- MOBILE MENU ---- */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,17,8,0.6);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s;
}
.mobile-overlay.open { opacity: 1; visibility: visible; }

.mobile-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: min(320px, 85vw);
  height: 100%;
  background: var(--surface);
  z-index: 1200;
  transition: right 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(26,17,8,0.2);
}
.mobile-menu.open { right: 0; }

.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: var(--border-rule-dark);
  background: var(--ink);
}
.mobile-menu-header .logo-main { color: #fff; font-size: 2rem; }

.mobile-close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.mobile-close-btn:hover { color: #fff; }

.mobile-nav-links { list-style: none; flex: 1; overflow-y: auto; }
.mobile-nav-links li a {
  display: block;
  padding: 0.9rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  border-bottom: var(--border-rule);
  color: var(--ink);
}
.mobile-nav-links li a:hover { background: var(--paper); color: var(--accent); }

.mobile-menu-footer {
  padding: 1.25rem 1.5rem;
  border-top: var(--border-rule);
}

@media (max-width: 900px) {
  .mobile-menu-btn { display: flex !important; z-index: 1001; }
  .nav-links, .nav-links-broadsheet { display: none !important; }
  .utility-actions #navSearchForm { display: none !important; }
  .masthead-inner { padding: 0.4rem 0; }
  .main-nav-broadsheet .container { padding: 0.35rem 0.6rem; }
  .user-dropdown { right: auto; left: 0; max-width: 88vw; }
}

@media (max-width: 600px) {
  .logo-main { font-size: 2.2rem; }
  .logo-sub { font-size: 0.6rem; letter-spacing: 0.15em; }
  .utility-actions { gap: 0.4rem !important; }
  .utility-actions .btn { padding: 0.3rem 0.65rem !important; font-size: 0.8rem !important; }
  .user-avatar-nav { width: 32px; height: 32px; font-size: 0.9rem; }
}

@media (max-width: 380px) {
  .utility-actions { gap: 0.25rem !important; }
  .utility-actions .btn { padding: 0.25rem 0.45rem !important; font-size: 0.74rem !important; }
  .logo-main { font-size: 1.9rem; }
}

/* ---- FOOTER ---- */
footer {
  background: var(--ink);
  color: #c4b9a5;
}

.footer-rule {
  height: 3px;
  background: linear-gradient(to left, var(--accent), var(--accent-gold), var(--accent));
}

.footer-content { padding-top: 0.85rem; padding-bottom: 0.6rem; }

.footer-grid {
  display: grid;
  grid-template-columns: 1.3fr 2fr 1fr;
  gap: 1rem 1.75rem;
  margin-bottom: 0.6rem;
  align-items: start;
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

.footer-logo {
  margin-bottom: 0.25rem;
}

.footer-logo-img {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.footer-tagline { font-size: 0.82rem; line-height: 1.4; margin-bottom: 0; }

.footer-col h4 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 0.35rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col ul li { margin-bottom: 0.2rem; }
.footer-col ul a { color: #c4b9a5; font-size: 0.84rem; }
.footer-col ul a:hover { color: var(--accent-gold-light); }

/* Multi-column grid for sections in footer */
.footer-sections-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)) !important;
  gap: 0.2rem 0.75rem !important;
}
.footer-sections-list li {
  margin-bottom: 0 !important;
}
.footer-sections-list a {
  display: inline-block;
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .footer-sections-list {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.2rem 0.5rem !important;
  }
}

.footer-bottom-rule {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin-bottom: 0.35rem;
}

.footer-bottom p {
  font-size: 0.75rem;
  color: #7a6a54;
  text-align: center;
  margin: 0;
}

/* ---- USER MENU ---- */
.user-menu { position: relative; }

.user-avatar-nav {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: box-shadow 0.2s;
  flex-shrink: 0;
}
.user-avatar-nav:hover { box-shadow: 0 0 0 3px rgba(139,26,26,0.3); }

.user-dropdown {
  position: absolute;
  top: 48px;
  left: 0;
  background: var(--surface);
  border: var(--border-rule);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 200;
}
.user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown-header {
  padding: 0.9rem 1rem;
  border-bottom: var(--border-rule);
  background: var(--paper);
}
.dropdown-header strong { display: block; color: var(--ink); font-size: 0.95rem; }
.dropdown-header small { color: var(--ink-light); font-size: 0.8rem; }

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  text-align: right;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink);
  transition: background 0.15s;
}
.dropdown-item:hover { background: var(--paper); color: var(--accent); }

/* ---- UTILITY ---- */
.text-center { text-align: center; }
.text-muted { color: var(--ink-light); }
.p-4 { padding: 2rem; }
.mt-4 { margin-top: 2rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
