/* Range Section Styles */

.range {
  background-color: var(--navy-900);
}

.range__sub {
  color: var(--muted);
  font-size: 1.1rem;
  margin-top: 8px;
  max-width: 600px;
}

/* Filters (Size tiles) */
.range__filters {
  margin-top: 32px;
}

/* On mobile, scrollable row of chips */
.range__sizes-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  /* Hide scrollbar but allow swipe */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.range__sizes-row::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.range__size-tile {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  flex-shrink: 0;
}

.range__size-tile:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background-color: var(--navy-700);
}

.range__size-tile[aria-pressed="true"] {
  background-color: var(--orange);
  border-color: var(--orange);
}

.range__size-tile[aria-pressed="true"] .range__size-name {
  color: var(--navy-950);
  font-weight: 600;
}

.range__size-tile[aria-pressed="true"] .range__size-count {
  background-color: var(--navy-950);
  color: var(--orange);
}

.range__size-name {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.range__size-count {
  font-size: 0.8rem;
  font-weight: 600;
  background-color: var(--navy-950);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}

@media (min-width: 640px) {
  /* On larger screens, tiles in a grid/row */
  .range__sizes-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    overflow-x: visible;
    gap: 12px;
    padding-bottom: 0;
  }
  
  .range__size-tile {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    height: 90px;
  }

  .range__size-name {
    font-size: 1rem;
  }

  .range__size-count {
    margin-top: auto;
  }
}

/* Search bar styling */
.range__search-container {
  margin-top: 24px;
  margin-bottom: 32px;
}

.range__search-wrapper {
  position: relative;
  max-width: 600px;
  width: 100%;
}

.range__search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
}

.range__search-input {
  width: 100%;
  background-color: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 48px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.2s;
  box-sizing: border-box;
}

.range__search-input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.15);
}

.range__search-clear {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

/* Fix: override display:flex when hidden attribute is present */
.range__search-clear[hidden] {
  display: none !important;
}

.range__search-clear:hover {
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Range Grid - always 2 columns below 640px width */
.range__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

@media (min-width: 640px) {
  .range__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .range__grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
  }
}

/* Card Styling */
.range__card {
  background-color: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s, box-shadow 0.3s;
  position: relative;
  box-sizing: border-box;
  animation: rangeFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.range__card:hover, .range__card:focus-visible {
  outline: none;
  transform: translateY(-4px);
  border-color: var(--orange);
  box-shadow: 0 12px 32px rgba(243, 156, 18, 0.1);
}

@keyframes rangeFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Top Panel with Image & Blurred Backdrop */
.range__card-image-panel {
  background: var(--studio);
  aspect-ratio: 4 / 5;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Blur Backdrop */
.range__card-image-panel::before,
.range__dialog-image-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--img) center/cover;
  filter: blur(22px) saturate(1.15);
  transform: scale(1.25);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}

.range__card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background-color: var(--orange);
  color: var(--navy-950);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* framed and intentional image style */
.range__card-image,
.range__dialog-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

.range__card:hover .range__card-image {
  transform: scale(1.03);
}

/* Card Body */
.range__card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.range__card-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.1;
}

.range__card-capacity-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.range__card-capacity {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}

.range__card-size {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.range__card-motor {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.3;
}

.range__card-price {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: auto;
  padding-top: 8px;
}

/* Card Actions */
.range__card-actions {
  padding: 0 16px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Default styling for cards action elements */
.range__card-enquire-btn {
  flex: 1;
  white-space: nowrap !important;
  padding-inline: 14px !important;
  font-size: 0.875rem !important;
  min-height: 40px !important;
}

.range__card-wa-btn {
  flex-shrink: 0;
  width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile responsive card adjustments (at ≤639px) */
@media (max-width: 639px) {
  .range__card-body {
    padding-inline: 12px !important;
  }
  .range__card-actions {
    padding-inline: 12px !important;
    padding-bottom: 12px !important;
    gap: 8px !important;
  }
  .range__card-enquire-btn {
    flex: 1 !important;
    min-height: 44px !important;
    padding: 0 10px !important;
    white-space: nowrap !important;
  }
  .range__card-wa-btn {
    flex-shrink: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
  }
}

/* Empty State */
.range__empty {
  text-align: center;
  padding-block: 48px;
  color: var(--muted);
  font-size: 1.1rem;
}

/* LOCK BODY SCROLL WHEN OPEN */
body.dialog-open {
  overflow: hidden !important;
}

/* Native Dialog Style */
.range__dialog {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  display: none; /* Overridden when open */
  position: fixed;
  z-index: 1000;
}

.range__dialog[open] {
  display: flex;
  align-items: flex-end; /* Bottom sheet on mobile */
  justify-content: center;
}

.range__dialog::backdrop {
  background-color: rgba(4, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Dialog Container */
.range__dialog-container {
  background-color: var(--navy-900);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  width: 100%;
  max-height: 90svh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  border-top: 1px solid var(--line);
  box-sizing: border-box;
}

/* Grab handle for bottom sheet on mobile */
.range__dialog-handle {
  width: 40px;
  height: 4px;
  background-color: var(--line);
  border-radius: 2px;
  margin: 12px auto 4px;
  flex-shrink: 0;
}

/* Close Button */
.range__dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--navy-800);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.range__dialog-close:hover {
  background-color: var(--navy-700);
  color: var(--orange);
}

/* Navigation arrows */
.range__dialog-nav {
  position: absolute;
  top: 50%;
  left: 12px;
  right: 12px;
  transform: translateY(-50%);
  display: none; /* Hidden on mobile */
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
  width: calc(100% - 24px);
}

.range__dialog-prev, .range__dialog-next {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--navy-800);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s;
}

.range__dialog-prev:hover, .range__dialog-next:hover {
  background-color: var(--navy-700);
  color: var(--orange);
}

/* Dialog content area */
.range__dialog-content {
  overflow-y: auto;
  padding: 16px 20px 32px;
  flex-grow: 1;
}

.range__dialog-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Image Side inside Dialog */
.range__dialog-image-side {
  width: 100%;
}

.range__dialog-image-panel {
  background: var(--studio);
  border-radius: var(--radius);
  aspect-ratio: 4 / 5;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.range__dialog-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  background-color: var(--orange);
  color: var(--navy-950);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-radius: 999px;
  z-index: 2;
}

/* Info Side inside Dialog */
.range__dialog-info-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.range__dialog-title {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--text);
  text-transform: uppercase;
  line-height: 1;
}

.range__dialog-blurb {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Spec Rows Alignment using a 3-column Grid per row */
.range__dialog-specs {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding-block: 16px;
}

@media (min-width: 1024px) {
  .range__dialog-specs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 24px;
    row-gap: 12px;
  }
}

.range__dialog-spec-item {
  display: grid;
  grid-template-columns: 20px 8.5rem 1fr;
  gap: 8px;
  align-items: baseline;
}

.range__dialog-spec-item .icon {
  color: var(--orange);
  width: 1.25rem;
  height: 1.25rem;
  opacity: 0.9;
}

.range__dialog-spec-label {
  color: var(--muted);
  font-weight: 400;
}

/* Responsive labels for mobile versus desktop */
.range__dialog-spec-label-short {
  display: inline;
}
.range__dialog-spec-label-full {
  display: none;
}

@media (min-width: 640px) {
  .range__dialog-spec-label-short {
    display: none;
  }
  .range__dialog-spec-label-full {
    display: inline;
  }
}

.range__dialog-spec-value {
  color: var(--text);
  font-weight: 500;
}

/* Price & Actions inside Dialog */
.range__dialog-price-section {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.range__dialog-price {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.range__dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.range__dialog-enquire-btn, .range__dialog-wa-btn {
  width: 100%;
}

/* Large view (≥640px) Centered dialog */
@media (min-width: 640px) {
  .range__dialog[open] {
    align-items: center;
  }
  
  .range__dialog-container {
    border-radius: var(--radius);
    max-width: 600px;
    height: auto;
    max-height: 85vh;
    border: 1px solid var(--line);
  }

  .range__dialog-handle {
    display: none; /* No swipe handle on desktop/tablet */
  }

  .range__dialog-content {
    padding: 32px;
  }

  .range__dialog-body {
    gap: 28px;
  }

  .range__dialog-actions {
    flex-direction: row;
  }

  .range__dialog-enquire-btn {
    flex: 1.5;
  }

  .range__dialog-wa-btn {
    flex: 1;
  }
}

/* Dual Column layout at ≥1024px */
@media (min-width: 1024px) {
  .range__dialog-container {
    max-width: 960px;
    max-height: 80vh;
  }

  .range__dialog-body {
    flex-direction: row;
    align-items: stretch;
    gap: 40px;
  }

  .range__dialog-image-side {
    width: 45%;
    display: flex;
    flex-direction: column;
  }

  .range__dialog-image-panel {
    flex-grow: 1;
    height: 100%;
  }

  .range__dialog-info-side {
    width: 55%;
    justify-content: center;
  }

  /* Show nav arrows only on desktop */
  .range__dialog-nav {
    display: flex;
  }
}

/* Bottom Sheet Opening Animations */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.range__dialog[open] .range__dialog-container {
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 640px) {
  @keyframes fadeInScale {
    from {
      opacity: 0;
      transform: scale(0.95);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
  .range__dialog[open] .range__dialog-container {
    animation: fadeInScale 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .range__card {
    animation: none !important;
    transform: none !important;
  }
  
  .range__card:hover {
    transform: none !important;
  }
  
  .range__dialog-container {
    transition: none !important;
  }
  
  .range__dialog[open] .range__dialog-container {
    animation: none !important;
  }
  
  /* Disable card image hover scale/transition under reduced motion */
  .range__card-image {
    transition: none !important;
  }
  
  .range__card:hover .range__card-image {
    transform: none !important;
  }
}

/* Prevent horizontal overflow on screens around 360px */
@media (max-width: 360px) {
  .range__size-tile {
    padding: 8px 12px;
    gap: 8px;
  }
}
