:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #0f1523;
  --bg-surface: #141b2b;
  --bg-surface-hover: #1a2338;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --accent-lime: #d4ff33;
  --accent-lime-hover: #ceff1a;
  --cat-nauka: #7ca1ff;
  --cat-kultura: #ffd166;
  --cat-sport: #5ce1a6;
  --cat-rozrywka: #ff7597;
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background-color: var(--bg-primary);
  color: #f8fafc;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Accessible visually-hidden utility */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Native <dialog> scroll containment and backdrop styling */
dialog:modal {
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-color: var(--bg-secondary);
  color: #f8fafc;
  border-radius: 1.25rem;
  padding: 0;
  max-width: min(92vw, 34rem);
  width: 100%;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
}

#place-detail-dialog:modal {
  max-width: min(94vw, 44rem);
  max-height: 90dvh;
  overflow-y: auto;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(6px);
}

/* Subtle custom scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

/* Hide scrollbars for compact strips */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Force light scheme on inherently light surfaces (map & official state plaque) */
.smk-light-surface {
  color-scheme: only light;
  background-color: #ffffff;
  color: #0b0f19;
}

.funding-plaque-frame {
  color-scheme: only light;
  background-color: #f1f3f5;
}

/* Leaflet map aesthetic matching the clean light map in the PDFs */
.smk-leaflet-container {
  color-scheme: only light;
  background: #e5eaee;
  color: #0b0f19;
  font-family: inherit;
}

.smk-leaflet-container .leaflet-tile-pane {
  filter: saturate(0.85) contrast(1.03) brightness(0.99);
}

/* Custom Leaflet Markers */
.smk-marker-wrapper {
  background: transparent;
  border: 0;
}

.smk-marker {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  border: 2.5px solid #0b0f19;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  color: #0b0f19;
  box-shadow: 0 6px 16px rgba(11, 15, 25, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
}

.smk-marker:hover,
.smk-marker.is-active {
  transform: scale(1.18);
  box-shadow: 0 0 0 4px rgba(212, 255, 51, 0.55), 0 10px 22px rgba(11, 15, 25, 0.45);
}

/* Custom Dark Leaflet Popup matching the PDF design */
.smk-popup .leaflet-popup-content-wrapper {
  color-scheme: only dark;
  background-color: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.9rem;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.65);
  padding: 0;
}

.smk-popup .leaflet-popup-content {
  margin: 0;
  min-width: 215px;
  max-width: 265px;
}

.smk-popup .leaflet-popup-tip {
  background-color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.smk-popup .leaflet-popup-close-button {
  color: #94a3b8;
  top: 8px;
  right: 10px;
  font-size: 18px;
  width: 24px;
  height: 24px;
}

.smk-popup .leaflet-popup-close-button:hover {
  color: #ffffff;
}

/* Leaflet Zoom controls matching PDF aesthetic */
.smk-leaflet-container .leaflet-bar {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.smk-leaflet-container .leaflet-bar a {
  background-color: #ffffff;
  color: #0b0f19;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  width: 34px;
  height: 34px;
  line-height: 34px;
  font-weight: 700;
}

.smk-leaflet-container .leaflet-bar a:hover {
  background-color: #f1f5f9;
}

.smk-leaflet-container .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.75);
  color: #475569;
  font-size: 10px;
}

/* Form controls & :user-invalid validation (admin.html) */
.smk-input,
.smk-select {
  font: inherit;
  font-size: max(1rem, 0.9375rem);
  min-height: 44px;
}

.smk-error-msg {
  display: none;
  color: #fda4af;
  font-size: 0.8125rem;
  margin-top: 0.35rem;
  align-items: center;
  gap: 0.35rem;
}

:is(.smk-input, .smk-select):is(:user-invalid, .user-invalid-fallback) {
  border-color: #fb7185 !important;
  background-color: rgba(251, 113, 133, 0.08) !important;
}

:is(.smk-input, .smk-select):is(:user-invalid, .user-invalid-fallback) + .smk-error-msg {
  display: flex;
}

:is(.smk-input, .smk-select):is(:user-valid, .user-valid-fallback) {
  border-color: rgba(92, 225, 166, 0.55);
}

/* Ensure readable focus ring across interactive elements */
:focus-visible {
  outline: 2px solid var(--accent-lime);
  outline-offset: 2px;
}

/* Touch target sizing on coarse pointers */
@media (pointer: coarse) {
  .cat-filter-btn,
  .tag-filter-btn,
  #clear-filters-btn,
  #sort-toggle-btn {
    min-block-size: 40px;
  }
}

/* Place card hover & selection state */
.place-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.place-card:hover {
  transform: translateY(-2px);
}

.place-card.is-selected {
  box-shadow: 0 0 0 3px var(--accent-lime), 0 18px 36px -12px rgba(0, 0, 0, 0.6);
}

/* Collapsible map disclosure inside place details dialog */
.smk-detail-map-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.smk-detail-map-summary::-webkit-details-marker {
  display: none;
}

.smk-detail-map-summary::before {
  content: '';
  inline-size: 1em;
  block-size: 1em;
  flex-shrink: 0;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat center / contain;
  rotate: -90deg;
}

.smk-detail-map-details[open] > .smk-detail-map-summary::before {
  rotate: 0deg;
}

.smk-detail-map-details:not([open]) .smk-map-label-collapse,
.smk-detail-map-details[open] .smk-map-label-expand {
  display: none;
}

.smk-detail-map-details::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

.smk-detail-map-details:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .smk-detail-map-summary::before {
    transition: rotate 0.2s ease;
  }

  .smk-detail-map-details::details-content {
    transition: block-size, content-visibility, display;
    transition-duration: 0.28s;
    transition-timing-function: ease-in-out;
    transition-behavior: allow-discrete;
  }
}
