/* InjusticeToAll.org - Shared Styles */

/* ==========================================================================
   BASE STYLES
   ========================================================================== */

/* Enhanced mobile-first card interactions */
.card-hover {
  transition: all 0.3s ease;
  transform: translateZ(0);
  -webkit-tap-highlight-color: transparent;
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Mobile touch optimizations */
.touch-manipulation {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Mobile active states */
@media (hover: none) {
  .card-hover:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
  
  .btn-primary:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* ==========================================================================
   SCROLLING & CONTAINERS
   ========================================================================== */

/* Improved mobile scrolling */
.scroll-container {
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ==========================================================================
   WORLD MAP STYLES (v2.1)
   ========================================================================== */

/* ---- Design Tokens ---- */
:root {
  --map-surface: #ffffff;
  --map-surface-2: #f7f7fb;
  --map-ink: #0b0b10;
  --map-muted: #6b7280;

  /* Brand accent (UI chrome) — tweak freely */
  --map-brand: #8B4513;           /* InjusticeToAll brand brown */
  --map-brand-contrast: #ffffff;

  --map-ring: color-mix(in oklab, var(--map-brand) 55%, black);
  --map-shadow: 0 10px 30px rgb(0 0 0 / 0.10);
  --map-radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --map-surface: #0e0f13;
    --map-surface-2: #151720;
    --map-ink: #e7e9ee;
    --map-muted: #a1a6b3;
    --map-brand: #B8804A;
    --map-ring: color-mix(in oklab, var(--map-brand) 45%, white);
    --map-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  }
}

/* ---- Background ---- */
.world-bg {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(153, 170, 255, .18), transparent 55%),
    radial-gradient(900px 500px at 100% 10%, rgba(255, 211, 153, .15), transparent 60%),
    var(--map-surface-2);
}

/* ---- Card Container (now a container for queries) ---- */
.map-card {
  background: var(--map-surface);
  border: 1px solid color-mix(in oklab, var(--map-surface) 85%, black);
  border-radius: var(--map-radius);
  box-shadow: var(--map-shadow);
  overflow: hidden;

  /* enable container queries on inline-size */
  container: map / inline-size;
}

.map-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid color-mix(in oklab, var(--map-surface) 85%, black);
  background: linear-gradient(180deg, color-mix(in oklab, var(--map-surface) 96%, black), var(--map-surface));
}

/* ---- Legend Chips ---- */
.legend {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: .5rem .75rem;
  align-items: center;
}
.legend__item {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .825rem;
  color: var(--map-muted);
  background: color-mix(in oklab, var(--map-surface) 88%, black);
  border: 1px solid color-mix(in oklab, var(--map-surface) 75%, black);
  border-radius: 999px;
  padding: .35rem .6rem;
}
.legend__swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.08);
}

/* ---- Map Stage ---- */
#world-map {
  position: relative;
  aspect-ratio: 16 / 8.5;
  width: 100%;
  background: linear-gradient(180deg, color-mix(in oklab, var(--map-surface) 97%, black), var(--map-surface));
}
#world-map svg { display: block; width: 100%; height: 100%; }

/* ---- Zoom Controls (brand-tinted) ---- */
.map-zoom {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 10px;
}
.zoom-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: color-mix(in oklab, var(--map-surface) 85%, var(--map-brand) 10%);
  border: 1px solid color-mix(in oklab, var(--map-surface) 70%, var(--map-brand) 20%);
  border-radius: 999px;
  box-shadow: var(--map-shadow);
  color: var(--map-ink);
  font-weight: 600;
  line-height: 1;
  transition: transform .15s ease, filter .2s ease;
  backdrop-filter: saturate(1.2) blur(6px);
}
.zoom-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.zoom-btn:active { transform: translateY(0); }

/* ---- Tooltip ---- */
#map-tooltip {
  position: absolute;
  z-index: 50;
  background: color-mix(in oklab, var(--map-surface) 15%, black);
  color: white;
  padding: .5rem .65rem;
  border-radius: 10px;
  font-size: .875rem;
  line-height: 1.1;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: none;
  transform: translateY(-4px);
  border: 1px solid rgba(255,255,255,.08);
}

/* ---- Loading ---- */
.map-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2.5rem 0;
  color: var(--map-muted);
}
.map-loading__retry {
  border: 1px solid color-mix(in oklab, var(--map-surface) 70%, var(--map-brand) 20%);
  border-radius: 6px;
  background: var(--map-surface);
  color: var(--map-ink);
  font-weight: 600;
  padding: .4rem .7rem;
}
.map-loading__retry:disabled { opacity: .65; }

/* ---- States ---- */
.country--active { filter: saturate(1.15); }
.country--active:hover { filter: saturate(1.3) brightness(1.02); }

/* ---- Container queries for narrow cards ---- */
@container map (max-width: 820px) {
  .map-card__header { align-items: start; flex-direction: column; gap: .5rem; }
  .legend { grid-auto-flow: row; grid-template-columns: repeat(2, max-content); }
}
@container map (max-width: 520px) {
  .legend { grid-template-columns: 1fr 1fr; }
}

/* ---- Safety for tiny screens ---- */
@media (max-width: 640px) {
  .map-zoom { top: auto; bottom: 12px; transform: none; }
}

.scroll-container::-webkit-scrollbar {
  display: none;
}

/* ==========================================================================
   TEXT UTILITIES
   ========================================================================== */

/* ==========================================================================
   WORLD MAP: COUNTRY PANEL
   ========================================================================== */

.country-panel {
  position: fixed;
  right: 20px;
  top: 88px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 74vh;
  background: var(--map-surface);
  border: 1px solid color-mix(in oklab, var(--map-surface) 80%, black);
  border-radius: 16px;
  box-shadow: var(--map-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  animation: panelIn .18s ease-out;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.country-panel__header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid color-mix(in oklab, var(--map-surface) 85%, black);
  background: linear-gradient(180deg, color-mix(in oklab, var(--map-surface) 96%, black), var(--map-surface));
}
.country-panel__header-main { display: grid; gap: .5rem; }

.country-panel__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--map-ink);
}

.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  font-size: .8rem;
  padding: .35rem .6rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--map-surface) 75%, black);
  background: color-mix(in oklab, var(--map-surface) 92%, var(--map-brand) 6%);
  color: var(--map-ink);
}
.chip--active {
  background: var(--map-brand);
  color: var(--map-brand-contrast);
  border-color: color-mix(in oklab, var(--map-brand) 85%, black);
}

.country-panel__close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--map-surface) 75%, black);
  background: color-mix(in oklab, var(--map-surface) 90%, var(--map-brand) 6%);
  color: var(--map-ink);
  font-size: 20px;
  line-height: 1;
}

.country-panel__body {
  overflow: auto;
  padding: .85rem 1rem 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: .85rem;
}

@media (min-width: 1024px) {
  .country-panel__body { grid-template-columns: 1fr; }
}

/* Mobile: use full-screen slide-over */
@media (max-width: 768px) {
  .country-panel {
    right: 12px; left: 12px; top: 84px; width: auto; height: calc(100vh - 100px);
  }
  .filter-chips { overflow-x: auto; white-space: nowrap; padding-bottom: .25rem; }
}

/* Country panel cards */
.country-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: .85rem;
  padding: .6rem;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.country-card__img {
  width: 112px; height: 72px; border-radius: 10px; object-fit: cover; background: #f2f2f2;
}
.country-card__title {
  font-weight: 700; color: #0f172a; font-size: .95rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.country-card__meta { font-size: .75rem; color: #64748b; margin-top: .25rem; }
.country-card__summary { font-size: .8rem; color: #334155; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: .35rem; }

.line-clamp-2 {
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  overflow: hidden;
}

.line-clamp-3 {
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  overflow: hidden;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

.loading-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

.spinner {
  animation: spin 1s linear infinite;
}

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

.fade-in {
  animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary {
  background-color: #8B4513;
  color: white;
}

.btn-primary:hover {
  background-color: #5D2F02;
}

/* ==========================================================================
   LAYOUT COMPONENTS
   ========================================================================== */

.category-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
}

/* ==========================================================================
   HERO BACKGROUNDS
   ========================================================================== */

.hero-bg {
  background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.4)),
    url('https://images.unsplash.com/photo-1589994965851-a8f479c573a9?w=1600&h=800&fit=crop');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* ==========================================================================
   ARTICLE SPECIFIC STYLES
   ========================================================================== */

.article-content {
  line-height: 1.8;
}

.back-btn {
  transition: all 0.3s ease;
}

.back-btn:hover {
  transform: translateX(-4px);
}

/* ==========================================================================
   MOBILE SPECIFIC IMPROVEMENTS
   ========================================================================== */

@media (max-width: 640px) {
  .hero-bg {
    background-attachment: scroll;
  }
  
  .min-h-screen {
    min-height: 100vh;
  }
}

/* Ongoing header pill */
.ongoing-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 9999px;
  background: #fde8e8;
  color: #991b1b;
  font-weight: 600;
  letter-spacing: .2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06) inset;
}
.ongoing-pill .count { margin-left: 6px; opacity: .85; }
