/*
 * /tools/pinyin-checker — the checker and Pinyin Police (growth plan D111).
 *
 * The visual job is one thing: make the SYLLABLE BOUNDARY visible. Everything this page
 * teaches — the ü that hides after j/q/x/y, the contractions, the y and w insertions and the
 * apostrophe — is about where one syllable stops and the next begins, and a reader who cannot
 * see the break at a glance is reading a wall of letters. So syllables are tiles, the break
 * between them is a real gap, and the apostrophe is the only accent in the line.
 *
 * Dark mode goes through [data-bs-theme="dark"], as everywhere else on the site.
 */

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.pc-hero {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 45%, #134e4a 100%);
    position: relative;
    overflow: hidden;
}

.pc-hero::after {
    content: "ü";
    position: absolute;
    right: 0.05em;
    bottom: -0.34em;
    font-size: 12rem;
    line-height: 1;
    opacity: 0.09;
    font-weight: 700;
    pointer-events: none;
}

/* ── The box you type in ──────────────────────────────────────────────────── */

.pc-input {
    font-size: 1.2rem;
    line-height: 1.6;
    min-height: 6.5rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.pc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pc-chip {
    border: 1px solid rgba(13, 148, 136, 0.4);
    background: rgba(13, 148, 136, 0.08);
    color: #0f766e;
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.pc-chip:hover {
    background: rgba(13, 148, 136, 0.2);
    transform: translateY(-1px);
}

[data-bs-theme="dark"] .pc-chip {
    color: #5eead4;
    border-color: rgba(94, 234, 212, 0.35);
}

/* ── Results ──────────────────────────────────────────────────────────────── */

.pc-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.85rem;
    color: #6c757d;
    min-height: 1.2rem;
}

.pc-stat strong {
    color: inherit;
}

.pc-stat-ok strong { color: #15803d; }
.pc-stat-amb strong { color: #b45309; }
.pc-stat-bad strong { color: #b91c1c; }

.pc-out.pc-empty::before {
    content: "Type or paste pinyin above — a syllable, a word or a whole paragraph.";
    display: block;
    color: #6c757d;
    font-size: 0.95rem;
    padding: 1.25rem 0;
    text-align: center;
}

.pc-card {
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-left-width: 4px;
    border-radius: 0.6rem;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
    animation: pc-in 0.25s ease both;
}

@keyframes pc-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .pc-card { animation: none; }
}

[data-bs-theme="dark"] .pc-card { border-color: rgba(255, 255, 255, 0.12); }

.pc-ok { border-left-color: #15803d; background: rgba(21, 128, 61, 0.04); }
.pc-amb { border-left-color: #d97706; background: rgba(217, 119, 6, 0.05); }
.pc-bad { border-left-color: #b91c1c; background: rgba(185, 28, 28, 0.05); }

.pc-card header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.pc-card h3 {
    font-size: 1.35rem;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

.pc-verdict {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    color: #fff;
}

.pc-ok .pc-verdict { background: #15803d; }
.pc-amb .pc-verdict { background: #d97706; }
.pc-bad .pc-verdict { background: #b91c1c; }

/* ── Syllable tiles: the break is the message ─────────────────────────────── */

.pc-syllables {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem;
    margin: 0.35rem 0 0.5rem;
}

.pc-syl {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: rgba(13, 148, 136, 0.12);
    border: 1px solid rgba(13, 148, 136, 0.25);
    border-radius: 0.4rem;
    padding: 0.2rem 0.55rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.1rem;
    line-height: 1.3;
}

.pc-syl em {
    font-style: normal;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    opacity: 0.6;
}

[data-bs-theme="dark"] .pc-syl {
    background: rgba(94, 234, 212, 0.13);
    border-color: rgba(94, 234, 212, 0.3);
}

.pc-break { width: 0.45rem; }

.pc-apos {
    font-size: 1.3rem;
    font-weight: 700;
    color: #d97706;
    padding: 0 0.1rem;
    cursor: help;
}

.pc-line { font-size: 0.92rem; margin: 0 0 0.4rem; }
.pc-note { font-size: 0.85rem; color: #6c757d; margin: 0 0 0.4rem; }

.pc-words {
    font-size: 0.87rem;
    margin-top: 0.3rem;
}

.pc-words a {
    display: inline-block;
    margin-right: 0.5rem;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

/* ── Readings ─────────────────────────────────────────────────────────────── */

.pc-readings {
    list-style: none;
    padding: 0;
    margin: 0 0 0.6rem;
    display: grid;
    gap: 0.5rem;
}

.pc-readings li {
    border: 1px dashed rgba(0, 0, 0, 0.14);
    border-radius: 0.45rem;
    padding: 0.45rem 0.6rem;
}

[data-bs-theme="dark"] .pc-readings li { border-color: rgba(255, 255, 255, 0.16); }

.pc-reading-spelling {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pc-tag {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.08rem 0.45rem;
    border-radius: 999px;
    font-weight: 700;
    font-family: inherit;
}

.pc-tag-free { background: rgba(21, 128, 61, 0.15); color: #15803d; }
.pc-tag-marked { background: rgba(217, 119, 6, 0.18); color: #b45309; }
.pc-tag-rule { background: rgba(185, 28, 28, 0.13); color: #b91c1c; }

[data-bs-theme="dark"] .pc-tag-free { color: #4ade80; }
[data-bs-theme="dark"] .pc-tag-marked { color: #fbbf24; }
[data-bs-theme="dark"] .pc-tag-rule { color: #fca5a5; }

.pc-rule {
    background: rgba(13, 148, 136, 0.09);
    border-left: 3px solid #0f766e;
    padding: 0.55rem 0.75rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
}

.pc-rule-open {
    background: rgba(217, 119, 6, 0.1);
    border-left-color: #d97706;
}

.pc-hint {
    font-size: 0.87rem;
    margin-top: 0.4rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    background: rgba(0, 0, 0, 0.035);
}

[data-bs-theme="dark"] .pc-hint { background: rgba(255, 255, 255, 0.06); }

.pc-hint-tag {
    font-weight: 700;
    color: #0f766e;
    margin-right: 0.25rem;
}

[data-bs-theme="dark"] .pc-hint-tag { color: #5eead4; }

/* ── Problems ─────────────────────────────────────────────────────────────── */

.pc-problem { margin-bottom: 0.6rem; }
.pc-problem:last-child { margin-bottom: 0; }

.pc-problem-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.2rem;
}

.pc-problem-head code {
    font-size: 1.1rem;
    background: rgba(185, 28, 28, 0.12);
    padding: 0.05rem 0.4rem;
    border-radius: 0.3rem;
    color: inherit;
    text-decoration: line-through;
    text-decoration-color: rgba(185, 28, 28, 0.6);
}

.pc-problem-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.15rem; }

.pc-fix {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pc-fix strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #15803d;
    font-size: 1.1rem;
}

[data-bs-theme="dark"] .pc-fix strong { color: #4ade80; }

.pc-fix-btn {
    border: 1px solid rgba(21, 128, 61, 0.4);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    font-size: 0.78rem;
    padding: 0.05rem 0.6rem;
    cursor: pointer;
}

.pc-near { font-size: 0.87rem; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

/* ══ Pinyin Police ════════════════════════════════════════════════════════ */

.pcg-stage {
    position: relative;
    border-radius: 0.75rem;
    background: linear-gradient(160deg, rgba(13, 148, 136, 0.07), rgba(13, 148, 136, 0.02));
    border: 1px solid rgba(13, 148, 136, 0.18);
    padding: 0.9rem;
    min-height: 23rem;
    overflow: hidden;
}

[data-bs-theme="dark"] .pcg-stage { border-color: rgba(94, 234, 212, 0.22); }

.pcg-shake { animation: pcg-shake 0.4s ease; }

@keyframes pcg-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
    .pcg-shake { animation: none; }
}

.pcg-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.pcg-hud div { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.pcg-hud small { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.65; }
.pcg-hud b { font-size: 1.15rem; }

.pcg-hearts { color: #dc2626; letter-spacing: 0.1em; font-size: 1.15rem; }

.pcg-combo {
    font-weight: 700;
    font-size: 1.15rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.pcg-combo-hot {
    color: #d97706;
    transform: scale(1.18);
}

.pcg-timer {
    height: 6px;
    background: rgba(0, 0, 0, 0.09);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.pcg-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0d9488, #f59e0b);
    transition: width 0.06s linear;
}

.pcg-prompt {
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(1.8rem, 9vw, 3rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    margin: 0.5rem 0 0.2rem;
    word-break: break-all;
}

.pcg-prompt-spelling { font-size: clamp(1rem, 4.5vw, 1.35rem); font-family: inherit; font-weight: 600; }

.pcg-sub { text-align: center; font-size: 0.87rem; opacity: 0.75; margin-bottom: 0.9rem; }

.pcg-options { display: grid; gap: 0.5rem; }
.pcg-options-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pcg-options-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pcg-options-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.pcg-option {
    position: relative;
    border: 1px solid rgba(13, 148, 136, 0.35);
    background: #fff;
    border-radius: 0.55rem;
    padding: 0.7rem 0.6rem 0.7rem 1.9rem;
    font-size: 1.1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: left;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

[data-bs-theme="dark"] .pcg-option { background: rgba(255, 255, 255, 0.06); }

.pcg-option:hover:not(:disabled) { transform: translateY(-2px); border-color: #0d9488; }

.pcg-key {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    opacity: 0.45;
    font-family: inherit;
}

.pcg-right { border-color: #15803d !important; background: rgba(21, 128, 61, 0.16) !important; }
.pcg-wrong { border-color: #b91c1c !important; background: rgba(185, 28, 28, 0.14) !important; }

.pcg-feedback {
    min-height: 3.2rem;
    margin-top: 0.7rem;
    font-size: 0.88rem;
    border-radius: 0.45rem;
    padding: 0.4rem 0.6rem;
}

.pcg-feedback-right { background: rgba(21, 128, 61, 0.1); }
.pcg-feedback-wrong { background: rgba(185, 28, 28, 0.1); }

.pcg-burst {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.pcg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-align: center;
    padding: 1rem;
    z-index: 3;
}

[data-bs-theme="dark"] .pcg-overlay { background: rgba(33, 37, 41, 0.97); }

.pcg-bands { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; }

.pcg-band {
    border: 1px solid rgba(13, 148, 136, 0.4);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 0.2rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.pcg-band.active { background: #0f766e; border-color: #0f766e; color: #fff; }

.pcg-final-score {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    color: #0f766e;
}

[data-bs-theme="dark"] .pcg-final-score { color: #5eead4; }

.pcg-final-stats { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; font-size: 0.85rem; }

.pcg-missed-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid rgba(185, 28, 28, 0.3);
    background: rgba(185, 28, 28, 0.08);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.8rem;
    margin: 0.15rem;
}

.pcg-missed-chip b { font-family: ui-monospace, Menlo, Consolas, monospace; }
.pcg-missed-chip em { font-style: normal; opacity: 0.7; }
.pcg-missed-head { font-size: 0.85rem; font-weight: 700; }
.pcg-missed-foot { font-size: 0.78rem; opacity: 0.7; max-width: 26rem; margin: 0.3rem auto 0; }

.pcg-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
