/* ===== Base ===== */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-manrope { font-family: 'Manrope', system-ui, sans-serif; }

html { scroll-behavior: smooth; }

/* ===== RTL Support ===== */
html[dir="rtl"] { direction: rtl; text-align: right; }
html[dir="rtl"] .pl-12 { padding-left: 1.25rem; padding-right: 3rem; }
html[dir="rtl"] .left-4 { left: auto; right: 1rem; }
html[dir="rtl"] .source-arrow { transform: scaleX(-1); }
html[dir="rtl"] .sr-only:focus { left: auto; right: 0.5rem; }

/* ===== Ghost Border Utility ===== */
.ghost-border {
  border: 1px solid rgba(196, 203, 209, 0.15);
}

/* ===== Glass Card Utility ===== */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(196, 203, 209, 0.1);
}

/* ===== Navbar ===== */
.nav-link {
  position: relative;
  padding-bottom: 2px;
}
.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #4059aa;
  border-radius: 1px;
}
html[dir="rtl"] .nav-link-active::after {
  left: 0;
  right: 0;
}

/* ===== Language Switcher ===== */
.lang-btn {
  transition: all 0.2s ease;
  background: transparent;
  color: #5f6b72;
  cursor: pointer;
  border: none;
}
.lang-btn:hover {
  color: #2a3439;
}
.lang-btn.active {
  background: #1e3a8a;
  color: white;
  border-radius: 9999px;
}

/* ===== Risk Filter Pills ===== */
.risk-btn {
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 7px 16px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  color: #5f6b72;
  border: 1px solid rgba(196, 203, 209, 0.25);
}
.risk-btn:hover {
  color: #2a3439;
  border-color: rgba(196, 203, 209, 0.5);
}
.risk-btn.active {
  background: #1e3a8a;
  color: white;
  border-color: #1e3a8a;
}
.risk-btn-high.active {
  background: #9e3f4e;
  border-color: #9e3f4e;
  color: white;
}
.risk-btn-medium.active {
  background: #4059aa;
  border-color: #4059aa;
  color: white;
}
.risk-btn-low.active {
  background: #5a6abf;
  border-color: #5a6abf;
  color: white;
}

/* ===== Category Pills ===== */
.cat-pill {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: transparent;
  color: #5f6b72;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.cat-pill:hover {
  color: #2a3439;
  background: rgba(64, 89, 170, 0.04);
}
.cat-pill.active {
  background: #d5e3fc;
  color: #1e3a8a;
  font-weight: 600;
}

/* ===== Brand Card ===== */
.brand-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  border: 1px solid rgba(196, 203, 209, 0.08);
}
.brand-card:hover {
  box-shadow: 0 4px 20px rgba(42, 52, 57, 0.06), 0 1px 4px rgba(42, 52, 57, 0.03);
  transform: translateY(-1px);
}
.brand-card:hover .brand-card-title {
  color: #4059aa;
}

/* ===== Brand Logo Container ===== */
.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 12px;
  background: #f1f5f9;
  padding: 8px;
  flex-shrink: 0;
  border: 1px solid #f8fafc;
  image-rendering: -webkit-optimize-contrast;
}

/* ===== Risk Badges ===== */
.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}
.risk-high {
  background: #fce8ec;
  color: #9e3f4e;
}
.risk-medium {
  background: #d5e3fc;
  color: #4059aa;
}
.risk-low {
  background: #dce1ff;
  color: #5a6abf;
}

/* ===== Source Link Arrow ===== */
.source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: gap 0.2s ease;
}
.source-link:hover {
  gap: 8px;
}
.source-link .source-arrow {
  transition: transform 0.2s ease;
}
.source-link:hover .source-arrow {
  transform: translateX(2px);
}
html[dir="rtl"] .source-link:hover .source-arrow {
  transform: translateX(-2px) scaleX(-1);
}

/* ===== Scrollbar Hide ===== */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, #f0f4f7 25%, #e8ecf0 50%, #f0f4f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite ease-in-out;
  border-radius: 16px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Scroll to Top ===== */
#scroll-top {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}
#scroll-top:hover {
  transform: translateY(-2px);
}

/* ===== Print Styles ===== */
@media print {
  nav, footer, #scroll-top, .risk-btn, .cat-pill, section.sticky,
  section:has(.rounded-3xl) {
    display: none !important;
  }
  .brand-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #e5e7eb !important;
  }
  body {
    background: white !important;
  }
  main {
    padding: 0 !important;
  }
}

/* ===== Focus Visible Styles (WCAG 2.1 AA) ===== */
*:focus-visible {
  outline: 2px solid #4059aa;
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #4059aa;
  outline-offset: 2px;
}

.lang-btn:focus-visible {
  outline: 2px solid #1e3a8a;
  outline-offset: -1px;
  border-radius: 9999px;
}

.risk-btn:focus-visible,
.cat-pill:focus-visible {
  outline: 2px solid #1e3a8a;
  outline-offset: 2px;
}

#scroll-top:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ===== Improved Contrast: risk-low badge ===== */
.risk-low {
  background: #dce1ff;
  color: #3d4a99;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 640px) {
  .brand-card {
    padding: 24px;
    min-height: 220px;
  }
  .brand-logo {
    width: 48px;
    height: 48px;
  }
}
