/* 3K Home Store Top Bar
 * Two modes (configurable via Settings → Store Locator):
 *   .threek-topbar--stores   ─ store names directly, hover for details
 *   .threek-topbar--regions  ─ region groups, hover reveals stores in region
 * Compact strip; hover panel pops below.
 */

.threek-topbar {
  /* Brand defaults — overridable via wp_head inline style from admin settings */
  --3k-tb-bg: #073634;
  --3k-tb-fg: #ffffff;
  --3k-tb-accent: #c89947;
  --3k-tb-panel-bg: #ffffff;
  --3k-tb-panel-title: #0a4d4a;
  --3k-tb-padding: 8px 14px;
  --3k-tb-font-size: 13px;
  --3k-tb-case: uppercase;
  --3k-tb-radius: 10px;

  --3k-text-dark: #1d2a2a;
  --3k-border: rgba(255,255,255,.18);
  --3k-tb-cols: 6;

  background: var(--3k-tb-bg);
  color: var(--3k-tb-fg);
  font-size: var(--3k-tb-font-size);
  width: 100%;
  position: relative;
  z-index: 500;
}

.threek-topbar__inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  padding: 0 16px;
  gap: 0;
  overflow: visible;
}

.threek-topbar__store {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

/* Name shown in the bar by default */
.threek-topbar__name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--3k-tb-padding);
  color: var(--3k-tb-fg);
  font-weight: 600;
  font-size: var(--3k-tb-font-size);
  letter-spacing: .04em;
  text-transform: var(--3k-tb-case);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, background-color .15s;
  cursor: pointer;
}
.threek-topbar__store + .threek-topbar__store .threek-topbar__name {
  border-left: 1px solid var(--3k-border);
}
.threek-topbar__name:hover,
.threek-topbar__store:hover > .threek-topbar__name {
  color: var(--3k-tb-accent);
  background: rgba(255,255,255,.04);
}
.threek-topbar__caret { font-size: 10px; margin-left: 2px; }
.threek-topbar__count { font-size: 10.5px; font-weight: 500; opacity: .7; margin-left: 4px; }

/* ────────────────────────────────────────────────────────────────────
 * STORES MODE — grid of N cols × M rows
 * ────────────────────────────────────────────────────────────────────*/
.threek-topbar--stores .threek-topbar__inner {
  display: grid;
  grid-template-columns: repeat(var(--3k-tb-cols), minmax(0, 1fr));
}
.threek-topbar--stores .threek-topbar__store {
  display: flex;
  border-left: 1px solid var(--3k-border);
}
.threek-topbar--stores .threek-topbar__store:first-child { border-left: 0; }
.threek-topbar--stores .threek-topbar__name {
  width: 100%;
  justify-content: center;
  border-left: 0;       /* row separator already provided by store cell */
}
/* Scroll overflow → single row, horizontal scroll */
.threek-topbar--stores[data-overflow="scroll"][data-max-rows="1"] .threek-topbar__inner {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}
.threek-topbar--stores[data-overflow="scroll"][data-max-rows="1"] .threek-topbar__inner::-webkit-scrollbar { height: 0; }

/* ────────────────────────────────────────────────────────────────────
 * REGIONS MODE — fewer items, each group hovers to reveal stores
 * ────────────────────────────────────────────────────────────────────*/
.threek-topbar--regions .threek-topbar__inner {
  justify-content: center;
}
.threek-topbar--regions .threek-topbar__name--region {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
}

/* ────────────────────────────────────────────────────────────────────
 * Hover panel (shared, with variants)
 * ────────────────────────────────────────────────────────────────────*/
/* Hover panel:
 * Uses position: fixed (set by JS) so it escapes every Woodmart stacking
 * context (.whb-main-header creates a z=390 context that would clip an
 * absolute panel). z-index is high but stays below WP admin bar (99999). */
.threek-topbar__panel {
  position: fixed;
  z-index: 99990;
  top: 0;
  left: 0;
  min-width: 280px;
  max-width: 360px;
  background: var(--3k-tb-panel-bg);
  color: var(--3k-text-dark);
  border-radius: 0 0 var(--3k-tb-radius) var(--3k-tb-radius);
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  padding: 14px 16px;
  border-top: 3px solid var(--3k-tb-accent);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .15s, visibility .15s, transform .15s;
  pointer-events: none;
}
.threek-topbar__store:hover > .threek-topbar__panel,
.threek-topbar__store:focus-within > .threek-topbar__panel,
.threek-topbar__panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Regions panel ─ wider to fit multiple stores cleanly */
.threek-topbar__panel--region {
  min-width: 320px;
  max-width: 420px;
  max-height: 70vh;
  overflow-y: auto;
}
.threek-topbar__sep {
  border: 0;
  border-top: 1px solid #ece5d4;
  margin: 12px 0;
}

.threek-topbar__panel-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--3k-tb-panel-title);
  text-decoration: none;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ece5d4;
  transition: color .15s;
}
.threek-topbar__panel-title:hover { color: var(--3k-tb-accent); }
/* Inside region panel, each store title doesn't need bottom border (sep does) */
.threek-topbar__panel--region .threek-topbar__panel-title {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 8px;
}

.threek-topbar__panel-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.45;
  color: var(--3k-text-dark);
  margin-bottom: 6px;
  text-decoration: none;
}
.threek-topbar__panel-row:last-child { margin-bottom: 0; }
.threek-topbar__panel-link:hover { color: var(--3k-tb-accent); }

.threek-topbar__panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--3k-tb-accent);
}
.threek-topbar__panel-icon svg { width: 16px; height: 16px; display: block; }

/* Tablet — tighter padding */
@media (max-width: 900px) {
  .threek-topbar__inner { padding: 0 8px; }
  .threek-topbar__name { padding: 8px 10px; font-size: 12px; }
  .threek-topbar__inner > .threek-topbar__store:nth-last-child(-n+3) > .threek-topbar__panel {
    left: auto;
    right: 0;
    border-radius: 10px 0 10px 10px;
  }
}

/* Mobile — touch: hide panels, scroll horizontally instead */
@media (max-width: 640px) {
  .threek-topbar__inner,
  .threek-topbar--stores .threek-topbar__inner {
    display: flex;
    grid-template-columns: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .threek-topbar__inner::-webkit-scrollbar { height: 0; }
  .threek-topbar__store { flex: 0 0 auto; }
  .threek-topbar__panel { display: none; }
}
