:root {
  --bg: #F7F4EE;
  --bg-elevated: #FFFDF9;
  --bg-subtle: #EFEAE0;
  --bg-glass: rgba(255, 253, 249, 0.86);
  --ink: #14171F;
  --ink-secondary: #4B5161;
  --ink-muted: #767C8B;
  --border: rgba(20, 23, 31, 0.09);
  --border-strong: rgba(20, 23, 31, 0.16);

  --accent: #C85A3F;
  --accent-hover: #B24B32;
  --accent-soft: rgba(200, 90, 63, 0.11);
  --slate: #14171F;

  --marker-free: #1F9D68;
  --marker-famous: #D48C17;
  --marker-festival: #C85A3F;
  --marker-business: #2E6FD9;
  --marker-culture: #7C4DCC;

  --badge-free-bg: rgba(31, 157, 104, 0.12);
  --badge-free-ink: #126E47;
  --badge-price-bg: rgba(20, 23, 31, 0.07);
  --badge-price-ink: #272C38;
  --badge-famous-bg: rgba(212, 140, 23, 0.14);
  --badge-famous-ink: #8E5B08;
  --badge-hot-bg: rgba(200, 90, 63, 0.13);
  --badge-hot-ink: #A03D25;
  --badge-new-bg: rgba(46, 111, 217, 0.12);
  --badge-new-ink: #1F54AD;

  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 23, 31, 0.06), 0 1px 3px rgba(20, 23, 31, 0.04);
  --shadow-lg: 0 14px 36px rgba(20, 23, 31, 0.10);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font-sans: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #101319;
  --bg-elevated: #171B24;
  --bg-subtle: #1E2430;
  --bg-glass: rgba(23, 27, 36, 0.86);
  --ink: #F3EFE8;
  --ink-secondary: #B9BECA;
  --ink-muted: #848B9B;
  --border: rgba(243, 239, 232, 0.09);
  --border-strong: rgba(243, 239, 232, 0.18);

  --accent: #E07054;
  --accent-hover: #EA8267;
  --accent-soft: rgba(224, 112, 84, 0.16);
  --slate: #F3EFE8;

  --badge-free-bg: rgba(44, 198, 132, 0.16);
  --badge-free-ink: #6BE2AC;
  --badge-price-bg: rgba(243, 239, 232, 0.09);
  --badge-price-ink: #DDE1EA;
  --badge-famous-bg: rgba(242, 179, 64, 0.18);
  --badge-famous-ink: #F7CB73;
  --badge-hot-bg: rgba(224, 112, 84, 0.18);
  --badge-hot-ink: #F59E88;
  --badge-new-bg: rgba(86, 148, 250, 0.18);
  --badge-new-ink: #93BDFF;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 88% -8%, var(--accent-soft), transparent 62%),
    var(--bg);
  line-height: 1.65;
  font-size: 15px;
}

button, input, a {
  font-family: inherit;
  color: inherit;
}

.num-tabular {
  font-variant-numeric: tabular-nums;
}

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* Header */
.site-header {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 22px;
}

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

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), #9E3E28);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(200, 90, 63, 0.26);
  flex-shrink: 0;
}

.brand-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFFDF9;
  box-shadow: 0 0 0 4px rgba(255, 253, 249, 0.28);
}

.site-title {
  margin: 0;
  font-size: clamp(1.22rem, 2.2vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.title-sep {
  color: var(--ink-muted);
  font-weight: 400;
}

.title-en {
  font-size: 0.78em;
  font-weight: 600;
  color: var(--ink-secondary);
}

.site-subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--marker-free);
  box-shadow: 0 0 0 3px rgba(31, 157, 104, 0.2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.btn:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #FFFDF9;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: transparent;
}

.btn-telegram {
  background: var(--slate);
  color: var(--bg-elevated);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.btn-telegram:hover {
  opacity: 0.92;
}

.handle-en {
  font-size: 0.78rem;
  opacity: 0.78;
  font-weight: 500;
}

.btn-subtle {
  background: var(--bg-subtle);
  border-color: transparent;
  color: var(--ink-secondary);
}

.btn-subtle:hover {
  color: var(--ink);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: 9px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1rem;
}

html[data-theme="light"] .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  appearance: none;
  text-align: right;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.kpi-free .kpi-value { color: var(--marker-free); }
.kpi-new .kpi-value { color: var(--marker-business); }
.kpi-famous .kpi-value { color: var(--marker-famous); }

.kpi-meta {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* Controls Panel */
.controls-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.primary-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.primary-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.tab-btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

.tab-btn.is-active {
  background: var(--slate);
  color: var(--bg-elevated);
  border-color: transparent;
}

.tab-count {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.tab-btn.is-active .tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
}

html[data-theme="dark"] .tab-btn.is-active .tab-count {
  background: rgba(16, 19, 25, 0.22);
}

.secondary-filters {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

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

.search-icon {
  position: absolute;
  right: 13px;
  color: var(--ink-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
  position: absolute;
  left: 10px;
  border: none;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  display: grid;
  place-items: center;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group-wide {
  width: 100%;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
}

.pill-btn:hover {
  color: var(--ink);
  background: var(--bg-subtle);
}

.pill-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

/* Map Section */
.map-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 26px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
}

.map-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ink);
}

.map-counter,
.results-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  padding: 3px 10px;
  border-radius: 999px;
}

.map-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot-free { background: var(--marker-free); }
.dot-famous { background: var(--marker-famous); }
.dot-festival { background: var(--marker-festival); }
.dot-business { background: var(--marker-business); }
.dot-culture { background: var(--marker-culture); }

.map-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-only { display: none; }

.map-container-wrap {
  height: 410px;
  transition: height 240ms ease, opacity 200ms ease;
  overflow: hidden;
}

.map-container-wrap.is-collapsed {
  height: 0;
  opacity: 0;
}

#yerevan-map {
  width: 100%;
  height: 410px;
  z-index: 1;
}

/* Custom Leaflet Markers & RTL Popups */
.event-pin-wrapper {
  background: transparent;
  border: none;
}

.event-pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2.5px solid #FFFDF9;
  box-shadow: 0 4px 12px rgba(20, 23, 31, 0.32);
  display: grid;
  place-items: center;
  transition: transform 160ms ease;
}

.event-pin::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFFDF9;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  direction: rtl;
  text-align: right;
}

.leaflet-popup-tip {
  background: var(--bg-elevated);
}

.leaflet-popup-content {
  margin: 12px 14px;
  min-width: 225px;
  max-width: 280px;
}

.popup-title {
  margin: 0 0 6px;
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--ink);
}

.popup-meta {
  font-size: 0.79rem;
  color: var(--ink-secondary);
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 9px;
}

.popup-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.popup-link {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--ink);
  border: 1px solid var(--border);
}

.popup-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Events Section & Grid */
.events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.results-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.event-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.event-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.event-card.is-highlighted {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  line-height: 1.4;
}

.badge-free { background: var(--badge-free-bg); color: var(--badge-free-ink); }
.badge-price { background: var(--badge-price-bg); color: var(--badge-price-ink); }
.badge-famous { background: var(--badge-famous-bg); color: var(--badge-famous-ink); }
.badge-hot { background: var(--badge-hot-bg); color: var(--badge-hot-ink); }
.badge-new { background: var(--badge-new-bg); color: var(--badge-new-ink); }
.badge-schedule {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-muted);
  font-weight: 600;
  margin-right: auto;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 800;
  line-height: 1.45;
  color: var(--ink);
}

.card-title-en {
  margin: 0;
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--ink-muted);
  direction: ltr;
  text-align: right;
  unicode-bidi: plaintext;
}

.card-datetime {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bg-subtle);
  font-size: 0.82rem;
}

.datetime-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  color: var(--ink);
}

.days-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.card-location {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.83rem;
  color: var(--ink-secondary);
  padding-right: 10px;
  border-right: 2px solid var(--accent-soft);
}

.loc-venue {
  font-weight: 700;
  color: var(--ink);
}

.loc-street {
  font-weight: 600;
  color: var(--ink-secondary);
}

.loc-address {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.card-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-secondary);
  line-height: 1.65;
}

.card-tip {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.79rem;
  line-height: 1.55;
}

.card-actions {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--ink);
  font-size: 0.77rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 140ms ease;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-elevated);
}

.action-map-focus {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent-soft);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-icon { font-size: 2.2rem; margin-bottom: 8px; }
.empty-state h3 { margin: 0 0 6px; font-size: 1.05rem; }
.empty-state p { margin: 0 0 16px; color: var(--ink-secondary); font-size: 0.88rem; }

.site-footer {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.site-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }

@media (max-width: 1060px) {
  .events-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { padding: 16px 14px 36px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .events-grid { grid-template-columns: 1fr; }
  .mobile-only { display: inline-flex; }
  .map-container-wrap, #yerevan-map { height: 320px; }
  .map-legend { order: 3; width: 100%; }
  .handle-en { display: none; }
}
