/* 基本配色与变量 */
:root {
  --text-color: #333;
  --muted-color: #6c757d;
  --bg-soft: #fff7fb;
  --brand-primary: #9c27b0;
  --brand-accent: #ff6f61;
  --petal-color: #ffb6b3; /* soft default petal */
  --surface: #ffffff;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --radius: 16px;

  /* Map common Bootstrap button variables to our theme so .btn and outline variants use theme colors */
  --bs-primary: var(--brand-primary);
  /* also map legacy/bootstrap color tokens that may be used by compiled bootstrap CSS */
  --bs-blue: var(--brand-primary);
  --bs-info: var(--brand-accent);
  --bs-btn-color: var(--brand-primary);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--brand-primary);
  --bs-btn-hover-border-color: var(--brand-primary);
  --bs-btn-hover-bg: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--brand-accent);
  --bs-btn-active-border-color: var(--brand-accent);
  --bs-btn-disabled-color: #6c757d;
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: #6c757d;
  --bs-btn-focus-shadow-rgb: 156,39,176; /* fallback - will be tinted by theme variables where possible */
}

/* 主题：玫瑰（默认） */
:root[data-theme="rose"] {
  --brand-primary: #9c27b0;
  --brand-accent: #ff6f61;
  --bg-soft: #fff7fb;
}
/* 主题：蜜桃 (peach) */
:root[data-theme="peach"] {
  --brand-primary: #bc6c25;
  --brand-accent: #ff9a76;
  --bg-soft: #fff6f1;
  --petal-color: #ffd1b8;
}
/* 主题：珊瑚 (coral) */
:root[data-theme="coral"] {
  --brand-primary: #c63d2f;
  --brand-accent: #ff7a59;
  --bg-soft: #fff7f5;
  --petal-color: #ffb39a;
}
/* 主题：暖金 */
:root[data-theme="warm-gold"] {
  --brand-primary: #8d6e63;
  --brand-accent: #ffb74d;
  --bg-soft: #fff9f0;
}

html, body {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Expose safe-area inset top as a CSS variable so JS can read it if needed. */
:root { --safe-inset-top: env(safe-area-inset-top, 0px); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--text-color);
  background: #fff;
}

.hero {
  /* gentle gradient that adapts to current theme colors */
  background: linear-gradient(135deg, rgba(0,0,0,0.02), rgba(0,0,0,0.01));
}
/* enhance hero slightly using brand colors via overlay pseudo-element */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(0,0,0,0), rgba(0,0,0,0));
  mix-blend-mode: screen;
}

.hero .display-4 {
  font-weight: 700;
}

/* 文艺标题 */
.text-gradient {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.heading-glam { letter-spacing: 0.5px; }

.section-title {
  font-weight: 700;
  position: relative;
}
.section-title::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -10px;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  border-radius: 2px;
}

.badge-accent {
  background: var(--brand-accent);
}

.btn-gradient {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  border: none;
  box-shadow: var(--shadow);
}
.btn-gradient:hover {
  opacity: 0.9;
  color: #fff;
}

/* Make outline / interactive controls adopt theme colors */
.nav-link { color: var(--text-color); transition: color .18s ease; }
/* stronger specificity to override Bootstrap defaults */
.navbar .nav-link:hover, .navbar .nav-link:focus, .navbar .nav-link.active { color: var(--brand-primary) !important; }

/* Outline style for focus visible using brand accent */
:where(button, a, .form-select):focus { outline: none; box-shadow: 0 0 0 4px rgba(0,0,0,0.03); }

/* Use brand for outline buttons and map-load button */
/* Strongly override Bootstrap outline primary colors */
.btn-outline-primary, a.btn-outline-primary, button.btn-outline-primary {
  color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  background: transparent !important;
}
/* Explicitly reference CSS variables Bootstrap expects to ensure consistent color usage */
.btn-outline-primary {
  color: var(--bs-btn-color, var(--brand-primary)) !important;
  background-color: var(--bs-btn-bg, transparent) !important;
  border-color: var(--bs-btn-border-color, var(--brand-primary)) !important;
}
/* hover / focus / active states */
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active,
a.btn-outline-primary:hover, a.btn-outline-primary:focus, button.btn-outline-primary:hover {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)) !important;
  color: #fff !important;
  border-color: var(--brand-primary) !important;
}
/* Smooth transition and subtle lift on hover for tactile feedback */
.btn-outline-primary, a.btn-outline-primary, button.btn-outline-primary {
  transition: transform .14s ease, box-shadow .14s ease, opacity .14s ease, background .18s ease;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active,
a.btn-outline-primary:hover, a.btn-outline-primary:focus, button.btn-outline-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}
/* Explicit map-load button styling (stronger) */
.map-skeleton .btn-load-map, .btn-load-map.btn-outline-primary {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: var(--shadow) !important;
}
.map-skeleton .btn-load-map:hover, .btn-load-map.btn-outline-primary:hover { opacity: 0.95 !important; }

/* Ensure nav links also override Bootstrap when active/hover */
.navbar .nav-link { color: var(--text-color) !important; }
.navbar .nav-link:hover, .navbar .nav-link:focus, .navbar .nav-link.active { color: var(--brand-primary) !important; }

/* Target the specific map link buttons and enforce theme styling (Chrome default blue override) */
/* Specific map link buttons: cover link, visited, hover, active and focus states */
#link-ceremony-gaode:link, #link-ceremony-gaode:visited,
#link-ceremony-gaode:hover, #link-ceremony-gaode:active, #link-ceremony-gaode:focus,
#link-ceremony-google:link, #link-ceremony-google:visited,
#link-ceremony-google:hover, #link-ceremony-google:active, #link-ceremony-google:focus,
#link-banquet-gaode:link, #link-banquet-gaode:visited,
#link-banquet-gaode:hover, #link-banquet-gaode:active, #link-banquet-gaode:focus,
#link-banquet-google:link, #link-banquet-google:visited,
#link-banquet-google:hover, #link-banquet-google:active, #link-banquet-google:focus {
  color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  background: transparent !important;
  text-decoration: none !important;
}
#link-ceremony-gaode:hover, #link-ceremony-google:hover, #link-banquet-gaode:hover, #link-banquet-google:hover,
#link-ceremony-gaode:focus, #link-ceremony-google:focus, #link-banquet-gaode:focus, #link-banquet-google:focus {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)) !important;
  color: #fff !important;
  border-color: var(--brand-primary) !important;
}

/* Ensure the map load buttons show theme color even when Chrome applies link styles */
.map-skeleton .btn-load-map, .btn-load-map {
  background: transparent !important;
  color: var(--brand-primary) !important;
  border: 1px solid var(--brand-primary) !important;
}
.map-skeleton .btn-load-map:hover, .btn-load-map:hover { opacity: 0.98 !important; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.08); background: linear-gradient(90deg, color-mix(in srgb, var(--brand-primary) 85%, var(--brand-accent) 15%)) !important; color: #fff !important; }

/* Map link buttons (A tags) hover highlight */
#link-ceremony-gaode, #link-ceremony-google, #link-banquet-gaode, #link-banquet-google {
  transition: transform .14s ease, box-shadow .14s ease, background .18s ease, color .12s ease;
}
#link-ceremony-gaode:hover, #link-ceremony-google:hover, #link-banquet-gaode:hover, #link-banquet-google:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

/* Subtle decorative accent on glass cards to carry theme */
.card-glass { position: relative; overflow: hidden; }
.card-glass::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  opacity: 0.10;
  pointer-events: none;
}

/* Make small badges and counters reflect theme */
.badge-accent { background: var(--brand-accent); color: #fff; }
.carousel-counter { background: linear-gradient(90deg, color-mix(in srgb, var(--brand-primary) 28%, black 0%), rgba(0,0,0,0.45)); }

.navbar-blur {
  backdrop-filter: saturate(160%) blur(8px);
  background: rgba(255,255,255,0.7) !important;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* When using a fixed navbar, add top padding so content isn't hidden under it */
/* reduce default top padding slightly for mobile */
body { padding-top: 56px; }
.navbar-blur { z-index: 1030; }

.timeline {
  border-left: 2px solid rgba(0,0,0,0.1);
  margin-left: 1rem;
  padding-left: 1rem;
}
.timeline .item::marker { color: var(--brand-primary); }

.card-glass {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: var(--radius);
}

.section-divider {
  height: 24px;
  background: radial-gradient(50% 100% at 50% 0%, rgba(0,0,0,0.06), rgba(0,0,0,0) 70%);
}

.footer {
  background: var(--bg-soft);
}

/* 祝福墙样式 */
.blessing .card-body { min-height: 120px; }

/* 花瓣动画层 */
.petal-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.petal { position: absolute; width: 10px; height: 14px; background: var(--petal-color); opacity: 0.85; border-radius: 60% 40% 60% 40%/60% 40% 60% 40%; filter: blur(0.2px); animation: fall 12s linear infinite; transform-origin: center; }
@keyframes fall { from { transform: translateY(-10%) rotate(0deg); } to { transform: translateY(120vh) rotate(360deg); } }

/* 滚动显现 */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* Map placeholder skeleton */
.map-placeholder { position: relative; display:flex; align-items:center; justify-content:center; background: transparent; border-radius:12px; overflow:hidden; width:100%; max-width:100%; aspect-ratio: 16 / 9; }
.map-skeleton { position: relative; display: flex; align-items: center; justify-content: center; background: transparent; height:100%; width:100%; padding:0; }
.map-skeleton .btn-load-map { min-width: 140px; }

/* 浮动按钮 */
.fab { position: fixed; right: 16px; bottom: 16px; background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)); color: #fff; padding: 12px 16px; border-radius: 999px; box-shadow: var(--shadow); text-decoration: none; font-weight: 600; }
.fab:focus { outline: 3px solid rgba(156,39,176,0.3); outline-offset: 2px; }

/* 小屏优化 */
@media (max-width: 576px) {
  .display-4 { font-size: 2.0rem; }
  /* globally reduce base font-size slightly on phones so the UI feels more compact */
  html { font-size: 15px; }
  /* tighten hero spacing on very small screens to reduce top white space */
  .hero { padding-top: 0.02rem !important; padding-bottom: 0.5rem !important; }
  .hero .container.py-4 { padding-top: 0.12rem !important; padding-bottom: 0.5rem !important; }
  .hero .display-4.mt-3 { margin-top: 0.12rem !important; }
  /* tighten navbar vertical padding */
  .navbar { padding-top: 0.02rem; padding-bottom: 0.02rem; }
  /* lower global top padding; JS will measure and reduce further when safe */
  body { padding-top: 28px; }
}

/* Navbar mobile selectors: ensure compact size and spacing */
@media (max-width: 992px) {
  /* mobile visible selects container */
  .navbar .form-select.form-select-sm { font-size: 1rem; line-height: 1.3; padding: 0.25rem 0.5rem; height: 36px; }
  .navbar .d-lg-none { gap: 0.5rem; }
  /* visually hide native selects but keep them accessible to assistive tech */
  .navbar .mobile-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  /* custom pop menu */
  .pop-menu { position: fixed; /* use fixed to avoid ancestor transforms affecting position */ min-width: 180px; background: #fff; border: 1px solid rgba(0,0,0,0.12); border-radius: 10px; box-shadow: 0 8px 22px rgba(0,0,0,0.12); padding: 6px; z-index: 2000; }
  .pop-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; font-size: 16px; line-height: 1.4; }
  .pop-item:hover { background: rgba(0,0,0,0.04); }
}

/* Reusable visually-hidden native control for mobile (outside navbar too) */
@media (max-width: 992px) {
  .mobile-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
}

/* RSVP mobile pop button basic sizing to match form controls */
@media (max-width: 576px) {
  .rsvp-pop-btn { height: 38px; font-size: 1rem; }
}

@media (max-width: 420px) {
  .navbar .form-select.form-select-sm { font-size: 1rem; height: 36px; }
}

/* Even smaller base font on very small narrow phones */
@media (max-width: 420px) {
  html { font-size: 14px; }
}

/* Make primary action buttons and map/share buttons more compact on small devices */
@media (max-width: 576px) {
  /* Reduce large button sizing (used for hero actions) */
  .btn-lg {
    padding: 6px 10px;
    font-size: 0.95rem;
    border-radius: 10px;
  }

  /* Tighter default button sizing for outline and primary variants used in maps/list */
  .btn, .btn-outline-primary, .btn-outline-secondary, .btn-gradient {
    padding: 6px 10px;
    font-size: 0.95rem;
    min-width: 0; /* allow buttons to shrink to content width */
  }

  /* Make floating action button slightly smaller on very small phones */
  .fab {
    padding: 8px 12px;
    right: 12px;
    bottom: 12px;
    font-size: 0.95rem;
  }

  /* Map load button inside skeleton should fit without expanding container */
  .btn-load-map { padding: 6px 10px; font-size: 0.95rem; }

  /* Ensure gap spacing remains comfortable but not excessive */
  .d-flex.gap-2, .d-flex.gap-3 { gap: 8px !important; }

  /* Center hero action buttons (添加到日历 / 分享邀请) on small screens */
  .hero .d-flex {
    justify-content: center !important;
    align-items: center;
    flex-wrap: wrap;
  }

  /* Center map link buttons (高德地图 / Google 地图) in venue sections */
  #venue .d-flex { justify-content: center !important; }

  /* Ensure the map skeleton's load button stays centered (it already is, but ensure no wide min-width) */
  .map-skeleton { padding: 12px; }
  .map-skeleton .btn-load-map { min-width: 0; }
}

/* Enlarge native dropdown option text where supported */
.navbar select option, .navbar select optgroup { font-size: 16px !important; line-height: 1.5 !important; }
/* Some WebKit/Blink implementations honor font-size on select if repeated on element */
.navbar select { font-size: 16px; }

/* RSVP form: ensure select controls and their dropdown options are readable on small devices
  Reuse the same approach as navbar selects so native pickers show larger option text. */
#rsvp select option, #rsvp select optgroup { font-size: 16px !important; line-height: 1.4 !important; }
#rsvp select { font-size: 16px; }

/* Keep collapsed navbar left-aligned on small screens (minimal, safe) */
@media (max-width: 991.98px) {
  .navbar-collapse.show .navbar-nav.ms-auto { margin-left: 0 !important; }
  .navbar-collapse .navbar-nav { text-align: left; }
  .navbar-collapse .nav-link { padding-left: 1rem; }
}

/* Stronger: make collapsed navbar a full-width left-aligned panel so it won't shift
   This applies only on small/medium viewports where the collapse is used. */
@media (max-width: 991.98px) {
  /* Keep navbar single-line top bar; prevent items from wrapping */
  .navbar .container { display: flex; align-items: center; flex-wrap: nowrap; padding-left: 12px; padding-right: 12px; position: relative; }
  .navbar .navbar-toggler { order: 0; }
  /* Mobile selectors inline on the right, not overlapping */
  .navbar .d-lg-none { order: 1; margin-left: auto; display: flex; align-items: center; gap: 8px; }
  .navbar .d-lg-none .form-select { height: 34px; }
  /* Render collapsed menu as an absolute overlay below the bar so it doesn't push items.
     Position relative on container so fixed-top navbar stays fixed at viewport top. */
  .navbar .navbar-collapse,
  .navbar .navbar-collapse.show { position: absolute !important; top: 100% !important; left: 0 !important; right: 0 !important; padding: 0.25rem 0; background: rgba(255,255,255,0.98); box-shadow: 0 6px 12px rgba(0,0,0,0.06); border-radius: 0 0 8px 8px; }
  .navbar .navbar-collapse .navbar-nav { width: 100%; align-items: flex-start; }
  .navbar-collapse.show .navbar-nav.ms-auto { margin-left: 0 !important; margin-right: auto !important; }
}

/* 无障碍与动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Photo carousel styles */
.carousel-root {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f8f8f8;
}
.carousel-track {
  display: flex;
  transition: transform 320ms cubic-bezier(.22,.9,.39,1);
  will-change: transform;
}
.carousel-slide {
  min-width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}
.carousel-slide img { display:block; width:100%; height:auto; border-radius:12px; object-fit:contain; background:#f8f8f8; }

/* Limit image height so a tall photo won't exceed viewport excessively but keep whole image visible */
.carousel-root { max-height: 80vh; display:flex; align-items:center; justify-content:center; }
.carousel-slide { display:flex; align-items:center; justify-content:center; flex: 0 0 100%; width: 100%; }
/* Ensure full image is visible: constrain both width and height while preserving aspect ratio */
.carousel-slide img {
  max-height: 78vh; /* leave some space for header/footer */
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
}

/* For very tall portrait images, also ensure not to overflow viewport width by limiting width */
@media (max-width: 420px) {
  .carousel-slide img { max-height: 72vh; max-width: 96%; }
}

/* Hide visual indicators (thumbnails/dots). We show numeric counter only. */
.carousel-indicators { display: none !important; }
.carousel-counter { position: absolute; right: 12px; top: 12px; background: rgba(0,0,0,0.45); color:#fff; padding:6px 10px; border-radius:999px; font-weight:600; z-index:8; font-size:0.95rem; }

/* Ensure tall images won't overflow on very small devices */
@media (max-width: 420px) {
  .carousel-root { max-height: 56vh; }
  .carousel-slide img { max-height: 56vh; }
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 6;
}
.carousel-prev { left: 12px; }
.carousel-next { right: 12px; }
.carousel-btn:focus { outline: 2px solid rgba(255,255,255,0.6); }
.carousel-indicators {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  display: flex;
  gap: 8px;
  z-index: 7;
}
.carousel-indicators button {
  width: 10px; height: 10px; border-radius: 999px; border: none; background: rgba(255,255,255,0.7); padding:0; cursor:pointer;
}
.carousel-indicators button[aria-selected="true"] { background: var(--brand-primary); }

/* Hide controls on very small screens and rely on swipe, but keep indicators */
@media (max-width: 576px) {
  .carousel-btn { display: none; }
  .carousel-root { border-radius: 12px; }
}

/* Venue images (ceremony & banquet)
   Goal: never crop the image. Fit within the available width and the viewport height
   while preserving aspect ratio. On desktop we keep the original 16:9 container,
   on mobile we let the image size itself freely up to the viewport. */
.map-placeholder {
  position: relative;
  display: block;
  background: #f8f8f8;
}
.map-placeholder img,
.map-skeleton img {
  display: block;
  border-radius: inherit; /* use container's rounded corners */
  background: #f8f8f8;
  object-fit: contain;
  /* Allow the image to size by its intrinsic aspect ratio, never forcing both axes */
  width: auto;
  height: auto;
  max-width: 100%;
  /* Cap height to viewport so tall images don’t exceed a screen */
  max-height: 100dvh;
  margin: 0 auto;
}

/* Large screens: keep the 16:9 container behavior, but still avoid excessive height */
@media (min-width: 992px) {
  /* On large screens allow the 16:9 container to scale, but cap height so it doesn't become too tall */
  .map-placeholder { max-height: 56vh; }
  .map-placeholder img,
  .map-skeleton img {
    max-height: 100%;
  }
}

/* Small screens: remove fixed aspect-ratio container and let image scale to device */
@media (max-width: 576px) {
  /* Override earlier container rule (aspect-ratio:16/9 & overflow:hidden) */
  .map-placeholder { max-height: none; aspect-ratio: auto; overflow: visible; }
  .map-placeholder img, .map-skeleton img { max-height: calc(100dvh - 8px); max-width: 100%; width: auto; height: auto; }
}

/* Very small narrow phones */
@media (max-width: 420px) {
  .map-placeholder { max-height: none; }
  .map-placeholder img, .map-skeleton img { max-height: calc(100dvh - 8px); }
}
