/* ==========================================================================
   CORE.CSS — Design Foundations
   Contains: CSS Reset, Custom Properties, Font Faces, Base Typography,
   Animations, Container & Grid Layout Utilities
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  line-height: 1.6;
  min-height: 100vh;
}

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

button {
  border: none;
  background: none;
  cursor: pointer;
}

a {
  color: inherit;
}

main {
  display: block;
}

html {
  scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   2. Custom Properties (Design Tokens)
   Environmental, minimalistic palette for a doctor & writer brand
   -------------------------------------------------------------------------- */
:root {
  /* Primary palette */
  --color-primary: #2A352A;
  --color-primary-light: #3A4A3A;
  --color-secondary: #C4D6C8;
  --color-secondary-dark: #A8C0AE;

  /* Backgrounds & surfaces */
  --color-bg: #C4D6C8;
  --color-bg-card: #FFFFFF;

  /* Text */
  --color-text: #2A352A;
  --color-text-light: #4A5A4A;

  /* Borders */
  --color-border: #A8C0AE;

  /* Border radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 24px;

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 72px;

  /* Box shadows */
  --shadow-sm: 0 1px 3px rgba(42, 53, 42, 0.08);
  --shadow-md: 0 10px 30px rgba(42, 53, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(42, 53, 42, 0.08);

  /* Typography */
  --font-main: "Sahel", sans-serif;

  /* Admin sidebar width (used in admin.css) */
  --admin-sidebar-width: 280px;
}

/* --------------------------------------------------------------------------
   3. Font Faces
   -------------------------------------------------------------------------- */

/* Vazirmatn — Used primarily for book reader content */
@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-Thin.woff2') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-ExtraLight.woff2') format('woff2');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/vazirmatn/webfonts/Vazirmatn-Black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* Sahel — Primary UI font */
@font-face {
  font-family: 'Sahel';
  src: url('/static/fonts/sahel/Sahel-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sahel';
  src: url('/static/fonts/sahel/Sahel.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sahel';
  src: url('/static/fonts/sahel/Sahel-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sahel';
  src: url('/static/fonts/sahel/Sahel-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sahel';
  src: url('/static/fonts/sahel/Sahel-Black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   4. Base Typography
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
}

h1, h2, h3, h4 {
  font-weight: 600;
}

p {
  margin-bottom: 1rem;
}

/* --------------------------------------------------------------------------
   5. Animations (Minimal & Elegant)
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes preloaderPulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Apply entrance animations to key sections */
.section-panel,
.hero,
.section {
  animation: fadeInUp 0.8s ease-out forwards;
}

/* Staggered card entrance */
.posts-grid .post-card,
.catalog-grid .book-card,
.card {
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
}

.posts-grid .post-card:nth-child(1),
.catalog-grid .book-card:nth-child(1),
.card:nth-child(1) { animation-delay: 0.1s; }

.posts-grid .post-card:nth-child(2),
.catalog-grid .book-card:nth-child(2),
.card:nth-child(2) { animation-delay: 0.2s; }

.posts-grid .post-card:nth-child(3),
.catalog-grid .book-card:nth-child(3),
.card:nth-child(3) { animation-delay: 0.3s; }

.posts-grid .post-card:nth-child(4),
.catalog-grid .book-card:nth-child(4),
.card:nth-child(4) { animation-delay: 0.4s; }

.posts-grid .post-card:nth-child(5),
.catalog-grid .book-card:nth-child(5),
.card:nth-child(5) { animation-delay: 0.5s; }

.posts-grid .post-card:nth-child(6),
.catalog-grid .book-card:nth-child(6),
.card:nth-child(6) { animation-delay: 0.6s; }

/* Fade in footer after content settles */
.footer {
  animation: fadeIn 1s ease-out 0.3s forwards;
  opacity: 0;
}

/* Smooth transitions for interactive elements */
.btn,
.nav-links a,
.footer-links a {
  transition: all 0.3s ease;
}

/* --------------------------------------------------------------------------
   6. Layout Utilities (Container & Grid)
   -------------------------------------------------------------------------- */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

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

/* Utility classes */
.muted {
  color: var(--color-text-light);
}

.stack > * + * {
  margin-top: var(--space-md);
}
