/* EncyclopediaMatrix.css */
.em-outer-container {
    display: flex;
    justify-content: flex-start; /* Core: content aligns to left */
    gap: 30px;
    padding: 20px;
    width: 100%;
}

.em-main-viewport {
    flex: 1;
    min-width: 0;
    width: auto;
    overflow: visible;
}

.em-main-viewport::-webkit-scrollbar {
    display: none;
}

.em-main-viewport {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Loading state */
.em-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: 16px;
    color: #64748b;
    font-size: 14px;
}

.em-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #ef4444;
    border-radius: 50%;
    animation: em-spin 0.8s linear infinite;
}

@keyframes em-spin {
    to { transform: rotate(360deg); }
}

/* 4-column grid: narrower spacing to accommodate 300px ad sidebar */
.em-matrix-grid {
    display: grid;
    grid-template-columns: repeat(4, 130px);
    gap: 10px 4px;
    margin-bottom: 32px;
    justify-items: start;
}

/* Compact card design (following frontend-design aesthetics) */
.em-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 13px 5px 12px 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    width: 116px;
}

.em-card:hover {
    border-color: #ef4444;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.em-active {
    background-color: #fff1f2;
    border: 2px solid #ef4444 !important;
}

/* Text typography */
.em-kanji-wrapper {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.em-kanji { font-size: 16px; font-weight: 700; color: #1e293b; }
.em-furigana { font-size: 11px; color: #64748b; font-weight: normal; }
.em-meaning { display: block; font-size: 14px; color: #64748b; margin-top: 4px; text-align: center; }

/* Play icon: semi-transparent by default, colored on hover */
.em-icon-play {
    position: absolute;
    right: 4px;
    top: 1px;
    width: 14px;
    height: 14px;
    color: #cbd5e1;
}
.em-card:hover .em-icon-play { color: #ef4444; }

/* Red category label */
.em-group-label {
    display: inline-block;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 3px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Banner ad at bottom of content */
.em-bottom-banner-ad {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    margin-top: 32px;
    display: flex;
    justify-content: center;
}

.em-bottom-banner-ad .banner-ad-content {
    display: flex;
    align-items: center;
    max-width: 800px;
    margin-left: 0;
    margin-right: 0;
    padding: 0 16px;
    height: 70px;
    gap: 12px;
}

/* Right sidebar ad (300x600)：顶边贴二级导航下分割线、右边贴页面右边缘
   （负 margin 抵消外层容器 padding，尺寸允许与其他模块不一致） */
.em-ad-sidebar {
    box-sizing: border-box;
    width: 320px;
    padding-left: 20px;
    flex-shrink: 0;
    margin-top: -20px;
    margin-right: -20px;
}

.em-ad-sticky {
    width: 300px;
    height: 600px;
    position: sticky;
    top: 0; /* 滚动时粘在滚动区顶沿（即分割线位置） */
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder-300 {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 14px;
    font-weight: 500;
}
