/* ==========================================================================
   Document thumbnail card + grid (Briox\Components\DocumentThumbnail)
   Rendered by com/components/document_thumbnail.htm in the grid view of
   Incoming documents. Geometry follows the Figma spec (248x325 card, 3:4
   preview, body anchored to the bottom edge); colours come from the theme.
   ========================================================================== */

.doc-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--doc-thumb-card-min, 14rem), var(--doc-thumb-card-max, 15.5rem)));
    gap: 1rem;
    justify-content: start;
    padding: var(--spacing-xs) 0 1rem 0;
}
/* Each size is a min-max range, so the grid packs one more column when there is spare gutter. */
.doc-thumb-grid--size-s { --doc-thumb-card-min: 10rem;   --doc-thumb-card-max: 11.5rem; }
.doc-thumb-grid--size-m { --doc-thumb-card-min: 14rem;   --doc-thumb-card-max: 15.5rem; }
.doc-thumb-grid--size-l { --doc-thumb-card-min: 17.5rem; --doc-thumb-card-max: 19.5rem; }

/* No overflow: hidden on the card: the kebab menu opens outside it. The preview clips the image instead. */
.doc-thumb-card {
    position: relative;
    width: 100%;
    aspect-ratio: 248 / 325;
    background: var(--color-bg-default);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}
.doc-thumb-card:hover,
.doc-thumb-card:focus-within {
    border-color: var(--accent);
}

.doc-thumb-card__preview {
    position: absolute;
    inset: 0;
    background: var(--color-bg-sunken);
    overflow: hidden;
    border-radius: var(--radius-md);
}
.doc-thumb-card__img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 88.1%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.doc-thumb-card__status {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.1875rem 0.5625rem;
    background: var(--color-bg-default);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xs);
    font-size: var(--font-body-sm-size);
    line-height: 1rem;
    color: var(--color-text-muted);
    pointer-events: none;
    max-width: calc(100% - 1rem);
}
/* Dot colour comes from the row-colour class the table view uses (finalpayed / unposted / overdue). */
.doc-thumb-card__status-dot {
    display: inline-block;
    width: 0.375rem;
    height: 0.375rem;
    border-radius: var(--radius-full);
}

/* The box itself is the design-system checkbox; this only places it and reveals it on hover. */
.doc-thumb-card__checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    margin: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 2;
}
/* Invisible hit-area extension, so a near miss does not open the document. */
.doc-thumb-card__checkbox::before {
    content: '';
    position: absolute;
    inset: -0.5rem;
}
.doc-thumb-card:hover .doc-thumb-card__checkbox,
.doc-thumb-card:focus-within .doc-thumb-card__checkbox,
.doc-thumb-card:has(.massop_checkbox:checked) .doc-thumb-card__checkbox {
    opacity: 1;
}

/* Margins rather than flex gap, so collapsed meta blocks leave no phantom gap. */
.doc-thumb-card__body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg-default);
    padding: 0.75rem;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: 0 -0.5rem 1rem -0.25rem rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 1;
}
.doc-thumb-card__title {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.doc-thumb-card__filename {
    margin: 0;
    font-size: var(--font-caption-lg-size);
    font-weight: var(--font-caption-lg-weight);
    color: var(--color-text-default);
    line-height: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-thumb-card__type {
    margin: 0;
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-body-sm-weight);
    line-height: 1rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Metadata is always rendered and grows in when the body is hovered. */
.doc-thumb-card__meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 0.5rem;
    row-gap: 0.5rem;
    font-size: var(--font-body-sm-size);
    line-height: 0.6875rem;
    color: var(--color-text-muted);
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;
    transition: max-height 0.22s ease, opacity 0.18s ease, margin-top 0.22s ease;
}
.doc-thumb-card__meta-received {
    margin: 0;
    font-size: var(--font-body-sm-size);
    line-height: 1rem;
    color: var(--color-text-muted);
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;
    transition: max-height 0.22s ease, opacity 0.18s ease, margin-top 0.22s ease;
}
.doc-thumb-card__body:hover .doc-thumb-card__meta,
.doc-thumb-card__body:focus-within .doc-thumb-card__meta {
    max-height: 6rem;
    opacity: 1;
    margin-top: 0.5rem;
}
.doc-thumb-card__body:hover .doc-thumb-card__meta-received,
.doc-thumb-card__body:focus-within .doc-thumb-card__meta-received {
    max-height: 2rem;
    opacity: 0.75;
    margin-top: 0.5rem;
}
.doc-thumb-card__meta-label {
    color: var(--color-text-muted);
    white-space: nowrap;
}
.doc-thumb-card__meta-value {
    margin: 0;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-thumb-card__actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-top: 0.5rem;
    padding-top: 0.5625rem;
    border-top: 1px solid var(--color-border-subtle);
}
/* The attachment icon and the Briox.Select kebab still inject SVGs; clamp them to icon size. */
.doc-thumb-card__actions svg {
    width: var(--icon-size-sm);
    height: var(--icon-size-sm);
    display: block;
}
.doc-thumb-card__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    padding: 0.5rem 0.25rem;
}
.doc-thumb-card__action .sym {
    font-size: var(--icon-size-sm);
}
.doc-thumb-card__action:hover {
    background: var(--color-hover-bg);
}
/* .greyed_out_icon (general.css) dims the icon; it should not get a hover background either. */
.doc-thumb-card__action.greyed_out_icon:hover {
    background: transparent;
}

.doc-thumb-card__kebab {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

@media (prefers-reduced-motion: reduce) {
    .doc-thumb-card,
    .doc-thumb-card__checkbox,
    .doc-thumb-card__meta,
    .doc-thumb-card__meta-received {
        transition: none;
    }
}
