/* ==========================================================================
   ELITEPRESSLINE DESIGN SYSTEM
   Custom properties, typography, spacing, grid, and base element styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
  /* ---- Colors ---- */
  --ep-accent:           #D91E2A; /* Contrast check: 4.88:1 on white (PASS) */
  --ep-accent-hover:     #B51923;
  --ep-accent-light:     rgba(217, 30, 42, 0.1);
  --ep-accent-dark:      #911119;

  --ep-bg-primary:       #FFFFFF;
  --ep-bg-secondary:     #F7F7F8;
  --ep-bg-tertiary:      #EEEEF0;
  --ep-bg-card:          #FFFFFF;
  --ep-bg-elevated:      #FFFFFF;

  --ep-text-primary:     #121212;
  --ep-text-secondary:   #4A4A4A;
  --ep-text-tertiary:    #666666; /* Contrast check: 5.7:1 on white (PASS) */
  --ep-text-inverse:     #FFFFFF;
  --ep-text-link:        #D91E2A;

  --ep-border-color:     #E5E5E7;
  --ep-border-light:     #F0F0F2;
  --ep-divider:          #E5E5E7;

  /* ---- Shadows ---- */
  --ep-shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --ep-shadow-md:        0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --ep-shadow-lg:        0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
  --ep-shadow-xl:        0 20px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);
  --ep-shadow-card:      0 2px 8px rgba(0, 0, 0, 0.06);
  --ep-shadow-card-hover:0 8px 24px rgba(0, 0, 0, 0.10);

  /* ---- Typography ---- */
  --ep-font-heading:     'Outfit', system-ui, -apple-system, sans-serif;
  --ep-font-body:        'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ep-font-mono:        'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Font Sizes — fluid with clamp */
  --ep-text-xs:          0.75rem;      /* 12px */
  --ep-text-sm:          0.875rem;     /* 14px */
  --ep-text-base:        1rem;         /* 16px */
  --ep-text-lg:          1.125rem;     /* 18px */
  --ep-text-xl:          1.25rem;      /* 20px */
  --ep-text-2xl:         clamp(1.375rem, 1.2rem + 0.5vw, 1.5rem);    /* 22-24px */
  --ep-text-3xl:         clamp(1.5rem, 1.3rem + 0.8vw, 1.875rem);    /* 24-30px */
  --ep-text-4xl:         clamp(1.875rem, 1.5rem + 1.2vw, 2.5rem);    /* 30-40px */
  --ep-text-5xl:         clamp(2.25rem, 1.8rem + 1.5vw, 3rem);       /* 36-48px */
  --ep-text-hero:        clamp(2.5rem, 2rem + 2vw, 3.75rem);         /* 40-60px */

  /* Font Weights */
  --ep-weight-normal:    400;
  --ep-weight-medium:    500;
  --ep-weight-semibold:  600;
  --ep-weight-bold:      700;
  --ep-weight-extrabold: 800;

  /* Line Heights */
  --ep-leading-tight:    1.2;
  --ep-leading-snug:     1.35;
  --ep-leading-normal:   1.5;
  --ep-leading-relaxed:  1.7;
  --ep-leading-loose:    1.8;

  /* Letter Spacing */
  --ep-tracking-tight:   -0.025em;
  --ep-tracking-normal:  0em;
  --ep-tracking-wide:    0.025em;
  --ep-tracking-wider:   0.05em;
  --ep-tracking-caps:    0.08em;

  /* ---- Spacing (8px grid) ---- */
  --ep-space-1:          0.25rem;   /* 4px */
  --ep-space-2:          0.5rem;    /* 8px */
  --ep-space-3:          0.75rem;   /* 12px */
  --ep-space-4:          1rem;      /* 16px */
  --ep-space-5:          1.25rem;   /* 20px */
  --ep-space-6:          1.5rem;    /* 24px */
  --ep-space-8:          2rem;      /* 32px */
  --ep-space-10:         2.5rem;    /* 40px */
  --ep-space-12:         3rem;      /* 48px */
  --ep-space-16:         4rem;      /* 64px */
  --ep-space-20:         5rem;      /* 80px */
  --ep-space-24:         6rem;      /* 96px */

  /* ---- Layout ---- */
  --ep-container-max:    1200px;
  --ep-container-narrow: 720px;
  --ep-container-pad:    1.25rem;
  --ep-header-height:    72px;

  /* ---- Borders ---- */
  --ep-radius-sm:        6px;
  --ep-radius-md:        10px;
  --ep-radius-lg:        12px;
  --ep-radius-xl:        16px;
  --ep-radius-full:      9999px;

  /* ---- Transitions ---- */
  --ep-transition-fast:  150ms ease;
  --ep-transition-base:  250ms ease;
  --ep-transition-slow:  400ms ease;
  --ep-transition-spring:350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ---- Z-Index Scale ---- */
  --ep-z-dropdown:       100;
  --ep-z-sticky:         200;
  --ep-z-overlay:        300;
  --ep-z-modal:          400;
  --ep-z-toast:          500;
  --ep-z-progress:       9999;
}

/* --------------------------------------------------------------------------
   2. Base Typography
   -------------------------------------------------------------------------- */

body {
  font-family: var(--ep-font-body);
  font-size: var(--ep-text-base);
  font-weight: var(--ep-weight-normal);
  line-height: var(--ep-leading-normal);
  color: var(--ep-text-primary);
  background-color: var(--ep-bg-secondary);
  letter-spacing: var(--ep-tracking-normal);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--ep-font-heading);
  font-weight: var(--ep-weight-bold);
  line-height: var(--ep-leading-tight);
  letter-spacing: var(--ep-tracking-tight);
  color: var(--ep-text-primary);
}

h1 { font-size: var(--ep-text-5xl); }
h2 { font-size: var(--ep-text-4xl); }
h3 { font-size: var(--ep-text-3xl); }
h4 { font-size: var(--ep-text-2xl); }
h5 { font-size: var(--ep-text-xl); }
h6 { font-size: var(--ep-text-lg); }

p {
  margin-bottom: var(--ep-space-4);
  line-height: var(--ep-leading-relaxed);
}

a {
  color: var(--ep-text-link);
  transition: color var(--ep-transition-fast);
}

a:hover {
  color: var(--ep-accent-hover);
}

strong, b {
  font-weight: var(--ep-weight-semibold);
}

small {
  font-size: var(--ep-text-sm);
}

/* Selection */
::selection {
  background-color: var(--ep-accent);
  color: var(--ep-text-inverse);
}

/* --------------------------------------------------------------------------
   3. Container & Layout Utilities
   -------------------------------------------------------------------------- */

.ep-container {
  width: 100%;
  max-width: var(--ep-container-max);
  margin-inline: auto;
  padding-inline: var(--ep-container-pad);
}

.ep-container--narrow {
  max-width: var(--ep-container-narrow);
}

.ep-container--wide {
  max-width: 1400px;
}

/* Grid */
.ep-grid {
  display: grid;
  gap: var(--ep-space-6);
}

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

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

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

/* Responsive grid */
@media (max-width: 1024px) {
  .ep-grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .ep-grid--3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .ep-grid--4,
  .ep-grid--3,
  .ep-grid--2 {
    grid-template-columns: 1fr;
  }

  .ep-container {
    --ep-container-pad: 1rem;
  }
}

/* Flex utilities */
.ep-flex {
  display: flex;
}

.ep-flex--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ep-flex--between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ep-flex--col {
  display: flex;
  flex-direction: column;
}

.ep-flex--wrap {
  flex-wrap: wrap;
}

.ep-gap-1 { gap: var(--ep-space-1); }
.ep-gap-2 { gap: var(--ep-space-2); }
.ep-gap-3 { gap: var(--ep-space-3); }
.ep-gap-4 { gap: var(--ep-space-4); }
.ep-gap-6 { gap: var(--ep-space-6); }
.ep-gap-8 { gap: var(--ep-space-8); }

/* --------------------------------------------------------------------------
   4. Section Spacing
   -------------------------------------------------------------------------- */

.ep-section {
  padding-block: var(--ep-space-16);
}

.ep-section--sm {
  padding-block: var(--ep-space-10);
}

.ep-section__header {
  margin-bottom: var(--ep-space-8);
}

.ep-section__title {
  font-size: var(--ep-text-3xl);
  font-weight: var(--ep-weight-extrabold);
  letter-spacing: var(--ep-tracking-tight);
  position: relative;
  display: inline-block;
}

.ep-section__title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 48px;
  height: 3px;
  background-color: var(--ep-accent);
  border-radius: var(--ep-radius-full);
}

.ep-section__header .ep-section__link {
  font-size: var(--ep-text-sm);
  font-weight: var(--ep-weight-semibold);
  color: var(--ep-accent);
  text-transform: uppercase;
  letter-spacing: var(--ep-tracking-wide);
  transition: color var(--ep-transition-fast);
}

.ep-section__header .ep-section__link:hover {
  color: var(--ep-accent-hover);
}

/* --------------------------------------------------------------------------
   5. Visibility & Accessibility
   -------------------------------------------------------------------------- */

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  -webkit-clip-path: inset(50%);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  background-color: var(--ep-bg-primary);
  border-radius: var(--ep-radius-sm);
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
  clip: auto !important;
  -webkit-clip-path: none;
  clip-path: none;
  color: var(--ep-text-primary);
  display: block;
  font-size: var(--ep-text-sm);
  font-weight: var(--ep-weight-bold);
  height: auto;
  left: 5px;
  line-height: normal;
  padding: 15px 23px 14px;
  text-decoration: none;
  top: 5px;
  width: auto;
  z-index: 100000;
}

/* Skip link */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--ep-space-4);
  z-index: 100000;
  padding: var(--ep-space-3) var(--ep-space-6);
  background-color: var(--ep-accent);
  color: var(--ep-text-inverse);
  font-weight: var(--ep-weight-semibold);
  border-radius: 0 0 var(--ep-radius-md) var(--ep-radius-md);
  transition: top var(--ep-transition-fast);
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--ep-text-inverse);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   6. Responsive Breakpoint Reference
   --------------------------------------------------------------------------
   Mobile:      < 640px
   Tablet:      640px – 1024px
   Desktop:     1024px – 1400px
   Wide:        > 1400px
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  :root {
    --ep-header-height: 60px;
    --ep-container-pad: 1rem;
  }

  .ep-section {
    padding-block: var(--ep-space-10);
  }

  .ep-section--sm {
    padding-block: var(--ep-space-6);
  }
}

/* --------------------------------------------------------------------------
   7. Back to Top Button
   -------------------------------------------------------------------------- */

.ep-back-to-top {
  position: fixed;
  bottom: var(--ep-space-6);
  right: var(--ep-space-6);
  z-index: var(--ep-z-sticky);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background-color: var(--ep-bg-card);
  border: 1px solid var(--ep-border-light);
  border-radius: var(--ep-radius-full);
  box-shadow: var(--ep-shadow-lg);
  color: var(--ep-text-secondary);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: all var(--ep-transition-base);
}

.ep-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ep-back-to-top:hover {
  background-color: var(--ep-accent);
  color: var(--ep-text-inverse);
  border-color: var(--ep-accent);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   8. Search Suggestions Dropdown
   -------------------------------------------------------------------------- */

.ep-search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--ep-bg-card);
  border: 1px solid var(--ep-border-light);
  border-radius: var(--ep-radius-md);
  box-shadow: var(--ep-shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: var(--ep-z-dropdown);
  margin-top: var(--ep-space-2);
}

.ep-search-suggestions.is-active {
  display: block;
}

.ep-search-suggestion {
  display: flex;
  align-items: center;
  gap: var(--ep-space-3);
  padding: var(--ep-space-3) var(--ep-space-4);
  transition: background-color var(--ep-transition-fast);
}

.ep-search-suggestion:hover,
.ep-search-suggestion.is-highlighted {
  background-color: var(--ep-bg-secondary);
}

.ep-search-suggestion__thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--ep-radius-sm);
  overflow: hidden;
}

.ep-search-suggestion__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ep-search-suggestion__title {
  font-size: var(--ep-text-sm);
  font-weight: var(--ep-weight-semibold);
  color: var(--ep-text-primary);
}

.ep-search-suggestion__category {
  font-size: var(--ep-text-xs);
  color: var(--ep-text-tertiary);
  margin-top: var(--ep-space-1);
}

/* --------------------------------------------------------------------------
   9. Numbered (Trending) Item
   -------------------------------------------------------------------------- */

.ep-numbered-item {
  display: flex;
  align-items: flex-start;
  gap: var(--ep-space-5);
  padding-bottom: var(--ep-space-6);
  border-bottom: 1px solid var(--ep-border-light);
}

.ep-numbered-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ep-numbered-item__rank {
  font-family: var(--ep-font-heading);
  font-size: var(--ep-text-4xl);
  font-weight: var(--ep-weight-extrabold);
  color: var(--ep-accent-light);
  line-height: 1;
  flex-shrink: 0;
  min-width: 48px;
}

/* --------------------------------------------------------------------------
   10. Compact Card (list item variant)
   -------------------------------------------------------------------------- */

.ep-card--compact {
  display: flex;
  gap: var(--ep-space-4);
  padding-bottom: var(--ep-space-4);
  border-bottom: 1px solid var(--ep-border-light);
}

.ep-card--compact:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ep-card--compact .ep-card__image {
  width: 88px;
  height: 68px;
  flex-shrink: 0;
  border-radius: var(--ep-radius-sm);
  overflow: hidden;
}

.ep-card--compact .ep-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ep-card--compact .ep-card__title {
  font-size: var(--ep-text-sm);
  font-weight: var(--ep-weight-semibold);
  line-height: var(--ep-leading-snug);
  margin: 0;
}

.ep-card--compact .ep-card__title a {
  color: var(--ep-text-primary);
}

.ep-card--compact .ep-card__title a:hover {
  color: var(--ep-accent);
}

.ep-card--compact .ep-card__meta {
  margin-top: var(--ep-space-2);
}

/* --------------------------------------------------------------------------
   11. Bookmark Toggle
   -------------------------------------------------------------------------- */

.ep-bookmark {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ep-space-1);
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--ep-text-tertiary);
  cursor: pointer;
  transition: color var(--ep-transition-fast);
}

.ep-bookmark:hover {
  color: var(--ep-accent);
}

.ep-bookmark__icon--filled { display: none; }
.ep-bookmark.is-saved .ep-bookmark__icon--outline { display: none; }
.ep-bookmark.is-saved .ep-bookmark__icon--filled { display: block; color: var(--ep-accent); }

/* --------------------------------------------------------------------------
   12. Avatar
   -------------------------------------------------------------------------- */

.ep-avatar {
  border-radius: var(--ep-radius-full);
  overflow: hidden;
  flex-shrink: 0;
}

.ep-avatar img {
  border-radius: var(--ep-radius-full);
  width: 40px;
  height: 40px;
  object-fit: cover;
}

.ep-avatar--sm img {
  width: 28px;
  height: 28px;
}

.ep-avatar--xl img {
  width: 80px;
  height: 80px;
}

/* --------------------------------------------------------------------------
   13. Search Form (inline variant)
   -------------------------------------------------------------------------- */

.ep-search-form {
  position: relative;
  display: flex;
  align-items: center;
}

.ep-search-form__icon {
  position: absolute;
  left: var(--ep-space-4);
  display: flex;
  color: var(--ep-text-tertiary);
  pointer-events: none;
}

.ep-search-form .ep-input {
  padding-left: var(--ep-space-12);
}

/* --------------------------------------------------------------------------
   14. Content Visibility (LCP/INP performance)
   -------------------------------------------------------------------------- */

.ep-cv-auto {
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}
