/* ═══════════════════════════════════════════════
   COWORKINGS PAGE — barcelonaentrepreneurs.com
   Full-viewport directory: fixed header + filters, scrollable sidebar, sticky map.
   ═══════════════════════════════════════════════ */

/* Layout constants (derived from fixed header height) */
:root {
  --cw-header-h: 80px;
  --cw-filters-h: 68px;
}

/* Lock page scroll on desktop — only the sidebar scrolls */
body.cw-page { overflow: hidden; }

/* Hide the noise grain behind the solid map/sidebar so it never shows through */
body.cw-page::before { display: none; }

/* ── FILTERS (fixed below site header) ── */
.cw-filters {
  position: fixed;
  top: var(--cw-header-h);
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--cw-filters-h);
  background: rgba(var(--cream-rgb), 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.cw-filters-inner {
  width: 100%;
  padding: 0 48px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cw-filters-inner::-webkit-scrollbar { display: none; }

.cw-pill {
  flex-shrink: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 18px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.cw-pill:hover { border-color: var(--red); }
.cw-pill.is-active {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

/* ── SPLIT LAYOUT (fills viewport below header+filters) ── */
.cw-split {
  margin-top: calc(var(--cw-header-h) + var(--cw-filters-h));
  height: calc(100vh - var(--cw-header-h) - var(--cw-filters-h));
  display: grid;
  grid-template-columns: 42% 58%;
  position: relative;
  z-index: 1;
}

.cw-sidebar {
  height: 100%;
  overflow-y: auto;
  padding: 0 28px 48px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.cw-sidebar::-webkit-scrollbar { width: 6px; }
.cw-sidebar::-webkit-scrollbar-track { background: transparent; }
.cw-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.cw-sidebar:hover::-webkit-scrollbar-thumb { background: var(--red); }

/* ── SIDEBAR HEADER (compact editorial strip above the list) ── */
.cw-sidebar-header {
  padding: 28px 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--cream);
  z-index: 2;
}
.cw-sidebar-title {
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 1.8vw, 1.7rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 6px;
}
.cw-sidebar-title em { font-style: italic; color: var(--red); }
.cw-count {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  margin: 0;
}
.cw-count strong { color: var(--red); font-weight: 600; }

/* ── LIST ── */
.cw-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
}

/* ── CARD ── */
.cw-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.cw-card:hover {
  transform: translateY(-2px);
  border-color: var(--red);
  box-shadow: 0 4px 16px rgba(var(--ink-rgb), 0.06);
}
.cw-card:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.cw-card.is-active {
  border-color: var(--red);
  background: rgba(var(--red-rgb), 0.04);
}

.cw-card__photo {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--cream-alt);
  display: block;
}

.cw-card__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cw-card__hood {
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 6px;
}

.cw-card__name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 8px;
}

.cw-card__desc {
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cw-card__cta {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--red);
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  align-self: flex-start;
}
.cw-card__cta:hover { text-decoration: underline; }
.cw-card__cta::after {
  content: "\2192";
  transition: transform 0.2s;
}
.cw-card__cta:hover::after { transform: translateX(3px); }

/* ── EMPTY STATE ── */
.cw-empty {
  text-align: center;
  padding: 56px 24px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
}
.cw-empty em { color: var(--red); font-style: normal; font-weight: 600; }

/* ── MAP ── */
.cw-map-wrap {
  height: 100%;
  background: var(--cream-alt);
  position: relative;
}
#cwMap {
  width: 100%;
  height: 100%;
}
.cw-map-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-family: var(--font-heading);
  font-style: italic;
  color: var(--muted);
  background: var(--cream-alt);
}

/* ── LEAFLET CUSTOM PIN ── */
.cw-pin {
  background: transparent;
  border: none;
}
.cw-pin__dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(var(--ink-rgb), 0.25);
  transition: transform 0.15s;
}
.cw-pin:hover .cw-pin__dot { transform: scale(1.1); }
.cw-pin.is-active .cw-pin__dot {
  background: var(--red-dim);
  border-width: 3px;
  box-shadow: 0 4px 14px rgba(var(--red-rgb), 0.45);
}

/* ── LEAFLET POPUP OVERRIDES ── */
.leaflet-popup.cw-popup .leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  font-family: var(--font-body);
  box-shadow: 0 16px 48px rgba(var(--ink-rgb), 0.18);
  background: var(--white);
}
.leaflet-popup.cw-popup .leaflet-popup-content {
  margin: 0;
  min-width: 220px;
  max-width: 280px;
}
.leaflet-popup.cw-popup .leaflet-popup-tip { background: var(--white); }
.leaflet-popup.cw-popup a.leaflet-popup-close-button {
  top: 8px;
  right: 8px;
  color: var(--muted);
  font-size: 20px;
  padding: 4px 8px;
}
.leaflet-popup.cw-popup a.leaflet-popup-close-button:hover { color: var(--red); }

.leaflet-container { font-family: var(--font-body); background: var(--cream-alt); }
.leaflet-control-attribution {
  font-size: 0.65rem !important;
  background: rgba(var(--cream-rgb), 0.85) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--red) !important; }

.cw-iw {
  min-width: 220px;
  max-width: 260px;
  overflow: hidden;
  border-radius: 14px;
}
.cw-iw__photo {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--cream-alt);
}
.cw-iw__body {
  padding: 14px 18px 14px;
}
.cw-iw__hood {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 6px;
}
.cw-iw__name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 4px;
}
.cw-iw__addr {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 10px;
}
.cw-iw__cta {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--red);
  text-decoration: none;
}
.cw-iw__cta:hover { text-decoration: underline; }

/* ── MOBILE TOGGLE ── */
.cw-mobile-toggle {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 100px;
  box-shadow: 0 12px 32px rgba(var(--ink-rgb), 0.18);
  padding: 4px;
}
.cw-mobile-toggle button {
  background: transparent;
  border: none;
  padding: 10px 22px;
  border-radius: 100px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cw-mobile-toggle button.is-active {
  background: var(--red);
  color: var(--white);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  :root {
    --cw-header-h: 68px;
    --cw-filters-h: 60px;
  }

  /* Allow page scroll on mobile — list stacks below filters */
  body.cw-page { overflow: auto; }

  .cw-filters-inner { padding: 0 20px; }

  .cw-split {
    display: block;
    height: auto;
    min-height: calc(100vh - var(--cw-header-h) - var(--cw-filters-h));
  }

  .cw-sidebar {
    height: auto;
    overflow: visible;
    padding: 0 20px 120px;
  }

  .cw-sidebar-header {
    position: static;
    padding: 20px 0 16px;
    margin-bottom: 16px;
  }

  .cw-card {
    grid-template-columns: 88px 1fr;
    gap: 14px;
    padding: 12px;
  }
  .cw-card__photo { width: 88px; height: 88px; }
  .cw-card__name { font-size: 1rem; }

  .cw-map-wrap {
    position: fixed;
    inset: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 80;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }
  body.cw-view-map .cw-map-wrap { transform: translateY(0); }
  body.cw-view-map { overflow: hidden; }

  .cw-mobile-toggle { display: flex; }
}

@media (max-width: 600px) {
  .cw-card { grid-template-columns: 76px 1fr; gap: 12px; }
  .cw-card__photo { width: 76px; height: 76px; }
}
