/* /documents — annotated Japanese documents (doc-reader.js). The sheet stays paper-white in both themes;
   on narrow screens it keeps a readable width and scrolls sideways, with the explanation pinned below. */

.docr-hero { margin: 0 0 1.25rem; }
.docr-hero__kicker {
    display: inline-block;
    margin: 0 0 0.4rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.docr-hero h1 { margin: 0 0 0.35rem; }
.docr-hero h1 .docr-hero__ja { display: block; font-size: 0.55em; font-weight: 600; color: var(--color-text-secondary); }
.docr-hero p { margin: 0; color: var(--color-text-secondary); max-width: 62ch; }

.docr { display: grid; gap: 1rem; margin: 0 0 2.5rem; }
.docr > * { min-width: 0; }
@media (min-width: 1100px) {
    .docr { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
    .docr__panel { position: sticky; top: calc(var(--header-offset) + 1rem); }
    .docr.is-reading .docr__main { padding-bottom: 30vh; }
    .docr.is-reading .docr__panel { height: min(calc(100vh - var(--header-offset) - 2rem), 640px); }
}

/* ---------- Toolbar ---------- */
.docr__tools { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin: 0 0 0.6rem; }
.docr__switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 600; min-height: var(--tap-target-sm); }
.docr__switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.docr__switch-track {
    width: 38px; height: 22px; border-radius: 999px; flex: none;
    background: var(--color-border-strong); position: relative; transition: background 0.2s ease;
}
.docr__switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.2s ease;
}
.docr__switch input:checked + .docr__switch-track { background: var(--color-primary); }
.docr__switch input:checked + .docr__switch-track::after { transform: translateX(16px); }
.docr__switch input:focus-visible + .docr__switch-track { outline: 2px solid var(--color-ring); outline-offset: 2px; }
.docr__hint { font-size: 0.82rem; color: var(--color-text-muted); }

.docr__btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    min-height: var(--tap-target); padding: 0 1rem; border-radius: var(--radius-sm);
    border: 1px solid var(--color-primary); background: var(--color-primary); color: var(--color-primary-contrast);
    font: inherit; font-weight: 600; cursor: pointer;
}
.docr__btn:hover { background: var(--color-primary-hover); }
.docr__btn--ghost { background: transparent; color: var(--color-primary); }
.docr__btn--ghost:hover { background: var(--color-surface-alt); }
.docr__btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- Sheet ---------- */
.docr__scroll {
    overflow-x: auto;
    border-radius: var(--radius);
    background: #e9e4d8;
    padding: 0.75rem;
    scrollbar-width: thin;
    overscroll-behavior-x: contain;
}
.docr__sheet {
    position: relative;
    container-type: inline-size;
    margin: 0 auto;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.12);
}
.docr__sheet--image { min-width: 940px; }
.docr__sheet--image img { display: block; width: 100%; height: auto; }
.docr__layer { position: absolute; inset: 0; }

/* Drawn hotspots over an image */
.docr__box {
    position: absolute; padding: 0; margin: 0; border: 0; background: transparent; cursor: pointer;
    border-radius: 3px; transition: box-shadow 0.2s ease, background 0.2s ease;
}
.docr__box:hover { background: rgba(217, 164, 65, 0.12); box-shadow: inset 0 0 0 2px rgba(217, 164, 65, 0.7); }
.docr__box:focus-visible { outline: 2px solid var(--tengri-sky); outline-offset: 1px; }
.docr__box.is-active {
    background: transparent;
    box-shadow: inset 0 0 0 2.5px var(--tengri-sun), 0 0 0 9999px rgba(18, 32, 74, 0.38);
    z-index: 2;
}
.docr__sheet--image { overflow: hidden; }

/* Number markers (and Mongolian names on image sheets) */
.docr__mark {
    position: absolute; top: 0; left: 0; z-index: 1;
    display: inline-flex; align-items: center; gap: 0.25em;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font: 700 11px/1 var(--font-body);
}
.docr__no {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
    background: var(--tengri-sky); color: #fff; box-shadow: 0 0 0 2px #fff;
}
.is-active > .docr__mark .docr__no, .is-active.docr__mark .docr__no { background: var(--tengri-sun); color: var(--tengri-sky-deep); }
.docr__mn {
    display: none; position: absolute; z-index: 1; pointer-events: none;
    padding: 2px 5px; border-radius: 3px; background: #fffbea;
    color: var(--tengri-sky-deep); box-shadow: 0 0 0 1px rgba(27, 42, 87, 0.35);
    font: 600 10.5px/1.2 var(--font-body); white-space: nowrap;
}
.docr--mn .docr__mn { display: block; }

/* Handwriting of the sample person */
.docr__ink {
    position: absolute; white-space: nowrap; pointer-events: none;
    font-family: "Yomogi", "Noto Sans JP", cursive;
    font-size: calc(var(--fs, 1.3) * 1cqw);
    line-height: 1;
    color: #1f3f9a;
}
.docr__ink--circle { border: 0.13cqw solid #1f3f9a; border-radius: 50%; width: 1.5cqw; height: 1.5cqw; }
.docr__ink--check { font-family: system-ui, sans-serif; font-weight: 700; }

/* ---------- HTML sheet: payslip ---------- */
.docr__sheet--slip { min-width: 640px; max-width: 860px; padding: 22px 22px 26px; font-family: "Noto Sans JP", var(--font-body); }
.slip__title { text-align: center; font-size: 1.35rem; letter-spacing: 0.4em; margin: 0 0 0.9rem; font-weight: 700; }
.slip__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: 0 0 0.9rem; }
.slip__month { font-weight: 700; white-space: nowrap; }
.slip table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.slip th, .slip td { border: 1px solid #555; padding: 0; height: 26px; font-size: 12.5px; position: relative; }
.slip th { background: #eaf3f6; font-weight: 500; text-align: center; }
.slip td { text-align: right; padding: 0 6px; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.slip td.slip__c { text-align: center; }
.slip .slip__sec {
    width: 30px; background: #eaf3f6; font-weight: 700; font-size: 13px; line-height: 1.6;
}
.slip .slip__gap { border-left: 0; border-right: 0; background: transparent; }
.slip__who td, .slip__who th { height: 30px; }
.slip__who .slip__name { font-size: 16px; text-align: center; }
.slip__total th { background: #dcecf1; }
.slip__total td { font-weight: 700; font-size: 14.5px; }
.slip [data-field] { cursor: pointer; transition: background 0.15s ease, opacity 0.2s ease; }
.slip [data-field]:hover { background: #fff6dc; }
.slip [data-field]:focus-visible { outline: 2px solid var(--tengri-sky); outline-offset: -2px; }
.slip [data-field].is-active { background: #ffe9a8; box-shadow: inset 0 0 0 2px var(--tengri-sun); }
.slip .docr__mark { transform: translate(-30%, -45%); font-size: 10px; }
.slip .docr__no { min-width: 16px; height: 16px; }
.has-active .slip th[data-field]:not(.is-active),
.has-active .slip td[data-field]:not(.is-active) { opacity: 0.45; }
.docr--mn .slip th [data-mn] { font-size: 11px; line-height: 1.15; display: inline-block; padding: 2px 1px; }

/* ---------- Panel ---------- */
.docr__panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
}
/* While reading, the panel keeps one size and the text scrolls inside it, so the buttons never move. */
.docr.is-reading .docr__panel { display: flex; flex-direction: column; }
.docr__card:not([hidden]) { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.docr__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.docr__nav { flex: none; }
.docr__body.has-more { -webkit-mask-image: linear-gradient(#000 calc(100% - 3rem), transparent); mask-image: linear-gradient(#000 calc(100% - 3rem), transparent); }
@media (max-width: 1099px) {
    .docr.is-reading { padding-bottom: 46vh; }
    .docr.is-reading .docr__panel {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        height: 46vh; padding-bottom: calc(0.9rem + env(safe-area-inset-bottom));
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.14);
        border-width: 1px 0 0; border-radius: var(--radius) var(--radius) 0 0;
    }
}
@media (max-width: 768px) {
    .docr.is-reading .docr__panel { bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom)); padding-bottom: 0.9rem; }
}
.docr__intro p { margin: 0 0 0.75rem; }
.docr__intro p:last-of-type { margin-bottom: 1rem; }
.docr__step { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.docr__card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.docr__close {
    border: 0; background: transparent; color: var(--color-text-muted); font-size: 1.3rem; line-height: 1;
    width: var(--tap-target-sm); height: var(--tap-target-sm); border-radius: 50%; cursor: pointer;
}
.docr__close:hover { background: var(--color-surface-alt); color: var(--color-text); }
.docr__title { margin: 0.15rem 0 0.1rem; font-size: 1.2rem; }
.docr__ja { margin: 0 0 0.6rem; font-family: "Noto Sans JP", var(--font-body); color: var(--color-text-secondary); }
.docr__body { line-height: 1.55; }
.docr__body p { margin: 0 0 0.6rem; }
.docr__body ul { margin: 0 0 0.6rem; padding-left: 1.15rem; }
.docr__body li { margin: 0 0 0.25rem; }
.docr__body .docr__calc {
    display: block; margin: 0.2rem 0 0.7rem; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
    background: var(--color-surface-alt); font-variant-numeric: tabular-nums; font-size: 0.92rem;
}
.docr__body .docr__key {
    margin: 0 0 0.7rem; padding: 0.55rem 0.7rem; border-left: 3px solid var(--color-accent);
    background: var(--color-warning-bg); color: #3b2a05; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.docr__nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.9rem; }
.docr__nav .docr__btn { flex: 1; }

/* ---------- Hub ---------- */
.docr-hub { display: grid; gap: 1rem; margin: 0 0 2rem; }
@media (min-width: 760px) { .docr-hub { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.docr-hub__card {
    display: grid; grid-template-rows: auto 1fr; overflow: hidden;
    border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface);
    color: inherit; text-decoration: none; transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.docr-hub__card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1); }
.docr-hub__thumb { aspect-ratio: 16 / 9; background: #e9e4d8; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.docr-hub__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: left top; }
.docr-hub__thumb--slip { font: 700 2rem/1 "Noto Sans JP", sans-serif; letter-spacing: 0.3em; color: #33505c; background: #eaf3f6; }
.docr-hub__body { padding: 0.9rem 1rem 1.1rem; }
.docr-hub__ja { margin: 0; font-family: "Noto Sans JP", var(--font-body); color: var(--color-text-secondary); font-size: 0.9rem; }
.docr-hub__title { margin: 0.1rem 0 0.4rem; font-size: 1.15rem; }
.docr-hub__desc { margin: 0; color: var(--color-text-secondary); font-size: 0.92rem; line-height: 1.5; }
.docr-hub__when { display: inline-block; margin-top: 0.6rem; font-size: 0.8rem; font-weight: 700; color: var(--color-primary); }

@media (prefers-reduced-motion: reduce) {
    .docr__box, .docr-hub__card, .docr__switch-track, .docr__switch-track::after { transition: none; }
}
