/* =====================================================================
   Auctions page cards + single listing page
   (loaded after styles.css on auctions.html, listing.html, account.html)
   ===================================================================== */

/* ---------- Listing cards ---------- */
.listing-card {
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--ink); text-decoration: none;
  transition: border-color .15s, transform .15s;
}
a.listing-card:hover { border-color: rgba(208, 243, 74, .6); transform: translateY(-2px); }
a.listing-card:hover img { transform: scale(1.03); }
.listing-card-media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #0b0c0d; }
.listing-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.listing-card-body { display: grid; gap: 6px; padding: 16px 18px 18px; }
.listing-card-body h3 { margin: 0; font-size: 21px; }
.listing-card-trim { margin: 0; color: var(--muted); font-size: 14px; }
.listing-card-trim .card-timer { color: #D0F34A; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-location { margin: -2px 0 0; color: var(--muted); font-size: 14px; }
.listing-card-price { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.listing-card-price small { display: block; font-size: 12px; color: var(--muted); }
.listing-card-price strong { font-family: var(--font-display); font-size: 24px; font-variant-numeric: tabular-nums; }
.no-photo { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }

/* Loading placeholders */
.listing-card.is-skeleton .listing-card-media,
.listing-card.is-skeleton .listing-card-body span { background: rgba(243, 244, 239, .06); animation: pulse 1.2s ease-in-out infinite; }
.listing-card.is-skeleton .listing-card-body span { display: block; height: 18px; border-radius: 4px; }
.listing-card.is-skeleton .listing-card-body span:first-child { width: 70%; }
.listing-card.is-skeleton .listing-card-body span:last-child { width: 40%; height: 26px; margin-top: 10px; }
@keyframes pulse { 50% { opacity: .4; } }

.load-more { display: flex; justify-content: center; margin-top: 32px; }
.load-more:has(> [hidden]) { display: none; }
#listings-error { margin-top: 16px; }
#result-count { margin: 4px 0 0; }

/* Account page cards are links too */
a.listing-link { color: var(--ink); text-decoration: none; transition: transform .15s; }
a.listing-link:hover { transform: translateY(-2px); }

/* ---------- Single listing page ---------- */
.lp-main-wrap { padding: 24px 0 var(--section); }
.back-link { display: inline-block; padding: 8px 0; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-weight: 500; }
.back-link:hover { color: var(--accent); }

.lp-head { margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.lp-edit-btn { flex: none; }
.lp-edit { max-width: 880px; }
.lp-edit .listing-form { margin-top: 24px; }
.edit-actions { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
.lp-title { font-size: clamp(32px, 7vw, 60px); margin-bottom: 8px; }
.lp-subtitle { color: var(--muted); font-size: var(--fs-lead); margin: 0; }
#lp-owner-note { margin-bottom: 20px; }

.lp-grid { display: grid; gap: 28px; grid-template-areas: "gallery" "side" "desc"; }
.lp-gallery { grid-area: gallery; min-width: 0; }
.lp-side { grid-area: side; display: grid; gap: 16px; align-content: start; }
.lp-desc { grid-area: desc; }

/* Gallery: full-bleed swipe on phones */
.gallery { position: relative; margin: 0 calc(var(--gutter) * -1); }
.gallery-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  aspect-ratio: 4 / 3; background: #0b0c0d;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-slide { position: relative; flex: 0 0 100%; scroll-snap-align: start; }
.gallery-slide img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: none; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(16, 18, 20, .75); color: var(--ink);
  font-size: 30px; line-height: 1; cursor: pointer;
}
.gallery-nav:hover { background: var(--accent); color: var(--on-accent); }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-count {
  position: absolute; left: 12px; bottom: 12px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(16, 18, 20, .8); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.gallery-count:empty { display: none; }
.gallery-expand {
  position: absolute; right: 12px; bottom: 12px;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(16, 18, 20, .8); color: var(--ink); font-size: 18px; cursor: pointer;
}
.gallery-thumbs {
  display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin; scroll-behavior: smooth;
}
.gallery-thumb {
  flex: 0 0 76px; aspect-ratio: 4 / 3; padding: 0; overflow: hidden;
  border: 2px solid transparent; border-radius: 6px; background: var(--surface); cursor: pointer; opacity: .65;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb:hover { opacity: 1; }
.gallery-thumb.is-active { border-color: var(--accent); opacity: 1; }

/* Side panel */
.lp-card { padding: 22px; background: var(--surface); border-radius: var(--radius); }
.lp-card-title { font-size: 20px; letter-spacing: -0.02em; margin: 0 0 4px; }
.tag { display: inline-block; margin-left: 4px; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; vertical-align: 1px; }
.tag-muted { background: rgba(243, 244, 239, .12); color: var(--ink); }

/* ---------- Bid bar (above the gallery) ---------- */
.bid-bar {
  display: grid; gap: 16px; align-items: center;
  margin-bottom: 20px; padding: 20px;
  background: var(--surface);
  border: 1px solid rgba(208, 243, 74, .25);
  border-radius: var(--radius);
}
.bid-bar-price small { display: block; color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.bid-leader { color: #D0F34A; text-transform: none; letter-spacing: 0; }
.bid-bar-price strong {
  display: inline-block; font-family: var(--font-display);
  font-size: clamp(38px, 8vw, 54px); line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
  border-radius: 6px;
}
.bid-bar-price strong.flash { animation: bid-flash 1.6s ease-out; }
@keyframes bid-flash { 0% { color: var(--accent); background: rgba(208, 243, 74, .15); } }
.bid-bar-meta { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.bid-timer { color: #D0F34A; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bid-bar-action { display: grid; gap: 8px; }
.bid-button { min-height: 54px; font-size: 18px; }
.bid-bar-note { margin: 0; color: var(--muted); font-size: 14px; }
.bid-bar-note:empty { display: none; }
.bid-bar-note.is-winning { color: var(--accent); font-weight: 600; }
.bid-bar-note.is-outbid { color: #ffc56b; font-weight: 600; }

/* ---------- Bid dialog ---------- */
.bid-dialog .dialog-body { gap: 16px; }
.bid-step { display: grid; gap: 16px; }
.bid-step h3 { margin: 0; padding-right: 44px; font-size: 26px; }
.bid-car { margin: -8px 0 0; }
.bid-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.bid-chip {
  min-height: 40px; padding: 0 14px;
  border: 1px solid rgba(243, 244, 239, .25); border-radius: 999px;
  background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.bid-chip:hover { border-color: var(--accent); color: var(--accent); }
.bid-confirm-amount {
  margin: 0; font-family: var(--font-display); font-size: 44px; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.bid-typo { display: block; margin-top: 8px; font-family: var(--font-body); font-size: 14px; letter-spacing: 0; color: #ffc56b; font-weight: 600; }
.bid-warning {
  padding: 14px 16px; border-radius: var(--radius);
  background: rgba(255, 197, 107, .08); border: 1px solid rgba(255, 197, 107, .45);
}
.bid-warning strong { color: #ffc56b; }
.bid-warning p { margin: 4px 0 0; font-size: 14px; color: var(--ink); }
.bid-confirm-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.bid-confirm-actions .btn { white-space: nowrap; }
.form-error:empty { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 16px; z-index: 300;
  max-width: calc(100% - 32px);
  padding: 12px 20px; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  transform: translate(-50%, 160%); transition: transform .25s;
}
.toast.show { transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .bid-bar { grid-template-columns: 1fr auto; padding: 24px 28px; }
  .bid-bar-action { justify-items: end; text-align: right; }
  .bid-button { min-width: 220px; }
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; }
.lp-seller { margin: 0; font-size: 14px; }

.lp-desc-text { white-space: pre-line; line-height: 1.65; overflow-wrap: anywhere; }
.lp-desc .lp-card-title { margin-bottom: 12px; }

/* Loading skeleton */
.lp-skel-title, .lp-skel-media { background: rgba(243, 244, 239, .06); animation: pulse 1.2s ease-in-out infinite; }
.lp-skel-title { height: 48px; width: min(520px, 80%); margin-bottom: 20px; border-radius: 6px; }
.lp-skel-media { aspect-ratio: 4 / 3; max-width: 860px; border-radius: var(--radius); }

/* Full-screen viewer */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: #000; color: var(--ink);
}
.lightbox::backdrop { background: #000; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox img { max-width: 100%; max-height: 100dvh; object-fit: contain; }
.lightbox .gallery-nav { display: grid; }
.lightbox-close {
  position: absolute; top: 12px; right: 12px;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(243, 244, 239, .12); color: var(--ink); font-size: 28px; line-height: 1; cursor: pointer;
}
.lightbox .gallery-count { left: 50%; transform: translateX(-50%); bottom: 16px; }

@media (min-width: 700px) {
  .gallery { margin: 0; }
  .gallery-track { border-radius: var(--radius); }
  .gallery-nav { display: grid; }
  .gallery-thumb { flex-basis: 96px; }
  .lp-card { padding: 28px; }
}
@media (min-width: 1000px) {
  .lp-main-wrap { padding-top: 40px; }
  .lp-grid {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas: "gallery side" "desc side";
    gap: 40px;
  }
  .lp-side { position: sticky; top: calc(var(--header-h) + 24px); }
}
/* Touch screens swipe instead of using arrow buttons */
@media (hover: none) { .gallery-nav, .lightbox .gallery-nav { display: none; } }

/* Home page: live auctions right under the hero */
.home-auctions { padding-top: 0; }
.home-auctions .section-head { max-width: none; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.home-auctions .section-head h2 { margin: 0; }

/* ---------- Comments (listing page) ---------- */
.lp-comments { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--line); max-width: 860px; }
.lp-comments .lp-card-title { margin-bottom: 16px; }
.comment-count { color: var(--muted); font-weight: 400; }
.comment-form { display: grid; gap: 10px; margin-bottom: 24px; }
.comment-form .field textarea { min-height: 96px; }
.comment-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.comment-closed { margin: 0 0 20px; }
.comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.comment { padding: 16px 18px; background: var(--surface); border-radius: var(--radius); }
.comment.is-new { animation: comment-in .6s ease-out; }
@keyframes comment-in { from { box-shadow: 0 0 0 2px var(--accent); } to { box-shadow: 0 0 0 2px transparent; } }
.comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px; font-size: 14px; }
.comment-head .tag { margin-left: 0; }
.comment-time { color: var(--muted); }
.comment-edited { color: var(--muted); }
.comment-actions { margin-left: auto; display: flex; gap: 2px; }
.comment-action { padding: 2px 6px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.comment-action:hover { color: var(--accent); text-decoration: underline; }
.comment-delete:hover { color: var(--danger); }
.comment-edit { display: grid; gap: 10px; }
/* Replies: nested under the comment they answer */
.comment-item { display: grid; gap: 12px; }
.comment-replies { list-style: none; margin: 0 0 0 18px; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.comment-replies.is-flat { margin-left: 0; padding-left: 0; border-left: 0; }
.comment-replying { margin: -2px 0 6px; color: var(--muted); font-size: 13px; }
.comment.is-deleted { background: transparent; border: 1px dashed var(--line); padding: 10px 18px; }
.comment.is-deleted .comment-body { font-size: 14px; font-style: italic; }
.comment-reply-box { padding: 14px 16px; background: var(--surface); border-radius: var(--radius); }
@media (max-width: 600px) {
  .comment-replies { margin-left: 6px; padding-left: 12px; }
}
.comment-edit .field textarea { min-height: 88px; }
.comment-edit-buttons { display: flex; gap: 8px; }
.comment-body { margin: 0; white-space: pre-line; line-height: 1.6; overflow-wrap: anywhere; }
.comment-empty { margin: 0; }

/* ---------- Username links + public profile page ---------- */
.user-link { color: inherit; text-decoration: none; }
.user-link:hover, .user-link:focus-visible { color: var(--accent); text-decoration: underline; }
a.bid-leader { color: #D0F34A; }
a.bid-leader:hover { color: #D0F34A; }
.profile-head { display: flex; align-items: center; gap: 20px; margin-bottom: 40px; }
.profile-avatar {
  flex: none; display: grid; place-items: center;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 32px; font-weight: 700;
}
.profile-name { margin: 0 0 4px; overflow-wrap: anywhere; }
.profile-since { margin: 0; }
.profile-listings .section-head { max-width: none; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; }
.profile-listings .section-head h2 { margin: 0; font-size: var(--fs-subheading); }

/* ---------- Watch / Share buttons (in the listing subtitle) ---------- */
.lp-subtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.lp-actions { display: inline-flex; gap: 8px; }
.lp-actions[hidden], .lp-action[hidden] { display: none; }
.lp-action {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.lp-action svg { width: 18px; height: 18px; flex: none; }
.lp-action:hover { border-color: var(--accent); color: var(--accent); }
.lp-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lp-action.is-on { border-color: var(--accent); color: var(--accent); }
.lp-action.is-on svg path { fill: currentColor; }

/* ---------- Account page: watchlist ---------- */
.watchlist-table { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.watchlist-table[hidden] { display: none; }
.watchlist-list { list-style: none; margin: 0; padding: 0; }
.watchlist-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--line);
}
.watchlist-header { display: none; border-top: 0; padding-block: 12px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.watchlist-car { grid-column: 1 / -1; color: var(--ink); font-weight: 700; text-decoration: none; }
.watchlist-car:hover { color: var(--accent); text-decoration: underline; }
.watchlist-price strong { font-variant-numeric: tabular-nums; }
.watchlist-price small { margin-left: 6px; color: var(--muted); font-size: 12px; }
.watchlist-time { color: #D0F34A; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.watchlist-row.is-ended .watchlist-time { color: var(--muted); }
@media (min-width: 700px) {
  .watchlist-row { grid-template-columns: 1fr 200px 160px; }
  .watchlist-header { display: grid; }
  .watchlist-header span:last-child { text-align: right; }
  .watchlist-car { grid-column: auto; }
  .watchlist-list .watchlist-row:first-child { border-top: 1px solid var(--line); }
}

/* ---------- Profile page: bid history (reuses the watchlist table) ---------- */
.bid-history { margin-top: 48px; }
.history-status { color: var(--muted); font-size: 14px; }
.history-high { color: #D0F34A; font-weight: 700; }
.history-outbid { color: var(--ink); }
.history-date { color: var(--muted); font-size: 14px; text-align: right; white-space: nowrap; }
/* Phones: car · then price + date · then status */
@media (max-width: 699px) {
  .history-row .history-date { order: 1; }
  .history-row .history-status { order: 2; grid-column: 1 / -1; }
}
@media (min-width: 700px) {
  .history-row { grid-template-columns: 1fr 180px 240px 120px; }
}

/* ---------- Listing page: bid history (5 rows visible, rest scroll) ---------- */
.lp-bids .lp-card-title { margin-bottom: 12px; }
.lp-bids-empty { margin: 0; }
.bids-scroll {
  --row: 44px;
  max-height: calc(var(--row) * 6);   /* header + 5 bids */
  overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -8px; padding: 0 8px;
  scrollbar-width: thin; scrollbar-color: rgba(243, 244, 239, .3) transparent;
}
.bids-scroll[hidden] { display: none; }
.bids-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.bids-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bids-table th, .bids-table td { height: var(--row); padding: 0 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.bids-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
/* All columns left-aligned (headers and values line up) */
.bids-time { color: var(--muted); }
.bids-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.bids-table td:first-child { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.bids-table tr.is-top .bids-amount { color: #D0F34A; }
.bids-you { color: var(--muted); font-size: 12px; }
.bids-table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Account page: Post sale management (won auctions) ---------- */
/* Wide screens: Profile on the left, Post sale management on the right */
@media (min-width: 1000px) {
  .account-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
}
.post-sale .card-title { display: flex; align-items: center; min-height: 38px; margin-bottom: 16px; }  /* lines up with the Profile heading + button */
.post-sale-loading, .post-sale-empty { margin: 0; }
.won-scroll { overflow-x: auto; margin: 0 -4px; }
.won-scroll[hidden] { display: none; }
.won-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.won-table th {
  padding: 0 12px 10px 4px; text-align: left; white-space: nowrap;
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.won-table td { padding: 12px 12px 12px 4px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.won-table tr:last-child td { border-bottom: 0; }
.won-car { color: var(--ink); font-weight: 700; text-decoration: none; }
.won-car:hover { color: var(--accent); text-decoration: underline; }
.won-amount { color: #D0F34A; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.won-date { color: var(--muted); white-space: nowrap; }
