/* «Японы монголчууд: тоо баримтаар» (/mongolians-in-japan). The story runs on a night-sky stage (Tengri palette)
   pinned behind the step cards; mongolians-story.js draws the dots, labels and charts. */

.mij {
    --mij-night: #0b1430;
    --mij-sky: var(--tengri-sky-deep, #12204a);
    --mij-star: #f6e7bf;
    --mij-text: #e9e4d6;
    --mij-soft: rgba(233, 228, 214, 0.68);
    --mij-line: rgba(159, 179, 230, 0.22);
    --mij-stage-h: calc(100svh - var(--header-offset, 0px) - var(--tabbar-h, 0px));
    position: relative;
    color: var(--mij-text);
    background:
        radial-gradient(ellipse 80% 60% at 72% 30%, rgba(53, 88, 192, 0.35), transparent 70%),
        radial-gradient(ellipse 60% 40% at 20% 85%, rgba(217, 164, 65, 0.10), transparent 70%),
        linear-gradient(180deg, var(--mij-sky) 0%, var(--mij-night) 100%);
}

/* Pinned picture; the steps scroll over it */
.mij__stage {
    position: sticky;
    top: var(--header-offset, 0px);
    height: var(--mij-stage-h);
    overflow: hidden;
}
.mij__canvas, .mij__svg, .mij__labels { position: absolute; inset: 0; }
.mij__canvas { width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s var(--ease-out); }
.mij.is-ready .mij__canvas { opacity: 1; }
.mij__labels { pointer-events: none; }

.mij__steps {
    position: relative;
    margin-top: calc(-1 * var(--mij-stage-h));
    z-index: 2;
    pointer-events: none;
}
.mij__step {
    min-height: var(--mij-stage-h);
    display: flex;
    align-items: flex-end;
    padding: 0 1rem 7svh;
}
.mij__step + .mij__step { margin-top: 10svh; }
.mij__step:last-child { padding-bottom: 14svh; }

.mij__card {
    pointer-events: auto;
    width: 100%;
    max-width: 26rem;
    padding: 1.1rem 1.25rem 1.2rem;
    border-radius: 14px;
    background: rgba(251, 247, 236, 0.96);
    color: var(--tengri-ink, #1a1e2a);
    box-shadow: 0 18px 40px rgba(4, 10, 30, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
    opacity: 0.55;
    transform: translateY(12px);
    transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}
.mij__step.is-active .mij__card { opacity: 1; transform: none; }
.mij__card p { margin: 0 0 0.6rem; line-height: 1.55; font-size: 0.98rem; }
.mij__card p:last-child { margin-bottom: 0; }
.mij__card a { color: var(--tengri-sky, #1b2a57); font-weight: 600; }
.mij__big {
    font-family: var(--font-heading);
    font-size: 1.45rem !important;
    line-height: 1.2 !important;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--tengri-sky, #1b2a57);
}
.mij__small { font-size: 0.85rem !important; color: var(--tengri-ink-soft, #4a4e5c); }

/* Opening card: no paper, big type straight on the sky */
.mij__step--hero { align-items: flex-end; }
.mij__card--hero {
    background: none;
    box-shadow: none;
    color: var(--mij-text);
    padding: 0 0.25rem;
    opacity: 1;
    transform: none;
}
.mij__card--hero h1 {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 7vw, 4rem);
    line-height: 1.02;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0.2rem 0 0.8rem;
    color: #fff;
    text-shadow: 0 2px 30px rgba(11, 20, 48, 0.8);
}
.mij__kicker {
    font-size: 0.78rem !important;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tengri-sun, #d9a441);
    font-weight: 700;
}
.mij__lead { font-size: 1.2rem !important; color: #fff; }
.mij__lead strong { color: var(--tengri-sun-soft, #f2d988); font-size: 1.15em; }
.mij__card--hero p { color: var(--mij-soft); text-shadow: 0 1px 12px rgba(11, 20, 48, 0.9); }
.mij__hint { margin-top: 1.4rem !important; font-size: 0.85rem !important; animation: mij-bob 2.4s ease-in-out infinite; }
@keyframes mij-bob { 50% { transform: translateY(5px); opacity: 0.6; } }

/* Labels placed over the canvas (translate set by the script) */
.mij__label {
    position: absolute;
    left: 0; top: 0;
    white-space: nowrap;
    font-size: 0.78rem;
    color: var(--mij-text);
    transition: opacity 0.6s var(--ease-out);
    translate: 8px -50%;
    text-shadow: 0 1px 6px var(--mij-night), 0 0 2px var(--mij-night);
}
.mij__label b { color: var(--tengri-sun-soft, #f2d988); font-weight: 700; margin-left: 0.15rem; }
.mij__label::before {
    content: ""; position: absolute; left: -9px; top: 50%;
    width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
    background: var(--tengri-sun, #d9a441); box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.25);
}
.mij__label.is-top { font-size: 0.95rem; font-weight: 700; }
.mij__label.is-left { translate: 0 -100%; font-size: 0.85rem; }
.mij__label.is-left::before, .mij__label.is-age::before, .mij__label.is-sex::before { display: none; }
.mij__label.is-left small { color: var(--mij-soft); }
.mij__label.is-age { translate: -50% -50%; font-size: 0.7rem; color: var(--mij-soft); }
.mij__label.is-sex { translate: -50% -50%; font-size: 0.85rem; font-weight: 600; }
.mij__mine { color: var(--tengri-sun, #d9a441); font-weight: 700; }
/* Kanto callouts: text in a column beside the cluster, joined to its ward by a leader line (SVG) */
.mij__label.is-callout { translate: 0 -50%; font-size: 0.82rem; }
.mij__label.is-callout.is-flip { translate: -100% -50%; }
.mij__label.is-callout::before { display: none; }
.mij__label.is-callout.is-top { font-size: 0.95rem; }
.mij-leaders path { fill: none; stroke: var(--tengri-sun, #d9a441); stroke-opacity: 0.7; stroke-width: 1; }
.mij-leaders circle { fill: var(--tengri-sun, #d9a441); stroke: var(--mij-night); stroke-width: 1.5; }
.mij__swatch {
    display: inline-block; width: 0.7em; height: 0.7em; border-radius: 2px; margin-right: 0.35em;
    background: var(--c); vertical-align: -0.02em;
}

/* Legend of visa colours (visa step only) */
.mij__legend {
    position: absolute;
    list-style: none; margin: 0; padding: 0.7rem 0.85rem;
    right: 1rem; top: 1rem;
    display: grid; gap: 0.25rem;
    font-size: 0.78rem;
    background: rgba(11, 20, 48, 0.72);
    border: 1px solid var(--mij-line);
    border-radius: 10px;
    backdrop-filter: blur(6px);
    opacity: 0; transform: translateY(-6px);
    transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
    pointer-events: none;
}
.mij.show-legend .mij__legend { opacity: 1; transform: none; }
/* Phones: under the map, where the Pacific side is empty */
.mij.is-phone .mij__legend { top: auto; bottom: 41%; right: 0.5rem; font-size: 0.7rem; padding: 0.5rem 0.6rem; gap: 0.15rem; }
.mij__legend li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.35rem; align-items: center; }
.mij__legend small { color: var(--mij-soft); }
.mij__legend b { font-variant-numeric: tabular-nums; color: var(--mij-text); }
.mij__legend li.is-mine span:nth-child(2)::after { content: " ★"; color: var(--tengri-sun, #d9a441); }
.mij__legend-note { display: block !important; color: var(--tengri-sun, #d9a441); font-size: 0.72rem; margin-top: 0.15rem; }

/* SVG charts over the stage */
.mij-chart text { fill: var(--mij-text); font-family: var(--font-body); }
.mij-axis text { font-size: 11px; fill: var(--mij-soft); }
.mij-axis line, .mij-axis path { stroke: var(--mij-line); }
.mij-axis--y line { stroke-dasharray: 2 4; }
.mij-band { fill: rgba(255, 255, 255, 0.05); }
.mij-band-label { font-size: 11px; fill: var(--mij-soft) !important; }
.mij-endlabels text { font-size: 12px; fill: var(--mij-text); }
.mij-note line { stroke: var(--tengri-sun, #d9a441); stroke-width: 1; }
.mij-note text { font-size: 11px; fill: var(--tengri-sun-soft, #f2d988); }
.mij-total { font-family: var(--font-heading); font-weight: 800; font-size: 18px; fill: #fff !important; }
.mij-total--first { font-size: 13px; font-weight: 700; fill: var(--mij-soft) !important; }
.mij-bars rect { fill: rgba(159, 179, 230, 0.45); }
.mij-bars .is-mn rect { fill: var(--tengri-sun, #d9a441); }
.mij-bars__name { font-size: 12px; fill: var(--mij-soft) !important; }
.mij-bars .is-mn .mij-bars__name, .mij-bars .is-mn .mij-bars__value { fill: var(--tengri-sun-soft, #f2d988) !important; font-weight: 700; }
.mij-bars__value { font-size: 12px; font-variant-numeric: tabular-nums; }

/* Desktop: cards in a left column, the picture beside them */
@media (min-width: 900px) {
    .mij__step { align-items: center; padding: 0 0 0 max(2rem, calc(50vw - 36rem)); }
    .mij__step + .mij__step { margin-top: 0; }
    .mij__card { max-width: 24rem; }
    .mij__step--hero { align-items: center; }
    .mij__card--hero { max-width: 30rem; }
    .mij__label { font-size: 0.85rem; }
    .mij__label.is-top { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
    .mij__card, .mij__canvas, .mij__legend, .mij__label { transition: none; }
    .mij__hint { animation: none; }
}

/* After the story: plain page with the tables, method and sources */
.mij-after { padding-top: 2.5rem; padding-bottom: 3rem; }
.mij-after h2 { margin-top: 2rem; }
.mij-after h3 { font-size: 1rem; margin: 1.2rem 0 0.5rem; color: var(--color-text-secondary); }
.mij-after ul { line-height: 1.6; }
.mij-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); }
.mij-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.mij-table th, .mij-table td { padding: 0.45rem 0.6rem; text-align: right; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.mij-table th:first-child, .mij-table td:first-child, #mij-munis td:nth-child(2), #mij-munis td:nth-child(3), #mij-munis th:nth-child(2), #mij-munis th:nth-child(3) { text-align: left; }
.mij-table th { background: var(--color-surface-alt); font-weight: 600; font-size: 0.78rem; vertical-align: bottom; }
.mij-table th small { font-weight: 400; color: var(--color-text-muted); }
.mij-table tbody tr:last-child td { border-bottom: 0; }

/* «Газрын зураг дээр хайх»: the same night sky, a map to pan and zoom, filtered by visa (mongolians-explore.js) */
.mij-explore {
    color: #e9e4d6;
    background: linear-gradient(180deg, #0b1430 0%, var(--tengri-sky-deep, #12204a) 100%);
    padding: 3rem 0 3.5rem;
}
.mij-explore__inner { max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
.mij-explore h2 { color: #fff; font-family: var(--font-heading); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.mij-explore h3 { color: rgba(233, 228, 214, 0.68); font-size: 0.95rem; margin: 1.4rem 0 0.6rem; }
.mij-explore__intro { color: rgba(233, 228, 214, 0.75); max-width: 40rem; margin: 0 0 1rem; line-height: 1.55; }
.mij-explore__chips { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.3rem; scrollbar-width: thin; }
@media (min-width: 900px) { .mij-explore__chips { flex-wrap: wrap; overflow: visible; } }
.mij-chip {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 0.15rem;
    min-height: var(--tap-target-sm, 36px);
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(159, 179, 230, 0.28);
    background: rgba(255, 255, 255, 0.04);
    color: #e9e4d6; font: inherit; font-size: 0.85rem; cursor: pointer;
    transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out), transform 0.15s var(--ease-out);
}
.mij-chip b { font-weight: 600; color: rgba(233, 228, 214, 0.6); margin-left: 0.25rem; font-variant-numeric: tabular-nums; }
.mij-chip:hover { border-color: rgba(159, 179, 230, 0.55); }
.mij-chip:active { transform: scale(0.97); }
.mij-chip[aria-pressed="true"] { background: rgba(242, 217, 136, 0.16); border-color: var(--tengri-sun, #d9a441); color: #fff; }
.mij-chip[aria-pressed="true"] b { color: var(--tengri-sun-soft, #f2d988); }
.mij-chip:focus-visible { outline: 2px solid var(--tengri-sun, #d9a441); outline-offset: 2px; }
.mij-chip__mine { color: var(--tengri-sun, #d9a441); font-weight: 700; }
.mij-explore__summary { margin: 0.7rem 0; font-size: 0.92rem; color: rgba(233, 228, 214, 0.8); min-height: 1.4em; }
.mij-explore__summary b { color: #fff; }

.mij-explore__map {
    position: relative;
    height: min(72svh, 760px);
    min-height: 420px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(159, 179, 230, 0.2);
    background: radial-gradient(ellipse 70% 60% at 60% 40%, rgba(53, 88, 192, 0.25), transparent 70%), #0b1430;
}
.mij-explore__canvas { position: absolute; inset: 0; touch-action: none; cursor: grab; }
.mij-explore__canvas:active { cursor: grabbing; }
.mij-explore__zoom { position: absolute; right: 0.6rem; top: 0.6rem; display: grid; gap: 0.3rem; }
.mij-explore__zoom button {
    width: 36px; height: 36px; border-radius: 8px;
    border: 1px solid rgba(159, 179, 230, 0.3); background: rgba(11, 20, 48, 0.8); color: #e9e4d6;
    font-size: 1.1rem; line-height: 1; cursor: pointer; backdrop-filter: blur(4px);
}
.mij-explore__zoom button:hover { border-color: var(--tengri-sun, #d9a441); }
.mij-explore__hint { position: absolute; left: 0.75rem; bottom: 0.5rem; margin: 0; font-size: 0.75rem; color: rgba(233, 228, 214, 0.5); pointer-events: none; }
@media (hover: hover) { .mij-explore__hint::after { content: " · хулганы дугуйгаар томруулна"; } }

.mij-explore__tip {
    position: absolute; left: 0; top: 0;
    width: 17.5rem;
    max-width: calc(100% - 16px);
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    background: rgba(251, 247, 236, 0.97);
    color: var(--tengri-ink, #1a1e2a);
    box-shadow: 0 12px 30px rgba(4, 10, 30, 0.5);
    font-size: 0.8rem;
    pointer-events: none;
}
.mij-explore__tip-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.mij-explore__tip-head b { font-size: 0.95rem; color: var(--tengri-sky, #1b2a57); }
.mij-explore__tip-head b span { font-weight: 500; font-size: 0.8em; color: var(--tengri-ink-soft, #4a4e5c); }
.mij-explore__tip-head small { color: var(--tengri-ink-soft, #4a4e5c); white-space: nowrap; }
.mij-explore__tip-total { font-weight: 700; margin: 0.15rem 0 0.45rem; }
.mij-explore__tip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; }
.mij-explore__tip li { display: grid; grid-template-columns: auto 9.5rem 1fr auto; align-items: center; gap: 0.3rem; }
.mij-explore__tip li i { display: block; height: 6px; border-radius: 3px; width: var(--w); background: var(--c); filter: saturate(0.9) brightness(0.9); }
.mij-explore__tip li b { font-variant-numeric: tabular-nums; }
.mij-explore__tip li.is-off { opacity: 0.4; }

.mij-explore__top { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.mij-explore__top button {
    width: 100%; display: grid; grid-template-columns: 1.4rem 1fr auto auto; gap: 0.5rem; align-items: center;
    padding: 0.55rem 0.75rem; min-height: var(--tap-target, 40px);
    border-radius: 10px; border: 1px solid rgba(159, 179, 230, 0.18); background: rgba(255, 255, 255, 0.03);
    color: #e9e4d6; font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer;
    transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
.mij-explore__top button:hover { border-color: var(--tengri-sun, #d9a441); background: rgba(242, 217, 136, 0.06); }
.mij-explore__top span[lang] { color: rgba(233, 228, 214, 0.55); font-size: 0.85em; }
.mij-explore__top small { color: rgba(233, 228, 214, 0.5); }
.mij-explore__top b { color: var(--tengri-sun-soft, #f2d988); font-variant-numeric: tabular-nums; }
.mij-explore__rank { color: rgba(233, 228, 214, 0.45); font-size: 0.8rem; }
@media (prefers-reduced-motion: reduce) { .mij-chip, .mij-explore__top button { transition: none; } }
.mij-explore__tip .mij__swatch { box-shadow: inset 0 0 0 1px rgba(26, 30, 42, 0.25); }
