

#blazor-error-ui {
    background: #b32121;
    color: #fff;
    border-top: 2px solid #ff6b6b;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }



/* ═══════════════════════════════════════════════
   Chess Openings Explorer — custom styles
   ═══════════════════════════════════════════════ */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Roboto', sans-serif;
    /* follow MudBlazor theme — switches automatically on dark/light toggle */
    background-color: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #9B6DFF44; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9B6DFF88; }

/* Main content top padding for app bar */
.main-content {
    padding-top: 64px !important;
    min-height: 100vh;
}

/* Chessboard wrapper — intrinsic square using padding-bottom trick.
   This keeps the board square regardless of parent layout changes
   (move chips appearing/disappearing, etc.) */
.board-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    flex-shrink: 0;       /* never let the board compress vertically */
}

.board-wrapper::before {
    content: '';
    display: block;
    padding-bottom: 100%; /* 1:1 square */
}

.board-wrapper > * {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Board paper */
.board-paper {
    display: flex;
    flex-direction: column;
}

.opening-item {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
    cursor: pointer;
}

.opening-item:hover {
    background: rgba(155, 109, 255, 0.08) !important;
}

.opening-item.selected {
    background: rgba(155, 109, 255, 0.18) !important;
    border-left: 3px solid #9B6DFF;
}

/* Info panel */
.info-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ── ECO badge large variant (used in info panel header) ── */
.eco-badge-lg {
    font-size: 0.82rem !important;
    padding: 5px 10px !important;
    border-radius: 6px !important;
    align-self: flex-start;
    flex-shrink: 0;
}

/* ── FEN row ── */
.fen-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px;
    border-radius: 6px;
    background: var(--mud-palette-background-grey);
    border: 1px solid var(--mud-palette-divider);
}

.fen-text {
    flex: 1;
    font-size: 0.6rem;
    font-family: 'Roboto Mono', monospace;
    color: var(--mud-palette-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* ── AI section ── */
.ai-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Placeholder: blurred fake lines + call-to-action */
.ai-placeholder {
    border: 1px dashed var(--mud-palette-primary-lighten);
    border-radius: 10px;
    padding: 16px;
    background: linear-gradient(135deg,
        rgba(155,109,255,0.04) 0%,
        rgba(255,180,0,0.04) 100%);
}

.ai-placeholder-lines {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 12px;
    filter: blur(3.5px);
    user-select: none;
    pointer-events: none;
    opacity: 0.5;
}

.ai-ph-line {
    display: block;
    height: 10px;
    border-radius: 5px;
    background: var(--mud-palette-text-secondary);
}
.ai-ph-line.w-full { width: 100%; }
.ai-ph-line.w-90   { width: 90%; }
.ai-ph-line.w-75   { width: 75%; }
.ai-ph-line.w-60   { width: 60%; }

.ai-placeholder-hint {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
    text-align: center;
    margin: 0 0 4px;
}

/* Loaded AI output card */
.ai-output-card {
    border-left: 3px solid var(--mud-palette-warning);
    border-radius: 0 8px 8px 0;
    padding: 12px 14px;
    background: var(--mud-palette-background-grey);
    font-size: 0.87rem;
    line-height: 1.85;
}

.ai-loading {
    padding: 14px;
    border-radius: 8px;
    background: var(--mud-palette-background-grey);
    border-left: 3px solid var(--mud-palette-warning);
}

/* ── Info panel empty state ── */
.info-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 24px;
}

.info-empty-icon {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 12px;
    opacity: 0.25;
    filter: grayscale(1);
}

.info-empty-steps {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px 16px;
    background: var(--mud-palette-background-grey);
    border-radius: 10px;
    border: 1px solid var(--mud-palette-divider);
}

.empty-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
}

/* Desktop info panel: visible md+ only */
.desktop-only-panel { display: flex; }

/* Mobile opening panel: visible only below md */
.mobile-opening-panel { display: block; }

/* Mobile FAB: visible only below md (960px) */
@media (min-width: 960px) {
    .mobile-fab    { display: none !important; }
    .mobile-sheet, .sheet-backdrop { display: none !important; }
    .mobile-opening-panel { display: none !important; }
}

/* Mobile adjustments */
@media (max-width: 960px) {
    .desktop-only-panel { display: none !important; }

    .opening-list {
        height: 40vh;
    }

    .main-content {
        padding-top: 56px !important;
    }

    /* extra bottom padding so FAB never overlaps content */
    .main-content .mud-container {
        padding-bottom: 88px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Mobile FAB — floating AI button (bottom-right, mobile only)
   ═══════════════════════════════════════════════════════════════ */

.mobile-fab {
    position: fixed;
    bottom: 22px;
    right: 18px;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    border-radius: 28px;
    background: linear-gradient(135deg, #FFB300 0%, #FF8F00 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(255, 160, 0, 0.55);
    cursor: pointer;
    border: none;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
}

.mobile-fab:hover, .mobile-fab:active {
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(255, 160, 0, 0.7);
}

/* ═══════════════════════════════════════════════════════════════
   Mobile bottom sheet
   ═══════════════════════════════════════════════════════════════ */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1300;
    animation: fadeIn 0.2s ease;
}

.mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1400;
    background: var(--mud-palette-surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.35);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sheet-header {
    flex-shrink: 0;
    padding-top: 10px;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--mud-palette-divider);
    margin: 0 auto 10px;
}

.sheet-body {
    overflow-y: auto;
    flex: 1;
    padding-bottom: 32px;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   Move list — 3-column grid: move-num | white move | black move
   ═══════════════════════════════════════════════════════════════ */

.move-list-grid {
    display: grid;
    grid-template-columns: 28px 1fr 1fr;
    gap: 2px 4px;
    align-items: center;
}

.move-num {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    text-align: right;
    padding-right: 2px;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

.move-token {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.82rem;
    font-family: 'Roboto Mono', monospace, sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    color: var(--mud-palette-text-primary);
    line-height: 1.5;
}

.move-token:hover {
    background: var(--mud-palette-primary-hover);
    border-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary);
}

.move-token.active {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-color: var(--mud-palette-primary);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   Drawer layout — flex column so list fills remaining height
   ═══════════════════════════════════════════════════════════════ */

/* MudBlazor's inner drawer wrapper must not scroll itself */
.mud-drawer .mud-drawer-content {
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.drawer-flex-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.drawer-top {
    flex-shrink: 0;          /* never compress the search + filters */
}

.drawer-search {
    /* just padding handled inline */
}

.drawer-content {
    flex: 1;            /* fill all height left after drawer-top */
    min-height: 0;      /* essential: lets flex child shrink + scroll */
    overflow-y: auto;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-divider);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-align: center;
    gap: 2px;
    min-height: 64px;
    color: var(--mud-palette-text-primary);
}

.cat-card:hover {
    background: var(--mud-palette-primary-hover);
    border-color: var(--mud-palette-primary);
    transform: translateY(-1px);
}

.cat-card.active {
    background: var(--mud-palette-primary);
    border-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    box-shadow: 0 2px 8px var(--mud-palette-primary-darken);
}

.cat-card .cat-icon {
    font-size: 1.2rem;
    opacity: 0.8;
}

.cat-card .cat-label {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.cat-card .cat-sub {
    font-size: 0.6rem;
    opacity: 0.65;
    line-height: 1.2;
    display: none; /* shown on wider drawers only */
}

/* ═══════════════════════════════════════════════════════════════
   ECO color badges (A=blue, B=green, C=orange, D=purple, E=teal)
   ═══════════════════════════════════════════════════════════════ */

.eco-badge, .family-eco-badge, .variation-eco {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: .02em;
    flex-shrink: 0;
    line-height: 1;
    padding: 2px 5px;
    font-variant-numeric: tabular-nums;
}

/* Per-group colour accents */
.eco-A, .eco-badge.eco-A { background: #1565C022; color: #64B5F6; border: 1px solid #1565C055; }
.eco-B, .eco-badge.eco-B { background: #2E7D3222; color: #81C784; border: 1px solid #2E7D3255; }
.eco-C, .eco-badge.eco-C { background: #E65100AA; color: #FFCC80; border: 1px solid #E6510055; }
.eco-D, .eco-badge.eco-D { background: #6A1B9A22; color: #CE93D8; border: 1px solid #6A1B9A55; }
.eco-E, .eco-badge.eco-E { background: #00695C22; color: #80CBC4; border: 1px solid #00695C55; }

/* Family-level eco badge (wider range label) */
.family-eco-badge {
    min-width: 72px;
    font-size: 0.6rem;
    padding: 2px 4px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Family tree rows
   ═══════════════════════════════════════════════════════════════ */

.family-tree {
    padding-bottom: 32px;
}

.family-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--mud-palette-divider);
    transition: background 0.12s;
    user-select: none;
}

.family-row:hover {
    background: var(--mud-palette-primary-hover);
}

.family-row.expanded {
    background: var(--mud-palette-background-grey);
    border-bottom-color: transparent;
}

.family-row.single:hover {
    background: rgba(155, 109, 255, 0.1);
}

.family-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
    overflow: hidden;
}

.family-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--mud-palette-text-primary);
}

.family-count {
    font-size: 0.65rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.family-arrow {
    flex-shrink: 0;
    color: var(--mud-palette-text-secondary);
    transition: transform 0.2s;
}

.family-row.expanded .family-arrow {
    color: var(--mud-palette-primary);
}

.single-arrow {
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════════════
   Variation rows (inside expanded family)
   ═══════════════════════════════════════════════════════════════ */

.variations-container {
    background: var(--mud-palette-background-grey);
    border-bottom: 2px solid var(--mud-palette-primary);
    padding: 2px 0;
}

.variation-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 7px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s, border-color 0.1s;
}

.variation-row:hover {
    background: var(--mud-palette-primary-hover);
    border-left-color: var(--mud-palette-primary-lighten);
}

.variation-row.selected {
    background: rgba(155, 109, 255, 0.18);
    border-left-color: var(--mud-palette-primary);
}

.variation-eco {
    min-width: 36px;
    font-variant-numeric: tabular-nums;
}

.variation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.variation-name {
    font-size: 0.79rem;
    color: var(--mud-palette-text-primary);
    line-height: 1.3;
    word-break: break-word;
}

.variation-plies {
    font-size: 0.65rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 1px;
}

/* Search result items */
.opening-item {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.12s;
    cursor: pointer;
}

.opening-item:hover  { background: rgba(155, 109, 255, 0.08) !important; }
.opening-item.selected { background: rgba(155, 109, 255, 0.18) !important;
                         border-left: 3px solid var(--mud-palette-primary); }


