/* Minna no Nihongo vocabulary: lesson list, word modal, word detail page.
   Loaded together with minna-no-nihongo/assets/index.css (provides .mn, .mn-top, .kicker, .rule …). */

.mn { --v-noun:#2563eb; --v-verb:#c0392b; --v-adj:#7c3aed; --v-adv:#0f766e; --v-expr:#b45309; --v-other:#475569; }
.mn-top.mn-vtop::before { content: "語彙"; }
.mn-crumbs { font-size: .82rem; margin: 0 0 1.1rem; color: #8d95a2; }
.mn-crumbs a { color: #cfd5de; text-decoration: none; }
.mn-crumbs a:hover { color: #fff; text-decoration: underline; }
.mn-crumbs span { margin: 0 .35rem; }

/* ------------------------------------------------------------ type chip */
.mn-type {
    display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; padding: .2rem .5rem; border-radius: 999px; white-space: nowrap;
    color: var(--v-other); background: color-mix(in srgb, var(--v-other) 10%, #fff);
}
.mn-type[data-t="noun"]  { color: var(--v-noun);  background: color-mix(in srgb, var(--v-noun) 10%, #fff); }
.mn-type[data-t="verb"]  { color: var(--v-verb);  background: color-mix(in srgb, var(--v-verb) 10%, #fff); }
.mn-type[data-t="adj"]   { color: var(--v-adj);   background: color-mix(in srgb, var(--v-adj) 10%, #fff); }
.mn-type[data-t="adv"]   { color: var(--v-adv);   background: color-mix(in srgb, var(--v-adv) 10%, #fff); }
.mn-type[data-t="expr"]  { color: var(--v-expr);  background: color-mix(in srgb, var(--v-expr) 12%, #fff); }
.mn-extra { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; border: 1px dashed #c9c3b8; border-radius: 999px; padding: .12rem .45rem; white-space: nowrap; }

/* -------------------------------------------------------------- toolbar */
.mn-vtools {
    display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
    background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .75rem;
    margin-bottom: 1rem; position: sticky; top: var(--mn-sticky-top, 104px); z-index: 5;
    transition: top .15s ease;
}
.mn-vsearch { flex: 1 1 220px; position: relative; }
.mn-vsearch i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #9aa1ab; }
.mn-vsearch input {
    width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem .55rem 2.2rem;
    font-size: .95rem; background: var(--paper); outline: none;
}
.mn-vsearch input:focus { border-color: var(--vermil); background: #fff; }
.mn-vfilters { display: flex; flex-wrap: wrap; gap: .35rem; }
.mn-vfilters button, .mn-vtoggle {
    border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .75rem;
    font-size: .82rem; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.mn-vfilters button[aria-pressed="true"], .mn-vtoggle[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.mn-vcount { font-size: .85rem; color: var(--muted); margin: 0 0 .75rem; }

/* --------------------------------------------------- back to word list */
.mn-back {
    display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 1.1rem; padding: .55rem 1rem;
    border-radius: 999px; background: #fff; color: #14181f !important; font-weight: 700; font-size: .9rem;
    text-decoration: none; box-shadow: 0 6px 18px -8px rgba(0,0,0,.5); transition: transform .15s ease, background .15s ease;
}
.mn-back:hover { background: #ffc107; transform: translateX(-2px); }
/* row we came back to: clear the sticky header + filter bar, and flash it */
.mn-vrow { scroll-margin-top: calc(var(--mn-sticky-top, 104px) + 90px); }
.mn-vrow.mn-flash { animation: mnFlash 2.2s ease; }
@keyframes mnFlash { 0%, 40% { background: #fff4c2; } 100% { background: transparent; } }

/* ------------------------------------------------------------ word list */
.mn-vlist { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.mn-vrow {
    display: grid; grid-template-columns: 2.4rem minmax(0, 1.2fr) minmax(0, 1.6fr) auto;
    gap: .9rem; align-items: center; padding: .85rem 1rem; border-top: 1px solid var(--line);
    transition: background .15s ease;
}
.mn-vrow:first-child { border-top: 0; }
.mn-vrow:hover { background: #fbfaf7; }
.mn-vno { font-family: var(--serif); font-weight: 700; color: #b8b2a7; font-size: .95rem; text-align: right; }
.mn-vword { min-width: 0; }
.mn-vword a { text-decoration: none; color: var(--ink); }
.mn-vword a:hover .mn-vmain { color: var(--vermil); }
.mn-vmain { display: block; font-size: 1.3rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.mn-vread { display: block; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.mn-vromaji { display: block; font-size: .8rem; color: #9aa1ab; font-style: italic; overflow-wrap: anywhere; }
.mn-vmeaning { min-width: 0; font-size: .95rem; color: var(--ink-2); overflow-wrap: anywhere; }
.mn-vmeaning .mn-type { margin-top: .35rem; }
.mn-vactions { display: flex; gap: .3rem; }
.mn-ibtn {
    width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 1px solid var(--line); background: #fff;
    display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2);
    cursor: pointer; font-size: 1.05rem; transition: all .15s ease; flex: 0 0 auto;
}
.mn-ibtn:hover, .mn-ibtn:focus-visible { background: var(--ink); color: #fff; border-color: var(--ink); }
.mn-ibtn.info { color: var(--vermil); }
.mn-ibtn.info:hover { color: #fff; }
.mn-hide-romaji .mn-vromaji, .mn-hide-romaji .mn-ex-r { display: none; }
.mn-vempty { display: none; padding: 2rem 1rem; text-align: center; color: var(--muted); }
@media (max-width: 575.98px) {
    .mn-vrow { grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; padding: .85rem .9rem; }
    .mn-vno { display: none; }
    .mn-vmeaning { grid-column: 1; grid-row: 2; }
    .mn-vactions { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; }
    /* compact toolbar: search + romaji on one row, filters in one swipeable row */
    .mn-vtools { gap: .5rem; padding: .6rem; border-radius: 12px; }
    .mn-vsearch { flex: 1 1 0; }
    .mn-vsearch input { padding-top: .5rem; padding-bottom: .5rem; font-size: 16px; } /* 16px: no iOS zoom */
    .mn-vfilters {
        flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
        scrollbar-width: none; margin: 0 -.6rem; padding: 0 .6rem 2px;
    }
    .mn-vfilters::-webkit-scrollbar { display: none; }
    .mn-vfilters button { flex: 0 0 auto; }
}

/* --------------------------------------------------------- lesson cards */
.mn-vcard-words { display: flex; flex-wrap: wrap; gap: .3rem; margin: .2rem 0 1rem; padding: 0; list-style: none; }
.mn-vcard-words li { font-size: .88rem; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: .1rem .45rem; }

/* ------------------------------------------------------- modal (dialog) */
/* The modal is moved to the end of <body> by vocab.js, so it sits above the site header
   (header uses z-index up to 1065 !important) and does not inherit .mn — tokens are repeated here. */
.mn-modal {
    --ink:#14181f; --ink-2:#2b3340; --paper:#f7f5f1; --line:#e2ddd4; --vermil:#0d6efd; --muted:#6b7280;
    --serif:"Noto Serif JP", Georgia, serif;
    --v-noun:#2563eb; --v-verb:#c0392b; --v-adj:#7c3aed; --v-adv:#0f766e; --v-expr:#b45309; --v-other:#475569;
    position: fixed; inset: 0; z-index: 2147483000 !important; display: none;
    align-items: center; justify-content: center; padding: 88px 24px 24px;   /* top: clear the site header bar */
    font-family: "Inter", -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    color: var(--ink);
}
.mn-modal.open { display: flex; }
.mn-modal .jp { font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif; }
.mn-modal p { color: inherit; margin: 0; }          /* site css sets p { color: black } */
.mn-modal-backdrop { position: absolute; inset: 0; background: rgba(12, 15, 22, .72); backdrop-filter: blur(4px); animation: mnFade .2s ease; }
.mn-modal-box {
    position: relative; width: min(880px, 100%); max-height: min(860px, calc(100vh - 112px));
    display: flex; flex-direction: column; background: var(--paper); border-radius: 22px; overflow: hidden;
    box-shadow: 0 40px 100px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.06);
    animation: mnUp .26s cubic-bezier(.2,.8,.2,1);
}

/* header */
.mn-modal-head, .mn-modal-foot { flex-shrink: 0; }
.mn-modal-head {
    position: relative; overflow: hidden; color: #fff; padding: 1.6rem 2rem 1.7rem;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(13,110,253,.35) 0%, rgba(13,110,253,0) 55%),
        linear-gradient(135deg, #14181f 0%, #1d2433 100%);
}
.mn-modal-head::after {
    content: attr(data-mark); position: absolute; right: 1.2rem; bottom: -.22em; font-family: var(--serif);
    font-size: 9rem; font-weight: 700; line-height: 1; color: rgba(255,255,255,.06); pointer-events: none;
}
.mn-modal-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: #9aa9c0; margin-bottom: .75rem; padding-right: 6rem; }
.mn-modal-meta > span:first-child { background: rgba(255,255,255,.08); border-radius: 999px; padding: .28rem .7rem; }
.mn-modal .mn-modal-main {
    color: #fff !important; font-size: clamp(2.4rem, 5vw, 3.4rem); font-weight: 700; line-height: 1.15;
    margin: 0; letter-spacing: .02em; overflow-wrap: anywhere; position: relative; z-index: 1;
}
.mn-modal-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .9rem; margin-top: .45rem; position: relative; z-index: 1; }
.mn-modal-read { font-size: 1.2rem; color: #dbe3ef; }
.mn-modal-romaji { font-size: 1.02rem; color: #9aa9c0; font-style: italic; }
.mn-modal-close, .mn-modal-speak {
    position: absolute; top: 1.1rem; width: 2.5rem; height: 2.5rem; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; cursor: pointer; z-index: 2;
    transition: background .15s ease, border-color .15s ease;
}
.mn-modal-close { right: 1.1rem; }
.mn-modal-speak { right: 4.1rem; }
.mn-modal-close:hover, .mn-modal-speak:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.45); color: #fff; }

/* body: info on the left, examples on the right (one column on small screens) */
.mn-modal-body { padding: 1.5rem 2rem; overflow-y: auto; overscroll-behavior: contain; }
.mn-modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 1.5rem; align-items: start; }
.mn-modal-info { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1.15rem 1.25rem; }
.mn-sec-label { font-size: .7rem !important; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted) !important; margin: 0 0 .5rem !important; }
.mn-modal .mn-modal-meaning { font-size: 1.35rem; font-weight: 700; line-height: 1.35; color: var(--ink) !important; margin: 0 0 .65rem; overflow-wrap: anywhere; }
.mn-modal-type { margin: 0 0 1rem !important; display: flex; gap: .4rem; flex-wrap: wrap; }
.mn-modal-info hr { border: 0; border-top: 1px dashed var(--line); margin: 0 0 .9rem; opacity: 1; }
.mn-modal .mn-modal-desc { font-size: .95rem; line-height: 1.7; color: var(--ink-2) !important; margin: 0; }
.mn-modal .mn-ex { counter-reset: mnex; }
.mn-modal .mn-ex li { position: relative; padding-left: 3rem; border-left: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.mn-modal .mn-ex li::before {
    counter-increment: mnex; content: counter(mnex); position: absolute; left: .85rem; top: .85rem;
    width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--vermil); color: #fff;
    font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* footer */
.mn-modal-foot { display: flex; gap: .5rem; align-items: center; padding: .9rem 2rem; border-top: 1px solid var(--line); background: #fff; }
.mn-modal-foot .mn-ibtn { width: 2.6rem; height: 2.6rem; }
.mn-modal-foot .mn-ibtn:disabled { opacity: .35; cursor: default; background: #fff; color: var(--ink-2); border-color: var(--line); }
.mn-modal-pos { font-size: .85rem; font-weight: 600; color: var(--muted); margin-right: auto; padding-left: .35rem; }
.mn-btn-page {
    display: inline-flex; align-items: center; gap: .5rem; background: var(--vermil); color: #fff !important;
    text-decoration: none; font-weight: 700; font-size: .92rem; padding: .7rem 1.2rem; border-radius: 999px;
    box-shadow: 0 8px 20px -8px rgba(13,110,253,.7); transition: transform .15s ease, filter .15s ease;
}
.mn-btn-page:hover { filter: brightness(1.08); transform: translateY(-1px); }
.mn-btn-close {
    display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
    font-weight: 600; font-size: .9rem; padding: .62rem 1rem; border-radius: 999px; cursor: pointer;
}
.mn-btn-close:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.mn-modal [hidden] { display: none !important; }
body.mn-modal-lock { overflow: hidden; }
@keyframes mnFade { from { opacity: 0; } }
@keyframes mnUp { from { opacity: 0; transform: translateY(18px) scale(.98); } }
@keyframes mnSheet { from { transform: translateY(100%); } }

@media (max-width: 767.98px) {
    .mn-modal-grid { grid-template-columns: 1fr; gap: 1.1rem; }
    .mn-modal-head { padding: 1.3rem 1.25rem 1.4rem; }
    .mn-modal-body { padding: 1.1rem 1.25rem; }
    .mn-modal-foot { padding: .75rem 1.25rem; }
}
/* phones: bottom sheet */
@media (max-width: 575.98px) {
    .mn-modal { padding: 0; align-items: flex-end; }
    .mn-modal-box { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; animation: mnSheet .28s cubic-bezier(.2,.8,.2,1); }
    .mn-modal-head::before { content: ""; position: absolute; top: .5rem; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: rgba(255,255,255,.3); }
    .mn-modal-head::after { font-size: 6.5rem; }
    .mn-modal-meta { padding-right: 5.5rem; }
    .mn-modal-foot { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
    .mn-btn-page { padding: .65rem 1rem; font-size: .88rem; }
    .mn-modal-foot { flex-wrap: wrap; }
    .mn-modal-pos { margin-right: auto; }
    .mn-btn-close { order: 3; flex: 1 1 40%; justify-content: center; }
    .mn-btn-page { order: 4; flex: 1 1 55%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .mn-modal-box, .mn-modal-backdrop { animation: none; } }

/* ------------------------------------- example sentences (modal + word page) */
.mn-sec-label { font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted, #6b7280); margin: 0 0 .6rem; }
.mn-ex { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.mn-ex li {
    background: #fff; border: 1px solid var(--line, #e2ddd4); border-left: 3px solid var(--vermil, #0d6efd);
    border-radius: 12px; padding: .85rem 1rem; margin: 0;
}
.mn-ex-j { font-size: 1.12rem; font-weight: 600; line-height: 1.5; display: flex; gap: .6rem; align-items: flex-start; justify-content: space-between; color: var(--ink, #14181f); }
.mn-ex-h { font-size: .88rem; color: var(--muted, #6b7280); margin-top: .1rem; }
.mn-ex-r { font-size: .84rem; color: #9aa1ab; font-style: italic; }
.mn-ex-m { font-size: .95rem; margin-top: .35rem; color: var(--ink-2, #2b3340); padding-top: .35rem; border-top: 1px dashed var(--line, #e2ddd4); }
.mn-ex-say {
    flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--line, #e2ddd4); background: #fff;
    color: var(--muted, #6b7280); display: inline-flex; align-items: center; justify-content: center; font-size: .95rem;
    cursor: pointer; padding: 0; transition: all .15s ease;
}
.mn-ex-say:hover { background: var(--vermil, #0d6efd); border-color: var(--vermil, #0d6efd); color: #fff; }

/* ---------------------------------------------------- word detail page */
.mn-wtop .mn-wmain { font-size: clamp(2.6rem, 7vw, 4.2rem); font-weight: 700; line-height: 1.15; margin: .4rem 0 .2rem; overflow-wrap: anywhere; }
.mn-wtop .mn-wread { font-size: 1.3rem; color: #cfd5de; }
.mn-wtop .mn-wromaji { font-size: 1.05rem; color: #9aa3b1; font-style: italic; }
.mn-wtop .mn-wmeaning { font-size: 1.25rem; margin-top: 1rem; color: #fff; }
.mn-wtop .mn-wchips { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.mn-wtop .mn-type { background: rgba(255,255,255,.1); color: #fff; }
.mn-wtop .mn-extra { color: #cfd5de; border-color: rgba(255,255,255,.3); }
.mn-wspeak { margin-left: .25rem; border-color: rgba(255,255,255,.3); background: transparent; color: #fff; }
.mn-wspeak:hover { background: #fff; color: var(--ink); }
.mn-wcard { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem 1.5rem; margin-bottom: 1.5rem; }
.mn-wcard h2 { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; margin: 0 0 .9rem; }
.mn-wfacts { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.2rem; margin: 0; }
.mn-wfacts dt { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: .2rem; }
.mn-wfacts dd { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.mn-wcard .mn-ex li { background: var(--paper); }
.mn-wnote { margin-top: 1.2rem; background: #eef5ff; border: 1px solid #d6e6ff; border-radius: 12px; padding: .95rem 1.1rem; }
.mn-wnote .mn-sec-label { color: var(--vermil) !important; margin-bottom: .35rem; }
.mn-wnote p { color: var(--ink-2) !important; line-height: 1.7; }
.mn-wpager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0; }
.mn-wpager a { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1.1rem; text-decoration: none; color: var(--ink); min-width: 0; }
.mn-wpager a:hover { border-color: var(--vermil); }
.mn-wpager small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mn-wpager b { display: block; font-size: 1.1rem; overflow-wrap: anywhere; }
.mn-wpager .next { text-align: right; grid-column: 2; }
.mn-wrel { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.mn-wrel a { display: block; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; text-decoration: none; color: var(--ink); background: var(--paper); height: 100%; }
.mn-wrel a:hover { border-color: var(--vermil); background: #fff; }
.mn-wrel b { display: block; font-size: 1.05rem; overflow-wrap: anywhere; }
.mn-wrel span { display: block; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.mn-wlinks { display: flex; flex-wrap: wrap; gap: .6rem; }
.mn-wlinks a { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--line); border-radius: 999px; padding: .5rem .95rem; font-weight: 600; font-size: .9rem; text-decoration: none; color: var(--ink); background: #fff; }
.mn-wlinks a:hover { border-color: var(--vermil); color: var(--vermil); }
@media (max-width: 575.98px) {
    .mn-wfacts { grid-template-columns: 1fr; gap: .1rem; }
    .mn-wfacts dd { margin-bottom: .55rem; }
    .mn-wpager { grid-template-columns: 1fr; }
    .mn-wpager .next { grid-column: 1; }
    .mn-wcard { padding: 1.1rem 1rem; }
}

/* ------------------------------------------------- ad slots & loading */
.mn-ad { margin: 1.5rem 0; }
.mn-ad:empty { display: none; }
.mn-modal-body[aria-busy="true"] > * { opacity: .35; }
.mn-modal-body[aria-busy="true"]::before {
    content: ""; display: block; width: 28px; height: 28px; margin: .5rem auto 1rem;
    border: 3px solid var(--line, #e2ddd4); border-top-color: var(--vermil, #0d6efd); border-radius: 50%;
    animation: mnSpin .7s linear infinite;
}
@keyframes mnSpin { to { transform: rotate(360deg); } }
