/* Buy (docs/features/BUY_NAV.md goals 3-5; templates/pocket/buy.html, buy_species.html, buy_listings.html, watch.html),
   drawn as the B1b mockups (docs/features/BUY_MOCKUP_PASS.md): green pages (data-page-mode, docs/features/STYLE_SYSTEM.md) with gold
   eyebrows, serif headings, full-bleed species tiles, the species hero, the count strip and the numbered steps.
   Colours and sizes are shared tokens; the door's toggle (door.css) and search field (pocket.css) are reused. */

:root[data-surface="pocket"][data-page-mode="green"] {
    /* The hero and tiles' picture heights and the listing thumbnail, which no shared token holds. */
    --buy-tile-height: 168px;
    --buy-hero-height: 200px;
    --buy-thumb: 60px;
}

/* ---- The head: the gold brand on Buy and the gold Sign in pill ------------------------------------------------ */

:root[data-page-mode="green"] .pocket-root-head .pocket-page-title {
    font-family: var(--pocket-font-display);
    font-size: var(--pocket-font-size-lg);
    letter-spacing: 0.12em;
    color: var(--on-chrome-link);
}

:root[data-page-mode="green"] .pocket-toolbar-action {
    min-height: var(--pocket-target-min);
    padding: 0 var(--pocket-space-lg);
    border: 1.5px solid var(--on-chrome-link);
    border-radius: var(--pocket-radius-full);
}

/* ---- Shared look: serif headings, gold eyebrows, quiet links ---------------------------------------------------- */

.pocket-buy-headline,
.pocket-buy-title,
.pocket-buy .pocket-detail-title,
.pocket-buy-step-title,
.pocket-buy-tile-name {
    font-family: var(--pocket-font-display);
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
    color: var(--pocket-text-primary);
}

.pocket-buy-eyebrow {
    color: var(--link);
    font-weight: 700;
    letter-spacing: 0.14em;
}

.pocket-buy-quiet,
.pocket-buy-more-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--pocket-target-min);
    color: var(--pocket-text-muted);
    font-weight: 600;
    text-decoration: none;
}

.pocket-buy-more-link {
    color: var(--link);
    font-weight: 700;
}

.pocket-buy-more {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--pocket-space-lg);
    margin-bottom: var(--pocket-space-lg);
}

.pocket-buy-note,
.pocket-buy-lead {
    color: var(--pocket-text-muted);
    font-size: var(--pocket-font-size-sm);
}

.pocket-buy-card {
    display: block;
    padding: var(--pocket-space-lg);
    border: 1px solid var(--pocket-border);
    border-radius: var(--pocket-card-radius);
    background: var(--pocket-card-bg);
    color: var(--pocket-text-primary);
    margin-bottom: var(--pocket-space-md);
}

/* A full-width ask with its small second line (the sign-in note) under the label. */
.pocket-buy-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--pocket-row-height);
    font-weight: 700;
}

.pocket-buy-button small {
    font-size: var(--pocket-font-size-xs);
    font-weight: 500;
}

/* ---- Buy home -------------------------------------------------------------------------------------------------- */

.pocket-buy-headline {
    font-size: var(--pocket-font-size-2xl);
    line-height: 1.15;
    margin: 0 0 var(--pocket-space-lg);
    text-wrap: balance;
}

/* The search field: light on the green, the magnifier inside (pocket.css .pocket-species-search-field). */
.pocket-buy-search {
    margin-bottom: var(--pocket-space-lg);
}

.pocket-buy-search .pocket-search-input {
    min-height: var(--pocket-row-height);
    background: var(--on-chrome);
    color: var(--door-gold-ink);
}

.pocket-buy-search .pocket-species-search-icon {
    color: var(--door-gold-ink);
}

.pocket-buy-search .pocket-search-input::placeholder {
    color: var(--door-gold-ink);
    opacity: 0.6;
}

.pocket-buy-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--pocket-space-md);
    margin-bottom: var(--pocket-space-lg);
}

/* A tile: the art fills it edge to edge, a dark gradient at its foot carries the words. */
.pocket-buy-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 2px;
    min-height: var(--buy-tile-height);
    padding: var(--pocket-space-md);
    border-radius: var(--pocket-card-radius);
    color: var(--on-chrome);
    text-decoration: none;
    overflow: hidden;
    isolation: isolate;
}

.pocket-buy-tile::after,
.pocket-buy-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, transparent 35%, var(--door-deep));
}

.pocket-buy-art,
.pocket-buy-hero-art,
.pocket-watch-art img {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.pocket-buy-art {
    object-position: 50% 20%;
}

.pocket-buy-tile-name {
    font-size: var(--pocket-font-size-lg);
    color: var(--on-chrome);
}

.pocket-buy-tile-price,
.pocket-buy-tile-sales {
    font-size: var(--pocket-font-size-sm);
}

.pocket-buy-tile-price b {
    color: var(--door-gold-fig);
}

.pocket-buy-tile-sales {
    color: var(--on-chrome-80);
}

.pocket-buy-sex {
    font-style: normal;
}

/* ---- One species ----------------------------------------------------------------------------------------------- */

/* The hero: the art edge to edge under the toolbar, "BUY" and the name over its foot. */
/* The species top, on the species page and dimmed above the Watch sheet: edge to edge under the toolbar. */
.pocket-buy-hero,
.pocket-watch-art {
    position: relative;
    isolation: isolate;
    min-height: var(--buy-hero-height);
    margin: calc(-1 * var(--pocket-space-lg)) calc(-1 * var(--pocket-space-lg)) 0;
    overflow: hidden;
}

.pocket-buy-hero {
    display: flex;
    align-items: flex-end;
    margin-bottom: var(--pocket-space-lg);
    padding: var(--pocket-space-lg);
}

/* The species top's art, behind its words or dimmed above the Watch sheet: horns and hooves kept. */
.pocket-buy-hero-art,
.pocket-watch-art img {
    object-position: 50% 30%;
}

.pocket-buy-hero-words .pocket-section-title {
    margin: 0;
}

.pocket-buy-title {
    margin: 0;
    font-size: var(--pocket-font-size-hero);
    line-height: 1.05;
    color: var(--on-chrome);
    overflow-wrap: anywhere;
}

.pocket-buy .pocket-species-sexes {
    margin-bottom: var(--pocket-space-md);
}

.pocket-buy-typical {
    text-align: center;
}

.pocket-buy-typical .pocket-section-title {
    margin-bottom: var(--pocket-space-xs);
}

.pocket-buy-typical .pocket-aa-amount {
    margin: 0;
    font-size: var(--pocket-font-size-hero);
    font-weight: 800;
    color: var(--pocket-text-primary);
}

.pocket-buy-typical .pocket-buy-note {
    margin: var(--pocket-space-sm) 0 0;
}

.pocket-buy-note-link {
    color: inherit;
    text-decoration: none;
}

/* The count strip: three small boxes, each a link to its section. */
.pocket-buy-strip,
.pocket-buy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--pocket-space-sm);
    margin-bottom: var(--pocket-space-lg);
}

.pocket-buy-strip .pocket-buy-card {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    min-height: var(--pocket-target-min);
    margin: 0;
    padding: var(--pocket-space-sm) var(--pocket-space-md);
    font-size: var(--pocket-font-size-sm);
    font-weight: 700;
    text-decoration: none;
}

.pocket-buy-step {
    margin-bottom: var(--pocket-space-xl);
    scroll-margin-top: var(--pocket-top-chrome);
}

.pocket-buy-step-title {
    display: flex;
    align-items: center;
    gap: var(--pocket-space-sm);
    font-size: var(--pocket-font-size-xl);
    margin: var(--pocket-space-md) 0;
}

.pocket-buy-step-n {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.5em;
    height: 1.5em;
    border-radius: var(--pocket-radius-full);
    background: var(--chrome-pill);
    color: var(--on-chrome-pill);
    font-family: var(--pocket-font-family);
    font-size: var(--pocket-font-size-base);
}

.pocket-buy-empty {
    text-align: center;
    border-style: dashed;
}

.pocket-buy-empty-lead {
    margin: 0 0 var(--pocket-space-xs);
}

/* A listing (templates/pocket/_listing_row.html, docs/features/BUY_NAV_2.md goal 2): the species page's card and All
   listings' thumbnail row. A listing with no photo shows the tiles' green. */
.pocket-listing-thumb {
    display: block;
    overflow: hidden;
    flex-shrink: 0;
    width: var(--buy-thumb);
    aspect-ratio: 1;
    border-radius: var(--pocket-radius-md);
}

/* The door's greens: a tile or a species top with no art, a listing with no photo. */
.pocket-buy-tile,
.pocket-listing-thumb,
.pocket-buy-hero,
.pocket-watch-art {
    background: linear-gradient(180deg, var(--door-green), var(--door-deep));
}

.pocket-listing-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pocket-listing-tag,
.pocket-buy-sale-tag {
    display: inline-block;
    margin: 0 0 var(--pocket-space-md);
    padding: 2px var(--pocket-space-sm);
    border-radius: var(--pocket-radius-sm);
    background: var(--accent-fill);
    color: var(--on-accent-fill);
    font-size: var(--pocket-font-size-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pocket-listing-open {
    display: flex;
    gap: var(--pocket-space-md);
    align-items: flex-start;
    color: inherit;
    text-decoration: none;
}

.pocket-listing-words {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pocket-listing-title {
    font-size: var(--pocket-font-size-lg);
}

.pocket-listing-price {
    margin: var(--pocket-space-md) 0;
    font-family: var(--pocket-font-numeric);
    font-size: var(--pocket-font-size-2xl);
    color: var(--link);
}

.pocket-listing-price span {
    color: var(--pocket-text-muted);
    font-family: var(--pocket-font-family);
    font-size: var(--pocket-font-size-sm);
}

/* All listings' row: a wider thumbnail, details that wrap beside a wide price, the price in gold. */
.pocket-listing-thumb-row .pocket-listing-thumb {
    width: calc(var(--buy-thumb) + var(--pocket-space-md));
    aspect-ratio: 4 / 3;
}

.pocket-listing-thumb-row .pocket-aa-row-sub {
    white-space: normal;
}

.pocket-listing-thumb-row .pocket-aa-row-value {
    color: var(--link);
}

/* The next sale: the sale's own blue tag and outlined Watch, apart from the gold asks. */
.pocket-buy-sale-tag {
    background: var(--sale-blue);
}

/* Watch: the gold-lined ask on a lighter card. */
.pocket-buy-watch {
    border-color: var(--link);
    background: var(--door-panel);
}

.pocket-buy-watch .pocket-buy-step-title {
    margin-top: var(--pocket-space-xs);
}

.pocket-buy-bell {
    font-size: var(--pocket-font-size-xl);
}

/* A list drawn as one outlined card on the green (ranches that sold it, All listings, the watches): rows divided. */
.pocket-buy-ranches,
.pocket-buy-listings,
.pocket-watch-rows {
    border: 1px solid var(--pocket-border);
    box-shadow: none;
}

.pocket-buy-ranches .pocket-aa-row-name {
    font-weight: 700;
}

/* ---- All listings ---------------------------------------------------------------------------------------------- */

.pocket-buy .pocket-detail-title {
    font-size: var(--pocket-font-size-2xl);
    margin-top: var(--pocket-space-sm);
}

/* ---- Watch: the art dimmed above the sheet ---------------------------------------------------------------------- */

.pocket-watch-art img {
    opacity: 0.35;
}

.pocket-watch-sheet {
    position: relative;
    margin: calc(-1 * var(--pocket-space-xl)) calc(-1 * var(--pocket-space-lg)) 0;
    padding: var(--pocket-space-xl) var(--pocket-space-lg);
    border-radius: var(--pocket-radius-xl) var(--pocket-radius-xl) 0 0;
    background: var(--pocket-card-bg);
    border-top: 1px solid var(--pocket-border);
    text-align: center;
}

.pocket-watch-sheet .pocket-buy-headline {
    margin-bottom: var(--pocket-space-sm);
}

.pocket-watch-bell {
    display: block;
    font-size: var(--pocket-font-size-hero);
    color: var(--link);
}

.pocket-watch-rows {
    margin: var(--pocket-space-lg) 0;
    background: var(--pocket-bg);
    text-align: left;
}

.pocket-watch-rows .pocket-aa-row-value {
    color: var(--link);
    font-family: var(--pocket-font-family);
    font-size: var(--pocket-font-size-base);
}

.pocket-watch-sheet .pocket-btn {
    display: flex;
    justify-content: center;
}

/* A <button> shrinks to its label: the Watch ask's fills the sheet as Done's link does. */
.pocket-watch-sheet button.pocket-btn {
    box-sizing: border-box;
    width: 100%;
}

.pocket-watch-sheet .pocket-buy-more-link {
    justify-content: center;
    width: 100%;
}

/* Coming up at auction: a sale's lots (docs/features/BUY_SPECIES_AUCTION_LOTS.md), grouped by sex. A group is one grid and
   each row a subgrid of it, so every row lines up. Default: two columns (name and note, bid) under a line of ids. A wide
   card (a container query in rem, so it follows the root font size) makes three columns, except at Larger text. A narrow card
   drops the bid under the name, sooner at Larger text, so the name column never shrinks below a word. */
.pocket-buy-sale {
    --lot-bid-column: fit-content(calc(150 * var(--pocket-unit)));   /* the bid column grows with the text */
    container-type: inline-size;
}

.pocket-lot-bidnote {
    font-size: var(--pocket-font-size-xs);
}

.pocket-lot-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--lot-bid-column);
    column-gap: var(--pocket-space-sm);
}

.pocket-lot-head,
.pocket-lot-typical {
    grid-column: 1 / -1;
}

.pocket-lot-head {
    margin: var(--pocket-space-lg) 0 var(--pocket-space-xs);
}

.pocket-lot-sex {
    font-size: var(--pocket-font-size-lg);
    white-space: nowrap;
}

.pocket-lot-sex.pocket-sex-male,
.pocket-lot-name .pocket-sex-male {
    color: var(--pocket-male);
}

.pocket-lot-sex.pocket-sex-female,
.pocket-lot-name .pocket-sex-female {
    color: var(--pocket-female);
}

.pocket-lot-typical {
    margin: 0 0 var(--pocket-space-sm);
    color: var(--pocket-text-muted);
    font-size: var(--pocket-font-size-xs);
}

.pocket-lot-typical span {
    white-space: nowrap;
}

.pocket-lot-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    grid-template-areas: "ids ids" "main bid";
    column-gap: var(--pocket-space-sm);
    row-gap: var(--pocket-space-xs);
    align-items: first baseline;
    padding: var(--pocket-space-md) 0;
    border-top: 1px solid var(--pocket-border);
    color: inherit;
    text-decoration: none;
}

/* A browser without subgrid keeps a plain row: two columns, three on a wide card. */
@supports not (grid-template-columns: subgrid) {
    .pocket-lot-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    @container (min-width: 22rem) {
        .pocket-lot-row {
            grid-template-columns: max-content minmax(0, 1fr) auto;
        }
    }
}

.pocket-lot-ids {
    grid-area: ids;
    display: flex;
    flex-direction: row;
    gap: var(--pocket-space-md);
    color: var(--pocket-text-muted);
    font-size: var(--pocket-font-size-xs);
    white-space: nowrap;
}

.pocket-lot-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    gap: var(--pocket-space-xs);
    min-width: 0;
}

.pocket-lot-name {
    font-size: var(--pocket-font-size-base);
    overflow-wrap: break-word;
}

.pocket-lot-name .pocket-sex-male,
.pocket-lot-name .pocket-sex-female {
    font-size: var(--pocket-font-size-sm);
}

.pocket-lot-note {
    color: var(--pocket-text-muted);
    font-size: var(--pocket-font-size-xs);
    overflow-wrap: anywhere;
}

.pocket-lot-bid {
    grid-area: bid;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--pocket-space-xs);
    text-align: right;
}

.pocket-lot-bid b {
    font-size: var(--pocket-font-size-base);
    white-space: nowrap;
}

.pocket-lot-bid small {
    color: var(--pocket-text-muted);
    font-size: var(--pocket-font-size-xs);
}

.pocket-lot-chip {
    padding: 1px var(--pocket-space-sm);
    border-radius: var(--pocket-radius-sm);
    background: var(--warning-bg);
    color: var(--warning-ink);
    font-size: var(--pocket-font-size-xs);
    font-weight: 700;
}

@container (min-width: 22rem) {
    :root:not([data-text="larger"]):not([data-text="largest"]) .pocket-lot-group {
        grid-template-columns: max-content minmax(0, 1fr) var(--lot-bid-column);
    }

    :root:not([data-text="larger"]):not([data-text="largest"]) .pocket-lot-row {
        grid-template-areas: "ids main bid";
    }

    :root:not([data-text="larger"]):not([data-text="largest"]) .pocket-lot-ids {
        flex-direction: column;
        gap: var(--pocket-space-xs);
    }
}

/* Narrow card: the bid under the name. 15.5rem and 20rem are where the name column would fall under a word. */
@container (max-width: 15.5rem) {
    .pocket-lot-group {
        grid-template-columns: minmax(0, 1fr);
    }

    .pocket-lot-row {
        grid-template-areas: "ids" "main" "bid";
    }

    .pocket-lot-bid {
        align-items: flex-start;
        text-align: left;
    }
}

@container (max-width: 20rem) {
    :root[data-surface="pocket"][data-text="larger"] .pocket-lot-group,
    :root[data-surface="pocket"][data-text="largest"] .pocket-lot-group {
        grid-template-columns: minmax(0, 1fr);
    }

    :root[data-surface="pocket"][data-text="larger"] .pocket-lot-row,
    :root[data-surface="pocket"][data-text="largest"] .pocket-lot-row {
        grid-template-areas: "ids" "main" "bid";
    }

    :root[data-surface="pocket"][data-text="larger"] .pocket-lot-bid,
    :root[data-surface="pocket"][data-text="largest"] .pocket-lot-bid {
        align-items: flex-start;
        text-align: left;
    }
}
