/* ========== Variables ========== */
:root {
  --bg: #faf8f4;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #6b6560;
  --text-muted: #a8a098;
  --border: rgba(0,0,0,0.06);
  --radius: 16px;
  --radius-sm: 12px;
}

/* ========== Reset & Base ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  background: #1a1a1a;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
}

/* ========== App Container ========== */
.app {
  max-width: 430px;
  margin: 0 auto;
  width: 100%;
  height: 100vh;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

/* ========== Pages ========== */
.page {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.4s ease;
}
.page.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* ================================================================
   HOME
   ================================================================ */
#page-home { z-index: 20; }

.home-bg-slides {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.home-bg-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.8s ease, transform 10s ease;
  transform: scale(1);
}

.home-bg-slide:nth-child(1) { background-image: url('1.jpg'); }
.home-bg-slide:nth-child(2) { background-image: url('2.jpg'); }
.home-bg-slide:nth-child(3) { background-image: url('3.jpg'); }
.home-bg-slide:nth-child(4) { background-image: url('4.jpg'); }
.home-bg-slide:nth-child(5) { background-image: url('5.jpg'); }
.home-bg-slide:nth-child(6) { background-image: url('6.jpg'); }

.home-bg-slide.active {
  opacity: 1;
  transform: scale(1.06);
}

.home-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0.03) 35%),
    linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.08) 50%);
}

.home-content {
  position: relative;
  z-index: 5;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  padding-top: 60px;
  padding-bottom: 40px;
}

.home-top { flex-shrink: 0; }

.init-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
}
.init-error-content {
  text-align: center;
  color: rgba(255,255,255,0.8);
}
.init-error-content p {
  font-size: 15px;
  margin-bottom: 16px;
}
.init-error-content button {
  padding: 10px 24px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 100px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 500;
}

#home-counter {
  font-weight: 700;
  color: #fff;
  font-size: 13px;
}

.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 32px;
}

.home-welcome {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  font-weight: 400;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.home-title {
  font-size: 34px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  letter-spacing: -0.5px;
  margin-bottom: 24px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

/* Search */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-bar.open {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.25);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.home-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
}
.home-input::placeholder { color: rgba(255,255,255,0.4); }

.search-chevron {
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.search-bar.open .search-chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.search-dropdown {
  position: fixed;
  background: rgba(30,30,30,0.92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 8px;
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 200;
  animation: dropIn 0.25s ease;
  width: 350px;
  max-width: calc(100vw - 48px);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-dropdown.hidden { display: none; }

.dropdown-item {
  padding: 12px 16px;
  border-radius: 10px;
  color: rgba(255,255,255,0.85);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-item:hover, .dropdown-item:active {
  background: rgba(255,255,255,0.1);
}

.dropdown-item .city-name {
  font-weight: 500;
}

.dropdown-item .city-province {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

/* Bottom CTA */
.home-bottom { flex-shrink: 0; padding-bottom: 8px; }

.btn-primary-dark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 160px;
  margin: 0 auto;
  padding: 14px 24px;
  white-space: nowrap;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.25), rgba(255,255,255,0.1));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
}
.btn-primary-dark:active { transform: scale(0.97); }

/* ================================================================
   MODAL — Glass bottom sheet
   ================================================================ */
.modal {
  position: absolute;
  inset: 0;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 24px 24px 0 0;
  padding: 12px 24px 40px;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Glass variant */
.modal-sheet.glass {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255,255,255,0.15);
  border-bottom: none;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.3);
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #fff;
}

.modal-days-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.day-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  transition: all 0.25s ease;
}
.day-option:active { transform: scale(0.98); }

.day-option.selected {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
}

.day-icon { font-size: 28px; flex-shrink: 0; }

.day-label {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.day-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.glass-btn {
  width: 100%;
  padding: 16px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}
.glass-btn:active { transform: scale(0.97); }

/* ================================================================
   TRANSITION
   ================================================================ */
.page-transition {
  overflow: hidden;
}

.transition-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 0.4s ease;
}

.transition-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.transition-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 5;
}

.transition-text {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.5px;
  transition: opacity 0.4s ease;
  min-height: 22px;
}

/* Glass progress bar */
.transition-progress-track {
  width: 200px;
  height: 6px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.transition-progress-track.visible {
  opacity: 1;
}

.transition-progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, rgba(255,255,255,0.85), rgba(255,255,255,0.55));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-retry-btn {
  position: absolute;
  bottom: 40vh;
  padding: 12px 32px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}
.transition-retry-btn:active { transform: scale(0.95); }

.transition-retry-btn {
  position: absolute;
  bottom: 40vh;
  padding: 12px 32px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}
.transition-retry-btn:active { transform: scale(0.95); }

/* ================================================================
   RESULT PAGE
   ================================================================ */
.page-result { background: var(--bg); overflow: hidden; }

.result-page {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.result-visual {
  width: 100%;
  height: 240px;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 50% 50% / 0 0 30px 30px;
}
.result-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.result-visual img.error { display: none; }
.result-visual .fallback-visual {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: #fff;
}

.result-visual-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 50%, rgba(0,0,0,0.5));
  border-radius: inherit;
}

.back-btn {
  position: absolute;
  top: 16px; left: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.result-content { padding: 0 24px 24px; }

.result-name {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.06);
}

.result-quote {
  position: relative;
  margin: 0 0 24px;
  padding: 16px 20px;
  border-left: 3px solid #c9a96e;
  background: linear-gradient(135deg, rgba(201,169,110,0.06), rgba(201,169,110,0.02));
  border-radius: 0 12px 12px 0;
}

.result-quote::before {
  content: '"';
  position: absolute;
  top: -4px;
  left: 10px;
  font-size: 48px;
  font-weight: 700;
  color: #c9a96e;
  line-height: 1;
  opacity: 0.3;
}

.result-quote p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  font-style: italic;
  margin: 0;
  padding-left: 16px;
}

.result-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 0 1px 8px rgba(0,0,0,0.04);
  text-align: center;
}
.info-icon { font-size: 20px; margin-bottom: 6px; }
.info-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.info-value { font-size: 13px; font-weight: 600; }
.info-value.skeleton, .info-label.skeleton, .info-icon.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  min-width: 40px;
  min-height: 14px;
  color: transparent !important;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.result-highlights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.highlight-item {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

.highlight-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.highlight-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Skeleton shimmer */
.highlight-item.skeleton, .tag.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  min-height: 20px;
}
.tag.skeleton { min-height: 24px; min-width: 60px; border-radius: 100px; }
.highlight-item.skeleton { min-height: 50px; margin-bottom: 8px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Footer */
.result-footer {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  padding-bottom: 32px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.btn-outline, .btn-dark {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-outline {
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
}
.btn-outline.btn-sm { padding: 10px 24px; font-size: 13px; }

.btn-dark {
  border: none;
  background: var(--text);
  color: #fff;
}

.btn-outline:active, .btn-dark:active { transform: scale(0.97); }

/* Share overlay */
.share-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.share-overlay:not(.hidden) { opacity: 1; pointer-events: auto; }
.share-overlay.hidden { opacity: 0; pointer-events: none; }

/* Toast */
.toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 14px 28px;
  border-radius: 100px;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 500;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-20px);
}

.share-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  width: 100%;
}
.share-hint { font-size: 13px; color: rgba(255,255,255,0.5); }

.share-preview-img {
  max-width: 80%;
  max-height: 60vh;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ========== Share Card (hidden, for html2canvas) ========== */
.share-card {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 750px;
  height: 1334px;
  background: #faf8f4;
  border-radius: 24px;
  overflow: hidden;
  flex-shrink: 0;
}

.share-card-header {
  width: 100%;
  height: 400px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 160px;
  overflow: hidden;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}
.share-card-header-emoji {
  font-size: 160px;
  position: relative;
  z-index: 2;
}

.share-card-body {
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
}
.share-card-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.share-card-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.share-card-logo-text {
  font-size: 22px;
  font-weight: 600;
  color: #333;
}
.share-card-name {
  font-size: 52px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 16px;
  line-height: 1.2;
}
.share-card-quote {
  font-size: 28px;
  color: #6b6560;
  margin-bottom: 40px;
  font-style: italic;
  line-height: 1.5;
}
.share-card-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 40px;
}
.share-card-highlights .tag {
  padding: 12px 24px;
  background: rgba(0,0,0,0.06);
  border-radius: 100px;
  font-size: 24px;
  color: #333;
}
.share-card-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 24px;
  color: #555;
  margin-bottom: 32px;
}
.share-card-trip {
  font-size: 24px;
  color: #888;
  margin-bottom: 32px;
}
.share-card-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.share-card-qr img {
  border-radius: 12px;
}
.share-card-footer {
  text-align: center;
  font-size: 22px;
  color: #a8a098;
  padding-top: 32px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
