/* Collection cards (javascript/collection-shared.js) and the collection dialog
   (javascript/collection-form.js), used on collections.html and profile.html.
   Builds on the tokens in home-format.css. Like figure cards, a collection card has no
   box: a strip of photos on the light tile, then the name, owner and value as text. */

.cc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 32px 24px;
}

.cc-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cc-card__link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--ff-text);
    text-decoration: none;
    border-radius: 4px;
}

.cc-card__link:hover .cc-card__name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cc-card__link:hover .cc-tiles {
    box-shadow: 0 0 0 1px var(--ff-text-secondary);
}

.cc-card__link:focus-visible {
    outline: 2px solid var(--ff-gold);
    outline-offset: 4px;
}

/* ===== Photo tiles ===== */
.cc-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    margin-bottom: 6px;
    overflow: hidden;
    border-radius: 4px;
    transition: box-shadow 0.15s ease;
}

/* An empty collection still gets a strip, so its card lines up with the rest */
.cc-tiles:empty {
    aspect-ratio: 3 / 1;
    background: var(--ff-track);
}

.cc-tile {
    display: grid;
    place-items: center;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: var(--ff-photo);
}

.cc-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    display: block;
}

.cc-tile--more {
    font-size: 14px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--ff-text-secondary);
    background: var(--ff-track);
}

/* ===== Text ===== */
.cc-card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.cc-card__name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.cc-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 0;
    font-size: 13px;
    color: var(--ff-text-secondary);
}

.cc-card__owner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.cc-avatar {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    overflow: hidden;
    font-size: 11px;
    font-weight: 600;
    color: var(--ff-text);
    background: var(--ff-track);
    border: 1px solid var(--ff-card-border);
    border-radius: 50%;
}

.cc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cc-card__value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--ff-text-secondary);
}

/* ===== Labels =====
   Plain text: the value is the figure people look for, so it's the brightest thing
   on the line. Public / Private is a small outlined tag. */
.cc-pill {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--ff-text-secondary);
}

.cc-pill--value {
    font-weight: 600;
    color: var(--ff-text);
}

.cc-pill--public,
.cc-pill--private {
    padding: 1px 6px;
    font-size: 11px;
    border: 1px solid var(--ff-card-border);
    border-radius: 3px;
}

.cc-pill--public {
    color: var(--ff-text);
}

/* ===== Optional buttons under the card (My collections) ===== */
.cc-card__actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
    padding-top: 14px;
}

/* ===== ⋯ menu (popup-menu.js): opens above its button, or below with --below =====
   Same look as the account menu. Dark background, so the coral "danger" text passes */
.cl-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    min-width: 190px;
    padding: 6px;
    background: var(--ff-card);
    border: 1px solid var(--ff-card-border);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.cl-menu--below {
    top: calc(100% + 6px);
    bottom: auto;
}

.cl-menu button {
    min-height: 40px;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    color: var(--ff-text);
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.cl-menu button:hover:not(:disabled),
.cl-menu button:focus-visible {
    background: var(--ff-track);
    outline: none;
}

.cl-menu button:disabled {
    opacity: 0.45;
    cursor: default;
}

.cl-menu .cl-menu__danger {
    color: var(--ff-down);
}

/* ===== Form controls and the New / Edit collection dialog (collection-form.js) ===== */
.cl-control {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: 14px;
    color: var(--ff-text);
    background: var(--ff-track);
    border: 1px solid var(--ff-card-border);
    border-radius: 6px;
    color-scheme: dark;
}

.cl-control::placeholder {
    color: var(--ff-text-secondary);
}

.cl-control:hover {
    border-color: var(--ff-text-secondary);
}

.cl-control:focus {
    outline: none;
    border-color: var(--ff-gold);
}

.cl-dialog {
    width: min(480px, calc(100vw - 32px));
    padding: 0;
    color: var(--ff-text);
    background: var(--ff-card);
    border: 1px solid var(--ff-card-border);
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.cl-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.cl-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
}

.cl-form h2 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.cl-form > label {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
}

.cl-form > label span {
    font-weight: 400;
    color: var(--ff-text-secondary);
}

.cl-form textarea.cl-control {
    height: auto;
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
}

.cl-form__hint,
.cl-form__text {
    margin: 0;
    font-size: 13px;
    color: var(--ff-text-secondary);
}

.cl-form__text {
    font-size: 15px;
    color: var(--ff-text);
    line-height: 1.5;
}

/* Public / Private: two hairline rows, the chosen one outlined in gold */
.cl-form__vis {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0 0;
    padding: 0;
    border: none;
}

.cl-form__vis legend {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
}

.cl-form__vis label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid var(--ff-card-border);
    border-radius: 6px;
    cursor: pointer;
}

.cl-form__vis label:hover {
    border-color: var(--ff-text-secondary);
}

.cl-form__vis label:has(input:checked) {
    border-color: var(--ff-gold);
}

.cl-form__vis input {
    margin: 2px 0 0;
    accent-color: var(--ff-gold);
}

.cl-form__vis span {
    color: var(--ff-text-secondary);
}

.cl-form__vis b {
    display: block;
    font-weight: 500;
    color: var(--ff-text);
}

.cl-form__msg {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--ff-down);
}

.cl-form__msg:empty {
    display: none;
}

.cl-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.cl-btn {
    min-height: 40px;
    padding: 0 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--ff-text);
    background: transparent;
    border: 1px solid var(--ff-card-border);
    border-radius: 6px;
    cursor: pointer;
}

.cl-btn:hover {
    border-color: var(--ff-text-secondary);
}

.cl-btn--gold {
    color: #0E0F11;
    background: var(--ff-gold);
    border-color: var(--ff-gold);
}

.cl-btn--gold:hover {
    border-color: var(--ff-gold);
    filter: brightness(1.08);
}

/* White on the dark red fill passes contrast; the word "Delete" carries the meaning */
.cl-btn--danger {
    color: #fff;
    background: var(--ff-danger-bg);
    border-color: var(--ff-danger-bg);
}

.cl-btn--danger:hover {
    border-color: var(--ff-down);
}

.cl-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.cl-btn:focus-visible,
.cl-form__vis label:has(input:focus-visible) {
    outline: 2px solid var(--ff-gold);
    outline-offset: 2px;
}

@media (max-width: 767px) {
    .cl-control {
        height: 44px;
    }

    .cl-menu button {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cc-tiles {
        transition: none;
    }
}
