/* Item card: one card for every listing of projects, tenders and notices.
   Markup comes from <x-frontend.item-card> and <x-frontend.item-card-meta>. */

.gov-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.gov-item-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--gov-border-dark);
    border-top: 3px solid var(--gov-primary);
    border-radius: var(--gov-radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gov-item-card:hover {
    border-color: var(--gov-primary);
    box-shadow: var(--gov-shadow-md);
}

.gov-item-card--active { border-top-color: #047857; }
.gov-item-card--urgent { border-top-color: #b91c1c; }
.gov-item-card--closed { border-top-color: #9ca3af; }

/* Head: status badges on the left, reference code on the right */
.gov-item-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px 0;
}

.gov-item-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gov-item-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--gov-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    background: #eef2f7;
    color: var(--gov-primary);
}

.gov-item-badge--active { background: #ecfdf5; color: #047857; }
.gov-item-badge--urgent { background: #b91c1c; color: #fff; }
.gov-item-badge--closed { background: #f1f3f5; color: #4b5563; }

.gov-item-card-code {
    flex-shrink: 0;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.78rem;
    color: #5b6573;
    white-space: nowrap;
}

/* Title and subtitle */
.gov-item-card-main {
    padding: 12px 20px 0;
}

.gov-item-card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--gov-text-dark);
    overflow-wrap: anywhere;
}

.gov-item-card-title a {
    color: inherit;
    text-decoration: none;
}

.gov-item-card-title a:hover,
.gov-item-card-title a:focus-visible {
    color: var(--gov-primary);
    text-decoration: underline;
}

.gov-item-card-subtitle {
    margin: 6px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #5b6573;
}

/* Meta rows: label on the left, value on the right */
.gov-item-card-meta {
    flex: 1;
    margin: 16px 20px 0;
    padding: 0;
}

.gov-item-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 0;
    border-top: 1px solid var(--gov-border);
    font-size: 0.9rem;
}

.gov-item-meta dt {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    font-weight: 400;
    color: #5b6573;
}

.gov-item-meta dt i {
    width: 16px;
    text-align: center;
    color: var(--gov-primary);
}

.gov-item-meta dd {
    margin: 0;
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    color: var(--gov-text-dark);
}

/* Long free text (an address) may wrap */
.gov-item-meta--wrap dd {
    white-space: normal;
    overflow-wrap: anywhere;
}

.gov-item-meta-note {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
}

.gov-item-meta-note--active { color: #047857; }
.gov-item-meta-note--closed { color: #b91c1c; }

/* Notice inside a card (extension, comment) */
.gov-item-card-note {
    margin: 12px 20px 0;
    padding: 10px 12px;
    border-left: 3px solid var(--gov-primary);
    background: #f4f7fb;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--gov-text-body);
}

.gov-item-card-note strong {
    display: block;
    margin-bottom: 2px;
    color: var(--gov-primary);
}

/* Actions (selectors start with .gov-item-card so the Tilda link reset in gov-base.css does not win) */
.gov-item-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--gov-border);
}

.gov-item-card-actions:empty {
    display: none;
}

.gov-item-card .gov-item-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--gov-primary);
    border-radius: var(--gov-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    background: #fff;
    color: var(--gov-primary);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.gov-item-card .gov-item-btn:hover,
.gov-item-card .gov-item-btn:focus-visible {
    background: #eef2f7;
    color: var(--gov-primary-dark);
}

.gov-item-card .gov-item-btn--primary {
    background: var(--gov-primary);
    color: #fff;
}

.gov-item-card .gov-item-btn--primary:hover,
.gov-item-card .gov-item-btn--primary:focus-visible {
    background: var(--gov-primary-dark);
    color: #fff;
}

.gov-item-card .gov-item-btn--link {
    margin-left: auto;
    padding-left: 0;
    padding-right: 0;
    border-color: transparent;
    background: none;
}

.gov-item-card .gov-item-btn--link:hover,
.gov-item-card .gov-item-btn--link:focus-visible {
    background: none;
    text-decoration: underline;
}

/* Group heading above a grid (e.g. renovation stages) */
.gov-item-group + .gov-item-group {
    margin-top: 40px;
}

.gov-item-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gov-border-dark);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gov-primary);
}

.gov-item-group-count {
    padding: 2px 8px;
    border-radius: var(--gov-radius-sm);
    background: var(--gov-primary);
    color: #fff;
    font-size: 0.8rem;
}

/* Toolbar above a list: heading on the left, filters on the right */
.gov-item-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: 28px;
}

.gov-item-toolbar h2 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gov-text-dark);
}

.gov-item-toolbar p {
    margin: 0;
    color: #5b6573;
}

.gov-item-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gov-item-filters .gov-input::placeholder {
    color: #6b7280;
}

.gov-item-filters .gov-input,
.gov-item-filters .gov-select {
    width: auto;
    min-width: 200px;
    padding: 9px 12px;
    font-size: 0.9rem;
}

.gov-item-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--gov-border-dark);
    border-radius: var(--gov-radius-sm);
    background: #fff;
    color: var(--gov-text-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.gov-item-filter-btn:hover {
    border-color: var(--gov-primary);
    color: var(--gov-primary);
}

.gov-item-filter-btn[aria-pressed="true"] {
    border-color: var(--gov-primary);
    background: var(--gov-primary);
    color: #fff;
}

.gov-item-empty {
    padding: 48px 20px;
    border: 1px dashed var(--gov-border-dark);
    border-radius: var(--gov-radius);
    text-align: center;
    color: #5b6573;
}

@media (max-width: 768px) {
    .gov-item-grid {
        grid-template-columns: 1fr;
    }

    .gov-item-filters,
    .gov-item-filters .gov-input,
    .gov-item-filters .gov-select {
        width: 100%;
    }

    .gov-item-filter-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* Filtering hides cards and groups with the hidden attribute */
.gov-item-card[hidden],
.gov-item-group[hidden] {
    display: none;
}
