/* ==========================================================================
   TRENDWRITES - GLOBAL DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS CUSTOM PROPERTIES & THEMING
   -------------------------------------------------------------------------- */
:root {
  /* Brand Palette */
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #0f172a;
  --teal: #0d9488;
  --purple: #7c3aed;
  --amber: #d97706;
  --rose: #e11d48;

  /* Neutral Light Theme */
  --bg-body: #ffffff;
  --bg-surface: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);

  /* Layout & Geometry */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --container-max: 1320px;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-body: #090d16;
  --bg-surface: #0f172a;
  --bg-card: #131c2e;
  --bg-subtle: #1e293b;
  --border: #1e293b;
  --border-strong: #334155;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --text-inverse: #0f172a;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);

  --primary-light: rgba(30, 64, 175, 0.2);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

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

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

ul, ol {
  list-style: none;
}

/* Focus styles for keyboard accessibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  z-index: 10000;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY & BADGES
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -0.015em; }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }

p {
  margin-bottom: 0.75rem;
}
p:last-child {
  margin-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-teal { background-color: rgba(13, 148, 136, 0.12); color: var(--teal); }
.badge-purple { background-color: rgba(124, 58, 237, 0.12); color: var(--purple); }
.badge-amber { background-color: rgba(217, 119, 6, 0.12); color: var(--amber); }
.badge-rose { background-color: rgba(225, 29, 72, 0.12); color: var(--rose); }

/* Meta details */
.meta-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.meta-info span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--text-light);
}

/* --------------------------------------------------------------------------
   4. ANNOUNCEMENT BAR & HEADER & STICKY NAV
   -------------------------------------------------------------------------- */
.top-bar {
  background-color: var(--accent);
  color: #f8fafc;
  padding: 0.5rem 0;
  font-size: 0.825rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.top-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-trending-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.top-trending-tag .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.top-nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.top-nav-links a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Header Navbar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg-body);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition-normal), background-color var(--transition-normal);
}
.site-header.scrolled {
  box-shadow: var(--shadow-md);
  background-color: rgba(var(--bg-body-rgb, 255, 255, 255), 0.95);
  backdrop-filter: blur(10px);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
}
.brand-logo svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}
.brand-logo span {
  color: var(--primary);
}

/* Main Navigation */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-link {
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  font-size: 0.935rem;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background-color: var(--bg-subtle);
}

/* Mega Menu Item */
.has-mega-menu {
  position: relative;
}
.mega-menu {
  position: absolute;
  top: 100%;
  left: -200px;
  width: 850px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr) 250px;
  gap: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1100;
}
.has-mega-menu:hover .mega-menu,
.has-mega-menu:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.mega-col-title {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--primary-light);
}
.mega-list li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.mega-list li a:hover {
  color: var(--primary);
  transform: translateX(4px);
}

.mega-featured-card {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.mega-featured-card img {
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}
.mega-featured-card h5 {
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  background-color: var(--bg-subtle);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover {
  background-color: var(--border);
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}
.btn-outline {
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
}

/* Mobile Toggle */
.mobile-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   5. SEARCH OVERLAY MODAL
   -------------------------------------------------------------------------- */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: rgba(9, 13, 22, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.search-modal.active {
  opacity: 1;
  pointer-events: auto;
}
.search-modal-content {
  width: 90%;
  max-width: 680px;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform 0.25s ease;
}
.search-modal.active .search-modal-content {
  transform: translateY(0);
}

.search-modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.search-modal-header svg {
  color: var(--text-muted);
  margin-right: 0.75rem;
}
.search-modal-input {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-main);
}
.search-modal-close {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.search-modal-body {
  padding: 1.25rem;
  max-height: 420px;
  overflow-y: auto;
}
.search-suggestions-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.search-result-item:hover {
  background: var(--bg-subtle);
}
.search-result-item h5 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

/* --------------------------------------------------------------------------
   6. REUSABLE CARD COMPONENTS
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-img-wrapper {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background-color: var(--bg-subtle);
}
.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.card:hover .card-img-wrapper img {
  transform: scale(1.05);
}

.card-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  line-height: 1.35;
}
.card-title a:hover {
  color: var(--primary);
}

.card-excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.author-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.author-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Horizontal Card */
.card-horizontal {
  flex-direction: row;
  align-items: center;
}
.card-horizontal .card-img-wrapper {
  width: 38%;
  aspect-ratio: 4 / 3;
  flex-shrink: 0;
}

/* Small Sidebar Card */
.card-sidebar {
  display: flex;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
.card-sidebar:hover {
  transform: none;
}
.card-sidebar .card-img-wrapper {
  width: 90px;
  height: 70px;
  aspect-ratio: auto;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.card-sidebar h4 {
  font-size: 0.925rem;
  line-height: 1.3;
}

/* Trending Card with Numbering */
.trending-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.trending-number {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  opacity: 0.4;
  min-width: 40px;
}
.trending-item h4 {
  font-size: 0.975rem;
  line-height: 1.35;
}

/* Video & Webinar Card Badge overlays */
.card-badge-overlay {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
}
.play-btn-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 23, 42, 0.35);
  transition: background-color 0.25s ease;
}
.play-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s ease;
}
.card:hover .play-icon {
  transform: scale(1.15);
}

/* --------------------------------------------------------------------------
   7. SIDEBAR WIDGETS
   -------------------------------------------------------------------------- */
.widget {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.75rem;
}
.widget-title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.widget-newsletter {
  background: linear-gradient(135deg, var(--accent) 0%, #1e293b 100%);
  color: #ffffff;
  border: none;
}
.widget-newsletter .widget-title {
  color: #ffffff;
  border-bottom-color: var(--primary);
}
.widget-newsletter p {
  color: #94a3b8;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.newsletter-form-inline {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.newsletter-form-inline input {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.newsletter-form-inline input::placeholder {
  color: #94a3b8;
}
.newsletter-form-inline input:focus {
  border-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.15);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-item {
  padding: 0.35rem 0.75rem;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}
.tag-item:hover {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.ad-placeholder {
  background-color: var(--bg-subtle);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   8. FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--accent);
  color: #94a3b8;
  padding-top: 4rem;
  padding-bottom: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .site-footer {
  background-color: #05080e;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 2.5rem;
  margin-bottom: 3rem;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.footer-logo {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.footer-logo span {
  color: var(--primary);
}
.footer-brand-desc {
  font-size: 0.875rem;
  line-height: 1.6;
  color: #94a3b8;
}

.footer-col-title {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links li {
  margin-bottom: 0.65rem;
}
.footer-links a {
  color: #94a3b8;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}
.footer-links a:hover {
  color: #ffffff;
  padding-left: 4px;
}

.social-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.social-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: background 0.2s ease, transform 0.2s ease;
}
.social-icon:hover {
  background: var(--primary);
  transform: translateY(-2px);
}

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #64748b;
}

/* Scroll To Top */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 900;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.25s ease;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
