/*
 * Vibes — masonry inspiration feed.
 *
 * Deliberately a separate stylesheet rather than an addition to style.css.
 * style.css and style-monochrome.css are mutually exclusive theme variants and
 * every rule added to one has to be mirrored into the other; keeping Vibes out
 * of that pair means one file instead of two, and no risk of the variants
 * drifting. Colours here read from the CSS custom properties both themes
 * define, so this file works under either without duplication.
 */

/* The rail used to be a 190px column beside the grid. It is now a horizontal
   pill scroller ABOVE it: this page's whole job is showing images, and a
   permanent side column spent ~190px of every viewport on a list of words —
   often a full extra tile column on desktop, and on mobile it pushed the grid
   into two cramped columns. */
.vibes-shell {
    display: block;
}

/* ── Category rail ─────────────────────────────────────────────────────── */
.vibes-rail {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    /* Edge-to-edge scroll on mobile without the pills touching the viewport. */
    padding: 2px 2px 16px;
    margin: 0 0 4px;
    scrollbar-width: none;         /* the pills are the affordance */
    -webkit-overflow-scrolling: touch;
}
.vibes-rail::-webkit-scrollbar { display: none; }

/* Heading is redundant once the pills read as a filter row. */
.vibes-rail-heading { display: none; }

.vibes-rail a {
    flex: 0 0 auto;
    display: inline-block;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    padding: 8px 15px;
    border-radius: 999px;
    background: var(--color-bg-soft, #f5f5f7);
    border: 1px solid var(--color-border, rgba(0,0,0,.07));
    color: var(--color-muted, #8492a6);
    text-decoration: none;
    white-space: nowrap;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.vibes-rail a:hover {
    color: var(--color-dark, #3c4858);
    border-color: var(--color-border-strong, rgba(0,0,0,.16));
}
.vibes-rail a.active {
    background: var(--color-primary, #cc0000);
    border-color: var(--color-primary, #cc0000);
    color: #fff;
}
.vibes-rail a:focus-visible {
    outline: 2px solid var(--color-primary, #cc0000);
    outline-offset: 2px;
}

.vibes-grid {
    flex: 1 1 auto;
    min-width: 0;
    column-count: 5;
    column-gap: 16px;
}
@media (max-width: 1399px) { .vibes-grid { column-count: 4; } }
@media (max-width: 1199px) { .vibes-grid { column-count: 3; } }
@media (max-width: 767px)  { .vibes-grid { column-count: 2; column-gap: 11px; } }

/* No card. The white panel + shadow made each tile read as a row in a
   directory; dropping it lets the images sit on the page background and BE the
   page. The radius moves to the media element so the image keeps its shape. */
.vibe-tile {
    break-inside: avoid;
    page-break-inside: avoid;   /* older Firefox */
    margin-bottom: 18px;
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform .22s cubic-bezier(.2,.7,.3,1);
}
@media (max-width: 767px) { .vibe-tile { margin-bottom: 11px; } }

.vibe-tile:hover { transform: translateY(-3px); }
.vibe-tile:hover .vibe-tile-media {
    box-shadow: 0 8px 22px rgba(26, 31, 46, .16);
}
.vibe-tile:focus-visible {
    outline: 2.5px solid var(--color-primary, #cc0000);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .vibe-tile, .vibe-tile:hover { transition: none; transform: none; }
}

/*
 * The image box is reserved from the server-supplied aspect ratio BEFORE the
 * image loads, via an inline aspect-ratio on .vibe-tile-media. Without it every
 * tile would collapse to zero height and the column heights would thrash as
 * images arrive — the single most visible failure mode in a masonry feed, and
 * the reason vibes.width/height exist at all.
 *
 * dominant_hex fills that reserved box, so the page looks composed while
 * loading rather than like a grid of grey holes.
 */
.vibe-tile-media {
    display: block;
    width: 100%;
    background: #eef0f4;
    aspect-ratio: 1 / 1;         /* overridden inline per tile */
    position: relative;
    /* The tile no longer clips, so the image does its own rounding. */
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow .22s ease;
}
.vibe-tile-media img,
.vibe-tile-media video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/*
 * Video tiles.
 *
 * The poster is painted by the element itself (poster=""), so the box looks
 * identical to an image tile until the clip is scrolled into view and starts.
 * Nothing here reserves space — .vibe-tile-media already owns the aspect ratio,
 * for stills and clips alike.
 */
.vibe-media-badge {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(12, 12, 14, .62);
    color: #fff;
    font-size: 14px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}
/*
 * The badge stays visible while playing rather than fading out. It is not a
 * play BUTTON — the tile is a link and tapping it opens the detail page — so
 * it reads as "this tile is a clip", which is true whether or not it happens
 * to be moving right now. Hiding it on play would make a muted autoplaying
 * clip indistinguishable from a still that simply moved.
 */

/*
 * display:block is load-bearing, not tidiness. These are <span>s (the tile is
 * an <a>, so its children must be phrasing content), and vertical padding on
 * an INLINE box paints without reserving any height. The tile clips with
 * overflow:hidden, so the caption block was being cut off at the bottom radius
 * — visibly so on any two-line title.
 */
.vibe-tile-body { display: block; padding: 8px 2px 0; }
.vibe-tile-title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-dark, #3c4858);
    margin: 0;
    /* Two lines, then ellipsis — keeps tile heights from varying wildly on
       long seller captions. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.vibe-tile-meta {
    display: block;   /* same inline-box reason as .vibe-tile-body */
    font-size: 11px;
    color: var(--color-muted, #8492a6);
    margin: 3px 0 0;
}

/* AI disclosure chip. Always rendered when ai_model is set — this is a
   compliance surface, not decoration, so it is never conditional on hover or
   viewport. */
.vibe-ai-chip {
    position: absolute;
    left: 8px;
    bottom: 8px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    background: rgba(12, 12, 14, .74);
    color: #fff;
    padding: 3px 7px;
    border-radius: 5px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.vibe-save-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    background: var(--color-primary, #cc0000);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(204, 0, 0, .38);
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity .18s ease, transform .18s ease;
    cursor: pointer;
}
.vibe-tile:hover .vibe-save-btn,
.vibe-save-btn:focus-visible { opacity: 1; transform: translateY(0); }
/* Touch devices get no hover, so the control must be permanently visible or it
   is unreachable. */
@media (hover: none) {
    .vibe-save-btn { opacity: 1; transform: none; }
}
.vibe-save-btn.is-saved { background: #3c4858; box-shadow: none; }

/* ── Detail page ───────────────────────────────────────────────────────── */
.vibe-detail-media {
    border-radius: 18px;
    overflow: hidden;
    background: #eef0f4;
    position: relative;
}
.vibe-detail-media img { display: block; width: 100%; height: auto; }

.vibe-detail-title {
    font-size: 26px;
    font-weight: 400;
    letter-spacing: -.02em;
    line-height: 1.2;
    margin: 0 0 6px;
}

.vibe-match-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f2f5;
    text-decoration: none;
    color: inherit;
}
.vibe-match-row:last-child { border-bottom: 0; }
.vibe-match-row:hover .vibe-match-name { color: var(--color-primary, #cc0000); }

.vibe-match-avatar {
    width: 46px; height: 46px;
    border-radius: 12px;
    object-fit: cover;
    background: #eef0f4;
    flex: 0 0 auto;
}
.vibe-match-avatar.is-ps { border-radius: 50%; }

.vibe-match-name {
    font-size: 14px; font-weight: 700;
    color: var(--color-dark, #3c4858);
    display: flex; align-items: center; gap: 5px;
    transition: color .15s ease;
}
.vibe-match-sub { font-size: 12px; color: var(--color-muted, #8492a6); margin-top: 1px; }

/*
 * Match bands are qualitative, never a percentage. The score behind them blends
 * IDF tag overlap with embedding cosine; "87% match" would claim a precision it
 * does not have, and one confidently wrong 87% costs more trust than ten honest
 * "Worth asking"s.
 */
.vibe-band {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
    flex: 0 0 auto;
}
.vibe-band--top          { background: #fdecec; color: #cc0000; }
.vibe-band--likely       { background: #e6f7f5; color: #00786f; }
.vibe-band--worth_asking { background: #f2f4f7; color: #8492a6; }

/*
 * Boosted rows — paid placement, disclosed.
 *
 * A boost lifts a shop's RANK; since the band is now computed from the organic
 * score (VibeMatcher::computeAndStore), it can no longer lift the match-strength
 * claim. This is the other half of that: the shopper is told which rows were
 * paid for rather than left to wonder why the ordering looks odd.
 *
 * Blue is deliberately outside the band palette (red/teal/grey) so it never
 * reads as a fourth, better band.
 *
 * The word "Boosted" is not optional decoration. Colour alone is not a
 * disclosure — it fails WCAG 1.4.1, it is invisible to a screen reader, and a
 * shopper has no way to learn what blue means. The border draws the eye; the
 * label is what actually discloses.
 */
.vibe-match-row--boosted {
    border-left: 3px solid var(--color-boosted, #3b82f6);
    padding-left: 10px;
    margin-left: -13px;
    border-radius: 2px 0 0 2px;
}
.vibe-boosted-tag {
    font-size: 10.5px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 999px;
    white-space: nowrap;
    flex: 0 0 auto;
    background: #eaf1fd;
    color: var(--color-boosted, #3b82f6);
    margin-left: auto;
}
/* When a Boosted tag is present it owns the auto margin, so the band must not
   also claim it — otherwise they push apart to opposite ends of the row. */
.vibe-boosted-tag + .vibe-band { margin-left: 6px; }

/* ── Empty / loading ───────────────────────────────────────────────────── */
.vibes-sentinel { height: 1px; }
.vibes-loading {
    text-align: center;
    padding: 30px 0;
    color: var(--color-muted, #8492a6);
    font-size: 13px;
}
.vibes-empty { text-align: center; padding: 70px 20px; color: var(--color-muted, #8492a6); }

/* Skeleton tiles for the append-on-scroll state. Page-shaped, and only ever
   shown for loading-more — the first page is server-rendered, so an initial
   skeleton would be a flash of nothing replacing real content. */
.vibe-skel {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: 16px;
    background: linear-gradient(100deg, #eef0f4 30%, #f6f8fa 50%, #eef0f4 70%);
    background-size: 220% 100%;
    animation: vibeShimmer 1.3s linear infinite;
}
@keyframes vibeShimmer { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) { .vibe-skel { animation: none; } }

@media (max-width: 991px) {
    .vibes-shell { display: block; }
    .vibes-rail {
        position: static;
        max-height: none;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 12px;
        margin-bottom: 16px;
        flex: none;
    }
    .vibes-rail-heading { display: none; }
    .vibes-rail a {
        white-space: nowrap;
        border: 1px solid #e8e8e8;
        border-radius: 999px;
        padding: 6px 14px;
    }
}

/* ── Matched shops on the tile ─────────────────────────────────────────────
 *
 * The line that makes this feed different from every other inspiration feed:
 * the shopper is looking at a beautiful thing AND at who can actually get it.
 * "7 shops" as grey text is a fact; three faces are a reason to tap.
 *
 * Avatars are decorative — the count beside them carries the meaning, so they
 * are aria-hidden and the row reads as plain text to a screen reader.
 */
.vibe-tile-shops {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 5px 0 0;
}
.vibe-shop-faces {
    display: flex;
    flex: 0 0 auto;
}
.vibe-shop-face {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    /* Ring is the PAGE colour, not white — the tile sits on the page now, and a
       white ring would draw a halo on any non-white theme. */
    border: 1.5px solid var(--color-bg, #f7f7f9);
    background: var(--color-bg-soft, #eef0f4);
    display: block;
}
.vibe-shop-face + .vibe-shop-face { margin-left: -6px; }

/* Fallback when a shop has no picture: its initial, on a stable tint. */
.vibe-shop-face--initial {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--color-muted, #8492a6);
    text-transform: uppercase;
    line-height: 1;
}

/* ── Overlay tiles ─────────────────────────────────────────────────────────
 *
 * Opt-in per tile (PHP adds the class for dark, high-contrast images). The
 * caption sits ON the image instead of under it, which suits a photograph with
 * its own dark region and saves the vertical space a caption row costs.
 *
 * The scrim is a flat rgba block rather than a gradient — gradients are banned
 * elsewhere in this codebase for streaming/paint reasons and there is no reason
 * to make an exception for one tile variant.
 */
.vibe-tile--overlay .vibe-tile-body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 26px 11px 11px;
    background: rgba(18, 20, 28, .55);
    border-radius: 0 0 14px 14px;
}
.vibe-tile--overlay .vibe-tile-title { color: #fff; }
.vibe-tile--overlay .vibe-tile-meta,
.vibe-tile--overlay .vibe-tile-shops { color: rgba(255, 255, 255, .84); }
.vibe-tile--overlay .vibe-shop-face { border-color: rgba(255, 255, 255, .5); }
