/**
 * 耳トレ（リデザイン版）
 * 共通部品は practice-focus.css。ここには耳トレ固有のものだけを置く
 * （旧デザインの ear-train.css はこのページでは読み込まない。バックアップは backups/2026-11-11_redesign/）
 * 接頭辞: pf-et-
 */

.pf {
    /* 反応速度の4段階（緑青〜朱の濃淡。色を増やさず速い・遅いを表す） */
    --pf-et-fast: var(--pf-rokusho);
    --pf-et-ok: #7DB9A3;
    --pf-et-slow: #E39A88;
    --pf-et-very-slow: var(--pf-shu);
}

/* ---------- 設定 ---------- */
.pf-et-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--pf-ink-2);
}
.pf-et-steps li { display: flex; align-items: center; gap: 6px; }
.pf-et-steps span {
    width: 22px; height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--pf-ai-soft);
    color: var(--pf-ai);
    font-size: 0.75rem;
    font-weight: 700;
}
.pf-et-audio {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 18px;
}
.pf-et-testbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--pf-line);
    border-radius: 12px;
    background: var(--pf-surface);
    color: var(--pf-ink);
    font-size: 0.875rem;
}
.pf-et-testbtn:hover { border-color: var(--pf-ai); }
.pf-et-audio-status { font-size: 0.8125rem; color: var(--pf-ink-3); }
.pf-et-audio-status.is-ok { color: var(--pf-rokusho); font-weight: 700; }
.pf-et-audio-status.is-ng { color: var(--pf-shu); font-weight: 700; }

.pf-et-levels .pf-chip { display: grid; place-items: center; padding: 6px 14px; line-height: 1.3; }
.pf-et-levels .pf-chip small { display: block; font-size: 0.6875rem; font-weight: 400; color: var(--pf-ink-3); }
.pf-chip.is-empty:not([aria-pressed="true"]) { color: var(--pf-ink-3); border-style: dashed; }
.pf-et-note { margin: 8px 0 0; font-size: 0.75rem; color: var(--pf-ink-3); }

.pf-et-dashlink {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 60px;
    margin: 4px 0 0;
    padding: 10px 14px;
    border: 1px solid var(--pf-line);
    border-radius: 14px;
    background: var(--pf-surface);
    color: var(--pf-ink);
    text-align: left;
}
.pf-et-dashlink:hover { border-color: var(--pf-ai); }
.pf-et-dashlink > .pf-svg:first-child { color: var(--pf-ai); }
.pf-et-dashlink > .pf-svg:last-child { color: var(--pf-ink-3); }
.pf-et-dashlink b { display: block; font-size: 0.9375rem; }
.pf-et-dashlink small { display: block; font-size: 0.75rem; color: var(--pf-ink-3); line-height: 1.5; }

/* ---------- 集中画面 ---------- */
.pf-et-play {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}
.pf-et-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    text-align: center;
    outline: none;
    overflow: hidden;
}
.pf-et-score {
    position: absolute;
    top: 4px; right: 16px;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--pf-ink-3);
    font-variant-numeric: tabular-nums;
}
.pf-et-score b { color: var(--pf-rokusho); font-size: 1rem; }

/* 読み上げ中の波 */
.pf-et-wave {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 56px;
}
.pf-et-wave i {
    display: block;
    width: 8px;
    height: 14px;
    border-radius: 4px;
    background: var(--pf-line);
    transition: background-color .2s;
}
.pf-et-wave.is-playing i { background: var(--pf-ai); animation: pf-et-wave .9s ease-in-out infinite; }
.pf-et-wave.is-playing i:nth-child(2) { animation-delay: .12s; }
.pf-et-wave.is-playing i:nth-child(3) { animation-delay: .24s; }
.pf-et-wave.is-playing i:nth-child(4) { animation-delay: .36s; }
.pf-et-wave.is-playing i:nth-child(5) { animation-delay: .48s; }
@keyframes pf-et-wave {
    0%, 100% { height: 14px; }
    50% { height: 52px; }
}
.pf-et-listen { margin: 0; font-size: 0.875rem; color: var(--pf-ink-2); }
.pf-et-kami {
    margin: 0;
    font-family: var(--pf-uta);
    font-weight: 600;
    font-size: clamp(1.125rem, 5vw, 1.5rem);
    line-height: 1.6;
    letter-spacing: .06em;
}

/* 回答後 */
.pf-et-fb { display: grid; justify-items: center; gap: 4px; }
.pf-et-time {
    margin: 0;
    font-weight: 700;
    font-size: clamp(2.75rem, 14vw, 4.25rem);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.pf-et-time small { margin-left: 4px; font-size: 1.125rem; color: var(--pf-ink-3); }
.pf-et-stage.is-ng .pf-et-time { color: var(--pf-ink-3); }
.pf-et-diff { margin: 0; font-size: 0.875rem; color: var(--pf-ink-2); }
.pf-et-diff.is-faster { color: var(--pf-rokusho); font-weight: 700; }
.pf-et-diff.is-slower { color: var(--pf-shu); font-weight: 700; }
.pf-et-poem {
    display: grid;
    gap: 2px;
    margin: 6px 0 0;
    font-family: var(--pf-uta);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--pf-ink-2);
}
.pf-et-poem small { font-family: var(--pf-ui); font-size: 0.75rem; color: var(--pf-ink-3); }

/* 下: 札（反応ボタン）。スマホは4枚を1列、上級8枚は4×2 */
.pf-et-cards {
    flex: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 0 12px 12px;
}
.pf-et-card {
    position: relative;
    display: block;
    padding: 4px;
    border: 2px solid var(--pf-line);
    border-radius: 10px;
    background: #FFFDF6;
    transition: border-color .12s, transform .06s, opacity .15s;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.pf-et-card:not(:disabled):hover { border-color: var(--pf-ai); }
.pf-et-card:not(:disabled):active { transform: scale(.97); }
.pf-et-card:disabled { cursor: default; }
.pf-et-img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 152 / 206;
    object-fit: contain;
    pointer-events: none;
}
.pf-et-card .pf-num {
    position: absolute;
    top: -6px; left: -6px;
    width: 24px; height: 24px;
    border: 2px solid var(--pf-paper);
    border-radius: 50%;
    background: var(--pf-ai);
    color: #fff;
    font-size: 0.75rem;
}
.pf-et-card.is-correct { border-color: var(--pf-rokusho); box-shadow: 0 0 0 3px var(--pf-rokusho); }
.pf-et-card.is-correct .pf-num { background: var(--pf-rokusho); }
.pf-et-card.is-wrong { border-color: var(--pf-shu); box-shadow: 0 0 0 3px var(--pf-shu); }
.pf-et-card.is-wrong .pf-num { background: var(--pf-shu); }
.pf-et-card.is-dim { opacity: .4; }

.pf-et-next {
    flex: none;
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 8px;
    padding: 0 12px calc(14px + env(safe-area-inset-bottom, 0px));
}
.pf-et-next[hidden] { display: none; }
.pf-et-detail { min-height: 56px; }

/* スマホ: 4枚のときは2×2で大きく（親指で押しやすい）。画面の低い端末は1列に戻す */
@media (max-width: 859px) and (min-height: 741px) {
    .pf-et-cards:not(.is-hard) {
        grid-template-columns: repeat(2, minmax(0, 136px));
        justify-content: center;
        gap: 12px 20px;
    }
}
@media (max-width: 859px) {
    .pf-et-cards.is-hard { gap: 8px; }
}

/* PC */
@media (min-width: 860px) {
    .pf-et-play { max-width: 820px; padding: 0 32px; }
    .pf-et-stage { gap: 14px; }
    .pf-et-cards {
        grid-template-columns: repeat(4, minmax(0, 150px));
        justify-content: center;
        gap: 16px;
        padding: 0 0 8px;
    }
    .pf-et-cards.is-hard { grid-template-columns: repeat(8, minmax(0, 120px)); gap: 10px; }
    .pf-et-next { max-width: 480px; width: 100%; margin: 8px auto 0; padding: 0; }
}

/* ---------- 結果 ---------- */
.pf-et-scorelabel {
    display: inline-block;
    margin-right: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--pf-ai-soft);
    color: var(--pf-ai);
    font-size: 0.75rem;
    font-weight: 700;
}
.pf-result .pf-score small { margin-left: 2px; font-family: var(--pf-ui); }
#resultSlowest { margin-top: 18px; }
.pf-et-slow a { grid-template-columns: auto 1fr auto; border-left-color: var(--pf-ai); }
.pf-et-slow a:hover { border-left-color: var(--pf-ai); }
.pf-et-rowtime {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--pf-ink);
    white-space: nowrap;
}

/* ---------- 成長ダッシュボード ---------- */
.pf-et-dash .pf-title { font-size: 1.5rem; }
.pf-et-h { margin: 18px 0 10px; font-size: 0.9375rem; }
.pf-et-group {
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--pf-line);
    border-radius: 14px;
    background: var(--pf-surface);
}
.pf-et-group-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.pf-et-group-label { font-size: 0.875rem; font-weight: 700; }
.pf-et-group-label small { margin-left: 6px; font-size: 0.75rem; font-weight: 400; color: var(--pf-ink-3); }
.pf-et-avg {
    flex: none;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.pf-et-avg.is-fast      { background: var(--pf-rokusho-soft); color: var(--pf-rokusho); }
.pf-et-avg.is-ok        { background: var(--pf-rokusho-soft); color: #2D6A55; }
.pf-et-avg.is-slow      { background: var(--pf-shu-soft); color: #A8331D; }
.pf-et-avg.is-very-slow { background: var(--pf-shu); color: #fff; }
.pf-et-avg.is-none      { background: var(--pf-line-2); color: var(--pf-ink-3); }
.pf-et-bar {
    height: 4px;
    margin-bottom: 10px;
    border-radius: 2px;
    background: var(--pf-line-2);
    overflow: hidden;
}
.pf-et-bar b { display: block; height: 100%; background: var(--pf-line); transition: width .4s; }
.pf-et-bar b.is-fast      { background: var(--pf-et-fast); }
.pf-et-bar b.is-ok        { background: var(--pf-et-ok); }
.pf-et-bar b.is-slow      { background: var(--pf-et-slow); }
.pf-et-bar b.is-very-slow { background: var(--pf-et-very-slow); }
.pf-et-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.pf-et-dot {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--pf-line);
}
.pf-et-dot.is-fast      { background: var(--pf-et-fast); }
.pf-et-dot.is-ok        { background: var(--pf-et-ok); }
.pf-et-dot.is-slow      { background: var(--pf-et-slow); }
.pf-et-dot.is-very-slow { background: var(--pf-et-very-slow); }
.pf-et-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--pf-ink-3);
}
.pf-et-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.pf-et-nodata {
    margin: 0;
    padding: 14px;
    border-radius: 14px;
    background: var(--pf-line-2);
    color: var(--pf-ink-2);
    font-size: 0.875rem;
    list-style: none;
}
.pf-et-top10 { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pf-et-top10-item {
    display: grid;
    grid-template-columns: 26px 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--pf-line);
    border-radius: 12px;
    background: var(--pf-surface);
}
.pf-et-top10-rank {
    width: 26px; height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: var(--pf-line-2);
    color: var(--pf-ink-2);
    font-size: 0.8125rem;
    font-weight: 700;
}
.pf-et-top10-poem { min-width: 0; font-family: var(--pf-uta); font-size: 0.9375rem; line-height: 1.4; }
.pf-et-top10-poem small { display: block; font-family: var(--pf-ui); font-size: 0.6875rem; color: var(--pf-ink-3); }
.pf-et-top10-time { font-weight: 700; font-size: 0.875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-et-top10-time.is-slow, .pf-et-top10-time.is-very-slow { color: var(--pf-shu); }
.pf-et-top10-btn {
    min-height: 44px;
    padding: 0 12px;
    border: 1.5px solid var(--pf-ai);
    border-radius: 10px;
    background: var(--pf-surface);
    color: var(--pf-ai);
    font-size: 0.8125rem;
    font-weight: 700;
}
.pf-et-top10-btn:hover { background: var(--pf-ai-soft); }

@media (prefers-reduced-motion: reduce) {
    .pf-et-wave.is-playing i { animation: none; height: 32px; }
}
