/* ==========================================================================
   Kanji Page — 漢字 the character's own room (kanji layer, second dress)
   The SECOND ROOM OF THE SAME MUSEUM: a right-anchored washi sheet soaked
   in the origin word's pigment (--kjp-tone, set per open by kanji-page.js),
   opened by a painting band — a close crop of the very painting the reader
   was just inside. Sections sit as ink on the washi (the word page's
   grammar); the watch-out keeps its earned gold card, the twin pair keeps
   its specimen tray. Slides in as a fusuma, like every door in the house.
   Palette = 和の感性 tokens: washi #FAF7EF · ink #2C2C2C · warm stone
   #57534e · indigo #3D5A80 · kintsugi gold #C9A96E.
   ========================================================================== */

.kjp-overlay {
    position: fixed;
    inset: 0;
    z-index: 9100; /* above the 図録 word page overlay (word-page.css: 9000) */
    display: none;
}
body.kanji-page-open .kjp-overlay { display: block; }

/* THE PILL/LIFT MUST DIE HERE — same trap word-page.css fights (lines 49-67):
   components.css paints every bare <button> as a floating white pill with a
   12px radius, a drop shadow, and a translateY(-2px) hover lift + glow
   (components.css:390). That lift is the "buttons shake on hover" the owner
   saw — the kanji overlay's buttons (.kjw-row, .kjr-more, .kjp-back,
   .kjp-part--door, .kjt-cell--twin) inherited it because this sheet, unlike
   the word page, had no scoped reset. Buttons in this room REST. Each button
   class re-states its intended look AFTER this reset in the cascade below. */
.kjp-overlay button {
    appearance: none;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    padding: 0;
    margin: 0;
}
.kjp-overlay button:hover,
.kjp-overlay button:active {
    transform: none;
    box-shadow: none;
}

/* the dimming is this painting's shadow — the scrim drinks the tone */
.kjp-scrim {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, rgba(44, 44, 44, 0.42) 88%, var(--kjp-tone, #b0a090) 12%);
    opacity: 0;
    transition: opacity 0.28s ease;
}
.kjp-overlay.kjp-in .kjp-scrim { opacity: 1; }

/* right-anchored adjacent room: the word page (or wall) stays visible at
   the left — a room beside the room, never a parked drawer. The washi is
   the word page's exact formula: paper soaked 7% in the painting's tone. */
.kjp-sheet {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: min(760px, 64vw);
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, #FAF7EF 93%, var(--kjp-tone, #b0a090) 7%);
    border-left: 1px solid rgba(44, 44, 44, 0.08);
    box-shadow: -14px 0 40px rgba(15, 11, 7, 0.25);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.32s ease, transform 0.42s cubic-bezier(0.33, 0, 0.2, 1);
}
.kjp-overlay.kjp-in .kjp-sheet { opacity: 1; transform: translateX(0); }

/* ── top bar ──────────────────────────────────────────────────────────── */

.kjp-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(44, 44, 44, 0.08);
}
.kjp-back {
    appearance: none;
    background: none;
    border: 0;
    width: 36px;
    height: 36px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #2C2C2C;
    transition: background-color 0.18s ease;
}
.kjp-back:hover { background: rgba(44, 44, 44, 0.05); }
.kjp-back svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.kjp-sheet:focus { outline: none; }
.kjp-sheet:focus-visible { outline: none; }
.kjp-bar-label {
    display: flex;
    align-items: baseline;
    gap: 7px;
    color: #57534e;
}
.kjp-bar-label [lang="ja"] {
    font: 600 15px 'Klee One', 'Noto Sans JP', sans-serif;
    color: #2C2C2C;
}
.kjp-bar-label span:not([lang]) {
    font: 600 10px 'Inter', 'Noto Sans JP', sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.7;
}

/* ── scrolling body ───────────────────────────────────────────────────── */

.kjp-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 28px 64px;
    color: #2C2C2C;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

/* 字を照らす — the word page's inline-JP law, shared: Japanese in prose
   is display Klee (spans minted by kanji-page.js wrapJP, text runs only) */
.kjp-body .wp-jp {
    font-family: 'Klee One', 'Noto Sans JP', sans-serif;
    font-size: 1.25em;
    color: #2C2C2C;
}

/* ── the painting band — you are still inside the picture ─────────────── */

.kjp-band {
    position: relative;
    height: 240px;
    margin: 0 -28px;            /* full-bleed across the sheet */
    background-color: var(--kjp-tone, #b0a090);   /* load guard */
    background-size: 200%;
    background-repeat: no-repeat;
}
.kjp-band::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
        color-mix(in srgb, var(--kjp-tone, #b0a090) 70%, #2C2C2C 30%) 0%,
        transparent 58%);
}
.kjp-band-ink {
    position: absolute;
    inset: auto 24px 18px 24px;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    gap: 22px;
}
.kjp-band .kjp-glyph {
    font: 600 150px/0.95 'Klee One', 'Noto Sans JP', sans-serif;
    color: #FAFAF7;
    text-shadow: 0 0 24px rgba(18, 14, 10, 0.45), 0 0 3px rgba(18, 14, 10, 0.3);
    flex: 0 0 auto;
}
.kjp-band .kjp-kw {
    font: 600 19px 'Inter', 'Noto Sans JP', sans-serif;
    color: #FAFAF7;
    text-shadow: 0 0 14px rgba(18, 14, 10, 0.55);
    margin-bottom: 7px;
}
.kjp-band .kjp-eyebrow {
    font: 600 10px 'Inter', 'Noto Sans JP', sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(250, 250, 247, 0.78);
    text-shadow: 0 0 12px rgba(18, 14, 10, 0.5);
}
.kjp-band-meta { padding-bottom: 14px; min-width: 0; }

/* band-off fallback (window._wpKanjiBand = false): ink on the washi */
.kjp-inkhead {
    display: flex;
    align-items: flex-end;
    gap: 22px;
    padding: 34px 0 6px;
}
.kjp-inkhead .kjp-glyph {
    font: 600 150px/0.95 'Klee One', 'Noto Sans JP', sans-serif;
    color: #2C2C2C;
    flex: 0 0 auto;
}
.kjp-inkhead .kjp-kw {
    font: 600 19px 'Inter', 'Noto Sans JP', sans-serif;
    color: #2C2C2C;
    margin-bottom: 7px;
}
.kjp-inkhead .kjp-eyebrow {
    font: 600 10px 'Inter', 'Noto Sans JP', sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #57534e;
}

/* ── sections: ink on the washi (the word page's grammar) ─────────────── */

.kjp-sec { padding: 30px 0 0; }
.kjp-sec + .kjp-sec,
.kjp-sec + .kjp-card,
.kjp-sec ~ .kjp-card { margin-top: 30px; }
/* the labels are gone (なりたち / あなたのことばの中で were self-explanatory),
   so the scenes must read apart on whitespace + the band + the READ AS group
   eyebrows alone. The shape story opens just under the band as its own scene
   (a touch more air than a labelled section once gave); the words section then
   sits a full scene-gap below, its first group eyebrow doing the framing. */
.kjp-story { padding-top: 34px; }
.kjp-story + .kjp-words { margin-top: 34px; }
.kjp-slabel {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
    color: #57534e;
}
.kjp-slabel [lang="ja"] {
    font: 600 15px 'Klee One', 'Noto Sans JP', sans-serif;
    color: #2C2C2C;
}
.kjp-slabel span:not([lang]) {
    font: 600 10.5px 'Inter', 'Noto Sans JP', sans-serif;
    letter-spacing: 0.17em;
    text-transform: uppercase;
    color: #57534e;
}

/* the one box that remains earned: the gold watch-out card (and the twin
   specimen tray below) — everything else reads as ink on the paper */
.kjp-card {
    background: #FAFAF7;
    border: 1px solid rgba(44, 44, 44, 0.08);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 20px 22px;
    margin: 30px 0 0;
}
.kjp-card .kjp-slabel [lang="ja"] { font-size: 13px; }

.kjp-story p { font-size: 16.5px; line-height: 1.85; color: #44403c; margin: 0; }
.kjp-story b, .kjp-watch b, .kjt-line b, .kjt-note b {
    font-family: 'Klee One', 'Noto Sans JP', sans-serif;
    font-weight: 600;
}
/* parts read as plain ink words on the washi — no pills, no frames (owner:
   "maybe no pills just words"). A part = glyph + its name, inline. The door
   law lives on, but as quiet TYPOGRAPHY, not a box: a gated part is still a
   <button data-kanji> (the test asserts BUTTON iff data-kanji), and on
   hover/focus its glyph + name tint indigo and a small gold arrow surfaces
   (opacity only, no movement — calm = colour, never a jump). Ungated parts
   are bare spans with the same words and no feedback. */
.kjp-parts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 16px; }
.kjp-part {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    /* reset already zeroed button padding/border/bg — leave them flat */
}
.kjp-part b {
    font: 600 18px 'Klee One', 'Noto Sans JP', sans-serif;
    color: #2C2C2C;
    transition: color 0.18s ease;
}
.kjp-part-name {
    font: 400 12.5px 'Inter', 'Noto Sans JP', sans-serif;
    color: #57534e;
    transition: color 0.18s ease;
}
/* the door affordance: a gold arrow that rests invisible and surfaces on
   intent — gold #C9A96E is earned here (it appears only on hover/focus) */
.kjp-part-go {
    font: 600 13px 'Inter', 'Noto Sans JP', sans-serif;
    color: #C9A96E;
    opacity: 0;
    transition: opacity 0.18s ease;
    align-self: center;
}
button.kjp-part--door:hover b,
button.kjp-part--door:focus-visible b,
button.kjp-part--door:hover .kjp-part-name,
button.kjp-part--door:focus-visible .kjp-part-name {
    color: #3D5A80;
}
button.kjp-part--door:hover .kjp-part-go,
button.kjp-part--door:focus-visible .kjp-part-go { opacity: 1; }

/* ── reading groups + word rows ───────────────────────────────────────── */

.kjr-group { margin-top: 20px; }
.kjr-group:first-of-type { margin-top: 0; }
.kjr-eyebrow {
    font: 600 9.5px 'Inter', 'Noto Sans JP', sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #78716c;
    margin-bottom: 2px;
}
.kjr-head {
    display: flex;
    align-items: baseline;
    gap: 11px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(44, 44, 44, 0.08);
    margin-bottom: 4px;
}
.kjr-name { font: 600 22px 'Klee One', 'Noto Sans JP', sans-serif; }
.kjr-name--whole { font-size: 14px; color: #57534e; }
.kjr-sub { font: 400 11.5px 'Inter', 'Noto Sans JP', sans-serif; color: #57534e; }

.kjw-row {
    appearance: none;
    background: none;
    border: 0;
    border-bottom: 1px solid rgba(44, 44, 44, 0.08);
    border-radius: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 4px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: inherit;
    transition: background-color 0.18s ease;
}
.kjw-row:hover { background: rgba(44, 44, 44, 0.03); }
.kjw-row:last-of-type { border-bottom: none; }
.kjw-row--hid { display: none; }

/* mini placards: the gallery's own 3:2 painting ratio, toned while lazy */
.kjw-thumb, .kjw-tile {
    width: 72px;
    height: 48px;
    border-radius: 3px;
    flex: 0 0 auto;
    object-fit: cover;
}
.kjw-tile {
    background: #F0EDE8;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 600 22px 'Klee One', 'Noto Sans JP', sans-serif;
    color: #57534e;
}
.kjw-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kjw-jp { font: 600 22px 'Klee One', 'Noto Sans JP', sans-serif; }
.kjw-hl { color: #3D5A80; }
.kjw-kana {
    font: 400 14px 'Klee One', 'Noto Sans JP', sans-serif;
    color: #57534e;
    margin-left: 9px;
}
.kjw-en {
    font: 400 13px 'Inter', 'Noto Sans JP', sans-serif;
    color: #57534e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kjw-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 0 0 auto;
}
.kjw-dot { width: 9px; height: 9px; border-radius: 50%; }
/* the app's one status grammar: amber = still learning, moss = known
   (the wall's stated law). Gold is EARNED-only — thirty gold dots in a
   reading list would spend the app's scarcest color on a checklist. */
.kjw-dot--learned { background: var(--color-moss); }
.kjw-dot--saved { background: var(--color-amber); }
.kjw-dot--new { border: 1.5px solid #57534e; opacity: 0.5; }

.kjr-more {
    appearance: none;
    background: none;
    border: 0;
    padding: 8px 4px 2px;
    font: 500 12px 'Inter', 'Noto Sans JP', sans-serif;
    color: #57534e;
    cursor: pointer;
    transition: color 0.18s ease;
}
.kjr-more:hover { color: #2C2C2C; }

/* ── watch-out (earned gold) ──────────────────────────────────────────── */

.kjp-watch { border-left: 3px solid #C9A96E; }
.kjp-watch .kjp-slabel { color: #C9A96E; }
.kjp-watch .kjp-slabel span:not([lang]) { opacity: 1; }
.kjp-watch p { font-size: 15px; line-height: 1.7; color: #44403c; margin: 0; }

/* ── confusable twin ──────────────────────────────────────────────────── */

.kjt-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.kjt-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #FAFAF7;
    border: 1px solid rgba(44, 44, 44, 0.08);
    border-radius: 3px;
    padding: 12px;
    text-align: left;
    font-family: inherit;
    color: inherit;
}
.kjt-cell--twin {
    cursor: pointer;
    /* feedback is colour + border only, never movement (the calm-it-down
       rule): no translateY, no shadow — the twin tray rests like its mate */
    transition: border-color 0.18s ease, background-color 0.18s ease;
}
.kjt-cell--twin:hover {
    border-color: rgba(44, 44, 44, 0.18);
    background: #FAFAF7;
}
.kjt-glyph { font: 600 40px/1 'Klee One', 'Noto Sans JP', sans-serif; }
.kjt-marker {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font: 400 11px 'Inter', 'Noto Sans JP', sans-serif;
    color: #57534e;
}
.kjt-marker b { font: 600 17px 'Klee One', 'Noto Sans JP', sans-serif; color: #2C2C2C; }
.kjt-line { font: 400 13.5px 'Inter', 'Noto Sans JP', sans-serif; color: #44403c; line-height: 1.65; }
.kjt-go {
    position: absolute;
    top: 10px;
    right: 12px;
    color: #C9A96E;
    font-weight: 600;
}
.kjt-note {
    font-size: 15px;
    line-height: 1.7;
    color: #44403c;
    margin: 12px 0 0;
}

/* (the .kjc-chip pill kit is retired — the hero entry is the word page's
   落款 rakkan marks in word-page.css; paper stickers never reached the art) */

/* ── gallery seam glyph → kanji page affordance ───────────────────────── */

button.grid-seam-kanji {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    transition: color 0.18s ease;
}
button.grid-seam-kanji:hover { color: #3D5A80; }

/* ── focus + reduced motion + small screens ───────────────────────────── */

.kjp-back:focus-visible,
.kjw-row:focus-visible,
.kjr-more:focus-visible,
.kjt-cell--twin:focus-visible,
button.kjp-part--door:focus-visible,
button.grid-seam-kanji:focus-visible {
    outline: 2px solid #3D5A80;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .kjp-sheet { width: 100%; border-left: 0; }
    .kjp-body { padding: 0 16px 56px; }
    .kjp-band { height: 170px; margin: 0 -16px; }
    .kjp-band .kjp-glyph, .kjp-inkhead .kjp-glyph { font-size: 88px; }
    .kjt-pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    /* every transitioned element neutralized — incl. the new part-door
       typography (glyph/name colour fade + the gold arrow opacity fade) */
    .kjp-scrim, .kjp-sheet, .kjp-back, .kjw-row, .kjr-more,
    .kjt-cell--twin, button.kjp-part--door, button.grid-seam-kanji,
    .kjp-part b, .kjp-part-name, .kjp-part-go {
        transition: none;
    }
    .kjp-sheet { transform: none; }
}
