/* TwinAFlow — Interactive World Time Zone Map Styles */
.legal:has(.map-tool-container),
.map-page.legal {
  max-width: 1240px;
}

.map-tool-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0 32px;
}

/* 1. Top City Cards Bar */
.top-cards-bar {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.top-cards-bar::-webkit-scrollbar {
  height: 6px;
}
.top-cards-bar::-webkit-scrollbar-thumb {
  background: var(--bd);
  border-radius: 999px;
}

.top-city-card {
  flex: 0 0 auto;
  min-width: 175px;
  max-width: 220px;
  padding: 12px 14px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.top-city-card:hover {
  transform: translateY(-2px);
  border-color: var(--acc);
  box-shadow: 0 8px 24px var(--glow);
}
.top-city-card.is-ref {
  border-color: var(--acc);
  box-shadow: 0 0 0 1px var(--acc), 0 8px 24px var(--glow);
}

.top-city-card .top-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.top-city-card .city-name {
  font: 600 15px Outfit, Inter, sans-serif;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.top-city-card .actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.top-city-card .btn-ref,
.top-city-card .btn-rm {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 13px;
  color: var(--mut);
  border-radius: 6px;
  transition: all .15s ease;
}
.top-city-card .btn-ref.on {
  color: var(--acc);
}
.top-city-card .btn-ref:hover {
  color: var(--acc);
  background: rgba(255, 138, 61, 0.12);
}
.top-city-card .btn-rm:hover {
  color: #ff4757;
  background: rgba(255, 71, 87, 0.12);
}

.top-city-card .big-time {
  font: 700 26px/1 Outfit, Inter, sans-serif;
  color: var(--ink);
  letter-spacing: -0.5px;
  margin: 2px 0;
}

.top-city-card .bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
}
.top-city-card .tz-pill {
  color: var(--mut);
  font-weight: 500;
}
.top-city-card .cc-pill {
  background: rgba(120, 140, 160, 0.16);
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 130px;
}
.top-city-card .cc-pill span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-flag-ic {
  width: 18px;
  height: 13.5px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.25);
  display: inline-block;
  flex-shrink: 0;
}

.day-diff-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
}
.day-diff-pill.ahead {
  background: rgba(47, 179, 109, 0.18);
  color: var(--good);
}
.day-diff-pill.behind {
  background: rgba(242, 193, 78, 0.18);
  color: var(--mid);
}

.top-city-add {
  flex: 0 0 auto;
  min-width: 140px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--acc);
  background: var(--glass);
  border: 1px dashed var(--bd);
  transition: all .18s ease;
}
.top-city-add:hover {
  border-color: var(--acc);
  background: rgba(255, 138, 61, 0.08);
  transform: translateY(-2px);
}
.top-city-add .plus-icon {
  font-size: 24px;
  line-height: 1;
}

/* 2. Map Viewport & SVG Canvas */
.map-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  min-height: 380px;
  max-height: 600px;
  border-radius: 24px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.map-viewport.panning {
  cursor: grabbing;
}

#mapSvg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Map Layers */
.tz-ocean {
  fill: rgba(0, 60, 120, 0.06);
}
:root[data-theme=dark] .tz-ocean {
  fill: rgba(4, 10, 18, 0.7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .tz-ocean {
    fill: rgba(4, 10, 18, 0.7);
  }
}

.tz-country-poly {
  fill: rgba(130, 150, 175, 0.22);
  stroke: rgba(110, 130, 150, 0.35);
  stroke-width: 0.6;
  cursor: pointer;
  transition: fill .15s ease, stroke .15s ease;
}
.tz-country-poly.has-city {
  fill: rgba(255, 138, 61, 0.22);
  stroke: var(--acc);
  stroke-width: 0.8;
}
:root[data-theme=dark] .tz-country-poly.has-city {
  fill: rgba(0, 210, 255, 0.22);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .tz-country-poly.has-city {
    fill: rgba(0, 210, 255, 0.22);
  }
}
.tz-country-poly:hover {
  fill: rgba(255, 138, 61, 0.35);
  stroke: var(--acc);
  stroke-width: 1.2;
}
:root[data-theme=dark] .tz-country-poly:hover {
  fill: rgba(0, 210, 255, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .tz-country-poly:hover {
    fill: rgba(0, 210, 255, 0.35);
  }
}

.tz-zone-poly {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 0.4;
  pointer-events: none;
}

/* Solar Terminator Overlay */
.tz-terminator {
  fill: rgba(10, 20, 36, 0.38);
  pointer-events: none;
  mix-blend-mode: multiply;
  transition: d .4s ease;
}
:root[data-theme=dark] .tz-terminator {
  fill: rgba(0, 10, 22, 0.65);
  mix-blend-mode: normal;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .tz-terminator {
    fill: rgba(0, 10, 22, 0.65);
    mix-blend-mode: normal;
  }
}

/* Map Pins & Badges */
.map-badge-group {
  cursor: pointer;
  transition: transform .18s ease;
}
.map-badge-group:hover {
  filter: drop-shadow(0 0 8px var(--acc));
}

.pin-dot {
  fill: var(--acc);
}
.pin-pulse {
  fill: var(--acc);
  opacity: 0.45;
  transform-origin: 0 0;
  animation: mapPinPulse 2s infinite ease-out;
}
@keyframes mapPinPulse {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(2.6); opacity: 0; }
}

.pin-leader {
  stroke: var(--acc);
  stroke-opacity: 0.65;
  fill: none;
}
.home-pin .pin-dot {
  fill: var(--good);
}
.home-pin .pin-pulse {
  fill: var(--good);
}
.home-pin .pin-leader {
  stroke: var(--good);
}

.map-badge {
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.3));
}
.map-badge .badge-bg {
  fill: rgba(255, 251, 246, 0.94);
  stroke: rgba(255, 138, 61, 0.55);
  stroke-width: 1;
}
:root[data-theme=dark] .map-badge .badge-bg {
  fill: rgba(7, 18, 30, 0.94);
  stroke: rgba(0, 210, 255, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .map-badge .badge-bg {
    fill: rgba(7, 18, 30, 0.94);
    stroke: rgba(0, 210, 255, 0.45);
  }
}
.map-badge .badge-t1 {
  font: 600 10.5px Outfit, Inter, sans-serif;
  fill: var(--ink);
}
.map-badge .badge-t2 {
  font: 500 9px Inter, sans-serif;
  fill: var(--mut);
}
.map-badge .flag-border {
  fill: none;
  stroke: rgba(128, 128, 128, 0.35);
  stroke-width: 0.6;
}

/* Floating Map Controls */
.map-controls-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}
.map-controls-toolbar.left-bar {
  right: auto;
  left: 14px;
}

.map-control-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--bd);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all .15s ease;
}
.map-control-btn:hover {
  background: var(--ink);
  color: var(--bg1);
  transform: scale(1.05);
}
.map-control-btn.active {
  border-color: var(--acc);
  color: var(--acc);
  box-shadow: 0 0 12px var(--glow);
}

.map-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  font: 600 16px Outfit, sans-serif;
  color: var(--mut);
  z-index: 20;
}

/* Tooltip */
.map-tooltip {
  position: absolute;
  z-index: 100;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 251, 246, 0.96);
  border: 1px solid rgba(255, 138, 61, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 240px;
  transition: opacity .12s ease;
}
:root[data-theme=dark] .map-tooltip {
  background: rgba(7, 18, 30, 0.95);
  border-color: rgba(0, 210, 255, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .map-tooltip {
    background: rgba(7, 18, 30, 0.95);
    border-color: rgba(0, 210, 255, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  }
}
.map-tooltip-head {
  display: flex;
  align-items: center;
  gap: 7px;
}
.search-item-main {
  display: flex;
  align-items: center;
  gap: 9px;
}
.map-tooltip.hid {
  opacity: 0;
  visibility: hidden;
}
.map-tooltip b {
  font-weight: 600;
}
.map-tooltip span {
  color: var(--acc);
  font-size: 12px;
}
.map-tooltip small {
  color: var(--mut);
  font-size: 11px;
}

/* 3. Bottom 24-Hour Timeline & Meeting Overlap Grid */
.timeline-card {
  padding: 16px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
}
.timeline-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.timeline-header-bar h2 {
  font-size: 18px;
}
.timeline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-scroll-wrap {
  position: relative;
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--bd);
  background: rgba(0, 0, 0, 0.05);
}

.timeline-grid {
  display: flex;
  flex-direction: column;
  min-width: 780px;
  position: relative;
}

.tl-row {
  display: grid;
  grid-template-columns: 150px repeat(24, 1fr);
  border-bottom: 1px solid rgba(120, 140, 160, 0.12);
}
.tl-row:last-child {
  border-bottom: none;
}

.tl-header {
  background: rgba(120, 140, 160, 0.08);
  font-size: 11px;
  font-weight: 600;
  color: var(--mut);
}

.tl-label-col {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid rgba(120, 140, 160, 0.12);
  background: var(--glass);
  position: sticky;
  left: 0;
  z-index: 2;
}
.tl-label-col b {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
.tl-label-col small {
  font-size: 11px;
  color: var(--mut);
}

.tl-hour-col {
  padding: 6px 0;
  text-align: center;
  font-size: 10px;
  color: var(--mut);
  border-right: 1px solid rgba(120, 140, 160, 0.08);
  cursor: pointer;
}
.tl-hour-col:hover {
  background: rgba(255, 138, 61, 0.15);
}

.tl-cell {
  height: 28px;
  border-right: 1px solid rgba(120, 140, 160, 0.08);
  cursor: pointer;
  transition: opacity .15s ease;
}
.tl-cell:hover {
  opacity: 0.8;
}

.tl-cell.work {
  background: var(--good);
  opacity: 0.85;
}
.tl-cell.mid {
  background: var(--mid);
  opacity: 0.85;
}
.tl-cell.night {
  background: var(--night);
  opacity: 0.35;
}

/* Overlap Row */
.tl-overlap-row {
  background: rgba(120, 140, 160, 0.06);
}
.tl-overlap-row .tl-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.tl-overlap-row .tl-cell.all-overlap {
  background: var(--good);
  color: #fff;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.15);
}
.tl-overlap-row .tl-cell.part-overlap {
  background: var(--mid);
  color: #222;
}
.tl-overlap-row .tl-cell.no-overlap {
  background: transparent;
}

/* Scrubber Needle */
.tl-scrubber-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--acc);
  box-shadow: 0 0 10px var(--acc);
  pointer-events: none;
  z-index: 5;
  transition: left .1s ease-out;
}
.tl-scrubber-line::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 8px var(--acc);
}
.scrubber-time {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg1);
  padding: 2px 6px;
  border-radius: 6px;
  font: 700 11px Outfit, Inter, sans-serif;
  white-space: nowrap;
}

/* Legend */
.map-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--mut);
  margin-top: 10px;
  flex-wrap: wrap;
}
.map-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* City Search Modal */
.city-search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.city-search-modal.hid {
  display: none;
}
.search-modal-box {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.search-input-wrap {
  position: relative;
}
.search-input-wrap input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--bd);
  background: var(--glass);
  color: var(--ink);
  font: 500 15px Inter, sans-serif;
  outline: none;
}
.search-input-wrap input:focus {
  border-color: var(--acc);
  box-shadow: 0 0 16px var(--glow);
}
.search-results-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.search-item {
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background .15s ease;
}
.search-item:hover {
  background: rgba(255, 138, 61, 0.15);
}
.search-item b {
  color: var(--ink);
}
.search-item span {
  color: var(--mut);
  font-size: 12px;
}

/* Toast */
.map-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  padding: 10px 20px;
  border-radius: 999px;
  font: 600 13px Inter, sans-serif;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 300;
}
.map-toast.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
  .map-viewport {
    aspect-ratio: 16 / 10;
    min-height: 320px;
  }
  .map-controls-toolbar {
    top: 10px;
    right: 10px;
    gap: 6px;
  }
  .map-controls-toolbar.left-bar {
    right: auto;
    left: 10px;
  }
  .map-control-btn {
    width: 30px;
    height: 30px;
    font-size: 13px;
    border-radius: 10px;
  }
  .tl-row {
    grid-template-columns: 120px repeat(24, 1fr);
  }
  .tl-label-col {
    padding: 6px 8px;
  }
}
