/* Sabermetrics — supplemental styles.
 *
 * Layout, spacing, and structural styling live in Tailwind utility classes
 * directly in the templates. This file carries only:
 *   1. Base typography for prose that Tailwind's Preflight resets away
 *      (raw <h*>, <p>, <ul> inside content bodies).
 *   2. Mana pips.
 *   3. The JS-generated deck views (stack / spoiler / hover overlay) whose
 *      class names are hard-coded in deck_view.html.
 *   4. The deck-generation loading overlay.
 * Palette mirrors tailwind.config in base.html so JS-built DOM stays on-theme.
 */

:root {
    --ink: #0b1020;
    --panel: #151b30;
    --panel2: #1b233d;
    --field: #1e2740;
    --line: #2a3350;
    --body: #e6e8f0;
    --muted: #9aa3c0;
    --brand: #e94560;
    --brand-hover: #ff6b81;
}

/* --- Prose recovery (Preflight strips these) --- */
.prose-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 1.75rem 0 0.75rem;
}
.prose-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--body);
    margin: 1.25rem 0 0.5rem;
}
.prose-content h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 1rem 0 0.4rem;
}
.prose-content p {
    color: #cfd4e6;
    margin: 0.5rem 0;
    line-height: 1.65;
}
.prose-content ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}
.prose-content li {
    margin: 0.35rem 0;
    line-height: 1.6;
    color: #cfd4e6;
}
.prose-content a {
    color: var(--brand);
    text-decoration: none;
}
.prose-content a:hover {
    color: var(--brand-hover);
}
.prose-content strong {
    color: var(--body);
    font-weight: 600;
}

/* --- Favorite (heart) button --- */
.fav-btn {
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
    color: var(--muted);
    transition: color 0.15s ease, transform 0.15s ease;
}
.fav-btn:hover {
    color: var(--brand-hover);
    transform: scale(1.15);
}
.fav-btn.is-fav {
    color: var(--brand);
}
.fav-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* --- Card feedback controls --- */
.card-fb {
    display: flex;
    align-items: center;
    gap: 4px;
}
.fb-thumb {
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1px 5px;
    font-size: 0.85rem;
    line-height: 1.2;
    filter: grayscale(1) opacity(0.55);
    transition: filter 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.fb-thumb:hover {
    filter: grayscale(0) opacity(1);
    border-color: var(--muted);
}
.fb-up.active {
    filter: none;
    border-color: #1a7d4d;
    background: rgba(26, 125, 77, 0.18);
}
.fb-down.active {
    filter: none;
    border-color: var(--brand);
    background: rgba(233, 69, 96, 0.18);
}
.fb-comment {
    width: 8rem;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 0.78rem;
    color: var(--body);
}
.fb-comment:focus {
    outline: none;
    border-color: var(--brand);
}

/* --- Deck verdict buttons --- */
.verdict-btn {
    cursor: pointer;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 9999px;
    padding: 0.3rem 0.8rem;
    font-size: 0.82rem;
    color: var(--muted);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.verdict-btn:hover {
    color: var(--body);
    border-color: var(--muted);
}
.verdict-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

/* --- Mana pips --- */
.mana {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 3px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.mana-W { background: #f6f3e6; color: #2b2b2b; }
.mana-U { background: #2371b8; color: #fff; }
.mana-B { background: #1c1620; color: #d8d0dc; box-shadow: inset 0 0 0 1px #4a4450; }
.mana-R { background: #d3202a; color: #fff; }
.mana-G { background: #1a7d4d; color: #fff; }
.mana-C { background: #b9b4ce; color: #2b2b2b; }

/* --- Deck view: widened container for visual modes --- */
#app-main.wide { max-width: 1400px; }

/* --- Deck view: display/group toggle buttons (state toggled in JS) --- */
.tab-btn {
    padding: 0.4rem 0.9rem;
    background: var(--field);
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover:not(.active) { background: var(--panel2); color: var(--body); }
.tab-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* --- Deck view: static card tables (By Type / By Role) --- */
.card-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.card-table th {
    text-align: left;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}
.card-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(42, 51, 80, 0.5);
}
.card-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.card-table .reasoning { max-width: 320px; font-size: 0.78rem; color: var(--muted); }

/* ============================================================
 * Deck views generated in JS (class names referenced in deck_view.html)
 * ============================================================ */

/* --- Card preview sidebar --- */
.card-preview-sidebar {
    position: sticky;
    top: 5rem;
    width: 260px;
    min-width: 260px;
    max-height: calc(100vh - 6rem);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: flex-start;
    z-index: 10;
}
.card-preview-sidebar img {
    max-width: 240px;
    width: 100%;
    border-radius: 12px;
    margin-bottom: 0.6rem;
}
.card-preview-sidebar .preview-name {
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    margin-bottom: 0.2rem;
}
.card-preview-sidebar .preview-price {
    font-size: 0.85rem;
    color: var(--brand);
}
.card-preview-sidebar .preview-placeholder {
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 2.5rem 0;
}
.card-preview-sidebar.hidden { display: none; }

.deck-with-sidebar { display: flex; gap: 1.25rem; }
.deck-main-content { flex: 1; min-width: 0; }

/* --- Visual grid --- */
.visual-grid-section { margin-bottom: 1.5rem; }
.visual-grid-header,
.visual-stack-header,
.visual-spoiler-header {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--line);
}
.visual-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.visual-grid-card {
    width: 130px;
    cursor: pointer;
    position: relative;
    border-radius: 8px;
    transition: transform 0.15s ease;
}
.visual-grid-card img { width: 100%; border-radius: 8px; display: block; }
.visual-grid-card:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 0 0 2px var(--brand), 0 8px 20px rgba(0, 0, 0, 0.5);
}
.visual-grid-card .grid-card-qty {
    position: absolute; top: 4px; right: 4px;
    background: var(--brand); color: #fff;
    font-size: 0.7rem; font-weight: 700;
    width: 20px; height: 20px; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
}

/* --- Visual stack --- */
.visual-stack-columns { display: flex; gap: 1rem; flex-wrap: wrap; }
.visual-stack-column { flex: 1 1 200px; min-width: 180px; max-width: 280px; }
.visual-stack-card {
    height: 34px;
    overflow: hidden;
    transition: height 0.25s ease, margin-bottom 0.25s ease;
    cursor: pointer;
    position: relative;
    margin-bottom: 4px;
}
.visual-stack-card .card-bar {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.visual-stack-card .card-bar .bar-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.visual-stack-card .card-bar .bar-mana { color: var(--muted); font-size: 0.72rem; margin-left: 6px; flex-shrink: 0; }
.visual-stack-card .card-bar:hover { border-color: var(--brand); background: var(--panel2); }
.visual-stack-card.expanded { height: auto; margin-bottom: 10px; }
.visual-stack-card .stack-card-image { display: none; padding: 6px 0; }
.visual-stack-card.expanded .stack-card-image { display: block; }
.visual-stack-card .stack-card-image img { width: 100%; border-radius: 10px; }

/* --- Visual spoiler --- */
.visual-spoiler-section { margin-bottom: 1.5rem; }
.visual-spoiler { display: flex; flex-wrap: wrap; gap: 12px; }
.visual-spoiler-card {
    width: 200px;
    cursor: pointer;
    border-radius: 8px;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.visual-spoiler-card img { width: 100%; border-radius: 10px; display: block; }
.visual-spoiler-card:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 0 2px var(--brand), 0 8px 24px rgba(0, 0, 0, 0.5);
}
.visual-spoiler-card .spoiler-card-qty {
    position: absolute; top: 6px; right: 6px;
    background: var(--brand); color: #fff;
    font-size: 0.75rem; font-weight: 700;
    width: 22px; height: 22px; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
}

/* --- Floating full-card hover overlay --- */
.card-hover-overlay {
    position: fixed; z-index: 1000;
    pointer-events: none; display: none;
}
.card-hover-overlay.visible { display: block; }
.card-hover-overlay img {
    max-width: 300px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

/* ============================================================
 * Deck-generation loading overlay
 * ============================================================ */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(6, 9, 18, 0.9);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.loading-content { text-align: center; width: 420px; max-width: 90vw; }
.loading-commander {
    font-size: 1.4rem; font-weight: 600;
    color: var(--body); margin-bottom: 1.5rem;
}
.loading-bar-track {
    width: 100%; height: 10px;
    background: var(--field);
    border-radius: 9999px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.loading-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--brand), var(--brand-hover));
    border-radius: 9999px;
    transition: width 0.5s ease-out;
}
.loading-text {
    margin-top: 1.25rem;
    font-size: 0.95rem;
    color: var(--muted);
    min-height: 1.6em;
}
