/* =========================================================
   Gaudau.lt – CDN fallback styles
   Graceful degradation when external CDN dependencies
   (Google Fonts, Leaflet CSS/JS) fail to load.

   - Fonts: the font stack in styles.css already falls back to
     system-ui / -apple-system / Segoe UI, so no extra rule is
     needed for text. We only adjust letter-spacing slightly so
     headings do not look cramped when Outfit is unavailable.
   - Leaflet CSS: when the stylesheet fails to load, the map
     canvas would otherwise collapse to zero height and the
     tiles would render as unstyled images. We provide a
     minimal fallback so the map container keeps its layout
     and shows a clear message instead of a broken box.
   ========================================================= */

/* ---------- Font fallback ---------- */
/* When Google Fonts is blocked, the browser uses the system font
   stack. Outfit is a geometric sans with tighter tracking than
   most system fonts, so we relax the negative letter-spacing on
   headings to keep them readable. */
html.fonts-failed h1,
html.fonts-failed h2,
html.fonts-failed h3,
html.fonts-failed h4 {
  letter-spacing: -0.01em;
}

/* ---------- Leaflet CSS fallback ---------- */
/* The map canvas keeps a minimum height even without Leaflet's
   stylesheet so the surrounding layout does not collapse. */
html.leaflet-css-failed .map-canvas {
  min-height: 320px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  background-color: var(--surface-3);
  background-image:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-2) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

/* ---------- Leaflet JS fallback ---------- */
/* When the Leaflet script fails to load, map.js cannot initialise
   the map. We surface a clear, styled message inside the map
   canvas so the user knows the map is unavailable rather than
   seeing an empty box. The message is injected by cdn-fallback.js. */
.zk-map-cdn-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 320px;
  padding: 24px 20px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  background-color: var(--surface-3);
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
}

.zk-map-cdn-fallback-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--green-line);
  background-color: var(--green-soft);
  color: var(--green);
  flex-shrink: 0;
}

.zk-map-cdn-fallback-icon svg {
  width: 24px;
  height: 24px;
}

.zk-map-cdn-fallback-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.zk-map-cdn-fallback-hint {
  max-width: 420px;
  font-size: 0.85rem;
  color: var(--muted);
}

.zk-map-cdn-fallback-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--green-line);
  background-color: var(--green-soft);
  color: var(--green);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.zk-map-cdn-fallback-retry:hover {
  background-color: var(--green);
  border-color: var(--green);
  color: #0b1418;
}

.zk-map-cdn-fallback-retry:focus-visible {
  outline: 2px solid var(--green-bright);
  outline-offset: 3px;
  background-color: var(--green);
  border-color: var(--green);
  color: #0b1418;
  box-shadow: 0 0 0 4px var(--green-soft);
}

[data-theme="light"] .zk-map-cdn-fallback-retry:focus-visible {
  outline-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.zk-map-cdn-fallback-retry svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .zk-map-cdn-fallback-retry {
    transition: none;
  }
}
