/* =========================================================================
   THE MAP OF WISDOM — page-scoped styles.
   Sumi-ink palette, paper background. The graph stage is the centrepiece;
   every other element is restrained so the constellation can breathe.
   ========================================================================= */
:root {
    --map-paper: #F8F4ED;
    --map-paper-alt: #F2EDE0;
    --map-ink:   #1A1410;
    --map-mute:  #776E5C;
    --map-gold:  #B8860B;
    --map-hair:  rgba(26,20,16,.10);
    --map-link:  rgba(26,20,16,.45);
}
@media (prefers-color-scheme: dark) {
    :root {
        --map-paper: #14110D;
        --map-paper-alt: #1D1A14;
        --map-ink:   #F3EDE2;
        --map-mute:  #A39880;
        --map-hair:  rgba(243,237,226,.12);
        --map-link:  rgba(243,237,226,.50);
    }
}

body.page-map { background: var(--map-paper); color: var(--map-ink); }

/* ---------- Hero ---------- */
.map-hero {
    padding: 70px 0 32px;
    text-align: center;
}
.map-eyebrow {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-style: italic;
    letter-spacing: .05em;
    color: var(--map-mute);
    margin: 0 0 14px;
    font-size: 17px;
}
.map-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    font-size: clamp(36px, 5.2vw, 60px);
    color: var(--map-ink);
    margin: 0 0 16px;
    letter-spacing: -.01em;
}
.map-subtitle {
    max-width: 640px;
    margin: 0 auto;
    font-size: 17px;
    line-height: 1.7;
    color: var(--map-mute);
}
.map-subtitle strong { color: var(--map-ink); font-weight: 600; }

.map-legend {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 30px;
    padding: 6px;
    border: 1px solid var(--map-hair);
    border-radius: 999px;
    background: var(--map-paper-alt);
}
.map-chip {
    appearance: none;
    border: 0;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .03em;
    color: var(--map-mute);
    cursor: pointer;
    background: transparent;
    border-radius: 999px;
    transition: background .18s ease, color .18s ease;
    user-select: none;
}
.map-chip:hover { color: var(--map-ink); }
.map-chip.is-on { background: var(--map-ink); color: var(--map-paper); }
.map-chip-action { color: var(--map-gold); font-weight: 600; }
.map-chip[data-filter="all"].is-on,
.map-chip[data-filter="all"] { color: var(--map-ink); }

/* ---------- Stage ---------- */
.map-stage-wrap {
    padding: 24px 0 32px;
}
.map-stage {
    position: relative;
    max-width: 1180px;
    margin: 0 auto;
    height: clamp(540px, 78vh, 820px);
    background: linear-gradient(to bottom, var(--map-paper), var(--map-paper-alt));
    border: 1px solid var(--map-hair);
    border-radius: 14px;
    overflow: hidden;
}
.map-stage svg {
    width: 100%;
    height: 100%;
    color: var(--map-link);  /* drives line stroke via currentColor */
    cursor: default;
}

/* ---------- Loading flash ---------- */
.map-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-style: italic;
    color: var(--map-mute);
    font-size: 18px;
    transition: opacity .35s ease;
}

/* ---------- Node + link styling ---------- */
.map-node {
    cursor: pointer;
    transition: transform .18s ease;
}
.map-node circle {
    transition: fill-opacity .25s ease, stroke-width .25s ease, filter .25s ease;
}
.map-node:hover circle,
.map-node.is-active circle {
    fill-opacity: .35;
    stroke-width: 2.4;
    filter: drop-shadow(0 6px 18px rgba(26,20,16,.18));
}
.map-node.is-related circle {
    fill-opacity: .26;
    stroke-width: 2;
}
.map-node.is-faded circle { fill-opacity: .04; stroke-opacity: .25; }
.map-node.is-faded .map-node-title,
.map-node.is-faded .map-node-native { opacity: .25; }

.map-node-native {
    font-family: "Shippori Mincho","Noto Serif JP","Noto Serif Devanagari", serif;
    font-weight: 600;
    pointer-events: none;
    user-select: none;
}
.map-node-title {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 11px;
    fill: var(--map-ink);
    font-weight: 500;
    pointer-events: none;
    user-select: none;
    letter-spacing: .015em;
}

.map-links line { transition: stroke-opacity .25s ease, stroke-width .25s ease; }
.map-links line.is-active { stroke-opacity: .82 !important; stroke-width: 2.4 !important; }
.map-links line.is-faded  { stroke-opacity: .06 !important; }

/* ---------- Detail panel ---------- */
.map-detail {
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(360px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow-y: auto;
    padding: 24px 24px 22px;
    background: var(--map-paper);
    border: 2px solid var(--map-gold);
    border-radius: 12px;
    box-shadow: 0 16px 40px -12px rgba(0,0,0,.18);
    z-index: 5;
}
.map-detail[hidden] { display: none; }
.map-detail-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--map-mute);
    cursor: pointer;
    padding: 6px 10px;
}
.map-detail-close:hover { color: var(--map-ink); }
.map-detail-native {
    font-family: "Shippori Mincho","Noto Serif JP","Noto Serif Devanagari", serif;
    font-size: 26px;
    color: var(--map-mute);
    margin: 0 0 4px;
    letter-spacing: .04em;
}
.map-detail-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    font-size: 28px;
    color: var(--map-ink);
    margin: 0 0 8px;
    letter-spacing: -.01em;
}
.map-detail-meta {
    font-size: 12px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--map-mute);
    margin: 0 0 14px;
}
.map-detail-summary {
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--map-ink);
    margin: 0 0 18px;
}
.map-detail-connections-heading {
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--map-mute);
    font-weight: 600;
}
.map-detail-connections {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.map-detail-link {
    display: block;
    text-decoration: none;
    padding: 9px 12px;
    border: 1px solid var(--map-hair);
    border-radius: 8px;
    transition: border-color .15s ease, background .15s ease;
}
.map-detail-link:hover {
    background: var(--map-paper-alt);
    border-color: var(--map-gold);
}
.map-detail-link strong {
    display: block;
    font-size: 14.5px;
    color: var(--map-ink);
    font-weight: 600;
    margin-bottom: 2px;
}
.map-detail-link span {
    display: block;
    font-size: 12px;
    color: var(--map-mute);
    line-height: 1.5;
}
.map-detail-cta {
    display: inline-block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    color: var(--map-paper);
    background: var(--map-gold);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: .02em;
    transition: filter .15s ease;
}
.map-detail-cta:hover { filter: brightness(.92); }

/* ---------- Explainer ---------- */
.map-explainer {
    padding: 60px 0 100px;
    background: var(--map-paper-alt);
    border-top: 1px solid var(--map-hair);
    margin-top: 32px;
}
.map-section-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    font-size: clamp(26px, 3.4vw, 36px);
    color: var(--map-ink);
    margin: 0 0 26px;
    text-align: center;
}
.map-prose {
    max-width: 640px;
    margin: 0 auto 22px;
    font-size: 16px;
    line-height: 1.78;
    color: var(--map-ink);
}

/* ---------- Mobile tightening ---------- */
@media (max-width: 700px) {
    .map-stage { height: 64vh; min-height: 480px; border-radius: 0; border-left: 0; border-right: 0; }
    .map-detail { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
    .map-node-title { font-size: 10px; }
}
