/*
 * /tools/name-checker — the checker and Name Inspector (content pipeline item 4).
 *
 * The visual job is one thing: make the NAME the subject of the page. A report about somebody's
 * name that opens with a table reads like a receipt, so the characters are set large at the top,
 * the surname is visibly a different thing from the given name, and each finding points back at
 * the character it is about. Everything under that is ordinary card layout.
 *
 * Effects are chrome, per the retention layer's rule: nothing here is clickable, nothing shifts
 * layout, nothing animates near an ad unit, and every animation is off under reduced motion — a
 * report that assembles itself is pleasant, and one a reader has to wait for is not, so the whole
 * sequence is under half a second.
 *
 * Dark mode goes through [data-bs-theme="dark"], as everywhere else on the site.
 */

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

.nc-hero {
    background: linear-gradient(135deg, #5b21b6 0%, #6d28d9 45%, #4c1d95 100%);
    position: relative;
    overflow: hidden;
}

.nc-hero::after {
    content: "名";
    position: absolute;
    right: 0.04em;
    bottom: -0.28em;
    font-size: 12rem;
    line-height: 1;
    opacity: 0.09;
    font-weight: 700;
    pointer-events: none;
}

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

.nc-input {
    font-size: 1.35rem;
    letter-spacing: 0.04em;
}

.nc-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.nc-chip {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 1.05rem;
    line-height: 1.6;
    cursor: pointer;
}

.nc-chip:hover,
.nc-chip:focus-visible {
    border-color: #6d28d9;
    color: #6d28d9;
}

/* ── The name at the top of the report ────────────────────────────────────── */

.nc-name {
    position: relative;
    display: inline-flex;
    gap: 0.12em;
    font-size: clamp(2.4rem, 11vw, 3.4rem);
    line-height: 1.15;
    font-weight: 600;
}

.nc-name-char {
    display: inline-block;
    padding: 0 0.04em;
    border-bottom: 4px solid transparent;
}

/* The surname is underlined rather than coloured: the point is that it is a DIFFERENT PART of
   the name, and colour on a character is the one signal this site reserves for tones. */
.nc-name-char.is-surname {
    border-bottom-color: #a78bfa;
}

/* The character a finding is about, while that finding is hovered or focused. */
.nc-name-char.is-pointed {
    background: rgba(109, 40, 217, 0.14);
    border-radius: 0.25rem;
}

.nc-chars tbody tr.is-pointed {
    background: rgba(109, 40, 217, 0.08);
}

.nc-char {
    font-size: 1.6rem;
    line-height: 1.2;
}

.nc-pinyin {
    font-weight: 600;
}

/* ── The count ────────────────────────────────────────────────────────────── */

.nc-verdict-count {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: #6d28d9;
}

.nc-verdict-of {
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.55;
}

/* ── The scan, and the findings stamping in ───────────────────────────────── */

.nc-scan {
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    background: linear-gradient(180deg, transparent, #a78bfa 25%, #a78bfa 75%, transparent);
    opacity: 0;
    pointer-events: none;
}

.nc-report.is-scanning .nc-scan {
    animation: nc-sweep 620ms ease-in-out;
}

@keyframes nc-sweep {
    0% { left: 0; opacity: 0; }
    12% { opacity: 1; }
    88% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

.nc-report.is-scanning .nc-finding {
    animation: nc-stamp 320ms ease-out both;
    animation-delay: calc(620ms + var(--nc-delay, 0ms));
}

@keyframes nc-stamp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.nc-limits {
    border-left: 4px solid var(--bs-secondary-border-subtle) !important;
}

.nc-checklist li {
    margin-bottom: 0.4rem;
}

/* ── Name Inspector ───────────────────────────────────────────────────────── */

.ncg-levels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.ncg-level {
    text-align: left;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 0.6rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
}

.ncg-level:hover,
.ncg-level:focus-visible {
    border-color: #6d28d9;
}

.ncg-level b {
    display: block;
}

.ncg-level small {
    display: block;
    opacity: 0.7;
    line-height: 1.35;
}

.ncg-stage {
    position: relative;
}

.ncg-hud {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ncg-hud > div {
    text-align: center;
    flex: 1 1 0;
}

.ncg-hud small {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
}

.ncg-hearts {
    color: #dc2626;
    font-size: 1.1rem;
}

.ncg-combo {
    color: #6d28d9;
}

.ncg-card {
    border: 1px solid var(--bs-border-color);
    border-radius: 0.7rem;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
}

.ncg-name {
    font-size: clamp(2.2rem, 10vw, 3rem);
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 0.1em;
}

.ncg-name span {
    padding: 0 0.05em;
    border-radius: 0.2rem;
}

.ncg-name span.is-culprit {
    background: rgba(220, 38, 38, 0.18);
}

.ncg-name span.is-clean {
    background: rgba(22, 163, 74, 0.16);
}

.ncg-rows {
    display: grid;
    gap: 0.2rem;
    margin-top: 0.6rem;
    font-size: 0.86rem;
}

.ncg-row {
    display: grid;
    grid-template-columns: 2.2rem 5rem 1fr 3.4rem;
    gap: 0.4rem;
    align-items: baseline;
    padding: 0.15rem 0.25rem;
    border-radius: 0.25rem;
}

.ncg-row b {
    font-size: 1.15rem;
}

.ncg-row .ncg-strokes {
    text-align: right;
    opacity: 0.6;
}

.ncg-row .ncg-none {
    opacity: 0.5;
    font-style: italic;
}

.ncg-question {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.ncg-options {
    display: grid;
    gap: 0.4rem;
}

.ncg-option {
    text-align: left;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 0.5rem;
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    line-height: 1.4;
}

.ncg-option:hover:not(:disabled),
.ncg-option:focus-visible {
    border-color: #6d28d9;
}

.ncg-option.is-right {
    border-color: #16a34a;
    background: rgba(22, 163, 74, 0.12);
}

.ncg-option.is-wrong {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.12);
}

.ncg-feedback {
    min-height: 2.6rem;
    margin-top: 0.6rem;
    font-size: 0.9rem;
}

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

.ncg-over {
    text-align: center;
    padding: 1rem 0.5rem;
}

/* The pinpoint step: the player clicks the character the finding is about. */
.ncg-pinpoint .ncg-name span {
    cursor: pointer;
    outline: 1px dashed var(--bs-border-color);
}

.ncg-pinpoint .ncg-name span:hover {
    background: rgba(109, 40, 217, 0.14);
}

.ncg-bonus {
    animation: nc-stamp 260ms ease-out both;
    color: #16a34a;
    font-weight: 600;
}

/* ── Dark mode ────────────────────────────────────────────────────────────── */

[data-bs-theme="dark"] .nc-chip,
[data-bs-theme="dark"] .ncg-level,
[data-bs-theme="dark"] .ncg-option {
    background: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .nc-verdict-count {
    color: #c4b5fd;
}

[data-bs-theme="dark"] .nc-name-char.is-pointed,
[data-bs-theme="dark"] .nc-chars tbody tr.is-pointed {
    background: rgba(167, 139, 250, 0.16);
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .nc-report.is-scanning .nc-scan,
    .nc-report.is-scanning .nc-finding,
    .ncg-bonus {
        animation: none !important;
    }

    .nc-report.is-scanning .nc-finding {
        opacity: 1;
        transform: none;
    }
}
