/* Decks Svelte island — layout & details, using theme.css tokens */

.decks-app {
    display: flex;
    flex-direction: column;
    gap: var(--fc-gap-lg);
    color: var(--fc-text-main);
    box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/* Shared controls (buttons + inputs) — match Cards look              */
/* ------------------------------------------------------------------ */

/* Primary buttons: “Add deck”, “Add card to deck” */
.decks-app .decks-new-button,
.decks-app .decks-card-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 2.25rem;
    padding: 0 1rem;

    border-radius: var(--fc-radius-chip);
    border: 1px solid transparent;

    background: linear-gradient(
        to right,
        var(--fc-purple),
                                var(--fc-purple-soft)
    );
    color: var(--fc-text-main);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;

    cursor: pointer;
    transition:
    background 160ms ease-out,
    box-shadow 160ms ease-out,
    transform 80ms ease-out,
    border-color 160ms ease-out;
}

.decks-app .decks-new-button:hover:not(:disabled),
.decks-app .decks-card-button:hover:not(:disabled) {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-1px);
}

.decks-app .decks-new-button:active:not(:disabled),
.decks-app .decks-card-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.decks-app .decks-new-button:disabled,
.decks-app .decks-card-button:disabled {
    opacity: 0.55;
    cursor: default;
    box-shadow: none;
}

/* Shared input look for deck name + new card fields */
.decks-app .decks-new-input,
.decks-app .decks-card-input {
    width: 100%;
    min-height: 2.25rem;

    padding: 0.55rem 0.8rem;

    border-radius: 0.5rem;
    border: 1px solid var(--fc-border-subtle);

    background: rgba(15, 23, 42, 0.9);
    color: var(--fc-text-main);
    font-size: 0.9rem;
    box-sizing: border-box;
}

.decks-app .decks-new-input::placeholder,
.decks-app .decks-card-input::placeholder {
    color: var(--fc-text-muted);
}

.decks-app .decks-new-input:focus-visible,
.decks-app .decks-card-input:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.7);
    outline-offset: 1px;
    border-color: var(--fc-purple);
}

/* Let the “add card to deck” button sit at the right edge by default */
.decks-card-button {
    align-self: flex-end;
}

/* ------------------------------------------------------------------ */
/* Header row (title + status chip)                                   */
/* ------------------------------------------------------------------ */

.decks-header-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.decks-status {
    font-size: 0.85rem;
    color: var(--fc-text-muted);
}

.decks-status--loading {
    color: #c4b5fd; /* soft violet */
}

.decks-status--error {
    color: var(--fc-error);
}

.decks-status--hint {
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* Error lines */

.decks-error {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--fc-error);
}

.decks-error--inline {
    margin-top: 0.25rem;
}

/* ------------------------------------------------------------------ */
/* New deck form                                                      */
/* ------------------------------------------------------------------ */

.decks-new {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: var(--fc-gap-md);
}

.decks-new-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 260px;
    font-size: 0.82rem;
    color: var(--fc-text-muted);
}

/* layout bits only; visual comes from shared input styles */
.decks-new-input {
    /* no extra visual overrides needed */
}

/* ------------------------------------------------------------------ */
/* Main layout: list + detail                                         */
/* ------------------------------------------------------------------ */

.decks-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr);
    gap: var(--fc-gap-md);
    margin-top: var(--fc-gap-md);
}

/* Left: decks list */

.decks-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.decks-item {
    list-style: none;
}

.decks-item--unsorted {
    margin-bottom: 0.25rem;
}

.decks-item-button {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.9);
    color: var(--fc-text-main);
    cursor: pointer;
    text-align: left;
    transition:
    background 120ms ease-out,
    border-color 120ms ease-out,
    box-shadow 120ms ease-out,
    transform 120ms ease-out;
}

.decks-item-button:hover {
    background: rgba(76, 29, 149, 0.55);
    border-color: var(--fc-purple);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.9);
    transform: translateY(-1px);
}

.decks-item-button--selected {
    background:
    radial-gradient(circle at top left,
                    rgba(168, 85, 247, 0.4),
                    rgba(15, 23, 42, 0.95));
    border-color: var(--fc-purple);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 1);
}

.decks-item-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.decks-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--fc-text-main);
}

.decks-slug {
    font-size: 0.78rem;
    color: var(--fc-text-muted);
}

.decks-count {
    font-size: 0.8rem;
    color: var(--fc-text-muted);
}

/* Empty state in list */

.decks-empty {
    padding: 0.75rem 0.85rem;
    border-radius: 0.6rem;
    border: 1px dashed rgba(148, 163, 184, 0.5);
    font-size: 0.85rem;
    color: var(--fc-text-muted);
}

/* ------------------------------------------------------------------ */
/* Right: detail panel                                                */
/* ------------------------------------------------------------------ */

.decks-detail {
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 0.9rem 1rem 1rem;
    background: radial-gradient(
        circle at top,
        rgba(15, 23, 42, 0.92),
                                #020617
    );
    min-height: 9rem;
}

.decks-detail-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--fc-text-main);
}

/* Cards table inside selected deck */

/* Cards table inside selected deck — layout tweaks only;
 *   visual styling comes from shared table rules in cards.css */

.decks-cards-table {
    margin-bottom: 0.9rem;
    margin-top: 0.3rem;
}

/* Clamp front/back columns to avoid huge rows */
.decks-cards-table td:nth-child(1),
.decks-cards-table td:nth-child(2) {
    max-width: 14rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ */
/* New card form in detail                                            */
/* ------------------------------------------------------------------ */

.decks-card-new {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.decks-card-fields {
    display: grid;
    grid-template-columns:
    minmax(0, 1.3fr)
    minmax(0, 1.3fr)
    minmax(0, 1.1fr);
    gap: 0.6rem;
}

/* layout only; visual from shared input styles */
.decks-card-input {
    /* no extra visual overrides needed */
}

/* ------------------------------------------------------------------ */
/* Responsive tweaks                                                  */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
    .decks-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .decks-detail {
        margin-top: var(--fc-gap-md);
    }
}

@media (max-width: 640px) {
    .decks-new {
        flex-direction: column;
        align-items: stretch;
    }

    .decks-new-button {
        align-self: flex-start;
    }

    .decks-card-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .decks-card-button {
        width: 100%;
        text-align: center;
        align-self: stretch;
    }
}
