/* ================================================================
   LEFKADA GUIDE — Stylesheet
   Aesthetic: Ionian coastal minimal — sand cream + deep teal +
   terracotta accents. High-contrast for outdoor (sun) readability.
   Mobile-first, single-handed thumb-zone friendly.
   ================================================================ */

/* ---------- Fonts (Google Fonts) --------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Manrope:wght@400;500;600;700&display=swap');

/* ---------- Design tokens ---------------------------------------- */
:root {
  /* Palette */
  --c-bg:        #FAF6EE;   /* sand cream */
  --c-bg-alt:    #F1EADC;
  --c-ink:       #0F1F23;   /* near-black with teal undertone */
  --c-ink-soft:  #44555A;
  --c-line:      #E5DECC;
  --c-primary:   #0E7C8A;   /* Ionian teal */
  --c-primary-dk:#0A4F5C;
  --c-accent:    #D97757;   /* terracotta (CTA) */
  --c-accent-dk: #B95D40;
  --c-white:     #FFFFFF;

  /* Category colors */
  --c-cat-beaches:    #0EA5E9;
  --c-cat-food:       #D97757;
  --c-cat-activities: #7C9C3F;
  --c-cat-services:   #6B7280;

  /* Type */
  --f-display: 'Fraunces', 'Times New Roman', serif;
  --f-body:    'Manrope', system-ui, -apple-system, sans-serif;

  /* Geometry */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Shadows */
  --sh-1: 0 1px 2px rgba(15, 31, 35, 0.08);
  --sh-2: 0 6px 18px rgba(15, 31, 35, 0.10);
  --sh-3: 0 12px 32px rgba(15, 31, 35, 0.18);

  /* Layout */
  --header-h: 56px;
  --filters-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--f-body);
  font-size: 16px;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- App skeleton ----------------------------------------- */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- Header ---------------------------------------------- */
.header {
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 14px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--c-line);
  z-index: 600;
}
.brand {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--c-ink);
}
.brand .brand-mark {
  display: inline-block; width: 8px; height: 8px;
  background: var(--c-accent); border-radius: 50%;
  transform: translateY(-2px);
}
.brand small {
  font-family: var(--f-body); font-weight: 500; font-size: 11px;
  color: var(--c-ink-soft); letter-spacing: 0.02em;
  text-transform: uppercase;
}
.header-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* View counter accanto al brand */
.view-counter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 12px;
  padding: 4px 10px 4px 8px;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink-soft);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  transition: background .2s ease;
}
.view-counter:hover { background: var(--c-bg); }
.view-counter .vc-icon {
  width: 13px; height: 13px;
  flex-shrink: 0;
  opacity: 0.75;
}
.view-counter .vc-num {
  font-weight: 700;
  color: var(--c-ink);
}
@media (max-width: 480px) {
  .view-counter {
    margin-left: 8px;
    padding: 3px 8px 3px 6px;
    font-size: 11px;
  }
  .view-counter .vc-icon { width: 12px; height: 12px; }
}

.lang-switch {
  display: flex; gap: 2px; padding: 3px;
  background: var(--c-bg-alt); border-radius: var(--r-pill);
}
.lang-switch button {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; font-size: 12px; font-weight: 700;
  border-radius: var(--r-pill); color: var(--c-ink-soft);
  letter-spacing: 0.04em;
  transition: all .18s ease;
}
.lang-switch button .lang-code {
  font-weight: 700;
  line-height: 1;
}
.lang-switch button .lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 12px;
  line-height: 1;
}
.lang-switch button .lang-flag .flag-svg {
  width: 18px;
  height: 12px;
  display: block;
  border-radius: 1.5px;
  box-shadow: 0 0 1px rgba(0,0,0,0.15);
}
.lang-switch button.active {
  background: var(--c-ink); color: var(--c-white);
}

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-ink-soft);
  transition: background .18s ease, color .18s ease;
}
.icon-btn:hover { background: var(--c-bg-alt); color: var(--c-ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Filter bar ------------------------------------------ */
.filters {
  height: var(--filters-h);
  display: flex; align-items: center;
  padding: 0 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-line);
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  z-index: 500;
}
.filters::-webkit-scrollbar { display: none; }
.filters-inner { display: flex; gap: 8px; padding: 0 4px; }

.chip {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px 0 12px;
  border-radius: var(--r-pill);
  background: var(--c-white);
  border: 1.5px solid var(--c-line);
  font-size: 14px; font-weight: 600;
  color: var(--c-ink);
  transition: all .18s ease;
  user-select: none;
}
.chip svg { width: 18px; height: 18px; flex-shrink: 0; }
.chip .chip-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: currentColor;
}
.chip:hover { border-color: var(--c-ink); }
.chip.active {
  background: var(--c-ink); color: var(--c-white);
  border-color: var(--c-ink);
}
.chip.active.cat-beaches    { background: var(--c-cat-beaches);    border-color: var(--c-cat-beaches); }
.chip.active.cat-food       { background: var(--c-cat-food);       border-color: var(--c-cat-food); }
.chip.active.cat-activities { background: var(--c-cat-activities); border-color: var(--c-cat-activities); }
.chip.active.cat-services   { background: #6B7280; border-color: #6B7280; }
.chip.active.cat-tours      { background: #1B6BAB; border-color: #1B6BAB; }

/* ---------- Map -------------------------------------------------- */
.map-wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #BFD7DE; }

/* Leaflet marker custom — marker piccolo + label accanto */
.lmark-wrap {
  background: transparent !important;
  border: none !important;
  /* IMPORTANTE: lasciamo overflow visibile in modo che la label esca dall'iconSize */
  overflow: visible !important;
}
.lmark {
  width: 28px; height: 34px;
  position: absolute;
  top: 0; left: 0;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
}
.lmark svg { width: 100%; height: 100%; display: block; }
.lmark.lmark-active { transform: scale(1.15); transition: transform .2s ease; }

.lmark-label {
  position: absolute;
  left: 32px;                   /* a destra del pin */
  top: 50%;
  transform: translateY(-95%);  /* allineata con il "cerchio" del pin (sopra la punta) */
  white-space: nowrap;
  font-family: var(--f-body);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-ink);
  letter-spacing: 0.005em;
  /* Trucco per leggibilità su qualsiasi sfondo: contorno bianco doppio */
  text-shadow:
    -1.5px -1.5px 0 rgba(255,255,255,0.95),
    1.5px -1.5px 0 rgba(255,255,255,0.95),
    -1.5px  1.5px 0 rgba(255,255,255,0.95),
    1.5px  1.5px 0 rgba(255,255,255,0.95),
    0 0 4px rgba(255,255,255,0.85);
  padding: 1px 2px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-95%) translateX(-4px);
  transition: opacity .2s ease, transform .2s ease;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lmark-label.is-visible {
  opacity: 1;
  transform: translateY(-95%) translateX(0);
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md) !important;
  box-shadow: var(--sh-3) !important;
  padding: 0 !important;
  background: var(--c-white) !important;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0 !important;
  width: 280px !important;
  font-family: var(--f-body);
  color: var(--c-ink);
}
.leaflet-popup-tip { box-shadow: var(--sh-2) !important; }
.leaflet-popup-close-button {
  width: 30px !important; height: 30px !important;
  font-size: 20px !important;
  color: var(--c-ink-soft) !important;
  padding: 4px !important;
}
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,0.7) !important;
  padding: 2px 6px !important;
}
.leaflet-control-zoom { box-shadow: var(--sh-2) !important; border: none !important; }
.leaflet-control-zoom a {
  background: var(--c-white) !important;
  color: var(--c-ink) !important;
  border: none !important;
  width: 36px !important; height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
}

/* Popup card */
.popup {}
.popup-cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; margin: 12px 14px 0;
  background: var(--c-bg-alt); border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
  color: var(--c-ink-soft);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.popup-cat .dot { width: 8px; height: 8px; border-radius: 50%; }
.popup-name {
  font-family: var(--f-display);
  font-weight: 600; font-size: 19px;
  line-height: 1.2; letter-spacing: -0.01em;
  margin: 8px 14px 6px;
  color: var(--c-ink);
}
.popup-desc {
  margin: 0 14px 14px;
  font-size: 13.5px; line-height: 1.45;
  color: var(--c-ink-soft);
}
.popup-distance {
  margin: 0 14px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--c-primary-dk);
  display: flex; align-items: center; gap: 6px;
}

/* Telefono nel popup: pulsante outline che apre il dialer */
.popup-phone {
  display: flex; align-items: center; gap: 8px;
  margin: 0 14px 10px;
  padding: 10px 12px;
  background: var(--c-white);
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 600;
  color: var(--c-primary-dk);
  text-decoration: none;
  transition: all .15s ease;
}
.popup-phone:hover {
  border-color: var(--c-primary);
  background: var(--c-bg-alt);
}
.popup-phone svg { width: 16px; height: 16px; flex-shrink: 0; }
.popup-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 28px);
  margin: 0 14px 14px;
  padding: 12px;
  background: var(--c-accent); color: var(--c-white);
  border-radius: var(--r-md);
  font-weight: 700; font-size: 14px;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background .18s ease, transform .1s ease;
}
.popup-cta:hover { background: var(--c-accent-dk); }
.popup-cta:active { transform: scale(0.98); }
.popup-cta svg { width: 18px; height: 18px; }

/* ---------- Floating Action Buttons (thumb zone) ----------------- */
.fab-stack {
  position: absolute;
  right: 14px;
  bottom: calc(20px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 10px;
  z-index: 450;
}
.fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--c-white);
  color: var(--c-ink);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-2);
  transition: transform .12s ease, background .18s ease;
}
.fab:hover { background: var(--c-bg-alt); }
.fab:active { transform: scale(0.94); }
.fab svg { width: 24px; height: 24px; }
.fab.fab-primary { background: var(--c-primary); color: var(--c-white); }
.fab.fab-primary:hover { background: var(--c-primary-dk); }
.fab.locating svg { animation: pulse 1.2s ease infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* User location dot */
.user-loc-dot {
  width: 18px; height: 18px;
  background: #2196F3; border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(33,150,243,0.18), var(--sh-1);
}

/* ---------- Auth gate (overlay) ---------------------------------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 9999;
  background:
    radial-gradient(80% 60% at 50% 20%, rgba(14,124,138,0.12) 0%, transparent 70%),
    var(--c-bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .35s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.auth-gate.is-hidden { display: none; }

.auth-card {
  width: 100%; max-width: 380px;
  text-align: center;
}
.auth-mark {
  width: 56px; height: 56px;
  margin: 0 auto 20px;
  background: var(--c-ink); color: var(--c-bg);
  border-radius: 50%;
  display: grid; place-items: center;
}
.auth-mark svg { width: 26px; height: 26px; }

.auth-brand {
  font-family: var(--f-display);
  font-weight: 700; font-size: 32px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 6px;
}
.auth-sub {
  font-size: 13px; color: var(--c-ink-soft);
  margin: 0 0 26px;
  letter-spacing: 0.02em;
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-input {
  height: 52px;
  padding: 0 18px;
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-white);
  font-size: 16px; font-weight: 500;
  letter-spacing: 0.05em;
  text-align: center;
  transition: border-color .18s ease, box-shadow .18s ease;
  outline: none;
}
.auth-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(14,124,138,0.15);
}
.auth-input.shake { animation: shake .4s ease; border-color: #C0392B; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.auth-submit {
  height: 52px;
  background: var(--c-ink); color: var(--c-bg);
  border-radius: var(--r-md);
  font-weight: 700; font-size: 15px;
  letter-spacing: 0.02em;
  transition: background .18s ease, transform .1s ease;
}
.auth-submit:hover { background: var(--c-primary-dk); }
.auth-submit:active { transform: scale(0.99); }

.auth-error {
  margin-top: 10px;
  font-size: 13px; color: #C0392B;
  min-height: 18px;
  font-weight: 500;
}
.auth-hint {
  margin-top: 24px;
  font-size: 12px; color: var(--c-ink-soft);
  font-style: italic;
}

/* ---------- List drawer (bottom sheet) --------------------------- */
.sheet {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(15,31,35,0.32);
  display: none;
  align-items: flex-end; justify-content: center;
  animation: fadeIn .25s ease;
}
.sheet.is-open { display: flex; }
.sheet-panel {
  width: 100%; max-width: 720px;
  max-height: 85vh;
  background: var(--c-bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  display: flex; flex-direction: column;
  animation: slideUp .3s cubic-bezier(.2,.9,.3,1.1);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.20);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--c-line);
  border-radius: 4px;
  margin: 10px auto 6px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px 14px;
  border-bottom: 1px solid var(--c-line);
}
.sheet-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0;
}
.sheet-sort {
  display: flex; gap: 4px; padding: 3px;
  background: var(--c-bg-alt); border-radius: var(--r-pill);
}
.sheet-sort button {
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  border-radius: var(--r-pill); color: var(--c-ink-soft);
}
.sheet-sort button.active { background: var(--c-ink); color: var(--c-bg); }

.sheet-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 12px;
}
.sheet-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-line);
  cursor: pointer;
  transition: background .15s ease;
  width: 100%;
  text-align: left;
}
.sheet-item:hover { background: var(--c-bg-alt); }
.sheet-item:last-child { border-bottom: none; }
.sheet-item-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--c-white);
}
.sheet-item-icon svg { width: 20px; height: 20px; }
.sheet-item-body { flex: 1; min-width: 0; }
.sheet-item-name {
  font-weight: 600; font-size: 15px;
  margin-bottom: 2px;
  font-family: var(--f-display);
  letter-spacing: -0.005em;
}
.sheet-item-desc {
  font-size: 13px; color: var(--c-ink-soft);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sheet-item-meta {
  font-size: 11px; color: var(--c-primary-dk);
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sheet-empty {
  padding: 40px 20px; text-align: center;
  color: var(--c-ink-soft); font-size: 14px;
}

/* ---------- Loading ---------------------------------------------- */
.loader {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--c-bg);
  z-index: 700;
}
.loader.is-hidden { display: none; }
.loader-spin {
  width: 32px; height: 32px;
  border: 3px solid var(--c-line);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  left: 50%; top: calc(var(--header-h) + 12px);
  transform: translateX(-50%);
  background: var(--c-ink); color: var(--c-bg);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-2);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Tablet / desktop ------------------------------------- */
@media (min-width: 768px) {
  :root {
    --header-h: 64px;
  }
  .brand { font-size: 22px; }
  .header { padding: 0 22px; }
  .filters { padding: 0 18px; }
  .filters-inner { gap: 10px; }
  .chip { height: 44px; padding: 0 18px 0 14px; font-size: 14px; }
  .fab-stack { right: 22px; bottom: 28px; }
  .fab { width: 56px; height: 56px; }
  .leaflet-popup-content { width: 320px !important; }
}
@media (min-width: 1024px) {
  .brand { font-size: 24px; }
  .filters-inner { padding: 0 6px; }
}
