/*
  detail.css (improved)
  - Detail page (gallery + overview + lead form + lightbox)
  - No Tailwind dependency
  - Thumbs: desktop vertical scroll, mobile horizontal slider (scroll-snap)
*/

:root{
  --hf-bg: #0e1114;
  --hf-card: #141a21;
  --hf-border: rgba(255,255,255,.10);
  --hf-border-2: rgba(255,255,255,.16);
  --hf-text: rgba(255,255,255,.92);
  --hf-muted: rgba(255,255,255,.66);
  --hf-muted-2: rgba(255,255,255,.52);
  --hf-accent: #FACC15;
  --hf-radius: 18px;
  --hf-shadow: 0 18px 40px rgba(0,0,0,.35);
}

/* Scoped box sizing to prevent unexpected theme side-effects */
.cd-section,
.cd-section *{
  box-sizing: border-box;
}

/* Helpers */
.hf-no-scroll{ overflow: hidden !important; }
.w-full{ width: 100%; }
.hp{
  position:absolute !important;
  left:-9999px !important;
  height:0 !important;
  width:0 !important;
  opacity:0 !important;
  pointer-events:none !important;
}

/* Container */
.container{
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Base section */
.cd-section{
  background: var(--hf-bg);
  color: var(--hf-text);
  padding: 56px 0;
}

.cd-section a{ color: inherit; text-decoration: none; }
.cd-section p{ color: var(--hf-muted); }

/* A11y: focus ring (only keyboard) */
.cd-section :focus{ outline: none; }
.cd-section :focus-visible{
  outline: 3px solid rgba(250,204,21,.28);
  outline-offset: 3px;
  border-radius: 12px;
}

/* Typography */
.cd-kicker{
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 600;
  font-size: 12px;
  color: var(--hf-muted);
  margin: 0 0 10px;
}
.cd-title{
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 800;
}
.cd-subtitle{
  margin: 10px 0 0;
  max-width: 760px;
}

/* Pills */
.inv-pills{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:18px;
}
.pill{
  display:inline-flex;
  align-items:center;
  padding:9px 14px;
  border-radius:999px;
  border:1px solid var(--hf-border);
  background: rgba(255,255,255,.03);
  font-size:14px;
  color: var(--hf-muted);
  transition: transform .15s ease, border-color .15s ease, background .15s ease, color .15s ease;
}
.pill:hover{
  transform: translateY(-1px);
  border-color: var(--hf-border-2);
  background: rgba(255,255,255,.06);
  color: var(--hf-text);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-ghost{
  display:inline-flex;
  justify-content:center;
  align-items:center;
  gap:8px;
  height:44px;
  padding:0 16px;
  border-radius:12px;
  font-weight:700;
  border:1px solid transparent;
  cursor:pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary{
  background: var(--hf-accent);
  color:#0b0f14;
}
.btn-primary:hover{ transform: translateY(-1px); filter: brightness(1.02); }
.btn-secondary{
  background: rgba(255,255,255,.06);
  border-color: var(--hf-border);
  color: var(--hf-text);
}
.btn-secondary:hover{
  background: rgba(255,255,255,.09);
  border-color: var(--hf-border-2);
  transform: translateY(-1px);
}
.btn-ghost{
  background: transparent;
  border-color: var(--hf-border);
  color: var(--hf-muted);
}
.btn-ghost:hover{
  border-color: var(--hf-border-2);
  color: var(--hf-text);
}

/* Gallery layout */
.cd-gallery{
  display:grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, .9fr);
  gap:16px;
  margin-top:18px;
}
.cd-hero,
.thumbs-wrapper{
  min-width: 0; /* prevents overflow in CSS grid */
}

.cd-hero{
  position:relative;
  border:1px solid var(--hf-border);
  border-radius: var(--hf-radius);
  overflow:hidden;
  background: rgba(0,0,0,.25);
  box-shadow: var(--hf-shadow);
}
.cd-price{
  position:absolute;
  top:14px;
  left:14px;
  z-index:3;
  padding:8px 12px;
  border-radius:999px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  font-weight: 900;
}
.badge-sold{
  position:absolute;
  left:12px;
  top:12px;
  padding:6px 10px;
  border-radius:999px;
  font-weight:900;
  font-size:12px;
  letter-spacing:.06em;
  background: rgba(239,68,68,.22);
  border: 1px solid rgba(239,68,68,.45);
  color: var(--hf-text);
}
.cd-hero-btn{
  width:100%;
  border:0;
  padding:0;
  margin:0;
  background: transparent;
  cursor: zoom-in;
}
.hero-main-image{
  width:100%;
  height:auto;
  display:block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
.cd-noimage{
  padding:60px 20px;
  text-align:center;
  color: var(--hf-muted-2);
}

/* ===== Thumbnails (DESKTOP) ===== */
.thumbs-wrapper{
  border:1px solid var(--hf-border);
  border-radius: var(--hf-radius);
  background: rgba(255,255,255,.03);
  box-shadow: var(--hf-shadow);

  /* desktop: vertical scroll */
  overflow: auto;
  padding:12px;

  /* important: keeps thumbs compact and inside their panel */
  max-height: clamp(320px, 58vh, 720px); /* JS can override to exact hero height */

  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}
.thumbs-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
  align-content: start;
}

.thumb-btn{
  border:1px solid var(--hf-border);
  background: rgba(0,0,0,.18);
  border-radius:14px;
  overflow:hidden;
  padding:0;
  cursor:pointer;

  /* stable size */
  aspect-ratio: 16 / 10;

  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
@media (hover:hover){
  .thumb-btn:hover{
    transform: translateY(-1px);
    border-color: var(--hf-border-2);
  }
}
.thumb-btn.is-active{
  border-color: rgba(250,204,21,.70);
  box-shadow: 0 0 0 3px rgba(250,204,21,.15);
}
.thumb-btn img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

/* Scrollbar (works for both vertical + horizontal) */
.thumbs-scroll{
  scrollbar-width: thin;
  scrollbar-color: rgba(229,231,235,.85) rgba(2,6,23,.55);
}
.thumbs-scroll::-webkit-scrollbar{ width:10px; height:10px; }
.thumbs-scroll::-webkit-scrollbar-track{
  background: rgba(2,6,23,.55);
  border-radius:999px;
}
.thumbs-scroll::-webkit-scrollbar-thumb{
  background: rgba(229,231,235,.85);
  border-radius:999px;
  box-shadow: 0 0 0 2px rgba(2,6,23,.55) inset;
}
.thumbs-scroll::-webkit-scrollbar-thumb:hover{ background: var(--hf-accent); }

/* Content layout */
.cd-content{
  display:grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, .9fr);
  gap:16px;
  margin-top:16px;
  align-items:start;
}

.panel,
.overview,
.lead{
  border:1px solid var(--hf-border);
  border-radius: var(--hf-radius);
  background: rgba(255,255,255,.03);
  padding:18px;
  box-shadow: var(--hf-shadow);
}

.panel-title{
  margin:0 0 10px;
  font-size: 20px;
  font-weight: 800;
}
.panel-text{ color: var(--hf-muted); }
.panel-muted{ color: var(--hf-muted-2); margin: 0; }

/* Sticky sidebar on desktop */
@media (min-width: 981px){
  .cd-sidebar{
    position: sticky;
    top: 96px;
    display: grid;
    gap: 16px;
  }
}

/* Overview */
.overview-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}
.overview-title{ font-weight: 900; font-size: 18px; }
.overview-stock{ color: var(--hf-muted); font-size: 13px; }
.overview-list{ margin:0; }
.overview-list .row{
  display:grid;
  grid-template-columns: 1fr 1.4fr;
  gap:10px;
  padding:10px 0;
  border-top:1px solid var(--hf-border);
}
.overview-list .row:first-child{ border-top:0; padding-top:0; }
.overview-list dt{
  color: var(--hf-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.overview-list dd{
  margin:0;
  color: var(--hf-text);
  font-weight: 700;
}

/* Form */
.field{ display:flex; flex-direction:column; gap:6px; }
.label{
  font-size: 12px;
  color: var(--hf-muted);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.input{
  width:100%;
  border-radius:12px;
  border:1px solid var(--hf-border);
  background: rgba(0,0,0,.25);
  color: var(--hf-text);
  padding:11px 12px;
  outline:none;
}
.input::placeholder{ color: rgba(255,255,255,.40); }
.input:focus{
  border-color: rgba(250,204,21,.55);
  box-shadow: 0 0 0 3px rgba(250,204,21,.12);
}

.lead-title{ margin: 0 0 6px; font-size: 20px; font-weight: 900; }
.lead-subtitle{ margin: 0 0 14px; }
.lead-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:12px;
  margin-bottom:12px;
}
.field-full{ grid-column: 1 / -1; }
.lead-success{
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(34,197,94,.14);
  border: 1px solid rgba(34,197,94,.35);
  color: rgba(255,255,255,.92);
}

/* Lightbox */
.lightbox{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.78);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
  padding:18px;
}
.lightbox.hidden{ display:none; }
.lb-image{
  max-width: min(1100px, 96vw);
  max-height: 86vh;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.35);
}
.lb-close,
.lb-prev,
.lb-next{
  position:absolute;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.45);
  color: var(--hf-text);
  width:42px;
  height:42px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.lb-close:hover,
.lb-prev:hover,
.lb-next:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.28);
  background: rgba(0,0,0,.55);
}
.lb-close{ top:20px; right:20px; }
.lb-prev{ left:20px; }
.lb-next{ right:20px; }

/* ===== Responsive ===== */
@media (max-width: 980px){
  .cd-gallery{ grid-template-columns: 1fr; }

  /* mobile: turn thumbs into horizontal slider */
  .thumbs-wrapper{
    max-height: none;            /* allow natural height */
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;

    scroll-snap-type: x mandatory;
    scroll-padding: 10px;
  }

  .thumbs-grid{
    display:flex;
    gap:10px;
    min-width: max-content;
    align-content: initial;
  }

  .thumb-btn{
    flex: 0 0 170px;
    scroll-snap-align: start;
  }

  .cd-content{ grid-template-columns: 1fr; }
  .lead-grid{ grid-template-columns: 1fr; }

  /* Lightbox nav a bit closer on mobile */
  .lb-prev{ left:12px; }
  .lb-next{ right:12px; }
}

@media (max-width: 560px){
  .cd-title{ font-size: 28px; }
  .thumb-btn{ flex-basis: 150px; }
}

/* Reduce motion if user prefers */
@media (prefers-reduced-motion: reduce){
  .pill,
  .btn-primary,
  .btn-secondary,
  .btn-ghost,
  .thumb-btn,
  .lb-close,
  .lb-prev,
  .lb-next{
    transition: none !important;
  }
}
