/* The page toggles states with the `hidden` attribute; the display rules below
   (flex/grid) would otherwise override it and show every state at once. */
[hidden] { display: none !important; }

/* Link-styled buttons (Edit, Connect a data source) shouldn't be underlined */
a.btn { text-decoration: none; }

/* ============================================================
   HOME PAGE
   ============================================================ */

/* Page header: heading + "New dashboard" button side by side */
.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.home-header h1 {
    font-size: var(--text-xl);
}

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: var(--space-md);
    list-style: none;
    padding: 0;
    margin: 0;
}

/* ============================================================
   DASHBOARD CARD
   ============================================================ */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    transition:
        transform var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-fast) var(--ease-out);
    overflow: hidden;
}

.card:hover,
.card:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px -4px hsl(265 30% 10% / 0.2), 0 1px 0 hsl(265 20% 10% / 0.04);
}

/* Clickable card body — links to view.html */
.card-body {
    display: block;
    padding: var(--space-md);
    text-decoration: none;
    color: inherit;
    flex: 1;
}

.card-body:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
    border-radius: calc(var(--radius-md) - 1px);
}

.card-name {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
    /* clamp to two lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
    flex-wrap: wrap;
}

.card-updated {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* Public / Private badge */
.card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.15em 0.55em;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    line-height: 1.6;
}

.card-badge[data-public="true"] {
    background: color-mix(in srgb, var(--color-ok) 12%, transparent);
    color: var(--color-ok);
    border-color: color-mix(in srgb, var(--color-ok) 30%, transparent);
}

/* Card footer: Edit button + Delete icon */
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm) var(--space-sm);
    border-top: 1px solid var(--color-border);
}

.card-edit {
    flex: 1;
}

/* Delete icon button — less prominent than Edit */
.card-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    transition: color var(--dur-fast), background-color var(--dur-fast);
    flex-shrink: 0;
}

@media (hover: hover) {
    .card-delete:hover {
        color: var(--color-danger);
        background: var(--color-danger-bg);
    }
}

.card-delete:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Trash icon SVG inside the delete button */
.card-delete svg {
    width: 1rem;
    height: 1rem;
    pointer-events: none;
}

/* ============================================================
   SKELETON LOADING CARDS
   ============================================================ */
.card-skeleton {
    min-height: 130px;
    pointer-events: none;
    overflow: hidden;
}

.card-skeleton::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--color-bg-alt) 25%,
        color-mix(in srgb, var(--color-bg-alt) 60%, var(--color-surface)) 50%,
        var(--color-bg-alt) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .card-skeleton::after { animation: none; }
}

/* ============================================================
   EMPTY + ERROR STATES
   ============================================================ */
.home-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    gap: var(--space-sm);
    max-width: 480px;
    margin-inline: auto;
}

.home-state-eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent-text);
}

.home-state-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 500;
    color: var(--color-text);
    text-wrap: balance;
}

.home-state-body {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-wrap: balance;
    margin-bottom: var(--space-xs);
}

.home-state-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */
@media (max-width: 600px) {
    .home-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .home-header .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================
   IMPORT A LAYOUT
   ============================================================ */
.home-header-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.home-state-note {
    max-width: 44ch;
    font-size: var(--text-xs);
}

.home-state-note code,
.modal-import code {
    font-family: var(--font-mono);
    font-size: 0.92em;
    padding: 0.05em 0.3em;
    border-radius: 4px;
    background: var(--color-bg-alt);
}

.modal-import { width: min(560px, calc(100vw - 2rem)); }

.modal-import .eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent-text);
}

.modal-import input[type="file"] {
    padding: 0.55rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-sm);
}

.modal-import input[type="file"]:hover { border-color: var(--color-accent); }

.import-details {
    display: grid;
    gap: var(--space-md);
}

.import-slots-field {
    border: 0;
    padding: 0;
    margin: 0;
}

.import-slots {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    max-height: 42vh;
    overflow-y: auto;
}

.import-slot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 13rem);
    align-items: center;
    gap: var(--space-sm);
    padding: 0.6rem 0.75rem;
}

.import-slot + .import-slot { border-top: 1px solid var(--color-border); }

.modal-import .import-slot-name {
    text-transform: none;
    letter-spacing: 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}

.import-slot-name::before { content: '{{ '; color: var(--color-text-muted); font-weight: 400; }
.import-slot-name::after { content: ' }}'; color: var(--color-text-muted); font-weight: 400; }

.modal-body .import-slot-meta {
    margin-top: 0.1rem;
    font-size: var(--text-xs);
    overflow-wrap: anywhere;
}

.import-slot select {
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-sm);
}

.import-slot select:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }

@media (max-width: 520px) {
    .import-slot { grid-template-columns: 1fr; }
}
