/**
 * Root Calculator - Mobile Optimized
 * ルート計算機 - スマホ最適化版
 *
 * Strategy:
 * - 共通コンポーネント (stats-grid.css) を活用
 * - スマホで結果が常に見えるレイアウト
 * - 数式表示の美しさを保持
 * - 最小限の専用CSS
 *
 * Version: 1.0
 * Created: 2025-11-02
 */

/* ========================================
   1. Calculator Layout (モバイル優先)
   ======================================== */

.root-calc-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* 入力セクション（スマホで上部） */
.root-input-section {
    order: 1; /* モバイル: 上 - 計算が先 */
    width: 100%;
}

/* 結果セクション（スマホで下部） */
.root-results {
    order: 2; /* モバイル: 下 - 結果があと */
    width: 100%;
}

/* ========================================
   2. 数式表示エリア
   ======================================== */

.root-formula-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
}

.root-degree-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 120px;
}

.root-degree-box label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.root-degree-box input {
    font-size: 18px;
    padding: 10px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    box-sizing: border-box;
}

.root-degree-box input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.root-symbol {
    font-size: 48px;
    font-weight: bold;
    color: #0066cc;
    flex-shrink: 0;
}

.radicand-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
}

.radicand-box label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.radicand-box input {
    font-size: 18px;
    padding: 10px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    box-sizing: border-box;
}

.radicand-box input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.equals-symbol {
    font-size: 32px;
    font-weight: bold;
    color: #374151;
    flex-shrink: 0;
}

/* ========================================
   3. クイック計算ボタン
   ======================================== */

.quick-calculations {
    margin-top: 24px;
}

.quick-calculations h3 {
    font-size: 1.1em;
    margin-bottom: 12px;
    color: #374151;
}

.quick-root-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.quick-root-btn {
    padding: 12px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    color: #374151;
}

.quick-root-btn:hover {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
}

.quick-root-btn:active {
    transform: scale(0.95);
}

/* ========================================
   4. Stats Grid for Results
   ======================================== */

.root-results .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0;
}

.root-results .stat-card {
    padding: 16px;
    background: #fff;
}

.root-results .stat-value {
    font-size: 24px;
    margin: 8px 0;
    color: #0066cc;
    font-weight: 700;
    word-break: break-all;
}

.root-results .stat-label {
    font-size: 12px;
    color: #666;
}

/* コピーボタン */
.copy-result-btn {
    width: 100%;
    padding: 10px;
    margin-top: 12px;
    background: #059669;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-result-btn:hover {
    background: #047857;
}

.copy-result-btn.copied {
    background: #10b981;
}

/* ========================================
   5. ヒント・エラーメッセージ
   ======================================== */

.input-hint {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

/* ========================================
   6. Desktop Layout (769px+)
   ======================================== */

@media (min-width: 769px) {
    .root-calc-wrapper {
        flex-direction: row;
        gap: 24px;
        align-items: flex-start;
    }

    .root-input-section {
        flex: 1;
        order: 1; /* PC: 左 */
        min-width: 0;
    }

    .root-results {
        flex: 1;
        order: 2; /* PC: 右 */
        min-width: 0;
    }

    .root-results .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        width: 100%;
    }

    .root-results .stat-card {
        padding: 20px;
    }

    .root-results .stat-value {
        font-size: 28px;
        margin: 10px 0;
    }

    .root-results .stat-label {
        font-size: 13px;
    }

    .root-formula-display {
        flex-wrap: nowrap;
    }

    .quick-root-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .quick-root-btn {
        padding: 14px 10px;
        font-size: 18px;
    }
}

/* ========================================
   7. Small Mobile (640px-)
   ======================================== */

@media (max-width: 640px) {
    .root-formula-display {
        gap: 8px;
        padding: 16px;
    }

    .root-degree-box,
    .radicand-box {
        min-width: 100px;
    }

    .root-degree-box input,
    .radicand-box input {
        font-size: 16px;
        padding: 8px;
    }

    .root-symbol {
        font-size: 36px;
    }

    .equals-symbol {
        font-size: 24px;
    }

    .quick-root-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .quick-root-btn {
        padding: 10px 6px;
        font-size: 14px;
    }

    .root-results .stat-card {
        padding: 12px;
    }

    .root-results .stat-value {
        font-size: 20px;
    }

    .root-results .stat-label {
        font-size: 11px;
    }
}

/* ========================================
   8. Very Small Mobile (480px-)
   ======================================== */

@media (max-width: 480px) {
    .root-formula-display {
        padding: 12px;
    }

    .root-degree-box,
    .radicand-box {
        min-width: 80px;
    }

    .root-degree-box label,
    .radicand-box label {
        font-size: 11px;
    }

    .root-degree-box input,
    .radicand-box input {
        font-size: 14px;
        padding: 6px;
    }

    .root-symbol {
        font-size: 28px;
    }

    .equals-symbol {
        font-size: 20px;
    }

    .quick-root-btn {
        padding: 8px 4px;
        font-size: 13px;
    }
}
