/* The tiles: one per entry, folder or note, in a grid that fills the width and wraps by itself.
   Client/ui/tiles.js builds the markup; this decides how it looks. */

.pv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
    gap: var(--space-3);
}

.pv-grid:has(> .pv-empty) {
    display: block;
}

/* --- One tile ------------------------------------------------------------------------------------------------ */

.pv-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    min-width: 0;
    min-height: 104px;
    padding: var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-tile);
    background: var(--surface-1);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--motion-hover), border-color var(--motion-hover);
}

.pv-tile:hover {
    background: var(--surface-2);
}

.pv-tile[aria-selected="true"] {
    border-color: var(--accent-border);
    background: var(--accent-subtle);
}

.pv-tile__text {
    display: grid;
    gap: 2px;
    width: 100%;
    min-width: 0;
}

.pv-tile__title {
    overflow: hidden;
    font-size: var(--type-body);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pv-tile__meta {
    overflow: hidden;
    color: var(--text-tertiary);
    font-size: var(--type-caption);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pv-tile__star {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    display: inline-flex;
    color: var(--accent-text);
}

.pv-tile__star .pv-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* What the search found. */
.pv-hit {
    border-radius: 2px;
    background: var(--accent-glow);
    color: var(--accent-text);
}

/* --- The avatar: a letter on a hue that follows the name --------------------------------------------------- */

.pv-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: var(--type-body);
    font-weight: 650;
}

.pv-avatar--lg {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: var(--type-subtitle);
}

.pv-avatar--symbol {
    color: var(--accent-text);
}

/* The eight hues, from tokens.css. The border is the same hue at a third of its strength. */
.pv-hue-1 { color: var(--hue-1); border-color: color-mix(in srgb, var(--hue-1) 32%, transparent); }
.pv-hue-2 { color: var(--hue-2); border-color: color-mix(in srgb, var(--hue-2) 32%, transparent); }
.pv-hue-3 { color: var(--hue-3); border-color: color-mix(in srgb, var(--hue-3) 32%, transparent); }
.pv-hue-4 { color: var(--hue-4); border-color: color-mix(in srgb, var(--hue-4) 32%, transparent); }
.pv-hue-5 { color: var(--hue-5); border-color: color-mix(in srgb, var(--hue-5) 32%, transparent); }
.pv-hue-6 { color: var(--hue-6); border-color: color-mix(in srgb, var(--hue-6) 32%, transparent); }
.pv-hue-7 { color: var(--hue-7); border-color: color-mix(in srgb, var(--hue-7) 32%, transparent); }
.pv-hue-8 { color: var(--hue-8); border-color: color-mix(in srgb, var(--hue-8) 32%, transparent); }

/* --- Nothing to show: an invitation, not an apology --------------------------------------------------------- */

.pv-empty {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    padding: var(--space-10) var(--space-4);
    color: var(--text-tertiary);
    text-align: center;
}

.pv-empty strong {
    color: var(--text-primary);
    font-size: var(--type-subtitle);
    font-weight: 600;
}

.pv-empty p {
    max-width: 30rem;
    margin: 0;
    font-size: var(--type-body);
    line-height: 1.6;
}

@media (max-width: 720px) {
    .pv-grid {
        grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
        gap: var(--space-2);
    }

    .pv-tile {
        min-height: 96px;
    }
}

/* --- The list view: the same tiles as dense rows, for a vault with many entries ------------------------------- */

[data-vault-view="list"] .pv-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
}

[data-vault-view="list"] .pv-tile {
    flex-direction: row;
    align-items: center;
    min-height: 52px;
    padding: var(--space-2) var(--space-3);
}

[data-vault-view="list"] .pv-tile__star {
    position: static;
    margin-left: auto;
}

[data-vault-view="list"] .pv-tile__text {
    grid-template-columns: minmax(0, 1fr);
}
