/* ============================================
   CSS Flexbox 完全チートシート - スタイルシート
   ============================================ */

/* リセット & ベーススタイル */
/* WordPress記事本文用: スコープを限定してテーマとの競合を回避 */
.flexbox-cheatsheet-container * {
    box-sizing: border-box;
}

:root {
    /* カラーパレット */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #ec4899;
    --accent-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* WordPress記事本文用: コンテナクラスでスコープを限定 */
.flexbox-cheatsheet-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-color);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ヘッダー */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    animation: movePattern 20s linear infinite;
}

@keyframes movePattern {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(30px, 30px);
    }
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

/* 目次 */
.toc {
    background: var(--card-bg);
    padding: 30px 40px;
    border-bottom: 3px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.toc h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.toc ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.toc li {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    border-radius: 25px;
    transition: all 0.3s ease;
}

.toc li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.toc a {
    display: block;
    padding: 10px 20px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.toc a:hover {
    color: #f0f0f0;
}

/* セクション */
.section {
    padding: 40px;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
    position: relative;
}

.section h2::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100px;
    height: 3px;
    background: var(--secondary-color);
    animation: expandWidth 0.8s ease-out;
}

@keyframes expandWidth {
    from {
        width: 0;
    }
    to {
        width: 100px;
    }
}

/* プロパティカード */
.prop-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.prop-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    transition: width 0.3s ease;
}

.prop-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.prop-card:hover::before {
    width: 100%;
    opacity: 0.05;
}

.prop-card h3 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.syntax {
    background: #1e293b;
    color: #10b981;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    margin: 15px 0;
    overflow-x: auto;
    position: relative;
    z-index: 1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.syntax code {
    color: #10b981;
    background: transparent;
}

.description {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 20px;
    line-height: 1.8;
    position: relative;
    z-index: 1;
}

/* デモコンテナ */
.demo-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.demo-box {
    background: #f8fafc;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
}

.demo-box:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
    transform: scale(1.02);
}

.demo-box.full-width {
    grid-column: 1 / -1;
}

.demo-box h4 {
    color: var(--primary-dark);
    margin-bottom: 15px;
    font-size: 1rem;
    text-align: center;
    font-weight: 600;
}

/* Flexboxデモ */
.flex-demo {
    display: flex;
    background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px;
    min-height: 100px;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.flex-demo::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 9px,
            rgba(99, 102, 241, 0.1) 9px,
            rgba(99, 102, 241, 0.1) 10px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 9px,
            rgba(99, 102, 241, 0.1) 9px,
            rgba(99, 102, 241, 0.1) 10px
        );
    pointer-events: none;
    opacity: 0.3;
}

.flex-demo.basic {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }
}

.flex-item {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    min-width: 60px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    animation: itemAppear 0.5s ease-out;
}

@keyframes itemAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.flex-item:nth-child(1) {
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    animation-delay: 0.1s;
}

.flex-item:nth-child(2) {
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
    animation-delay: 0.2s;
}

.flex-item:nth-child(3) {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    animation-delay: 0.3s;
}

.flex-item:nth-child(4) {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    animation-delay: 0.4s;
}

.flex-item:nth-child(5) {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    animation-delay: 0.5s;
}

.flex-item:nth-child(6) {
    background: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
    animation-delay: 0.6s;
}

.flex-item:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: var(--shadow-lg);
    z-index: 2;
}

/* インタラクティブデモ */
.flex-demo.interactive {
    cursor: pointer;
    transition: all 0.3s ease;
}

.flex-demo.interactive:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.3);
}

/* コードブロック */
pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin-top: 20px;
    box-shadow: var(--shadow-md);
    position: relative;
}

pre code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

pre::before {
    content: 'CSS';
    position: absolute;
    top: 10px;
    right: 15px;
    color: var(--accent-color);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
}

/* 情報ボックス */
.info-box {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    border-left: 5px solid var(--primary-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-box p {
    margin-bottom: 15px;
    color: var(--text-primary);
}

/* フッター */
footer {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: white;
    text-align: center;
    padding: 30px;
    font-size: 1.1rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .flexbox-cheatsheet-container {
        margin: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .section {
        padding: 20px;
    }

    .section h2 {
        font-size: 1.8rem;
    }

    .prop-card {
        padding: 20px;
    }

    .demo-container {
        grid-template-columns: 1fr;
    }

    .toc ul {
        flex-direction: column;
    }

    .toc li {
        width: 100%;
    }
}

/* スクロールバーのスタイリング */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 10px;
    border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
}

/* アニメーション強化 */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.prop-card:hover .flex-item {
    animation: shimmer 2s infinite;
}

/* 軸の視覚化 */
.axis-demo-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 25px;
}

.axis-demo-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 25px;
    transition: all 0.3s ease;
}

.axis-demo-box:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.axis-demo-box h4 {
    color: var(--primary-dark);
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
}

.axis-visualization {
    position: relative;
    margin-bottom: 20px;
}

.axis-main,
.axis-cross {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
}

.axis-arrow {
    font-size: 2rem;
    color: var(--primary-color);
    font-weight: bold;
    margin-right: 10px;
    animation: arrowPulse 2s ease-in-out infinite;
}

@keyframes arrowPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.axis-label {
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 1rem;
}

.axis-example {
    margin-top: 15px;
    position: relative;
}

.axis-note {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 10px;
    padding: 10px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 6px;
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 印刷スタイル */
@media print {
    .flexbox-cheatsheet-container {
        background: white;
        box-shadow: none;
    }

    .flex-demo,
    .flex-item {
        break-inside: avoid;
    }
}

