/* ============================================================
 *  破凡劫 · 玄天大陆·界域总览 样式
 *  配色：暗墨黑底 + 古铜金烫金（楷体），低饱和度，恢弘厚重
 * ============================================================ */

/* ---------- 根容器（覆盖 tab-world 占位） ---------- */
#realm-overview-root {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 72px;
    z-index: 50;
    background: #07080d;
    overflow: hidden;
    font-family: "KaiTi","STKaiti","楷体","Songti SC",serif;
    animation: realmFadeIn 0.7s ease-out both;
}
@keyframes realmFadeIn {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

/* 进入第二层后隐藏第一层视口与横幅，并停止其所有持续动画与底图重绘
   （否则两层大底图 + 两层呼吸/云动画叠加，低端设备会持续掉帧卡顿） */
#realm-overview-root.realm-secondlayer > .realm-viewport,
#realm-overview-root.realm-secondlayer > .realm-banner-wrap,
#realm-overview-root.realm-secondlayer > .realm-topbar {
    display: none !important;
}

/* 界域激活时隐藏主顶栏（战力/灵石栏），让界域全屏展示 */
body.realm-active #top-bar {
    display: none !important;
}

/* ---------- 顶栏：返回 + 玄天大陆 + ? ---------- */
.realm-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    z-index: 20;
    background: linear-gradient(180deg, rgba(10,10,16,0.55) 0%, rgba(10,10,16,0) 100%);
    pointer-events: none;
}
.realm-topbar > * { pointer-events: auto; }

.realm-back,
.realm-help {
    width: 60px;
    height: 30px;
    background: rgba(18,18,28,0.7);
    border: 1px solid rgba(232,205,130,0.45);
    color: #e8cd82;
    font-family: inherit;
    font-size: 13px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}
.realm-back:active,
.realm-help:active {
    background: rgba(232,205,130,0.18);
    transform: scale(0.96);
}
.realm-help {
    width: 30px;
    border-radius: 50%;
    font-weight: 700;
}

.realm-title {
    flex: 1;
    text-align: center;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 8px;
    background: linear-gradient(180deg, #fbe9a9 0%, #c89a3c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 18px rgba(232,205,130,0.25);
    padding-right: 4px;  /* 视觉居中补偿返回键宽度 */
}

/* ---------- 横幅：四序天象 + 请选择前往疆域 ---------- */
.realm-banner-wrap {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    z-index: 18;
    text-align: center;
    pointer-events: none;
}
.realm-meta-text {
    font-family: "KaiTi","STKaiti","楷体",serif;
    font-size: 11px;
    color: rgba(245,215,140,0.5);
    letter-spacing: 6px;
    margin-bottom: 2px;
    text-shadow: 0 0 8px rgba(0,0,0,0.85);
    padding-left: 6px;
    animation: realmMetaFade 1.8s ease-out 0.2s both;
}
.realm-banner {
    color: rgba(245,220,160,0.85);
    font-size: 15px;
    letter-spacing: 10px;
    text-shadow: 0 0 10px rgba(0,0,0,0.9), 0 0 5px rgba(120,80,30,0.5);
    padding-left: 10px; /* 抵消 letter-spacing 视觉偏移 */
    font-family: "KaiTi","STKaiti","楷体",serif;
    animation: realmBannerFade 1.4s ease-out 0.5s both;
}
@keyframes realmMetaFade {
    0%   { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes realmBannerFade {
    0%   { opacity: 0; transform: translateY(-3px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ---------- 视口（铺满根容器，地图固定全屏，不可拖动） ---------- */
.realm-viewport {
    position: absolute;
    top: 0;
    left: 0; right: 0;
    bottom: 0;
    overflow: hidden;
    cursor: default;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(40,52,72,0.35) 0%, rgba(10,10,18,1) 80%);
}

/* ---------- 舞台（变换层） ---------- */
.realm-stage {
    position: absolute;
    top: 0; left: 0;
    width: 720px;
    height: 1280px;
    transform-origin: 0 0;
    will-change: transform;
}

/* ---------- 底图 ---------- */
.realm-base {
    display: block;
    width: 720px;
    height: 1280px;
    pointer-events: none;
    -webkit-user-drag: none;
    opacity: 0;                 /* 默认隐藏，加载完成后淡入，避免突现闪烁 */
    transition: opacity 0.45s ease;
}
.realm-base.loaded { opacity: 1; }

/* 覆盖 AI 水印的云雾补丁（贴附底图右下） */
.realm-watermark-cover {
    position: absolute;
    right: 0; bottom: 0;
    width: 340px;
    height: 130px;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 85% 80%,
            rgba(210,225,240,0.78) 0%,
            rgba(200,215,230,0.55) 25%,
            rgba(195,210,225,0.30) 50%,
            rgba(195,210,225,0.10) 75%,
            rgba(195,210,225,0)    100%);
    filter: blur(2px);
}

/* 缓慢流动的云雾层（在底图之上、SVG 之下） */
.realm-clouds {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 320px 90px at 20% 22%, rgba(235,240,248,0.16) 0%, rgba(235,240,248,0) 70%),
        radial-gradient(ellipse 260px 70px at 78% 30%, rgba(230,238,248,0.13) 0%, rgba(230,238,248,0) 70%),
        radial-gradient(ellipse 300px 80px at 15% 70%, rgba(225,235,245,0.12) 0%, rgba(225,235,245,0) 70%),
        radial-gradient(ellipse 280px 80px at 80% 78%, rgba(220,232,245,0.12) 0%, rgba(220,232,245,0) 70%);
    animation: realmCloudDrift 38s ease-in-out infinite alternate;
    mix-blend-mode: screen;
}
@keyframes realmCloudDrift {
    0%   { transform: translate(-12px, 8px); }
    50%  { transform: translate(10px, -10px); }
    100% { transform: translate(14px, 6px); }
}

/* ---------- SVG 叠加层 ---------- */
.realm-svg {
    position: absolute;
    inset: 0;
    width: 720px;
    height: 1280px;
    pointer-events: none;   /* 子元素 polygon 重开 */
}

/* 已解锁疆域：呼吸微光 */
.realm-poly-unlocked {
    transition: filter 0.25s ease, fill-opacity 0.25s ease;
    filter: drop-shadow(0 0 6px rgba(245,215,140,0.4));
    animation: realmBreath 3.8s ease-in-out infinite;
    will-change: fill-opacity;
}
@keyframes realmBreath {
    0%, 100% { fill-opacity: 0.9; }
    50%      { fill-opacity: 1; }
}
.realm-poly-unlocked:hover {
    fill-opacity: 1;
    filter: drop-shadow(0 0 16px rgba(245,215,140,0.9));
}

/* 未解锁疆域：暗沉静态 */
.realm-poly-locked {
    filter: grayscale(0.45) brightness(0.7);
    transition: filter 0.2s;
}
.realm-poly-locked:hover {
    filter: grayscale(0.4) brightness(0.85);
}

.realm-label {
    text-rendering: geometricPrecision;
}

/* ---------- 各州分布图占位面板（第二层） ---------- */
.realm-state-panel {
    position: absolute;
    inset: 0;
    z-index: 40;
    animation: realmFadeIn 0.45s ease-out both;
}
.realm-state-panel.hidden { display: none; }
.realm-state-mask {
    position: absolute;
    inset: 0;
    background: rgba(8,8,14,0.78);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.realm-state-card {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 78%;
    max-width: 320px;
    background:
        linear-gradient(160deg, rgba(20,18,28,0.97) 0%, rgba(12,10,16,0.97) 100%);
    border: 1px solid rgba(232,205,130,0.55);
    border-radius: 14px;
    padding: 26px 20px 22px;
    text-align: center;
    box-shadow:
        0 0 32px rgba(232,205,130,0.18),
        inset 0 0 24px rgba(232,205,130,0.04);
}
.realm-state-name {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 8px;
    background: linear-gradient(180deg, #fbe9a9 0%, #b8893a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 6px;
    font-family: "KaiTi","STKaiti","楷体",serif;
}
.realm-state-sub {
    font-size: 13px;
    color: rgba(245,220,160,0.7);
    letter-spacing: 5px;
    margin-bottom: 18px;
}
.realm-state-desc {
    font-size: 13px;
    color: rgba(200,195,215,0.78);
    line-height: 1.9;
    margin-bottom: 22px;
    font-family: "KaiTi","STKaiti","楷体",serif;
}
.realm-state-back {
    display: inline-block;
    background: rgba(232,205,130,0.12);
    border: 1px solid rgba(232,205,130,0.55);
    color: #f0d68a;
    font-family: inherit;
    font-size: 14px;
    padding: 8px 22px;
    border-radius: 18px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
}
.realm-state-back:active {
    background: rgba(232,205,130,0.28);
    transform: scale(0.97);
}

/* ---------- 第二层：州域分布图（realm_state.js） ---------- */
.realm-state-view {
    position: absolute;
    inset: 0;
    z-index: 45;
    background: #07080d;
    overflow: hidden;
    opacity: 0;
    transform: scale(1.08);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.realm-state-view.realm-state-in {
    opacity: 1;
    transform: scale(1);
}

/* 州多边形 */
.realm-state-unlocked {
    transition: filter 0.25s ease;
    filter: drop-shadow(0 0 6px rgba(245,215,140,0.4));
    animation: realmStateBreath 3.8s ease-in-out infinite;
    will-change: fill-opacity;
}
@keyframes realmStateBreath {
    0%, 100% { fill-opacity: 0.9; }
    50%      { fill-opacity: 1; }
}
.realm-state-unlocked:hover { filter: drop-shadow(0 0 16px rgba(245,215,140,0.9)); }
.realm-state-locked { filter: grayscale(0.4) brightness(0.72); transition: filter 0.2s; }

/* 关隘 */
.realm-pass:hover polygon { fill: rgba(40,34,20,0.95); }

/* 第三层沙盘占位面板（复用 realm-state-* 卡片样式） */
.realm-sandbox-panel {
    position: absolute;
    inset: 0;
    z-index: 46;
    animation: realmFadeIn 0.4s ease-out both;
}
.realm-sandbox-panel.hidden { display: none; }

/* ---------- Toast 提示 ---------- */
.realm-toast {
    position: absolute;
    top: 38%; left: 50%;
    transform: translate(-50%,-50%);
    background: rgba(18,18,28,0.94);
    border: 1px solid rgba(232,205,130,0.5);
    color: #f0d68a;
    padding: 14px 22px;
    border-radius: 8px;
    font-size: 14px;
    letter-spacing: 1.5px;
    z-index: 50;
    pointer-events: none;
    box-shadow: 0 4px 18px rgba(0,0,0,0.6);
    animation: realmToastIn 0.25s ease-out both;
    font-family: "KaiTi","STKaiti","楷体",serif;
    text-align: center;
    line-height: 1.7;
}
@keyframes realmToastIn {
    0% { opacity: 0; transform: translate(-50%,-45%); }
    100% { opacity: 1; transform: translate(-50%,-50%); }
}
.realm-help-tip {
    top: 32%;
    max-width: 280px;
    padding: 16px 22px;
    text-align: left;
}
.realm-help-title {
    font-weight: 700;
    color: #f6e2a4;
    margin-bottom: 8px;
    letter-spacing: 3px;
    font-size: 14px;
    text-align: center;
}
