/* ============================================================
   红石镇 | Redstone Town —— 首页样式（index.html）
   目录：
     1. 首页 hero 流动标语背景层
     2. 首页介绍区（.intro 系列）
     3. 社区组织 · 卡片轮换
     4. 加入红石镇 CTA
     5. 响应式
   ============================================================ */

/* ========== 1. 首页 hero 流动标语背景层 ========== */
.hero .hero-flow {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.5;
    overflow: hidden;
}

.hero .hero-flow .flowing-section {
    height: 100%;
    align-items: center;
}

.hero .hero-flow .flowing-section-row {
    width: max-content;
    left: auto;
    top: -30%;
}

/* 流动标语的行与轨道（由 js/main.js 生成内容） */
.flowing-section {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.flowing-section-row {
    position: relative;
    width: 100%;
    display: flex;
    padding: 20px 0;
    white-space: nowrap;
    transform: rotate(-45deg);
    top: -20%;
    left: -25%;
}

.flowing-track {
    display: flex;
    flex: 0 0 auto;
    width: max-content;
    white-space: nowrap;
    will-change: transform;
}

.flowing-section-row:nth-child(odd) .flowing-track {
    animation: flowing-track 100s linear infinite;
}

.flowing-section-row:nth-child(even) .flowing-track {
    animation: flowing-track 80s linear infinite reverse;
}

@keyframes flowing-track {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

.flowing-section-row div i {
    opacity: 0.9;
    color: var(--red);
    font-size: clamp(3rem, 8vw, 6rem);
    font-style: normal;
    font-weight: 800;
    line-height: 1.05;
    margin-right: 28px;
    white-space: nowrap;
}

.flowing-section-row div i:nth-child(even) {
    opacity: 0.95;
    color: var(--bg);
    background: var(--red);
    padding: 2px 20px;
    margin-right: 28px;
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 400;
    letter-spacing: 0.2em;
}

@media (max-width: 820px) {
    .flowing-section-row {
        top: -50%;
    }
    .flowing-section-row div i {
        font-size: 28px;
        margin-right: 20px;
    }
    .flowing-section-row div i:nth-child(even) {
        font-size: 15px;
        padding: 2px 14px;
        margin-right: 20px;
    }
}

/* ========== 2. 首页介绍区（.intro 系列） ========== */

/* 介绍大段（版心 + 底部细线分隔） */
.intro {
    position: relative;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 96px var(--pad);
    border-bottom: 1px solid var(--line);
}

/* 巨型轮廓序号（海报标注感） */
.intro-no {
    position: absolute;
    top: 40px;
    right: var(--pad);
    font-family: var(--font-mono);
    font-size: clamp(4rem, 12vw, 9rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.05em;
    color: transparent;
    -webkit-text-stroke: 1px var(--line-strong);
    opacity: 0.5;
    user-select: none;
    pointer-events: none;
    z-index: 0;
}

/* 主标题：主题红 + 左侧竖轴 + 光标 */
.intro-title {
    position: relative;
    z-index: 1;
    display: inline-block;
    font-size: clamp(2.2rem, 4.5vw, 3.4rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--red);
    margin: 6px 0 36px;
    padding-left: 18px;
    border-left: 4px solid var(--red);
    line-height: 1.2;
}

/* 01 什么是红石镇：简介 */
.about-lead {
    position: relative;
    z-index: 2;
    color: var(--muted);
    max-width: 560px;
    font-size: 1.05rem;
}

.about-lead b {
    color: var(--ink);
}

/* 02 社区情况：左文右图 */
.comm-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(28px, 4vw, 72px);
    align-items: center;
}

.comm-text p {
    color: var(--muted);
    max-width: 420px;
    padding-left: 18px;
    border-left: 2px solid var(--line);
}

.comm-text p + p {
    margin-top: 6px;
}

.comm-text b {
    color: var(--red);
}

.comm-quote {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    border-left: 0;
    padding-left: 18px;
    border-left: 2px solid var(--red);
}

/* 图片（带红角括号 + 底部文件名铭牌） */
.comm-img {
    position: relative;
    background: var(--panel);
    border: 2px solid var(--line-strong);
    padding: 8px;
}

.comm-img::before,
.comm-img::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--red);
    z-index: 2;
    pointer-events: none;
}

.comm-img::before {
    top: -4px;
    left: -4px;
    border-right: 0;
    border-bottom: 0;
}

.comm-img::after {
    bottom: -4px;
    right: -4px;
    border-left: 0;
    border-top: 0;
}

.comm-img img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.comm-img figcaption {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--muted);
    text-transform: uppercase;
}

.comm-img figcaption i {
    font-style: normal;
    color: var(--red);
}

/* ========== 3. 社区组织 · 卡片切换（前后错落） ========== */
/* 所有部门卡片堆叠在舞台中央，js/main.js 按与当前卡的偏移量赋予
   pos-0 / pos-1 / pos--1 / pos-hidden：中间卡最大最前，两侧卡缩小、
   后移并淡出（保持正面、无倾斜），点击左右两侧卡片即可切换。
   舞台自带网格底纹与当前部门巨型轮廓编号，与首页海报 / HUD 风格呼应。 */

.dept-carousel {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 24px;
}

/* 舞台：卡片同格堆叠（自动取最高者决定高度），并提供 3D 透视 */
.dept-stage {
    position: relative;
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    place-items: center;
    perspective: 1500px;
    perspective-origin: 50% 45%;
    --dept-w: clamp(230px, 28vw, 340px);
    padding: clamp(36px, 6vw, 64px) 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    overflow: hidden; /* 收拢两侧溢出卡片，避免页面横向滚动 */
}

/* 舞台网格底纹：科技感线条，向中心淡出 */
.dept-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
    background-position: center;
    -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 0%, transparent 72%);
    mask-image: radial-gradient(ellipse at 50% 50%, #000 0%, transparent 72%);
    pointer-events: none;
}

/* 当前部门巨型轮廓编号（海报标注感，随卡片切换更新） */
.dept-stage::after {
    content: attr(data-no);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    font-family: var(--font-mono);
    font-size: clamp(8rem, 26vw, 18rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.05em;
    color: transparent;
    -webkit-text-stroke: 1px var(--line-strong);
    opacity: 0.35;
    pointer-events: none;
    user-select: none;
}

/* 卡片本体：全部落在同一网格单元里叠放 */
.dept-card {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    width: var(--dept-w);
    margin: 0;
    background: var(--panel);
    border: 2px solid var(--line-strong);
    padding: 8px;
    cursor: pointer;
    opacity: 0;
    backface-visibility: hidden;
    transition: transform 560ms cubic-bezier(0.22, 0.61, 0.36, 1),
        opacity 560ms ease,
        border-color 240ms ease;
    will-change: transform, opacity;
}

/* 正中：最大、最前、完全不透明 */
.dept-card.pos-0 {
    z-index: 3;
    opacity: 1;
    border-color: var(--red);
    transform: translateX(0) rotateY(0deg) scale(1);
}

/* 左侧：向左退开、缩小并后移（保持正面，不倾斜） */
.dept-card.pos--1 {
    z-index: 2;
    opacity: 0.85;
    transform: translateX(-82%) translateZ(-90px) rotateY(0deg) scale(0.86);
}

/* 右侧：向右退开、缩小并后移（保持正面，不倾斜） */
.dept-card.pos-1 {
    z-index: 2;
    opacity: 0.85;
    transform: translateX(82%) translateZ(-90px) rotateY(0deg) scale(0.86);
}

/* 背面（相隔两张）：退到后方淡出，不可点击 */
.dept-card.pos-hidden {
    z-index: 1;
    pointer-events: none;
    transform: translateX(0) rotateY(0deg) scale(0.7);
}

/* 侧卡悬停/聚焦点亮 */
.dept-card.pos--1:hover,
.dept-card.pos-1:hover,
.dept-card.pos--1:focus-visible,
.dept-card.pos-1:focus-visible {
    opacity: 1;
    border-color: var(--red);
}

.dept-card-img {
    position: relative;
}

/* 当前卡片的图片带红色角括号（与 .comm-img / .duty-img 同源） */
.dept-card.pos-0 .dept-card-img::before,
.dept-card.pos-0 .dept-card-img::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--red);
    z-index: 3;
    pointer-events: none;
}

.dept-card.pos-0 .dept-card-img::before {
    top: -4px;
    left: -4px;
    border-right: 0;
    border-bottom: 0;
}

.dept-card.pos-0 .dept-card-img::after {
    bottom: -4px;
    right: -4px;
    border-left: 0;
    border-top: 0;
}

.dept-card-img img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: var(--bg);
    border: 1px solid var(--line);
}

.dept-card figcaption {
    padding: 12px 4px 2px;
}

.dept-card-no {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--red);
}

.dept-card h3 {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: var(--red);
    margin: 2px 0 2px;
}

.dept-card-en {
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.dept-card-desc {
    color: var(--muted);
    margin-top: 10px;
    font-size: 0.95rem;
}

.dept-card-quote {
    margin-top: 12px;
    padding-top: 10px;
    padding-left: 12px;
    border-top: 1px dashed var(--line);
    border-left: 2px solid var(--red);
    color: var(--ink);
    font-size: 0.9rem;
}

/* 底部快速切换标签（同时标出当前部门） */
.dept-tabs {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 0;
    padding: 0;
}

.dept-tab {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.15em;
    color: var(--muted);
    border: 0;
    background: var(--panel);
    padding: 10px 20px;
    cursor: pointer;
    transition: color 200ms, background 200ms;
}

.dept-tab b {
    font-size: 11px;
    font-weight: 400;
    color: var(--red);
}

.dept-tab:hover {
    color: var(--ink);
    background: rgba(229, 72, 77, 0.08);
}

.dept-tab.active {
    color: var(--red);
    background: rgba(229, 72, 77, 0.12);
    box-shadow: inset 0 -2px 0 var(--red);
}

/* 查看更多 → 部门页面 */
.dept-more {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    border: 2px solid var(--red);
    padding: 10px 18px;
    color: var(--red);
    background: transparent;
    transition: background 240ms, color 240ms;
}

.dept-more:hover {
    background: var(--red);
    color: var(--bg);
}

/* ========== 4. 加入红石镇 CTA ========== */
.cta {
    position: relative;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 110px var(--pad);
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.cta:before,
.cta:after {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid var(--red);
    opacity: 0.7;
}

.cta:before {
    top: 24px;
    left: 24px;
    border-right: 0;
    border-bottom: 0;
}

.cta:after {
    bottom: 24px;
    right: 24px;
    border-left: 0;
    border-top: 0;
}

.cta-title {
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 900;
    line-height: 1.4;
    letter-spacing: 0.04em;
    margin: 10px 0 32px;
}

.cta-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

/* ========== 5. 响应式 ========== */
@media (max-width: 820px) {
    .comm-grid {
        grid-template-columns: 1fr;
    }

    .comm-img {
        order: -1;
    }

    .intro-no {
        top: auto;
        bottom: 12px;
        opacity: 0.25;
    }

    /* 社区组织：小屏收窄卡片与侧移，避免超出可视宽度 */
    .dept-carousel {
        grid-template-columns: 1fr;
    }

    .dept-stage {
        --dept-w: clamp(160px, 48vw, 230px);
        perspective: 900px;
        padding: 32px 0;
    }

    .dept-card.pos--1 {
        transform: translateX(-48%) translateZ(-60px) rotateY(0deg) scale(0.8);
    }

    .dept-card.pos-1 {
        transform: translateX(48%) translateZ(-60px) rotateY(0deg) scale(0.8);
    }

    .dept-more {
        grid-column: 1;
        grid-row: 3;
        justify-self: start;
        margin-top: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dept-card {
        transition: none;
    }
}