/* ==========================================================================
   Barter Express - Item detail. Restyles the existing markup/classes; the
   page's scripts are unchanged. Uses --bx-* tokens from app-shell.css.
   ========================================================================== */

.page-container {
    background: var(--bx-bg);
    color: var(--bx-text);
    min-height: calc(100vh - var(--bx-nav-h));
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: clip;
}
.page-container *, .page-container *::before, .page-container *::after { box-sizing: border-box; }
:where(.page-container) :is(h1, h2, h3, h4, p) { margin: 0; padding: 0; }
.page-container a { text-decoration: none; }
.page-container :focus-visible { outline: 3px solid var(--bx-orange); outline-offset: 2px; border-radius: 8px; }
.page-container .main-content { max-width: 1160px; margin: 0 auto; padding: 14px 14px 28px; }

/* ---------- Layout ---------- */
.item-container {
    background: var(--bx-surface); border: 1px solid var(--bx-border); border-radius: var(--bx-radius);
    box-shadow: var(--bx-shadow); overflow: hidden;
}
.item-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.item-layout > * { min-width: 0; }
.trade-button { text-align: center; line-height: 1.35; }

/* ---------- Slideshow ---------- */
.slideshow-section { background: var(--bx-tint); }
.slideshow-container { position: relative; }
.slideshow-wrapper { position: relative; overflow: hidden; aspect-ratio: 1 / 1; background: var(--bx-tint); }
.slideshow-track { position: absolute; inset: 0; display: flex; transition: transform .4s cubic-bezier(.22, .8, .3, 1); }
.slide { flex: 0 0 100%; height: 100%; min-width: 0; }
.slide img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--bx-tint); }
.slide-placeholder, .thumbnail-placeholder { display: grid; place-items: center; font-size: 3.4rem; color: var(--bx-muted); aspect-ratio: 1 / 1; }
.slideshow-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 44px; height: 44px; border: 0; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .92); color: var(--bx-blue); font-size: 1.6rem; line-height: 1; cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
    transition: transform .15s ease;
}
.slideshow-nav:active { transform: translateY(-50%) scale(.93); }
.slideshow-nav.prev { left: 10px; }
.slideshow-nav.next { right: 10px; }
.image-counter {
    position: absolute; right: 12px; top: 12px; z-index: 2; padding: 5px 12px; border-radius: 999px;
    background: rgba(16, 36, 61, .75); color: #fff; font-size: .78rem; font-weight: 700;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.thumbnail-nav { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; background: var(--bx-surface); }
.thumbnail-nav::-webkit-scrollbar { display: none; }
.thumbnail {
    flex: 0 0 62px; height: 62px; overflow: hidden; cursor: pointer;
    border: 2px solid transparent; border-radius: 12px; background: var(--bx-tint); opacity: .7;
    transition: opacity .15s ease, border-color .15s ease;
}
.thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbnail.active { opacity: 1; border-color: var(--bx-orange); }

.video-link-section { padding: 12px 16px 0; background: var(--bx-surface); }
.video-text-link {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px;
    background: #fdecec; color: #c0262d !important; font-size: .9rem; font-weight: 700;
}
html.dark-mode .video-text-link { background: rgba(220, 38, 38, .15); color: #fca5a5 !important; }

/* ---------- Info ---------- */
.info-section { padding: 18px 16px 22px; display: flex; flex-direction: column; gap: 18px; background: var(--bx-surface); }
.item-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-title { font-size: clamp(1.35rem, 5vw, 1.9rem); font-weight: 800; line-height: 1.2; letter-spacing: -.02em; color: var(--bx-text); overflow-wrap: anywhere; }
.title-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.favorite-button, .share-button {
    width: 46px; height: 46px; display: grid; place-items: center;
    border: 1px solid var(--bx-border); border-radius: 14px; background: var(--bx-surface); color: var(--bx-blue);
    font-size: 1.1rem; cursor: pointer; transition: transform .15s ease, border-color .15s ease;
    -webkit-tap-highlight-color: transparent;
}
html.dark-mode .share-button { color: #9cc7f5; }
.favorite-button:active, .share-button:active { transform: scale(.92); }
.favorite-button:hover, .share-button:hover { border-color: var(--bx-orange); }
.favorite-button.favorited { background: #fdecec; border-color: #f5b5b8; }
.item-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.meta-tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--bx-accent-soft); color: var(--bx-orange-dark); font-size: .85rem; font-weight: 700; }
html.dark-mode .meta-tag { color: #ffb066; }
.location-info { margin-top: 10px; color: var(--bx-muted); font-size: .92rem; font-weight: 500; }

.price-section {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 16px 18px; border-radius: var(--bx-radius-sm);
    background: linear-gradient(145deg, var(--bx-blue), var(--bx-blue-dark)); color: #fff;
}
.price-label { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .8); }
.price-value { font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 800; letter-spacing: -.02em; color: #fff; }

.description-title { font-size: 1rem; font-weight: 800; margin-bottom: 6px; color: var(--bx-text); }
.description-text { color: var(--bx-muted); line-height: 1.7; overflow-wrap: anywhere; white-space: pre-line; }
.description-text + .description-text { margin-top: 10px; }
.description-text strong { color: var(--bx-text); }

/* ---------- Actions ---------- */
.action-section { display: flex; flex-direction: column; gap: 10px; }
.action-section:empty { display: none; }
.reservation-banner {
    display: flex; flex-direction: column; gap: 3px;
    padding: 12px 14px; border-radius: var(--bx-radius-sm); border-left: 4px solid var(--bx-orange);
    background: var(--bx-accent-soft); color: var(--bx-text); font-size: .88rem; line-height: 1.45;
}
.reservation-banner strong { font-size: .95rem; }
.reservation-banner .rb-line { color: var(--bx-text); font-weight: 600; }
.reservation-banner .rb-note { margin-top: 4px; color: var(--bx-muted); font-size: .82rem; }
.trade-button {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; padding: 10px 18px;
    border: 0; border-radius: 999px; background: var(--bx-orange); color: #fff !important;
    font: inherit; font-size: .95rem; font-weight: 700; line-height: 1.2; cursor: pointer; text-decoration: none !important;
    box-shadow: 0 6px 14px rgba(255, 122, 0, .28); transition: transform .15s ease, background .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.trade-button i { font-size: .9rem; }
.trade-button:hover { background: var(--bx-orange-dark); }
.trade-button:active { transform: scale(.98); }
.trade-button.secondary { background: var(--bx-orange); }
form .trade-button.secondary { min-height: 42px; background: transparent; color: var(--bx-danger) !important; border: 1.5px solid color-mix(in srgb, var(--bx-danger) 40%, var(--bx-border)); box-shadow: none; font-size: .9rem; }
form .trade-button.secondary:hover { background: var(--bx-danger-soft); }
.action-hint { text-align: center; color: var(--bx-muted); font-size: .8rem; line-height: 1.4; }

/* ---------- Compact phone layout ---------- */
@media (max-width: 639px) {
    .page-container .main-content { padding: 10px 10px 24px; }
    .slideshow-wrapper { aspect-ratio: 4 / 3; }
    .slideshow-nav { width: 38px; height: 38px; font-size: 1.4rem; }
    .thumbnail { flex-basis: 52px; height: 52px; border-radius: 10px; }
    .thumbnail-nav { padding: 8px 12px; }
    .video-link-section { padding: 10px 14px 0; }
    .video-text-link { min-height: 38px; padding: 0 14px; font-size: .84rem; }
    .info-section { padding: 14px 14px 16px; gap: 14px; }
    .item-title { font-size: 1.25rem; }
    .favorite-button, .share-button { width: 40px; height: 40px; border-radius: 12px; font-size: 1rem; }
    .item-meta { margin-top: 8px; gap: 6px; }
    .meta-tag { padding: 4px 11px; font-size: .78rem; }
    .price-section { padding: 11px 14px; align-items: center; flex-wrap: nowrap; }
    .price-label { font-size: .7rem; }
    .price-value { font-size: 1.4rem; }
    .description-title { font-size: .92rem; margin-bottom: 4px; }
    .description-text { font-size: .92rem; line-height: 1.6; }
}


/* ---------- Related ---------- */
.related-section { margin-top: 22px; }
.related-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 0 2px; }
.related-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--bx-accent-soft); }
.related-title { font-size: 1.1rem; font-weight: 800; color: var(--bx-text); }
.related-grid { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.related-item {
    flex: 0 0 168px; scroll-snap-align: start; overflow: hidden;
    background: var(--bx-surface); border: 1px solid var(--bx-border); border-radius: 18px; box-shadow: var(--bx-shadow);
    transition: transform .2s ease, border-color .2s ease;
}
.related-item:hover { transform: translateY(-3px); border-color: var(--bx-orange); }
.related-item a { display: block; color: inherit; }
.related-image { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--bx-tint); }
.related-content { padding: 10px 12px 12px; }
.related-name { font-size: .88rem; font-weight: 700; color: var(--bx-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.related-price { margin-top: 4px; font-weight: 800; color: var(--bx-orange-dark); }
html.dark-mode .related-price { color: #ffb066; }
.empty-related { padding: 32px 16px; text-align: center; color: var(--bx-muted); background: var(--bx-surface); border: 1px dashed var(--bx-border); border-radius: var(--bx-radius); }
.empty-related-icon { font-size: 2rem; margin-bottom: 6px; }

/* ---------- Fullscreen viewer ---------- */
.fullscreen-modal { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 12, 24, .92); }
.fullscreen-modal.active { display: flex; }
.fullscreen-content { position: relative; max-width: 100%; max-height: 100%; }
.fullscreen-image { display: block; max-width: 100%; max-height: 86vh; border-radius: 12px; object-fit: contain; }
.fullscreen-close {
    position: absolute; right: 0; top: -52px; width: 44px; height: 44px; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer;
}

/* ---------- Tablet / desktop ---------- */
@media (min-width: 640px) {
    .page-container .main-content { padding: 22px 24px 44px; }
    .info-section { padding: 24px; }
    .related-item { flex-basis: 200px; }
}
@media (min-width: 960px) {
    .item-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
    .slideshow-section { align-self: start; }
    .video-link-section { grid-column: 1; grid-row: 2; background: var(--bx-tint); padding-bottom: 14px; }
    .info-section { grid-column: 2; grid-row: 1 / span 2; padding: 32px; }
}
@media (prefers-reduced-motion: reduce) {
    .slideshow-track, .related-item, .thumbnail { transition: none; }
}
.item-report-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 32px;
    margin-top: 8px;
    font-size: .78rem;
    color: #b91c1c;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.item-report-link:hover { color: #991b1b; }
html.dark-mode .item-report-link { color: #fca5a5; }
