/* ===================== Compass / FengShui Page ===================== */
.compass-page {
    min-height: calc(100vh - 60px);
    padding: 2rem 1.5rem;
}

.compass-header {
    text-align: center;
    margin-bottom: 2rem;
}

.compass-header h1 { font-size: 2rem; margin-bottom: 0.5rem; }

.compass-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
    align-items: start;
}

/* Compass Image */
.compass-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.compass-image-wrap {
    position: relative;
    width: 400px;
    height: 400px;
    margin: 1rem 0;
}

.compass-image-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(212, 168, 83, 0.25), 
                0 0 80px rgba(212, 168, 83, 0.1),
                inset 0 0 40px rgba(0, 0, 0, 0.4);
    border: 3px solid var(--primary-gold);
    transition: box-shadow 0.3s ease;
}

.compass-image-container:hover {
    box-shadow: 0 0 60px rgba(212, 168, 83, 0.35), 
                0 0 100px rgba(212, 168, 83, 0.15),
                inset 0 0 50px rgba(0, 0, 0, 0.5);
    transform: scale(1.02);
}

.compass-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    filter: brightness(1.05) contrast(1.1);
    transition: filter 0.3s ease;
}

.compass-image-container:hover .compass-image {
    filter: brightness(1.1) contrast(1.2);
}

/* 确保罗盘图片和指针有平滑的旋转过渡 */
.compass-image,
.compass-needle,
.compass-image-container {
    will-change: transform;
}

/* 罗盘旋转时的光效动画 */
@keyframes compass-rotate-glow {
    0% { box-shadow: 0 0 15px rgba(212, 168, 83, 0.3); }
    50% { box-shadow: 0 0 25px rgba(212, 168, 83, 0.6); }
    100% { box-shadow: 0 0 15px rgba(212, 168, 83, 0.3); }
}

.compass-image-container.rotating {
    animation: compass-rotate-glow 0.5s ease;
}

/* 角度显示的动画 */
@keyframes angle-update {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.angle-display.updated {
    animation: angle-update 0.4s ease;
}

/* Compass needle */
.compass-needle {
    position: absolute;
    top: 50%; left: 50%;
    width: 4px;
    height: 40%;
    transform-origin: bottom center;
    transform: translate(-50%, -100%);
    z-index: 10;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5));
}

.needle-red {
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 50% solid #EF4444;
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.5));
}

.needle-white {
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 50% solid #9CA3AF;
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 2px rgba(156, 163, 175, 0.5));
}

.compass-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 18px; height: 18px;
    background: var(--primary-gold);
    border-radius: 50%;
    z-index: 15;
    box-shadow: 0 0 10px rgba(212, 168, 83, 0.8),
                inset 0 0 5px rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Angle display */
.angle-display {
    font-size: 1.5rem;
    color: var(--primary-gold);
    font-family: 'Noto Serif SC', serif;
    font-weight: 700;
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: rgba(212, 168, 83, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(212, 168, 83, 0.3);
    box-shadow: 0 0 15px rgba(212, 168, 83, 0.2);
    transition: all 0.3s ease;
}

.angle-display:hover {
    background: rgba(212, 168, 83, 0.15);
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.3);
}

.angle-display span {
    font-size: 1rem;
    vertical-align: super;
    margin-left: 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .compass-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .compass-image-wrap {
        width: 300px;
        height: 300px;
    }
    
    .angle-display {
        font-size: 1.3rem;
        padding: 0.4rem 1.2rem;
    }
}

@media (max-width: 480px) {
    .compass-image-wrap {
        width: 260px;
        height: 260px;
    }
    
    .angle-display {
        font-size: 1.2rem;
        padding: 0.3rem 1rem;
    }
}

/* Angle display */
.angle-display {
    font-family: 'Noto Serif SC', serif;
    font-size: 2rem;
    color: var(--primary-gold);
    text-align: center;
    margin-bottom: 0.5rem;
}

.angle-display span { font-size: 1rem; }

/* Controls */
.compass-controls {
    padding: 1.5rem;
}

.control-group { margin-bottom: 1.5rem; }

.control-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

.angle-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.angle-input-row .form-input { flex: 1; }

.use-compass-btn {
    white-space: nowrap;
    padding: 0.65rem 1rem;
    background: transparent;
    border: 1px solid var(--primary-gold);
    border-radius: 10px;
    color: var(--primary-gold);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.use-compass-btn:hover { background: rgba(212, 168, 83, 0.1); }
.use-compass-btn.active { background: rgba(212, 168, 83, 0.15); border-style: solid; }

/* Building period selector */
.period-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.period-option {
    padding: 0.6rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.period-option:hover { color: var(--text-light); }

.period-option.active {
    color: var(--primary-gold);
    border-color: var(--primary-gold);
    background: rgba(212, 168, 83, 0.05);
}

.period-option .period-date {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.period-option .period-name {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.period-option.active .period-date {
    color: var(--primary-gold);
}

.period-option.active .period-name {
    color: var(--primary-gold);
    opacity: 0.9;
}

/* Results */
.compass-result {
    display: none;
    margin-top: 2rem;
}

.compass-result.show { display: block; }

.result-section {
    padding: 1.2rem;
    margin-bottom: 1rem;
}

.result-section h3 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: var(--primary-gold);
}

.result-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.result-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.result-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.result-item .value {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Flying Star Chart - 使用 flexbox 实现跨浏览器兼容 */
.flying-star-chart {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 320px;
    margin: 0 auto;
}

.star-cell {
    /* 使用固定尺寸确保跨浏览器一致，兼容 Firefox/Safari */
    width: calc((100% - 8px) / 3);
    min-height: 80px;
    height: calc((100% - 8px) / 3); /* 正方形比例 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-family: 'Noto Serif SC', serif;
    position: relative;
    padding: 0.3rem;
    box-sizing: border-box; /* 确保 padding 不影响尺寸 */
}

/* 旧版 aspect-ratio 降级方案（Firefox/Safari 备用） */
@supports not (aspect-ratio: 1) {
    .star-cell {
        height: auto;
        padding-bottom: calc((100% - 8px) / 3);
    }
}

.star-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    line-height: 1.3;
}

.star-row.yun-row {
    margin-top: 0.15rem;
    padding-top: 0.15rem;
    border-top: 1px dashed rgba(212, 168, 83, 0.2);
}

.star-cell .star-type {
    font-size: 0.6rem;
    color: var(--text-muted);
    min-width: 0.8rem;
}

.star-cell .star-num {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-gold);
}

.star-cell .star-num.shan {
    color: #10B981;
}

.star-cell .star-num.xiang {
    color: #EF4444;
}

.star-cell .star-num.yun {
    color: var(--primary-gold);
}

.star-cell .star-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.star-cell.center-cell .star-label {
    color: var(--primary-gold);
}

.star-cell .palace-name {
    font-size: 0.6rem;
    color: rgba(212, 168, 83, 0.6);
    margin-bottom: 0.15rem;
    font-weight: 500;
    letter-spacing: 1px;
}

/* Flying star annotations */
.flying-star-annotations {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.annotation-item {
    display: flex;
    flex-direction: column;
    padding: 0.4rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.4;
}

.annotation-item.luck-good {
    border-left: 3px solid #10B981;
}

.annotation-item.luck-bad {
    border-left: 3px solid #EF4444;
}

.annotation-item.luck-neutral {
    border-left: 3px solid var(--text-muted);
}

.annotation-palace {
    font-weight: 600;
    color: var(--primary-gold);
    margin-bottom: 0.1rem;
}

.annotation-luck {
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.annotation-item.luck-good .annotation-luck {
    color: #10B981;
}

.annotation-item.luck-bad .annotation-luck {
    color: #EF4444;
}

.annotation-item.luck-neutral .annotation-luck {
    color: var(--text-muted);
}

.annotation-text {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.star-cell.center-cell {
    background: rgba(212, 168, 83, 0.08);
    border-color: var(--primary-gold);
}

/* Flying star header info */
.flying-star-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.8rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.flying-star-info {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.9rem;
    color: var(--text-light);
    padding: 0.3rem 0.8rem;
    background: rgba(212, 168, 83, 0.08);
    border-radius: 4px;
    border: 1px solid rgba(212, 168, 83, 0.2);
}

/* Flying star chart wrapper with labels */
.flying-star-chart-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.flying-star-label {
    font-family: 'Noto Serif SC', serif;
    font-size: 1rem;
    color: var(--primary-gold);
    padding: 0.3rem 1rem;
    background: rgba(212, 168, 83, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(212, 168, 83, 0.3);
    margin: 0.3rem 0;
}

.flying-star-label.xiang-label {
    order: -1;
}

.flying-star-label.shan-label {
    order: 1;
}

/* Direction luck list */
.direction-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.direction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 6px;
    gap: 0.5rem;
}

.direction-item .direction-icon {
    font-size: 1rem;
}

.direction-item .direction-name {
    flex: 1;
    font-weight: 500;
}

.direction-item .direction-luck {
    font-weight: bold;
    margin-right: 0.5rem;
}

.direction-item .luck-type-tag {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    background: rgba(212, 168, 83, 0.2);
    color: var(--primary-gold);
    border-radius: 4px;
    font-style: normal;
}

.direction-item.luck-good {
    color: var(--success);
    background: rgba(16, 185, 129, 0.08);
    border-left: 3px solid var(--success);
}

.direction-item.luck-bad {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    border-left: 3px solid var(--danger);
}

/* 吉位汇总 */
.luck-summary {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.luck-summary-title {
    font-size: 0.85rem;
    color: var(--success);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.luck-summary-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.luck-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    background: rgba(16, 185, 129, 0.15);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--success);
}

.luck-tag.has-type {
    background: rgba(212, 168, 83, 0.2);
    color: var(--primary-gold);
}

.luck-tag em {
    font-style: normal;
    font-weight: bold;
    margin-left: 0.25rem;
}

@media (max-width: 768px) {
    .compass-content {
        grid-template-columns: 1fr;
    }
    .compass-circle-wrap {
        width: 260px;
        height: 260px;
    }
    .period-options { grid-template-columns: 1fr 1fr; }
    .result-grid { gap: 0.4rem; }
    .result-item { padding: 0.4rem 0.6rem; }
    .result-item .value { font-size: 0.85rem; }
    /* 飞星九宫格移动端适配 */
    .flying-star-chart {
        max-width: 280px;
        gap: 3px;
    }
    .flying-star-chart-wrap {
        overflow-x: auto;
        width: 100%;
    }
    .star-cell {
        padding: 0.2rem;
        min-width: 0;
    }
    .star-cell .star-num {
        font-size: 1rem;
    }
    .flying-star-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .flying-star-label {
        font-size: 0.85rem;
    }
}

/* ========== 计算中动画 ========== */
/* 计算时不旋转罗盘，只显示发光效果 */
.compass-image-container.calculating {
    animation: compass-calculate-glow 1.5s ease-in-out infinite;
}

/* 罗盘图片在计算时保持静止，不旋转 */
.compass-image-container.calculating .compass-image {
    transition: none !important;
    transform: rotate(var(--compass-current-angle, 0deg)) !important;
}

@keyframes compass-calculate-glow {
    0%, 100% { 
        box-shadow: 0 0 30px rgba(212, 168, 83, 0.3),
                    0 0 60px rgba(212, 168, 83, 0.15);
    }
    50% { 
        box-shadow: 0 0 50px rgba(212, 168, 83, 0.6),
                    0 0 100px rgba(212, 168, 83, 0.3);
    }
}

/* 指针在计算时保持静止 */
.compass-image-container.calculating #compassNeedle {
    transition: none !important;
}

.calculating-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 1px solid rgba(212, 168, 83, 0.2);
    backdrop-filter: blur(10px);
}

.calculating-content {
    text-align: center;
}

.calculating-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    position: relative;
}

.compass-rotate {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(212, 168, 83, 0.2);
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.compass-rotate::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 15px;
    background: var(--primary-gold);
    border-radius: 2px;
}

.compass-rotate::after {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 12px solid #EF4444;
}

.calculating-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-gold);
    margin-bottom: 0.5rem;
    font-family: 'Noto Serif SC', serif;
    letter-spacing: 2px;
}

.calculating-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 1rem;
}

.calculating-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-gold);
    border-radius: 50%;
    animation: dot-bounce 1.4s ease-in-out infinite;
}

.calculating-dots span:nth-child(1) { animation-delay: 0s; }
.calculating-dots span:nth-child(2) { animation-delay: 0.2s; }
.calculating-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.calculating-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}
