/* ============================================
   BASE RESET
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button, label, input[type="checkbox"] {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================
   APP WRAPPER — 9:16 phone frame
   overflow:hidden clips slide-in panels when
   they are translated off-screen.
   ============================================ */

#app-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 430px;
  max-height: calc(430px * 16 / 9);
  margin: 0 auto;
  overflow: hidden;
}

/* ============================================
   MAP
   ============================================ */

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.leaflet-tile-pane {
  transition: filter 0.5s ease;
}

/* ============================================
   LOCK SCREEN VIGNETTE
   Three zones:
     Top 40%    — fades from opaque (top) → transparent (40%)
     Middle 40% — fully clear (40% → 80%)
     Bottom 20% — fades from transparent (80%) → opaque (100%)

   Kept visible during dom-to-image export so the
   fade effect bakes into the downloaded wallpaper.
   ============================================ */

#lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;

  background:
    /* Top zone: builds opacity from the 40% boundary upward */
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.78)  0%,
      rgba(0, 0, 0, 0.52) 15%,
      rgba(0, 0, 0, 0.18) 30%,
      transparent         40%
    ),
    /* Bottom zone: builds opacity from the 80% boundary downward */
    linear-gradient(
      to bottom,
      transparent         80%,
      rgba(0, 0, 0, 0.14) 87%,
      rgba(0, 0, 0, 0.42) 94%,
      rgba(0, 0, 0, 0.62) 100%
    );
}

/* ============================================
   CIRCLE BUTTON — shared base for all 3 icons
   Position is set individually below.
   ============================================ */

.circle-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.20);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.circle-btn:active {
  transform: scale(0.91);
  background: rgba(0, 0, 0, 0.35);
}

/* Highlight ring when the style panel is open */
#style-trigger.open {
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.20), 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ============================================
   SEARCH TRIGGER — absolute, top-right
   ============================================ */

#search-trigger {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1002;
}

/* ============================================
   SEARCH PANEL — slides down from top
   ============================================ */

#search-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  padding: 16px 16px 12px;
  background: rgba(14, 14, 20, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transform: translateY(-100%);
  transition: transform 0.30s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#search-panel.open {
  transform: translateY(0);
  pointer-events: auto;
}

#search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  overflow: hidden;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 13px 16px;
  font-size: 15px;
  background: transparent;
  color: #fff;
}

#search-input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

#search-btn {
  border: none;
  background: transparent;
  padding: 13px 14px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

#search-btn:hover,
#search-btn:active {
  color: #fff;
}

/* Search results */
#search-results {
  list-style: none;
  background: rgba(22, 22, 32, 0.97);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.2s ease;
}

#search-results.visible {
  max-height: 240px;
  overflow-y: auto;
}

#search-results li {
  padding: 11px 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  line-height: 1.4;
  transition: background 0.15s;
}

#search-results li:first-child { border-top: none; }

#search-results li:hover,
#search-results li:active {
  background: rgba(255, 255, 255, 0.09);
}

#search-results li.status-msg {
  color: rgba(255, 255, 255, 0.38);
  font-style: italic;
  cursor: default;
}

#search-results li.status-msg:hover { background: transparent; }

/* ============================================
   BOTTOM BAR
   Flex column anchored to the bottom.
   #style-cards-panel sits above #bar-icons and
   expands upward — the two zones never overlap.
   ============================================ */

#bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* pointer-events:none on the bar so the transparent gradient
     area passes taps through to the map */
  pointer-events: none;
}

/* ── Style cards panel ── */

#style-cards-panel {
  overflow: hidden;
  /* Closed: collapsed to zero height */
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.30s cubic-bezier(0.4, 0, 0.2, 1),
    opacity    0.22s ease;
  pointer-events: none;
}

#style-cards-panel.open {
  /* 175px comfortably fits the toggle row + card row + padding */
  max-height: 175px;
  opacity: 1;
  pointer-events: auto;
}

/* Inner wrapper provides padding + frosted background */
.cards-inner {
  padding: 14px 20px 10px;
  background: transparent;
}

/* ── Labels toggle ── */

#controls-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  pointer-events: auto;
}

.toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.2px;
}

#labels-toggle {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 26px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 13px;
  transition: background 0.22s ease;
  flex-shrink: 0;
}

#labels-toggle:checked + .toggle-track { background: #34c759; }

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.30);
  transition: transform 0.22s ease;
}

#labels-toggle:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

/* ── Style cards horizontal scroll ── */

#style-drawer {
  width: 100%;
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#style-drawer::-webkit-scrollbar { display: none; }

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
  scroll-snap-align: start;
  background: none;
  border: none;
  padding: 0;
  pointer-events: auto;
}

.style-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.style-card.active .style-thumb {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.30), 0 6px 18px rgba(0, 0, 0, 0.55);
}

.style-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
  text-align: center;
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.4px;
  transition: color 0.25s ease;
}

.style-card.active .style-label {
  color: #fff;
  font-weight: 700;
}

/* ── Icon row ── */

#bar-icons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px 36px;
  pointer-events: none;
}

/* Re-enable pointer events and remove the absolute positioning
   that .circle-btn doesn't have — buttons here are in flex flow */
#bar-icons .circle-btn {
  pointer-events: auto;
}

/* ============================================
   LOADING OVERLAY + SPINNER
   ============================================ */

#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#loading-overlay.visible { display: flex; }

.spinner-ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.90);
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
  color: rgba(255, 255, 255, 0.88);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
  #app-wrapper {
    max-width: 100%;
    max-height: 100%;
  }
}
