/* ===== Alphabet chart (#page-alphabet, js/alphabet.js) ===== */

.alpha-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.alpha-tabs[hidden] { display: none; }   /* one tab for the learning language */
.mode-btn.alpha-tab {
    flex: 0 0 auto;
    min-width: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
    box-shadow: 0 3px 0 var(--edge);
}
/* phones: 9 tabs as an even 3 × 3 grid instead of rows of 4 / 4 / 1 */
@media (max-width: 560px) {
    .alpha-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mode-btn.alpha-tab { padding: 7px 4px; }
}
.mode-btn.alpha-tab.mode-btn-active {
    box-shadow: 0 3px 0 var(--primary-edge);
}

/* small tabs: a chart in pages of at most 3 rows (js/alphabet.js alphaPages) */
.alpha-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.alpha-pages:empty { display: none; }
.alpha-page {
    min-height: 34px;
    padding: 4px 12px;
    border: 2px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}
.alpha-page:hover { border-color: var(--primary); }
.alpha-page.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
@media (pointer: coarse) { .alpha-page { min-height: 44px; } }

.alpha-sec-title {
    margin: 22px 2px 10px;
    font-size: 1rem;
    color: var(--text-accent);
}
.alpha-sec-title:first-child {
    margin-top: 0;
}

.alpha-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.alpha-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 3px 0 var(--edge);
    overflow: hidden;
}

/* --- letter --- */
.alpha-head {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 6px;
    padding: 10px 10px 8px 12px;
}
.alpha-glyph {
    grid-column: 1;
    justify-self: start;
    padding: 0;
    border: none;
    background: none;
    color: var(--text);
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.alpha-glyph:hover {
    color: var(--primary);
}
.alpha-reading {
    grid-column: 1;
    grid-row: 2;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.4;
    overflow-wrap: break-word;
}
.alpha-head .alpha-speak {
    grid-column: 2;
    grid-row: 1 / span 2;
}
.speak-btn.alpha-speak {
    flex: none;
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
}

/* --- example word --- */
.alpha-ex {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    padding: 8px 10px 10px 12px;
    border-top: 1px dashed var(--line);
    background: var(--bg-card-alt);
}
.alpha-ex-none {
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}
.alpha-emoji {
    flex: none;
    font-size: 1.5rem;
    line-height: 1;
}
.alpha-ex-text {
    flex: 1;
    min-width: 0;
}
.alpha-word {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
    overflow-wrap: break-word;
}
.alpha-word mark {
    background: none;
    color: var(--primary);
}
.alpha-word-reading,
.alpha-meaning {
    font-size: 0.75rem;
    line-height: 1.4;
    overflow-wrap: break-word;
}
.alpha-word-reading {
    color: var(--text-muted);
}
.alpha-meaning {
    color: var(--text-secondary);
}


/* gaps that line the kana up like the 五十音 chart (や・ゆ・よ, わ・を) */
.alpha-blank {
    display: none;
}

@media (min-width: 1024px) {
    /* 5 a row like the 五十音 chart, so a word's reading and meaning fit one line */
    .alpha-grid, .alpha-grid.alpha-gojuon {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
    }
    .alpha-blank {
        display: block;
    }
    /* a little flatter, so 3 rows and the header fit a 1080p screen: the word's reading
       and meaning share one line */
    .alpha-head { padding: 7px 10px 5px 12px; }
    .alpha-ex { padding: 6px 10px 8px 12px; }
    .alpha-word-reading, .alpha-meaning { display: inline; }
    .alpha-word-reading + .alpha-meaning::before { content: " · "; color: var(--text-muted); }
    /* two sections on one small tab: a slimmer title between them */
    .alpha-sec-title { margin: 8px 2px 5px; }
    .alpha-tabs { margin-top: 12px; }
    .alpha-pages { margin-top: 10px; }
    /* two tabs (注音 / 拼音): the tabs and the small tabs share one row, so a page still fits */
    #page-alphabet > .mode-card { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 14px; }
    #alpha-title, #alpha-intro { flex: 0 0 100%; }
    .alpha-tabs:not([hidden]) { margin-top: 12px; }
    .alpha-tabs:not([hidden]) + .alpha-pages { margin-top: 12px; padding-left: 14px; border-left: 1px dashed var(--line); }
    /* the letter and its reading side by side and a smaller word 🔊 (2026-11-06), so a row
       stays one card high with a long word reading (注音 · pinyin) plus the meaning */
    #alpha-body .alpha-head { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto; column-gap: 10px; }
    #alpha-body .alpha-reading { grid-column: 2; grid-row: 1; }
    #alpha-body .alpha-head .alpha-speak { grid-column: 3; grid-row: 1; }
    #alpha-body .alpha-ex { gap: 6px; padding: 5px 8px 7px 12px; }
    #alpha-body .alpha-grid { gap: 8px; }
    #alpha-body .alpha-ex .alpha-speak { width: 26px; height: 26px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .alpha-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .alpha-glyph {
        font-size: 1.7rem;
    }
}
