/* リアルタイム2D太陽系ウィジェット CSS */

/* --- 基本設定とテーマ --- */
:root {
    /* 公転周期（秒） - リアルタイム: 1日 = 1日（86400秒） */
    /* データソース: NASA JPL (Jet Propulsion Laboratory) */
    /* エポック: J2000.0 (2000年1月1日 12:00 UTC) */
    --mercury-period: 7600848s;      /* 水星: 87.97日 */
    --venus-period:   19414080s;     /* 金星: 224.70日 */
    --earth-period:   31557600s;     /* 地球: 365.25日（1太陽年） */
    --mars-period:    59378688s;     /* 火星: 686.98日 */
    --jupiter-period: 374537576s;    /* 木星: 4332.59日（約11.86年） */
    --saturn-period:  930000448s;    /* 土星: 10759.22日（約29.46年） */
    --uranus-period:  2653298400s;   /* 天王星: 30688.5日（約84.01年） */
    --neptune-period: 5199736800s;   /* 海王星: 60182日（約164.79年） */
}

/* --- ウィジェットコンテナ --- */
.solar-system-widget-container {
    position: relative;
    margin: 0 auto;
    background-color: #000000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    box-sizing: border-box;
}

/* Canvas背景用（JavaScriptで星を描画） */
.solar-system-widget-container canvas.stars-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* サイドバーやウィジェットエリア内での自動調整 */
.widget .solar-system-widget-container,
aside .solar-system-widget-container,
.sidebar .solar-system-widget-container {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
}

/* --- 太陽系コンテナ --- */
.solar-system-widget-container .solar-system {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    padding: 20%; /* 外側の惑星のための余白 */
    box-sizing: border-box;
    z-index: 1;
}

/* 太陽系の中心位置調整 */
.solar-system-widget-container .solar-system::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* --- 太陽 --- */
.solar-system-widget-container #sun {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6%;
    height: 6%;
    border-radius: 50%;
    background: radial-gradient(circle, #ffd700, #ff8c00, #ff4500);
    box-shadow: 
        0 0 30px #ffc700, 
        0 0 45px #ff8c00,
        0 0 75px #ff4500;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* --- 惑星と軌道のスタイル --- */
.solar-system-widget-container .orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation-name: revolve;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    transition: border-color 0.3s ease, border-width 0.3s ease;
    pointer-events: none; /* 軌道自体はマウスイベントを受け取らない */
}

.solar-system-widget-container .planet {
    position: absolute;
    top: 50%;
    left: 0;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    pointer-events: auto; /* 惑星はマウスイベントを受け取る */
}

/* 惑星のホバー効果 */
.solar-system-widget-container .planet:hover {
    transform: translate(-50%, -50%) scale(1.8);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.9);
    z-index: 100;
}

/* 惑星にホバーした時に親の軌道も強調 */
.solar-system-widget-container .planet:hover ~ .orbit,
.solar-system-widget-container .orbit:has(.planet:hover) {
    border-color: rgba(255, 255, 255, 0.9);
    border-width: 2px;
    z-index: 20;
}

/* 太陽のホバー効果 */
.solar-system-widget-container #sun {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    pointer-events: auto;
}

.solar-system-widget-container #sun:hover {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 
        0 0 40px #ffc700, 
        0 0 60px #ff8c00,
        0 0 100px #ff4500;
    z-index: 100;
}

/* --- 各惑星の定義 --- */
.solar-system-widget-container #mercury-orbit { 
    width: 11%; 
    height: 11%; 
    animation-duration: var(--mercury-period); 
}
.solar-system-widget-container #mercury { 
    width: 20%; 
    height: 20%; 
    background-color: #a9a9a9; 
}

.solar-system-widget-container #venus-orbit { 
    width: 17%; 
    height: 17%; 
    animation-duration: var(--venus-period); 
}
.solar-system-widget-container #venus { 
    width: 18%; 
    height: 18%; 
    background-color: #e6d3a2; 
}

.solar-system-widget-container #earth-orbit { 
    width: 24%; 
    height: 24%; 
    animation-duration: var(--earth-period); 
}
.solar-system-widget-container #earth { 
    width: 18%; 
    height: 18%; 
    background-color: #4b89e0; 
}

.solar-system-widget-container #mars-orbit { 
    width: 33%; 
    height: 33%; 
    animation-duration: var(--mars-period); 
}
.solar-system-widget-container #mars { 
    width: 14%; 
    height: 14%; 
    background-color: #c1440e; 
}

.solar-system-widget-container #jupiter-orbit { 
    width: 45%; 
    height: 45%; 
    animation-duration: var(--jupiter-period); 
}
.solar-system-widget-container #jupiter { 
    width: 16%; 
    height: 16%; 
    background-color: #d8ca9d; 
}

.solar-system-widget-container #saturn-orbit { 
    width: 57%; 
    height: 57%; 
    animation-duration: var(--saturn-period); 
}
.solar-system-widget-container #saturn { 
    width: 15%; 
    height: 15%; 
    background-color: #f0e6c5; 
}

.solar-system-widget-container #saturn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotateX(70deg);
    box-sizing: border-box;
}

.solar-system-widget-container #uranus-orbit { 
    width: 69%; 
    height: 69%; 
    animation-duration: var(--uranus-period); 
}
.solar-system-widget-container #uranus { 
    width: 10%; 
    height: 10%; 
    background-color: #a9d5f0; 
}

.solar-system-widget-container #neptune-orbit { 
    width: 81%; 
    height: 81%; 
    animation-duration: var(--neptune-period); 
}
.solar-system-widget-container #neptune { 
    width: 10%; 
    height: 10%; 
    background-color: #3f54ba; 
}

/* --- アニメーション --- */
@keyframes revolve {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* --- ツールチップ --- */
.solar-system-widget-container .solar-system-tooltip {
    position: fixed;
    display: none;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    border-radius: 5px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- レスポンシブ対応 --- */
@media (max-width: 768px) {
    .solar-system-widget-container #sun {
        box-shadow: 
            0 0 15px #ffc700, 
            0 0 25px #ff8c00,
            0 0 40px #ff4500;
    }
    
    .solar-system-widget-container {
        width: 100% !important;
        height: auto !important;
    }
}

/* サイドバーやナローコンテナ内での追加調整 */
.widget-area .solar-system-widget-container,
.wp-block-group .solar-system-widget-container {
    width: 100% !important;
    height: auto !important;
}

/* インラインスタイルの上書き防止 */
.solar-system-widget-container[style*="width"] {
    max-width: 100%;
}

/* 親コンテナが狭い場合の自動調整 */
@container (max-width: 500px) {
    .solar-system-widget-container {
        width: 100% !important;
        height: auto !important;
    }
}