/* ===== Base styles ===== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1419;
  --card-bg: #1a1f2e;
  --card-hover: #222938;
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: rgba(0, 0, 0, 0.3);
  --gradient-from: #1e3a8a;
  --gradient-to: #4c1d95;
  --container: 1280px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --card-bg: #ffffff;
    --card-hover: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --shadow: rgba(0, 0, 0, 0.1);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  scroll-behavior: smooth;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.main-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 32px;
}

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

.brand .logo {
  width: 104px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
}

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

.brand-title {
  font-weight: 800;
  font-size: 18px;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.desktop-nav {
  display: flex;
  gap: 32px;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.desktop-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
}

.desktop-nav a:hover {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.1);
}

.desktop-nav a.active {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

#eli-nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 24px;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .desktop-nav {
    display: none;
  }
  
  #eli-nav-toggle {
    display: flex;
  }
}

/* ===== Hero Section ===== */
.hero {
  background: linear-gradient(135deg, var(--gradient-from) 0%, var(--gradient-to) 100%);
  padding: 80px 0;
  text-align: center;
  position: relative;
  overflow: visible;
  z-index: 10;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

.hero-title {
  font-size: 48px;
  font-weight: 800;
  margin: 0 0 16px;
  color: white;
  position: relative;
  z-index: 1;
}

.hero-subtitle {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 32px;
  position: relative;
  z-index: 1;
}

.search-box {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  background: white;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  padding: 12px 16px;
  background: transparent;
  color: #1e293b;
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-box input::placeholder {
  color: #94a3b8;
}

.search-box button {
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-box button:hover {
  transform: scale(1.05);
}

.search-icon {
  width: 24px;
  height: 24px;
  /* Removed filter: invert(1) to keep icon black as requested */
  transition: transform 0.2s;
}

/* Autocomplete Suggestions */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: 12px;
  margin-top: 8px;
  padding: 0;
  list-style: none;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  text-align: right;
  display: none;
}

.search-suggestions:not([hidden]) {
  display: block;
}

.search-suggestions li {
  padding: 12px 16px;
  cursor: pointer;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  transition: background 0.2s;
}

.search-suggestions li:last-child {
  border-bottom: none;
}

.search-suggestions li:hover {
  background: #f8fafc;
  color: var(--accent);
}

@media (max-width: 768px) {
  .hero {
    padding: 60px 0;
  }
  
  .hero-title {
    font-size: 32px;
  }
  
  .hero-subtitle {
    font-size: 16px;
  }
}

/* ===== Main Content ===== */
.main-content {
  padding: 60px 0;
  min-height: 60vh;
}

.content-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none;
  }
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 100px;
  align-self: start;
}

.sidebar-section {
  margin-bottom: 32px;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: block;
}

.sidebar-link:hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
  font-weight: 600;
}

/* ===== Content Area ===== */
.content-area {
  flex: 1;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

.filter-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== Cards Grid ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

.doc-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  opacity: 1;
  transform: scale(1);
}

.doc-card.hidden {
  display: none;
}

.doc-card.fade-out {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

.doc-card:hover {
  background: var(--card-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 24px var(--shadow);
  border-color: var(--accent);
}

.doc-card.expanded {
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: 0 12px 24px var(--shadow);
  transform: none;
}

.card-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  z-index: 10;
}

.card-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.card-description {
  color: var(--text-secondary);
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.6;
}

.card-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.meta-item {
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.card-link:hover {
  gap: 8px;
}

/* Expanded Content */
.card-expanded-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in-out;
  border-top: 1px solid var(--border);
  margin-top: 0;
}

.doc-card.expanded .card-expanded-content {
  max-height: 500px;
  opacity: 1;
  margin-top: 16px;
  padding-top: 16px;
}

.full-article-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.full-article-btn:hover {
  background: var(--accent-hover);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 60px 0 24px;
  margin-top: 80px;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text-primary);
}

.footer-section p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 14px;
}

/* Footer Links Animation Implementation - Fixed Layout */
.footer-section a {
  display: block; /* Ensures vertical list layout is maintained */
  width: fit-content; /* Ensures underline only matches text width, not full block */
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 8px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  transition: color 0.3s ease;
}

.footer-section a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 1px;
  bottom: -2px;
  right: 0; /* Anchors to right for RTL expansion */
  background-color: #FFF;
  transition: width 0.3s ease;
}

.footer-section a:hover {
  color: #FFF;
}

.footer-section a:hover::after {
  width: 100%; /* Expands to the left */
}

.footer-bottom {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  margin: 0 0 16px;
  font-size: 24px;
  color: var(--text-primary);
}

.modal-content h3 {
  margin: 16px 0 8px;
  font-size: 18px;
  color: var(--text-primary);
}

.modal-content p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--card-bg);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--card-hover);
  transform: scale(1.1);
}

.privacy-content {
  max-height: 60vh;
  overflow-y: auto;
}

.privacy-checkbox-wrapper {
  margin: 24px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.privacy-checkbox-wrapper input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.privacy-checkbox-wrapper label {
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
}

.privacy-confirm {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.privacy-confirm:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.privacy-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Cookie Banner ===== */
.cookie-banner {
  position: fixed;
  bottom: -300px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 600px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  transition: bottom 0.4s ease;
}

.cookie-banner.show {
  bottom: 20px;
}

.cookie-content h3 {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--text-primary);
}

.cookie-content p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}

.cookie-options {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cookie-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.cookie-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.cookie-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.cookie-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cookie-btn-accept {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.cookie-btn-accept:hover {
  background: var(--card-hover);
}

.cookie-btn-accept-all {
  background: var(--accent);
  color: white;
}

.cookie-btn-accept-all:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

@media (max-width: 600px) {
  .cookie-banner {
    width: calc(100% - 20px);
  }
  
  .cookie-buttons {
    flex-direction: column;
  }
}

/* ===== Drawer & Overlay ===== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 998;
  display: none;
}

body.drawer-open .drawer-overlay {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  width: min(86vw, 360px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-inline-start: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 999;
  display: none;
  flex-direction: column;
}

body.drawer-open .drawer {
  transform: translateX(0);
  display: flex;
}

.drawer-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  height: 64px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px;
}

.drawer-brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.drawer-close {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 40px;
  height: 40px;
  font-size: 24px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.drawer-close:hover {
  background: var(--card-bg);
}

.menu {
  padding: 16px 0;
  overflow: auto;
}

.menu-section {
  border-bottom: 1px solid var(--border);
}

.menu-toggle {
  width: 100%;
  text-align: inherit;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: 700;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 15px;
}

.menu-toggle .chev {
  transition: transform 0.25s ease;
}

.menu-toggle[aria-expanded="true"] .chev {
  transform: rotate(-90deg);
}

.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.submenu a {
  display: block;
  padding: 12px 24px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.2s;
}

.submenu a:hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

/* ===== A11Y Widget ===== */
#a11y-button {
  position: fixed;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border: none;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 9998;
  transition: all 0.3s;
}

#a11y-button:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

#a11y-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#a11y-panel {
  position: fixed;
  top: 50%;
  left: 88px;
  transform: translateY(-50%);
  width: min(92vw, 380px);
  max-height: calc(100vh - 80px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  padding: 16px;
  z-index: 9999;
  display: none;
  overflow: auto;
}

#a11y-panel[aria-hidden="false"] {
  display: block;
}

.a11y-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.a11y-close:hover {
  background: var(--card-bg);
}

.a11y-panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.a11y-panel__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.a11y-panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.a11y-btn {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  min-height: 40px;
}

.a11y-btn:hover {
  background: var(--card-hover);
  border-color: var(--accent);
}

.a11y-btn[aria-pressed="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.a11y-small {
  padding: 6px 12px;
  min-height: 36px;
}

.a11y-panel__row[data-tts-row] .a11y-panel__actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
}

/* High-contrast mode */
.a11y-contrast {
  background: #000 !important;
  color: #fff !important;
}

.a11y-underline-links a {
  text-decoration: underline !important;
}

.a11y-readable-font * {
  font-family: "Atkinson Hyperlegible", "Assistant", Arial, sans-serif !important;
}

html.a11y-zoom-1 {
  font-size: 110%;
}
html.a11y-zoom-2 {
  font-size: 120%;
}
html.a11y-zoom-3 {
  font-size: 135%;
}
html.a11y-zoom-4 {
  font-size: 150%;
}

.a11y-reduced-motion * {
  animation: none !important;
  transition: none !important;
}

/* TTS Bar */
#a11y-tts-bar {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 12px;
  display: none;
  gap: 8px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

#a11y-tts-bar[aria-hidden="false"] {
  display: flex;
}

#a11y-tts-bar button {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

#a11y-tts-bar button:hover {
  background: var(--card-hover);
  border-color: var(--accent);
}

.a11y-read-hover {
  outline: 3px solid var(--accent) !important;
  outline-offset: 2px !important;
}

@media (max-width: 600px) {
  #a11y-button {
    width: 48px;
    height: 48px;
    left: 8px;
  }
  
  #a11y-panel {
    top: auto;
    bottom: 80px;
    left: 8px;
    transform: none;
    width: calc(100% - 16px);
  }
  
  #a11y-tts-bar {
    right: 8px;
    bottom: 8px;
    flex-wrap: wrap;
  }
  
  .a11y-panel__row[data-tts-row] .a11y-panel__actions {
    grid-template-columns: 1fr;
  }
}
