.market-page {
    margin-left: 10%;
    margin-right: 10%;
    padding: 20px 0 40px;
}

/* ---------- Product rows ---------- */

/* No gap: each listing carries its own top rule and vertical padding, so
   the rules alone separate them -- a ruled catalogue list rather than a
   stack of cards. */
.market-product-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.market-status {
    color: var(--default-font-color);
    opacity: 0.7;
    font-family: var(--font-body);
    font-size: 15px;
    padding: 20px 0;
}

/* Each product spans the full content width, gallery on the left and
   details on the right -- one row per product, stacked vertically.
   position:relative makes this the containing block for the price and
   Purchase button below: with no align-items override, the row defaults
   to align-items:stretch, so .market-product__gallery is stretched to
   the row's full content-box height -- its top and (bottom, once
   .market-product__thumbs is pinned there) line up exactly with the
   padding-box edges that top:0/bottom:0 resolve against, which is what
   keeps the price flush with the image's top and the Purchase button
   flush with the thumbnails' bottom without any manual offset math. */
.market-product {
    position: relative;
    display: flex;
    gap: 28px;
    padding: 28px 0;
    border-top: 1px solid var(--border-color);
}

/* ---------- Gallery: main image + a thumbnail strip beneath it ---------- */

.market-product__gallery {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.market-product__main-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    background-color: var(--input-bg);
    overflow: hidden;
    cursor: zoom-in;
}

/* Scaled/panned on hover by attachImageZoom() in market.js -- transform
   (not width/height) drives the zoom so it stays smooth, and clips to
   .market-product__main-image's overflow:hidden frame. */
.market-product__main-image-zoom {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--default-font-color);
    font-family: var(--font-body);
    font-size: 15px;
    opacity: 0.8;
    text-align: center;
    transform: scale(1);
    transform-origin: 50% 50%;
    transition: transform 0.2s ease-out;
}

.market-product__main-image-zoom img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* margin-top:auto pushes the thumbnail row to the bottom of the (stretched,
   full row height) gallery column, so its bottom edge lands exactly on the
   same line as .market-product__purchase-btn's bottom:0. */
.market-product__thumbs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
}

.market-product__thumb {
    flex: 0 0 56px;
    width: 56px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    background: none;
    background-color: var(--input-bg);
    border-color: var(--border-color);
    border-style: solid;
    border-width: 1px;
    color: var(--default-font-color);
    font-family: var(--font-body);
    font-size: 11px;
    opacity: 0.65;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.market-product__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.market-product__thumb:hover {
    opacity: 0.9;
}

.market-product__thumb[aria-selected="true"] {
    opacity: 1;
    border-color: var(--accent-color);
}

/* ---------- Details: title / description / price ---------- */

/* padding-right reserves room so title/description text never runs under
   the absolutely-positioned price (top-right) or Purchase button
   (bottom-right), both of which overlay this column's right edge. */
.market-product__details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 170px;
}

.market-product__title {
    font-family: var(--font-display);
    font-size: 26px;
    color: var(--default-font-color);
    margin: 0;
}

/* Markdown-rendered (see js/market.js + window.ContentMarkdown) -- the
   admin's Portal description can include bold/italic/lists/etc. */
.market-product__description {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--default-font-color);
    opacity: 0.85;
}

.market-product__description p {
    margin: 0 0 0.8em 0;
}

.market-product__description p:last-child {
    margin-bottom: 0;
}

.market-product__description strong {
    font-weight: 700;
}

.market-product__description ul,
.market-product__description ol {
    margin: 0 0 0.8em 0;
    padding-left: 1.4em;
}

.market-product__description li {
    margin-bottom: 0.3em;
}

/* Top-right corner of the card. An absolutely positioned element's 0
   offset resolves against the padding EDGE of its containing block (i.e.
   flush with the inner border, before any padding) -- not the content
   edge normal-flow content like the image sits behind. Matching top/right
   to .market-product's own 20px padding puts the price at that same
   content-edge inset, flush with the main image's top edge. */
.market-product__price {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: var(--font-body);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-color);
}

/* Bottom-right corner of the card -- same reasoning as the price above:
   bottom/right of 20px (matching .market-product's padding) lines this up
   flush with the thumbnail row's bottom edge (see .market-product__thumbs
   margin-top:auto), instead of sitting 20px closer to the card's border. */
.market-product__etsy-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--default-font-color);
    color: var(--bg-color);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 10px 20px;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.market-product__etsy-btn:hover {
    background: var(--accent-color);
    color: var(--default-font-color);
}

/* No listing URL set yet -- inert placeholder, not a link. */
.market-product__etsy-btn--pending {
    background: var(--input-bg);
    color: var(--default-font-color);
    border: 1px solid var(--border-color);
    cursor: default;
    opacity: 0.6;
}

.market-product__etsy-btn--pending:hover {
    background: var(--input-bg);
    color: var(--default-font-color);
}

@media (max-width: 700px) {
    .market-product {
        flex-direction: column;
    }
    .market-product__gallery {
        flex: 0 0 auto;
    }
    /* Stacked layout: the title sits well clear of the top-right price
       once gallery is above it, so only the last (bottom) block of detail
       content needs clearance from the Etsy button. */
    .market-product__details {
        padding-right: 130px;
    }
}
