/* be-gao-reader — reader.css */

/* ── Keyframes ── */
@keyframes bgrJump  { 0%,100%{transform:translateY(0)} 40%{transform:translateY(-12px)} 70%{transform:translateY(-5px)} }
@keyframes bgrFall  { 0%{transform:translateY(-20px) rotate(0deg);opacity:1} 100%{transform:translateY(100vh) rotate(720deg);opacity:0} }
@keyframes bgrPulse { 0%,100%{box-shadow:0 3px 10px rgba(192,57,43,.4)} 50%{box-shadow:0 3px 22px rgba(192,57,43,.7)} }
@keyframes bgrRing  { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.12);opacity:.5} }
@keyframes bgrWave  { 0%,100%{transform:scaleY(.4)} 50%{transform:scaleY(1)} }

/* ── Wrapper ── */
.bgr-reader-wrap  { max-width: 820px; margin: 0 auto; font-family: 'Nunito', 'Segoe UI', sans-serif; }
.bgr-loading      { display: flex; flex-direction: column; align-items: center; padding: 48px; gap: 16px; color: #888; }
.bgr-spinner      { width: 36px; height: 36px; border: 3px solid #ddd; border-top-color: #5daa6b; border-radius: 50%; animation: bgrRing .8s linear infinite; }

/* ── App layout ── */
.bgr-app          { display: flex; flex-direction: column; gap: 14px; }

/* ── Score ── */
.bgr-score-row    { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 10px 16px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.bgr-score-label  { font-size: 13px; color: #777; white-space: nowrap; }
.bgr-bar          { flex: 1; height: 10px; background: #eee; border-radius: 10px; overflow: hidden; }
.bgr-bar-fill     { height: 100%; background: linear-gradient(90deg, #3a7d44, #5daa6b); border-radius: 10px; width: 0%; transition: width .5s cubic-bezier(.4,0,.2,1); }
.bgr-score-pct    { font-size: 14px; font-weight: 800; color: #3a7d44; min-width: 36px; }
.bgr-stars        { font-size: 18px; letter-spacing: 2px; }

/* ── Page image ── */
.bgr-page-display { border-radius: 16px; overflow: hidden; box-shadow: 0 8px 28px rgba(0,0,0,.13); background: #fff; }
.bgr-page-img     { width: 100%; display: block; transition: opacity .3s; }

/* ── Word panel ── */
.bgr-word-panel   { background: #fff; border-radius: 16px; padding: 16px 20px; box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.bgr-word-label   { font-size: 12px; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px; }
.bgr-word-display { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(18px, 3.5vw, 24px); line-height: 1.9; color: #2c2c2c; }
.bgr-w            { display: inline; padding: 2px 3px; border-radius: 4px; transition: background .2s, color .2s; }
.bgr-w-done       { background: #c5f0d0; color: #1e6635; font-weight: 700; }
.bgr-w-active     { background: #fff176; color: #8a6000; font-weight: 800; box-shadow: 0 2px 0 #f5c842; }
.bgr-w-missed     { background: #ffd6d6; color: #c0392b; text-decoration: underline wavy #e74c3c; }

/* ── Character panel ── */
.bgr-char-panel   { display: flex; align-items: flex-end; gap: 14px; background: #fff; border-radius: 20px; padding: 14px 18px; box-shadow: 0 4px 20px rgba(0,0,0,.07); }
.bgr-char-wrap    { position: relative; flex-shrink: 0; width: 80px; height: 80px; }
.bgr-char-img     { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid #5daa6b; }
#bgr-char-svg     { width: 80px; height: 80px; }

.bgr-char-speaking::before {
    content: '';
    position: absolute; inset: -6px; border-radius: 50%;
    border: 3px solid #f5c842;
    animation: bgrRing .8s ease-in-out infinite;
}

/* ── Speech bubble ── */
.bgr-bubble       { flex: 1; border-radius: 16px 16px 16px 4px; padding: 12px 16px; font-size: 15px; line-height: 1.5; color: #333; min-height: 52px; display: flex; align-items: center; gap: 8px; transition: background .3s; position: relative; }
.bgr-bubble::before { content: ''; position: absolute; left: -10px; bottom: 14px; border: 6px solid transparent; }
.bgr-bubble-idle  { background: #e8f4fd; }       .bgr-bubble-idle::before  { border-right-color: #e8f4fd; }
.bgr-bubble-speak { background: #e8f4fd; }       .bgr-bubble-speak::before { border-right-color: #e8f4fd; }
.bgr-bubble-happy { background: #fff9c4; }       .bgr-bubble-happy::before { border-right-color: #fff9c4; }
.bgr-bubble-error { background: #fde8e8; }       .bgr-bubble-error::before { border-right-color: #fde8e8; }
.bgr-bubble-text  { flex: 1; }

/* ── Mic waves ── */
.bgr-mic-waves    { display: none; gap: 3px; align-items: center; }
.bgr-waves-on     { display: flex; }
.bgr-mic-waves span { display: block; width: 4px; background: #3a7d44; border-radius: 4px; animation: bgrWave .7s ease-in-out infinite; }
.bgr-mic-waves span:nth-child(1){height:10px;animation-delay:0s}
.bgr-mic-waves span:nth-child(2){height:18px;animation-delay:.12s}
.bgr-mic-waves span:nth-child(3){height:14px;animation-delay:.24s}
.bgr-mic-waves span:nth-child(4){height:20px;animation-delay:.08s}
.bgr-mic-waves span:nth-child(5){height:10px;animation-delay:.20s}

/* ── Controls ── */
.bgr-controls     { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bgr-btn          { border: none; cursor: pointer; font-family: inherit; font-weight: 800; border-radius: 50px; transition: all .18s; display: flex; align-items: center; gap: 6px; box-shadow: 0 3px 10px rgba(0,0,0,.12); font-size: 15px; }
.bgr-btn:active   { transform: scale(.94); }
.bgr-btn:disabled { opacity: .35; cursor: not-allowed; }
.bgr-btn-nav      { background: #fff; color: #555; padding: 11px 18px; border: 2px solid #e0e0e0; }
.bgr-btn-listen   { background: linear-gradient(135deg,#3498db,#2471a3); color: #fff; padding: 11px 20px; }
.bgr-btn-read     { background: linear-gradient(135deg,#e74c3c,#c0392b); color: #fff; padding: 13px 28px; flex: 1; max-width: 220px; justify-content: center; }
.bgr-btn-on       { animation: bgrPulse 1.4s ease-in-out infinite; }
.bgr-page-badge   { margin-left: auto; font-size: 13px; font-weight: 700; color: #888; }

/* ── Library grid ── */
.bgr-library      { display: grid; grid-template-columns: repeat(var(--cols,3),1fr); gap: 20px; }
.bgr-card         { border-radius: 16px; overflow: hidden; background: #fff; text-decoration: none; color: inherit; box-shadow: 0 4px 16px rgba(0,0,0,.08); transition: transform .2s, box-shadow .2s; display: block; }
.bgr-card:hover   { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.bgr-card-thumb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.bgr-card-body    { padding: 14px; }
.bgr-card-body h3 { font-size: 16px; font-weight: 800; margin: 0 0 6px; color: #2c2c2c; }
.bgr-card-body p  { font-size: 13px; color: #666; margin: 0 0 8px; }
.bgr-badge        { display: inline-block; background: #e8f5e9; color: #2e7d32; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.bgr-featured     { border: 2px solid #f5c842; }
.bgr-empty        { color: #888; text-align: center; padding: 40px; font-size: 15px; }
.bgr-error        { color: #c0392b; padding: 16px; }

@media (max-width: 600px) {
    .bgr-library    { grid-template-columns: repeat(2,1fr); }
    .bgr-controls   { flex-wrap: wrap; }
    .bgr-btn-listen { display: none; }
    .bgr-word-display { font-size: 16px; }
}
@media (max-width: 380px) {
    .bgr-library    { grid-template-columns: 1fr; }
}
