/* ================================================================
   K12 Search Cards - LoveForm Exact Match
   Reference: https://www.loveform.com/s/Miami/homes
   ================================================================ */

/* Card Container */
.loveform-listing-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.loveform-listing-card:hover {
  transform: translateY(-2px);
}

/* Image Container - LoveForm uses 20:19 near-square ratio */
.loveform-listing-card__image {
  position: relative;
  width: 100%;
  aspect-ratio: 20 / 19; /* LoveForm's near-square ratio - NOT 4:3 */
  border-radius: 12px;
  overflow: hidden;
  background: #f7f7f7;
}

.loveform-listing-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.loveform-listing-card:hover .loveform-listing-card__image img {
  transform: scale(1.02);
}

/* ==========================================================================
   SMART CAROUSEL (Desktop + Map Popups)
   Mobile overrides live in mobile-search.css / mobile-card.css
   ========================================================================== */

.k12-smart-carousel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.k12-smart-carousel__track {
  display: flex;
  width: 100%;
  height: 100%;
  will-change: transform;
  transition: transform 0.22s ease;
}

.k12-smart-carousel__track img {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.k12-smart-carousel__btn {
  position: absolute;
  top: 50%;
  z-index: 12;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.k12-smart-carousel__btn:hover {
  background: #ffffff;
}

.k12-smart-carousel:hover .k12-smart-carousel__btn,
.k12-smart-carousel.is-active .k12-smart-carousel__btn,
.k12-smart-carousel.is-engaged .k12-smart-carousel__btn,
.k12-smart-carousel:focus-within .k12-smart-carousel__btn {
  opacity: 1;
  pointer-events: auto;
}

.k12-smart-carousel__btn:disabled {
  opacity: 0 !important;
  pointer-events: none !important;
}

.k12-smart-carousel__btn--prev {
  left: 10px;
}

.k12-smart-carousel__btn--next {
  right: 10px;
}

.k12-smart-carousel__btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 3;
  fill: none;
}

.k12-smart-carousel__btn svg path {
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.k12-smart-carousel__dots {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 11;
}

/* Make the price "button" read like a text link (Airbnb / LoveForm). */
.k12-price-details-trigger {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.k12-price-details-trigger:focus-visible {
  outline: 2px solid rgba(34, 34, 34, 0.35);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ==========================================================================
   PRICE DETAILS POPOVER (Airbnb-style)
   ========================================================================== */

.k12-price-popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  z-index: 1040;
}

.k12-price-popover {
  position: fixed;
  max-width: min(360px, calc(100vw - 24px));
  min-width: 320px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  z-index: 1045;
}

.k12-price-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #ebebeb;
}

.k12-price-popover__title {
  font-size: 16px;
  font-weight: 600;
  color: #222222;
  letter-spacing: -0.01em;
}

.k12-price-popover__close {
  width: 32px;
  height: 32px;
  border: 1px solid #dddddd;
  border-radius: 999px;
  background: #ffffff;
  color: #222222;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.k12-price-popover__close svg {
  width: 12px;
  height: 12px;
}

.k12-price-popover__close svg path {
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.k12-price-popover__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-size: 14px;
  color: #222222;
}

.k12-price-popover__row span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.k12-price-popover__row span:last-child {
  flex: 0 0 auto;
  white-space: nowrap;
}

.k12-price-popover__row--muted {
  color: #717171;
}

.k12-price-popover__row--discount {
  color: #2ac8c8;
  font-weight: 600;
}

.k12-price-popover__divider {
  height: 1px;
  background: #ebebeb;
  margin: 0 16px;
}

.k12-price-popover--sheet {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: 100%;
  max-width: none;
  min-width: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.22);
}

.k12-smart-carousel__dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease, background 0.2s ease;
  appearance: none;
  /* Override global mobile touch-target min sizes; keep dots visually small. */
  min-width: 0;
  min-height: 0;
}

.k12-smart-carousel__dot.active {
  background: #ffffff;
  transform: scale(1.2);
}

/* ==========================================================================
   MAP POPUP CARD (Google Maps InfoWindow)
   ========================================================================== */

.k12-map-popup-card {
  width: 268px;
  max-width: 268px;
  height: 286px;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.k12-map-popup-card.loveform-listing-card:hover {
  transform: none;
}

.k12-map-popup__image {
  position: relative;
  flex: 0 0 60%;
  width: 100%;
  border-radius: 0;
  aspect-ratio: auto;
  overflow: hidden;
  background: #f7f7f7;
}

.k12-map-popup__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.k12-map-popup__image:has(img[src*="default-school.jpg"]),
.k12-map-popup__image:has(img[src*="placeholder-school.jpg"]) {
  background: linear-gradient(135deg, #f7f7f7 0%, #e9ecef 100%);
}

.k12-map-popup__image:has(img[src*="default-school.jpg"])
  img[src*="default-school.jpg"],
.k12-map-popup__image:has(img[src*="placeholder-school.jpg"])
  img[src*="placeholder-school.jpg"] {
  opacity: 0;
}

.k12-map-popup__image:has(img[src*="default-school.jpg"])::before,
.k12-map-popup__image:has(img[src*="placeholder-school.jpg"])::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 96px 96px;
  opacity: 0.85;
  pointer-events: none;
  background-image: url("/assets/SVG/3d/school/school_no_photo_512.png");
}

.k12-map-popup__image:has(img[src*="default-school.jpg"])::after,
.k12-map-popup__image:has(img[src*="placeholder-school.jpg"])::after {
  content: "No photo yet";
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #222222;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.k12-map-popup__content {
  flex: 1 1 40%;
  min-width: 0;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  background: #ffffff;
}

.k12-map-popup__content .loveform-listing-card__type,
.k12-map-popup__content .loveform-listing-card__rating,
.k12-map-popup__content .loveform-listing-card__name,
.k12-map-popup__content .loveform-listing-card__details,
.k12-map-popup__content .loveform-listing-card__price {
  font-size: 13px;
}

.k12-map-popup__content .loveform-listing-card__name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.k12-map-popup__content .loveform-listing-card__price {
  margin: auto 0 0;
}

.k12-map-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.k12-map-popup__type {
  font-size: 13px;
  font-weight: 600;
  color: #222222;
}

.k12-map-popup__rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #222222;
  white-space: nowrap;
}

.k12-map-popup__rating svg {
  width: 12px;
  height: 12px;
}

.k12-map-popup__rating--new svg {
  opacity: 0.5;
}

.k12-map-popup__name {
  font-size: 14px;
  font-weight: 600;
  color: #222222;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.k12-map-popup__price {
  font-size: 14px;
  line-height: 1.25;
  margin-top: auto;
}

.k12-map-popup__price-amount {
  font-weight: 600;
  color: #222222;
  text-decoration: underline;
}

.k12-map-popup__price-suffix {
  color: #222222;
  font-weight: 400;
}

.k12-map-popup__actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.k12-map-popup__actions .loveform-listing-card__heart {
  position: static;
  top: auto;
  right: auto;
}

.k12-map-popup__close {
  position: static;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #222222;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.k12-map-popup__close svg {
  width: 12px;
  height: 12px;
}

.k12-map-popup__close svg path {
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

/* Map popup matches Airbnb: dots + arrows visible (arrows hide at edges via :disabled) */
.k12-map-popup-card .k12-smart-carousel__dots {
  display: flex;
}

.k12-map-popup-card .k12-smart-carousel__btn {
  opacity: 1;
  pointer-events: auto;
}

/* Use the in-card close button so it can sit next to the heart (Airbnb-style). */
.gm-style-iw:has(.k12-map-popup-card)
  button.gm-ui-hover-effect[aria-label="Close"],
.k12-search-page .gm-style-iw button.gm-ui-hover-effect[aria-label="Close"] {
  display: none !important;
}

.gm-style-iw-c:has(.k12-map-popup-card) {
  padding: 0 !important;
  border-radius: 14px !important;
}

.gm-style-iw-c:has(.k12-map-popup-card) .gm-style-iw-d {
  padding: 0 !important;
  overflow: hidden !important;
}

.gm-style-iw:has(.k12-map-popup-card) {
  padding: 0 !important;
  max-width: none !important;
}

.gm-style-iw:has(.k12-map-popup-card) .gm-style-iw-d {
  overflow: hidden !important;
}

/* Neutral placeholder (when the fallback "default-school.jpg" is used)
   Many schools legitimately have no photo yet; showing the bus placeholder makes the
   whole grid look broken/repetitive. Replace it with a calm gradient + label. */
.loveform-listing-card__image:has(img[src*="default-school.jpg"]),
.loveform-listing-card__image:has(img[src*="placeholder-school.jpg"]) {
  background: linear-gradient(135deg, #f7f7f7 0%, #e9ecef 100%);
}

.loveform-listing-card__image:has(img[src*="default-school.jpg"])
  img[src*="default-school.jpg"],
.loveform-listing-card__image:has(img[src*="placeholder-school.jpg"])
  img[src*="placeholder-school.jpg"] {
  opacity: 0;
}

.loveform-listing-card__image:has(img[src*="default-school.jpg"])::before,
.loveform-listing-card__image:has(img[src*="placeholder-school.jpg"])::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 96px 96px;
  opacity: 0.85;
  pointer-events: none;
  /* No-photo placeholder icon */
  background-image: url("/assets/SVG/3d/school/school_no_photo_512.png");
}

.loveform-listing-card__image:has(img[src*="default-school.jpg"])::after,
.loveform-listing-card__image:has(img[src*="placeholder-school.jpg"])::after {
  content: "No photo yet";
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #222222;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  pointer-events: none;
}

/* Heart Button - Top Right */
.loveform-listing-card__heart {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(34, 34, 34, 0.75);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.loveform-listing-card__heart svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition:
    transform 0.2s ease,
    fill 0.2s ease,
    stroke 0.2s ease;
}

.loveform-listing-card__heart:hover svg {
  transform: scale(1.1);
}

.loveform-listing-card__heart.is-favorited,
.loveform-listing-card__heart.favorited {
  color: #289a96;
}

.loveform-listing-card__heart.is-favorited svg,
.loveform-listing-card__heart.favorited svg {
  fill: currentColor;
  stroke: currentColor;
}

/* Guest Favorite Badge - Yellow, Top Left */
.loveform-listing-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #ffe066;
  color: #222;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.loveform-listing-card__badge svg {
  width: 12px;
  height: 12px;
}

/* Carousel Dots (bottom center of image) */
.loveform-listing-card__dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 10;
}

.loveform-listing-card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transition: all 0.2s ease;
}

.loveform-listing-card__dot.active {
  background: #fff;
  transform: scale(1.2);
}

/* Card Content - Below Image */
.loveform-listing-card__content {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Line 1: Type + Rating */
.loveform-listing-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.loveform-listing-card__type {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  /* Truncate if too long */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.loveform-listing-card__rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  color: #222;
  white-space: nowrap;
  flex-shrink: 0;
}

.loveform-listing-card__rating svg {
  width: 12px;
  height: 12px;
  fill: #222;
}

.loveform-listing-card__rating-count {
  color: #717171;
}

/* Line 2: Name/Description */
.loveform-listing-card__name {
  font-size: 15px;
  color: #717171;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

/* Line 3: Details */
.loveform-listing-card__details {
  font-size: 15px;
  color: #717171;
  line-height: 1.3;
  margin: 0;
}

.loveform-listing-card__details-separator {
  margin: 0 4px;
}

/* Line 4: Availability/Dates */
.loveform-listing-card__availability {
  font-size: 15px;
  color: #717171;
  line-height: 1.3;
  margin: 0;
}

/* Line 5: Price */
.loveform-listing-card__price {
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.3;
}

.loveform-listing-card__price-amount {
  font-weight: 600;
  color: #222;
  text-decoration: underline;
}

.loveform-listing-card__price-suffix {
  color: #222;
  font-weight: 400;
}

.loveform-listing-card__price-unavailable {
  color: #717171;
  font-weight: 500;
}

/* ================================================================
   Highlighted State (from map hover)
   ================================================================ */
.loveform-listing-card.map-highlighted {
  box-shadow: 0 0 0 2px #222;
  border-radius: 12px;
}

/* ================================================================
   Responsive Adjustments
   ================================================================ */
@media (max-width: 767px) {
  .loveform-listing-card__type,
  .loveform-listing-card__name,
  .loveform-listing-card__details,
  .loveform-listing-card__availability,
  .loveform-listing-card__price {
    font-size: 14px;
  }

  .loveform-listing-card__rating {
    font-size: 14px;
  }

  .loveform-listing-card__badge {
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* ================================================================
   Loading Skeleton
   ================================================================ */
.loveform-listing-card--skeleton .loveform-listing-card__image {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.loveform-listing-card--skeleton .loveform-listing-card__type,
.loveform-listing-card--skeleton .loveform-listing-card__name,
.loveform-listing-card--skeleton .loveform-listing-card__details,
.loveform-listing-card--skeleton .loveform-listing-card__price {
  background: #f0f0f0;
  border-radius: 4px;
  color: transparent;
  animation: skeleton-shimmer 1.5s infinite;
}

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