/* Detail view: single-scroll, non-cropping responsive layout. */
.detail-dialog {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  scrollbar-color: #b7bec8 transparent;
  scrollbar-width: thin;
}

.detail-dialog::-webkit-scrollbar {
  width: 7px;
}

.detail-dialog::-webkit-scrollbar-track {
  background: transparent;
}

.detail-dialog::-webkit-scrollbar-thumb {
  background: #b7bec8;
  border: 2px solid #fff;
  border-radius: 999px;
}

.detail-scroll-top {
  position: fixed;
  right: max(24px, calc((100vw - 1180px) / 2 + 20px));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 24;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #0c152c;
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(12, 21, 44, .14);
  border-radius: 50%;
  box-shadow: 0 12px 28px rgba(12, 21, 44, .16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity .18s ease, transform .18s ease, background .16s ease, border-color .16s ease;
}

.detail-scroll-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.detail-scroll-top:hover,
.detail-scroll-top:focus-visible {
  background: rgba(255, 255, 255, .98);
  border-color: rgba(12, 21, 44, .28);
}

.detail-scroll-top:active {
  transform: translateY(1px) scale(.96);
}

.detail-scroll-top:focus-visible {
  outline: 2px solid rgba(12, 21, 44, .22);
  outline-offset: 3px;
}

.detail-scroll-top .ui-arrow {
  width: 19px;
  height: 19px;
}

.detail-layout {
  min-height: 0;
  max-height: none;
  align-items: start;
}

.gallery-stage {
  min-width: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,.96), rgba(238,241,244,.96));
}

.gallery-main {
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.detail-info {
  min-width: 0;
}

.detail-info h2,
.detail-model,
.detail-price,
.quick-specs,
.vin,
.detail-section {
  position: relative;
}

.features {
  align-items: flex-start;
}

.feature {
  max-width: 100%;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (min-width: 901px) {
  .detail-dialog {
    width: min(1180px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    border-radius: 24px;
    box-shadow: 0 32px 100px rgba(7, 14, 30, .34);
  }

  .detail-dialog::backdrop {
    background: rgba(8, 15, 29, .76);
  }

  .detail-layout {
    grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr);
  }

  .gallery {
    position: sticky;
    top: 0;
    height: min(820px, calc(100dvh - 24px));
    min-height: 0;
    padding: 18px;
    display: grid;
    grid-template-rows: minmax(0, 1fr) 74px;
    gap: 12px;
    overflow: hidden;
    background: #edf0f3;
  }

  .gallery-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    border: 1px solid rgba(12, 21, 44, .06);
    border-radius: 18px;
  }

  .gallery-main {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 18px;
  }

  .thumbs {
    min-width: 0;
    margin: 0;
    padding: 1px 1px 4px;
    display: flex;
    grid-template-columns: none;
    gap: 9px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .thumb {
    width: 92px;
    min-width: 92px;
    height: 69px;
    flex: 0 0 92px;
    aspect-ratio: 4 / 3;
    scroll-snap-align: center;
    border-radius: 10px;
  }

  .detail-info {
    padding: 32px 34px 38px;
    overflow: visible;
  }

  .detail-info h2 {
    margin: 14px 0 7px;
    font-size: clamp(27px, 2.4vw, 34px);
  }

  .detail-model {
    margin-bottom: 18px;
  }

  .detail-price {
    margin-bottom: 22px;
    font-size: 32px;
  }

  .quick-specs {
    gap: 9px;
    margin-bottom: 24px;
  }

  .quick-spec {
    padding: 12px 11px;
  }

  .vin {
    padding: 12px 14px;
  }

  .detail-section {
    margin-top: 22px;
  }

  .detail-section h3 {
    margin-bottom: 11px;
  }

  .spec-table {
    gap: 0 26px;
  }

  .spec-row {
    padding: 8px 0;
    line-height: 1.35;
  }

  .features {
    gap: 7px;
  }

  .feature {
    padding: 7px 9px;
    font-size: 10.5px;
  }

  .dialog-close {
    top: max(18px, calc((100dvh - min(820px, calc(100dvh - 24px))) / 2 + 13px));
    right: max(18px, calc((100vw - min(1180px, calc(100vw - 24px))) / 2 + 13px));
    width: 43px;
    height: 43px;
    color: var(--ink);
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(12, 21, 44, .12);
  }
}

@media (max-width: 900px) {
  .detail-dialog {
    width: min(760px, calc(100% - 20px));
    height: auto;
    max-height: calc(100dvh - 20px);
    border-radius: 20px;
  }

  .detail-layout {
    display: block;
  }

  .gallery {
    position: relative;
    top: auto;
    height: auto;
    min-height: 0;
    padding: 12px 12px 10px;
    display: block;
    overflow: visible;
  }

  .gallery-stage {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 15px;
  }

  .gallery-main {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 15px;
  }

  .thumbs {
    display: flex;
    grid-template-columns: none;
    margin: 0;
    padding: 10px 0 1px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .detail-info {
    overflow: visible;
  }
}

@media (max-width: 600px) {
  .detail-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .gallery {
    padding: 0 0 10px;
  }

  .gallery-stage,
  .gallery-main {
    border-radius: 0;
  }

  .detail-info {
    padding-top: 22px;
  }

  .features {
    gap: 7px;
  }

  .feature {
    padding: 8px 9px;
    font-size: 11px;
  }
}

@media (min-width: 901px) and (max-height: 740px) {
  .gallery {
    height: calc(100dvh - 16px);
    padding: 12px;
    grid-template-rows: minmax(0, 1fr) 62px;
    gap: 8px;
  }

  .thumb {
    width: 80px;
    min-width: 80px;
    height: 60px;
    flex-basis: 80px;
  }

  .detail-dialog {
    max-height: calc(100dvh - 16px);
  }

  .detail-info {
    padding: 24px 30px 30px;
  }

  .detail-info h2 {
    font-size: 27px;
  }

  .detail-price {
    margin-bottom: 18px;
    font-size: 28px;
  }

  .quick-specs {
    margin-bottom: 18px;
  }

  .detail-section {
    margin-top: 17px;
  }
}

/* Full vehicle configuration, loaded only with the opened car card. */
.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.detail-section-head h3 {
  margin: 0;
}

.extended-specs-toggle {
  min-height: 34px;
  padding: 7px 10px 7px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #0c152c;
  background: #f5f6f8;
  border: 1px solid #dfe3e9;
  border-radius: 999px;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.extended-specs-toggle:hover,
.extended-specs-toggle:focus-visible {
  background: #eceff3;
  border-color: #c8ced8;
}

.extended-specs-toggle:active {
  transform: scale(.97);
}

.extended-specs-toggle:focus-visible {
  outline: 2px solid rgba(12, 21, 44, .22);
  outline-offset: 2px;
}

.extended-specs-toggle .ui-arrow {
  width: 15px;
  height: 15px;
  transition: transform .18s ease;
}

.extended-specs-toggle[aria-expanded="true"] .ui-arrow {
  transform: rotate(180deg);
}

.extended-specs {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.extended-specs[hidden] {
  display: none;
}

.extended-spec-group {
  min-width: 0;
  padding: 14px 15px 4px;
  background: #f7f8fa;
  border: 1px solid #e1e5ea;
  border-radius: 14px;
}

.extended-spec-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid #e2e6eb;
}

.extended-spec-group-head h4 {
  margin: 0;
  color: #0c152c;
  font-size: 13px;
  line-height: 1.35;
}

.extended-spec-group-head > span {
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #687286;
  background: #fff;
  border: 1px solid #dfe3e9;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
}

.extended-spec-grid {
  display: grid;
}

.extended-spec-row {
  min-width: 0;
  padding: 9px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .8fr);
  align-items: start;
  gap: 16px;
  border-bottom: 1px solid #e5e8ec;
  font-size: 11px;
  line-height: 1.38;
}

.extended-spec-row:last-child {
  border-bottom: 0;
}

.extended-spec-row span {
  min-width: 0;
  color: #737e91;
  overflow-wrap: anywhere;
}

.extended-spec-row strong {
  min-width: 0;
  color: #0c152c;
  text-align: right;
  overflow-wrap: anywhere;
}

.extended-spec-row strong.is-empty {
  color: #a4abb7;
  font-weight: 600;
}

@media (max-width: 600px) {
  .detail-scroll-top {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, .82);
  }

  .detail-section-head {
    gap: 10px;
    padding-right: 126px;
  }

  .extended-specs-toggle {
    min-height: 32px;
    padding: 6px 8px 6px 11px;
  }

  .extended-spec-group {
    padding: 13px 12px 3px;
    border-radius: 12px;
  }

  .extended-spec-row {
    grid-template-columns: minmax(0, 1fr) minmax(100px, .8fr);
    gap: 11px;
    padding: 9px 0;
    font-size: 10.5px;
  }
}

@media (max-width: 380px) {
  .detail-section-head {
    padding-right: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .extended-specs-toggle {
    align-self: flex-end;
  }
}
