/* ============================================================
   Interactive Map – Frontend CSS  v3
   Desktop: map 100vw×100vh, cards float top-left as individual
            white boxes, category bar floats bottom full-width
   Mobile:  map 100vw×100vh, bottom sheet floats over map
   ============================================================ */

:root {
  --im-font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --im-text:      #1a1a1a;
  --im-muted:     #6b7280;
  --im-white:     #ffffff;
  --im-marker:    #c8a96e;
  --im-radius:    12px;
  --im-card-w:    440px;
  --im-card-gap:  10px;
  --im-card-left: 20px;
  --im-card-top:  50px;
  --im-catbar-h:  80px;  /* height of pill bar + margin */
  --im-ease:      0.28s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ───────────────────────────────────────────────── */
#im-map-root *, #im-map-root *::before, #im-map-root *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}
#im-map-root button { cursor: pointer; font-family: var(--im-font); }

/* ── Root ─────────────────────────────────────────────────── */
#im-map-root {
  /* position:absolute fills the parent .our-map section exactly.
     No fixed/z-index takeover — plugin lives inside its section. */
  position: absolute;
  inset: 0;
  font-family: var(--im-font);
  color: var(--im-text);
  overflow: hidden; /* desktop: clip to section bounds */
}
/* ── Loading ──────────────────────────────────────────────── */
.im-loading {
  position: absolute; inset: 0; z-index: 99;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: #ede9e4; color: var(--im-muted); font-size: 14px;
}
.im-spinner {
  width: 32px; height: 32px;
  border: 3px solid #ddd; border-top-color: var(--im-marker);
  border-radius: 50%; animation: imSpin .8s linear infinite;
}
@keyframes imSpin { to { transform: rotate(360deg); } }
.im-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #999; font-size: 14px; padding: 24px; text-align: center;
}

/* ══════════════════════════════════════════════════════════
   MAP — always full screen base layer
══════════════════════════════════════════════════════════ */
.im-layout { position: absolute; inset: 0; overflow: visible; }

.im-map-wrap {
  position: absolute; inset: 0; z-index: 0;
  overflow: hidden;
  background: #abb3b6;
  cursor: default;
}

/* Zoom group — the single transformed element.
   inset:0 so its coordinate space = wrap coordinate space.
   img, overlay, markers all live inside and share the same origin. */
.im-zoom-group {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.im-map-image {
  /* position/size/objectFit set by JS (_positionImg) */
  display: block;
  position: absolute;
  user-select: none; pointer-events: none;
  -webkit-user-drag: none;
}
.im-no-map {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #ede9e4; color: var(--im-muted);
  font-size: 14px; text-align: center; padding: 24px;
}

/* Logistic SVG overlay
   JS sets left/top/width/height to match the unzoomed image rect.
   Same CSS transform as <img> is applied by JS so overlay zooms together.
   overflow:visible so SVG strokes don't clip during zoom.               */
.im-logistic-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
  transform-origin: 0 0;
}
.im-logistic-line {
  position: absolute;
  inset: 0;
  overflow: visible;
}
.im-logistic-line svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
@keyframes imDashMove { to { stroke-dashoffset: 0; } }

/* Markers */
.im-markers-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: visible; }
.im-marker {
  position: absolute;
  transform: translate(-50%, -100%);
  cursor: pointer; pointer-events: all;
  background: none; border: none; padding: 0;
  width: 36px;
  color: var(--im-marker);
  transition: transform var(--im-ease), filter var(--im-ease);
  z-index: 2;
}
.im-marker:hover   { transform: translate(-50%,-100%) scale(1.15); z-index: 4; }
.im-marker--active { transform: translate(-50%,-100%) scale(1.3); z-index: 5;
                     filter: drop-shadow(0 4px 10px rgba(200,169,110,.5)); }
.im-marker__pin    { width: 100%; height: 100%; }
.im-marker__icon   { width: 100%; height: 100%; object-fit: contain; }
.im-marker--fade-out { opacity: 0; pointer-events: none; transition: opacity .2s; }
@keyframes imFadeIn {
  from { opacity:0; }
  to   { opacity:1; }
}
.im-marker--enter { animation: imFadeIn .25s ease forwards; }

/* ══════════════════════════════════════════════════════════
   DESKTOP (≥ 768px)
══════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  /* Hide mobile elements */
  .im-bottom-sheet  { display: none !important; }
  .im-card-carousel { display: none !important; }  /* mobile carousel, hidden on desktop */

  /* ── Card stack: individual white boxes, top-left ──────── */
  .im-card-list {
    position: absolute;
    top: var(--im-card-top);
    left: var(--im-card-left);
    width: var(--im-card-w);
    /* Bottom edge: stop above category bar + gap */
    /* 40px margin-bottom + ~52px pill height + 16px gap */
    bottom: calc(40px + 56px + 16px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: var(--im-card-gap);
    overflow-y: auto;
    overflow-x: visible;
    scrollbar-width: none;
    /* Padding so box-shadow not clipped */
    padding: 2px 4px 2px 2px;
  }
  .im-card-list::-webkit-scrollbar { display: none; }

  /* Each card = individual white box */
  .im-card {
    flex-shrink: 0;
    background: var(--im-white);
    border-radius: var(--im-radius);
    box-shadow: 0 2px 12px rgba(0,0,0,.10);
    padding: 16px !important;
    cursor: pointer;
    transition: box-shadow var(--im-ease);
    border: none;
    width: 93%;
  }
  .im-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.14); }
  .im-card--active { box-shadow: 0 4px 24px rgba(0,0,0,.16); }

  .im-card__title {
    font-size: 20px; font-weight: 700;
    color: var(--im-text); line-height: 1.3;
    margin-bottom: 8px;
  }
  /* Logistic card title: serif Myfont, no thumbnail */
  .im-logistic-title {
    font-family: 'Myfont', serif;
    font-weight: 400;
    font-style: italic;
  }
  .im-card__desc {
    font-size: 14px; color: var(--im-muted); line-height: 1.6;
    /* Always show desc (2 lines max when collapsed) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
	text-align: justify;
  }
  .im-card--active .im-card__desc {
    display: block; overflow: visible;
  }

  /* Gallery: hidden until active */
  .im-card__gallery {
    display: none;
    gap: 8px;
    margin-top: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
	border-top: solid 1px rgba(21, 43, 28, 0.3);
	padding-top: .5em !important;
  }
  .im-card__gallery::-webkit-scrollbar { display: none; }
  .im-card--active .im-card__gallery { display: flex; }
  .im-card__img {
    flex-shrink: 0; width: 120px; height: 80px;
    object-fit: cover; border-radius: 8px;
  }

  /* ── Category bar: pill-shaped floating bar, bottom-center ── */
  .im-category-bar {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: var(--im-white);
    border-radius: 999px;
    display: flex;
    align-items: center;
    padding: 4px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    white-space: nowrap;
    box-shadow: 0 4px 24px rgba(0,0,0,.12);
    /* Don't stretch full width — shrink to content */
    width: auto;
    max-width: calc(100vw - 80px);
    right: auto;
    left: 50%;
  }
  .im-category-bar::-webkit-scrollbar { display: none; }

  .im-cat-btn {
    background: none;
    border: none;
    padding: 12px 40px !important;
    font-size: 18px;
    font-weight: 300;
    color: var(--im-text);
    white-space: nowrap;
    transition: background .2s, color .2s;
    flex-shrink: 0;
    border-radius: 99px;
    line-height: 1;
	text-transform: none;
  }
  .im-cat-btn:hover {
    background: rgba(21, 43, 28, 0.04);
  }
  .im-cat-btn--active {
    background: rgba(21, 43, 28, 0.05);
    border-radius: 99px;
    font-weight: 400;
    color: var(--im-text);
  }
}

/* ══════════════════════════════════════════════════════════
   MOBILE (< 768px) — minimal reset, built up incrementally
══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* ── Hide desktop-only elements ─────────────────────── */
  .im-card-list                       { display: none !important; }
  .im-category-bar#im-cat-bar-desktop { display: none !important; }
  /* .im-card-carousel display controlled by JS */

  /* ── Map: top 80dvh — dvh trừ address bar trên mobile ──── */
  .im-map-wrap,
  .im-zoom-group {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 20dvh !important;   /* dvh = dynamic viewport, trừ address bar */
    width: auto !important;
    height: auto !important;
  }
  /* Fallback cho browser không hỗ trợ dvh */
  @supports not (bottom: 1dvh) {
    .im-map-wrap, .im-zoom-group {
      bottom: 20vh !important;
    }
  }

  /* ── Bottom sheet: exactly 20dvh, flush bottom ────────── */
  .im-bottom-sheet {
    position: absolute;
    top: 80dvh;
    left: 0; right: 0;
    height: 20dvh;
    z-index: 20;
    background: #fff;
    display: flex;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 -1px 0 rgba(0,0,0,.08);
  }
  @supports not (top: 1dvh) {
    .im-bottom-sheet { top: 80vh; height: 20vh; }
  }

  /* ── Card carousel: floats above category bar ─────────── */
  .im-card-carousel {
    display: none;         /* default hidden; JS sets style.display='' to show */
    position: absolute;
    left: 0; right: 0;
    bottom: calc(20dvh + 2em);  /* 20dvh cat bar + 2em gap */
    height: 220px;
    z-index: 19;
    overflow: visible;
    pointer-events: none;
  }
  @supports not (bottom: 1dvh) {
    .im-card-carousel { bottom: calc(20vh + 2em); }
  }

  /* Cards inside carousel */
  .im-card-carousel .im-card {
    pointer-events: all;
    position: absolute;
    width: 70vw;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
    padding: 0.5em !important;
    cursor: pointer;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4,0,0.2,1),
                opacity   0.4s cubic-bezier(0.4,0,0.2,1);
    transform: scale(0.88);
    opacity: 0.6;
  }
  .im-card-carousel .im-card--active {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 6px 28px rgba(0,0,0,.16);
  }
  .im-card-carousel .im-card__title {
    font-size: 16px;
    font-weight: 300;
    color: #152B1C;
    margin-bottom: 6px;
    line-height: 1.3;
  }
  .im-card-carousel .im-card__desc {
    font-size: 13px;
    color: rgba(21,43,28,0.7);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .im-card-carousel .im-card__gallery {
    display: none;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .im-card-carousel .im-card__gallery::-webkit-scrollbar { display: none; }
  .im-card-carousel .im-card--active .im-card__gallery { display: flex; }
  .im-card-carousel .im-card__img {
    flex-shrink: 0;
    width: 80px; height: 56px;
    object-fit: cover;
    border-radius: 6px;
  }

  /* ── Category bar ────────────────────────────────────── */
  .im-category-bar#im-cat-bar-mobile {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    overflow: hidden;
  }

  /* ── Category button ─────────────────────────────────── */
  .im-cat-btn {
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    padding: 0px 25px !important;
    border-radius: 99px;
    border: none;
    background: transparent;
    color: rgba(21, 43, 28, 0.7);
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 400;
    text-transform: none;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .im-cat-btn img {
    width: 14px; height: 14px; object-fit: contain;
  }
  .im-cat-btn--active {
    background: rgba(21, 43, 28, 0.05);
    color: rgba(21, 43, 28, 1);
  }
}

/* ── WP theme override ────────────────────────────────── */
/* body.has-im-map rules removed — plugin is embedded inside a section,
   not fullscreen. Other page elements must remain visible. */

/* ══════════════════════════════════════════════════════════
   SUB-CATEGORY CARDS
══════════════════════════════════════════════════════════ */
.im-sub-card {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
}

.im-sub-card__thumb {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
}

.im-sub-card__thumb--empty {
  background: #f0f0f0;
}

.im-sub-card__body {
  flex: 1;
  min-width: 0;
}

.im-sub-card--detail .im-sub-card__thumb {
  width: 90px;
  height: 90px;
}

.im-sub-card__route {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--im-text);
  line-height: 1.5;
}

.im-sub-card__route-icon {
  margin-right: 4px;
}

/* ══════════════════════════════════════════════════════════
   MARKER POPUP  (logistic location popup)
══════════════════════════════════════════════════════════ */
.im-marker-popup {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.18));
}

.im-popup__inner {
  background: var(--im-white);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  max-width: 160px;
}

.im-popup__thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.im-popup__name {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--im-text);
  text-align: center;
  line-height: 1.3;
}

/* Arrow pointing down at marker */
.im-popup__inner::after {
  content: '';
  display: block;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--im-white);
  margin: 0 auto;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   ZOOM CONTROLS  (floating buttons, bottom-right of map)
══════════════════════════════════════════════════════════ */
.im-zoom-controls {
  position: absolute;
  right: 16px;
  bottom: calc(40px + 64px + 12px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: all;
}

.im-zoom-btn {
  width: 36px; height: 36px;
  border-radius: 8px; border: none;
  background: var(--im-white);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--im-text);
  transition: background .15s, box-shadow .15s;
  font-family: var(--im-font);
}
.im-zoom-btn:hover  { background: #f4f4f4; box-shadow: 0 3px 12px rgba(0,0,0,.2); }
.im-zoom-btn:active { background: #eee; }
.im-zoom-btn--reset { font-size: 15px; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════
   SUB-CATEGORY CARDS  (expand-in-place)
══════════════════════════════════════════════════════════ */
.im-sub-card__header {
  display: flex; gap: 14px; align-items: flex-start;
}
.im-sub-card__thumb {
  flex-shrink: 0; width: 72px; height: 72px;
  object-fit: cover; border-radius: 10px;
}
.im-sub-card__thumb--empty {
  flex-shrink: 0; width: 72px; height: 72px;
  background: #f0f0f0; border-radius: 10px;
}
.im-sub-card__body { flex: 1; min-width: 0; }
.im-sub-card__expanded {
  display: none;
  margin-top: 12px; padding-top: 12px;
}
.im-card--active .im-sub-card__expanded { display: block; }
.im-sub-card.im-card--active {
  border-left: 3px solid var(--im-marker);
  padding-left: 19px;
}
.im-sub-card__route {
  font-size: 13px; font-weight: 600;
  color: var(--im-text); line-height: 1.6;
}
.im-sub-card__route-icon { margin-right: 4px; }

/* ══════════════════════════════════════════════════════════
   STORE CARD TITLE TYPOGRAPHY
   Format: "CategoryName • Location Name"
   Serif font, dark green, large
══════════════════════════════════════════════════════════ */
.im-store-title {
  font-size: 22px;
  font-weight: 300;
  font-family: 'Myfont', serif;
  color: #152B1C;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* The bullet separator — slightly lighter weight */
.im-store-title .im-title-sep {
  font-weight: 400;
  margin: 0 6px;
  opacity: 0.7;
  padding: 0 .4em !important;
}

@media (min-width: 768px) {
  .im-store-card .im-card__title {
    font-size: 24px;
    margin-bottom: 16px !important;
  }
}
