/* ==========================================================================
   Magic deckbuilder FR : feuille de style complète
   Pages : index (.carte-list), fiche (.carte-page), formulaires (.carte-form)
   ========================================================================== */

:root {
    --bg: #121a22;
    --surface: #1b2732;
    --surface-2: #233241;
    --border: #34475a;
    --text: #e9e6dc;
    --muted: #93a3b3;
    --accent: #d4a73a;
    --accent-dark: #b98f26;
    --accent-ink: #1a1405;
    --danger: #ef7b72;

    --font-title: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Base ---------- */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 1.5rem 1rem 3rem;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.55;
}

h1, h2, h3 {
    font-family: var(--font-title);
    font-weight: 700;
    line-height: 1.2;
}

a {
    color: var(--accent);
}

a:hover {
    color: #f0c75e;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.back-link:hover {
    color: var(--accent);
}

.error-message {
    max-width: 640px;
    margin: 1rem auto;
    padding: 0.7rem 1rem;
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: var(--danger);
    text-align: center;
}

/* ---------- Page d'index : titre + lien d'ajout ---------- */

h1 > a {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s;
}

h1 > a:hover {
    background: var(--accent-dark);
    color: var(--accent-ink);
}

/* ---------- Index : grille de cartes ---------- */

.carte-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
    max-width: 1200px;
    margin: 1.5rem auto 0;
}

.carte-list > p {
    grid-column: 1 / -1;
    color: var(--muted);
    text-align: center;
}

.card-widget {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.card-widget:hover,
.card-widget:focus-within {
    border-color: var(--accent);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.card-widget a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    height: 100%;
    padding: 0.8rem;
    color: var(--text);
    text-decoration: none;
}

.card-widget a img {
    width: 100%;
    aspect-ratio: 63 / 88; /* format réel d'une carte Magic */
    object-fit: cover;
    border-radius: 4.5% / 3.2%; /* coins arrondis comme une vraie carte */
}

.card-widget a p {
    margin: 0;
    font-family: var(--font-title);
    font-weight: 700;
    text-align: center;
}

.card-placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 63 / 88;
    border: 2px dashed var(--border);
    border-radius: 4.5% / 3.2%;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Fiche d'une carte ---------- */

.carte-page {
    display: grid;
    grid-template-columns: minmax(240px, 380px) 1fr;
    gap: 2.5rem;
    align-items: start;
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem 0;
}

.carte-page > img {
    width: 100%;
    aspect-ratio: 63 / 88;
    object-fit: cover;
    border-radius: 4.5% / 3.2%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.carte-card {
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.carte-card h1 {
    margin: 0 0 0.6rem;
    font-size: 2rem;
}

.carte-card p {
    max-width: 60ch;
    margin: 1.2rem 0 0;
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Symboles de mana (police Mana font) */
.mana-cost {
    display: block;
    margin-bottom: 0.9rem;
    font-size: 1.5rem;
    line-height: 1.6;
}

/* Types */
.badge {
    display: inline-block;
    margin: 0 0.3rem 0.3rem 0;
    padding: 0.2rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.85rem;
}

.badge-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}

/* Actions */
.carte-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.carte-actions a,
.delete-btn {
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.carte-actions a:hover {
    background: var(--accent);
    color: var(--accent-ink);
}

.delete-btn {
    border-color: var(--danger);
    color: var(--danger);
}

.delete-btn:hover {
    background: var(--danger);
    color: #2a0d0b;
}

/* ---------- Formulaires (ajout / modification) ---------- */

.carte-form {
    max-width: 640px;
    margin: 1rem auto;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.carte-form h1 {
    margin: 0.3rem 0 1.5rem;
    font-size: 1.7rem;
}

/* Chaque ligne du formulaire */
.carte-form form > div > div {
    margin-bottom: 1.3rem;
}

.carte-form label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Texte d'aide sous un champ */
.carte-form .help-text,
.carte-form .form-text {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Champs texte, nombre, textarea */
.carte-form input[type="text"],
.carte-form input[type="number"],
.carte-form textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.carte-form input::placeholder,
.carte-form textarea::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.carte-form input:focus,
.carte-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 167, 58, 0.25);
}

.carte-form textarea {
    resize: vertical;
}

/* Upload d'image */
.carte-form input[type="file"] {
    width: 100%;
    padding: 0.8rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--muted);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s;
}

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

.carte-form input[type="file"]::file-selector-button {
    margin-right: 1rem;
    padding: 0.45rem 0.9rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.carte-form input[type="file"]::file-selector-button:hover {
    background: var(--accent-dark);
}

/* Cases à cocher (couleurs, types) en pastilles */
.carte-form div[id^="carte_form_couleurs"],
.carte-form div[id^="carte_form_Type"] {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.carte-form div[id^="carte_form_couleurs"] input[type="checkbox"],
.carte-form div[id^="carte_form_Type"] input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.carte-form div[id^="carte_form_couleurs"] label,
.carte-form div[id^="carte_form_Type"] label {
    margin: 0;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.carte-form div[id^="carte_form_couleurs"] label:hover,
.carte-form div[id^="carte_form_Type"] label:hover {
    border-color: var(--accent);
}

.carte-form input[type="checkbox"]:checked + label {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}

.carte-form input[type="checkbox"]:focus-visible + label {
    box-shadow: 0 0 0 3px rgba(212, 167, 58, 0.4);
}

/* Erreurs de validation */
.carte-form ul {
    margin: 0.4rem 0 0;
    padding: 0;
    list-style: none;
    color: var(--danger);
    font-size: 0.85rem;
}

.carte-form input:user-invalid,
.carte-form textarea:user-invalid {
    border-color: var(--danger);
}

/* Bouton d'envoi */
.carte-form .btn-submit {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}

.carte-form .btn-submit:hover {
    background: var(--accent-dark);
}

.carte-form .btn-submit:active {
    transform: translateY(1px);
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
    .carte-page {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .carte-page > img {
        max-width: 320px;
        margin: 0 auto;
    }

    .carte-card {
        padding: 1.3rem;
    }

    .carte-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.8rem;
    }
}

@media (max-width: 600px) {
    .carte-form {
        padding: 1.2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
/* À coller dans assets/styles/app.css (ou à importer depuis app.js). Adapte les couleurs à ton thème. */

.main-nav { display: flex; gap: 1rem; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid #ddd; }
.main-nav .nav-spacer { flex: 1; }
.main-nav .nav-user { color: #666; font-size: .9rem; }

.flash { margin: 1rem; padding: .75rem 1rem; border-radius: 6px; }
.flash-success { background: #e6f6ea; color: #17642b; }
.flash-error { background: #fde8e8; color: #9b1c1c; }

.deck-list { display: flex; flex-wrap: wrap; gap: 1rem; padding: 1rem; }
.deck-widget { width: 200px; text-align: center; text-decoration: none; color: inherit; }
.deck-widget img { width: 100%; border-radius: 8px; }
.deck-name { font-weight: bold; margin: .5rem 0 0; }
.deck-meta { color: #666; margin: 0; }

.deck-lignes { list-style: none; padding: 0; margin: 0 0 1rem; }
.deck-ligne { display: flex; gap: .75rem; align-items: flex-end; margin-bottom: .75rem; }
.deck-ligne > div { display: flex; gap: .75rem; align-items: flex-end; }

.deck-qty { font-weight: bold; }
.inline-form { display: inline; }
.btn-remove, .delete-btn { color: #9b1c1c; background: none; border: 1px solid #9b1c1c; border-radius: 4px; padding: .25rem .6rem; cursor: pointer; }
.btn-secondary { margin-bottom: 1rem; cursor: pointer; }

