/* ============================
   base.css
   共通変数・リセット・レイアウト・ボタン
   ============================ */

/* ===================================
   スターポイント - デザインシステム
   Vanilla CSS Modern Design
   =================================== */

/* ── カラーパレット & トークン ── */
:root {
    /* 子供向けポップ・プレミアムカラー */
    --color-primary: #6c5ce7;
    --color-primary-light: #a29bfe;
    --color-primary-dark: #4834d4;
    --color-primary-glow: rgba(108, 92, 231, 0.2);

    --color-accent: #ff7675;
    --color-accent-light: #fab1a0;
    --color-accent-glow: rgba(255, 118, 117, 0.2);

    --color-gold: #fdcb6e;
    --color-silver: #dfe6e9;
    --color-bronze: #e17055;

    --color-success: #55efc4;
    --color-warning: #ffeaa7;
    --color-danger: #d63031;
    --color-info: #74b9ff;

    /* Theme Subjects */
    --color-subject-math: #3b82f6;
    --color-subject-english: #f97316;
    --color-subject-japanese: #10b981;

    /* ライト・ポップ背景システム */
    --bg-base: #f0f3f8;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f9fbff;
    --bg-input: #f1f3f6;
    --bg-overlay: rgba(0, 0, 0, 0.4);

    /* テキスト */
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-muted: #b2bec3;
    --text-inverse: #ffffff;

    /* ボーダー */
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-dim: rgba(0, 0, 0, 0.08);
    --border-accent: rgba(108, 92, 231, 0.3);

    /* シャドウ - 子供向けに少し柔らかく、浮き出る感じ */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px var(--color-primary-glow);
    --shadow-gold: 0 0 20px rgba(253, 203, 110, 0.4);

    /* グラデーション */
    --grad-primary: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    --grad-accent: linear-gradient(135deg, #ff7675 0%, #fab1a0 100%);
    --grad-gold: linear-gradient(135deg, #fdcb6e 0%, #f1c40f 100%);
    --grad-success: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    --grad-rainbow: linear-gradient(135deg, #6c5ce7, #ff7675, #fdcb6e);
    --grad-card: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    --grad-sidebar: linear-gradient(180deg, #ffffff 0%, #f0f3f8 100%);

    /* 間隔 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* 角丸 - 子供向けに大きめ */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    /* トランジション */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* サイドバー幅（折り畳みアイコンのみ表示） */
    --sidebar-width: 72px;
}

body.sidebar-collapsed {
    --sidebar-width: 80px;
}

/* ── リセット & ベース ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

/* 🎬 ページ遷移カーテン (最前面オーバーレイ) */
.page-curtain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a; /* 深みのある黒背景 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
}

.page-curtain.active {
    opacity: 1;
    pointer-events: auto;
}

.curtain-content {
    text-align: center;
    color: #fff;
}

.curtain-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: curtain-pulse 1.5s ease-in-out infinite;
}

.curtain-text {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--color-gold);
    text-shadow: 0 0 10px rgba(253, 203, 110, 0.5);
}

@keyframes curtain-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(255,255,255,0.2)); }
    50% { transform: scale(1.2); filter: drop-shadow(0 0 30px var(--color-gold)); }
}

body {
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.4s ease;
    /* Smooth background transitions for subjects */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(108, 92, 231, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 118, 117, 0.03) 0%, transparent 40%);
}

/* ── 動的背景色（教科別テーマ） ── */
/* ページ全体ではなく、特定のパネルに適用するように変更 */
body.bg-math,
body.bg-english,
body.bg-japanese {
    background-color: var(--bg-body) !important;
}

.calc-result-panel.theme-math {
    background: linear-gradient(135deg, #1e293b 0%, #3b82f6 100%) !important;
    border: none !important;
    color: #fff !important;
}

.calc-result-panel.theme-english {
    background: linear-gradient(135deg, #2d1b0d 0%, #f97316 100%) !important;
    border: none !important;
    color: #fff !important;
}

.calc-result-panel.theme-japanese {
    background: linear-gradient(135deg, #062016 0%, #10b981 100%) !important;
    border: none !important;
    color: #fff !important;
}

/* 計算式内のパーツ (サイズ均一化) */
.calc-part-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calc-part-box .box-lbl {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-weight: 700;
    text-align: right;
    width: 100%;
}

.calc-part-box.result-box .calc-part-val-wrapper {
    background: #fffbdf !important;
    border: 2px solid var(--color-gold);
    box-shadow: var(--shadow-gold);
}

.calc-part-box.result-box .box-lbl {
    background: var(--color-gold);
    color: #000;
}

.calc-part-val-wrapper {
    background: #fff;
    border-radius: 12px;
    padding: 10px 16px;
    min-width: 160px;
    /* "88,888" pt が入る程度の幅を確保 */
    display: flex;
    justify-content: flex-end;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
}

.calc-part-val {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 2px;
    color: var(--text-primary);
}

.calc-part-val small {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* パネルがテーマ色の時の文字色調整 */
.calc-result-panel[class*="theme-"] .panel-title,
.calc-result-panel[class*="theme-"] .panel-subtitle {
    color: rgba(255, 255, 255, 0.9);
}

.calc-result-panel[class*="theme-"] .result-hint {
    color: rgba(255, 255, 255, 0.6);
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

ul,
ol {
    list-style: none;
}

/* ── スクロールバー非表示 (没入感向上のため) ── */
/* Chrome, Safari, Edge */
::-webkit-scrollbar {
    display: none;
}

/* Firefox */
* {
    scrollbar-width: none;
}

/* IE / old Edge */
body {
    -ms-overflow-style: none;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── レイアウト ── */
#app {
    display: flex;
    min-height: 100vh;
}

/* ══════════════════════════════════════════
   🏰 RPG サイドバー スタイル
   ══════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    /* ダークウッド調の背景 */
    background:
        linear-gradient(180deg, #1c1009 0%, #2a1a0d 40%, #1c1009 100%);
    border-right: 3px solid #8b6914;
    box-shadow:
        4px 0 20px rgba(0,0,0,0.5),
        inset -1px 0 0 rgba(255, 215, 0, 0.15);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow: hidden;
    /* 木目テクスチャ風のパターン */
    background-image:
        repeating-linear-gradient(
            180deg,
            transparent 0px,
            transparent 3px,
            rgba(0,0,0,0.15) 3px,
            rgba(0,0,0,0.15) 4px
        ),
        linear-gradient(180deg, #1e1208 0%, #2d1e0e 40%, #1e1208 100%);
}

/* 金のトップボーダー装飾 */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #d4af37, #ffd700, #d4af37, transparent);
}

/* ブランドエリア */
.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0 12px;
    position: relative;
}

/* ブランドテキストは折り畳み時非表示 */
.brand-text {
    display: none;
}

.brand-icon-rpg {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.brand-title {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    letter-spacing: 0.05em;
    /* 通常のtext-fill-colorをリセット */
    -webkit-text-fill-color: #ffd700;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

.brand-sub {
    font-size: 0.65rem;
    color: #c8a96e;
    font-weight: 500;
    margin-top: 2px;
    letter-spacing: 0.1em;
}

/* 区切り線 */
.sidebar__divider {
    display: none; /* 折り畳み時は非表示 */
}

/* ── ナビゲーション ── */
.sidebar__nav {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    flex: 1;
    gap: 4px;
}

.sidebar__nav-divider {
    height: 1px;
    margin: 8px 4px;
    background: linear-gradient(90deg, transparent, #4a3010, #8b6914, #4a3010, transparent);
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 10px 0;
    border-radius: 8px;
    color: #d4b896;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    border: 1px solid transparent;
    background: transparent;
}

/* ナビラベルは折り畳み時非表示 */
.nav-label {
    display: none;
}

.nav-icon {
    font-size: 1.35rem;
    width: auto;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    color: #ffd700;
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.15), inset 0 0 12px rgba(212, 175, 55, 0.05);
    transform: translateX(3px);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.nav-item.active {
    color: #1a1000;
    background: linear-gradient(135deg, #d4af37 0%, #ffd700 50%, #d4af37 100%);
    border-color: #b8860b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-weight: 700;
}

.nav-item.active .nav-icon {
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

/* 管理系ナビアイテム（控えめに） */
.nav-item--muted {
    opacity: 0.75;
    font-size: 0.82rem;
}

.nav-item--muted:hover {
    opacity: 1;
}


/* ── サイドバーフッター ── */
.sidebar__footer {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #4a3010;
    background: rgba(0,0,0,0.2);
}

.data-status {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.status-text {
    display: none; /* 折り畳み時は非表示 */
}

.data-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.data-actions .btn-label {
    display: none; /* 折り畳み時は文字列非表示 */
}

/* RPGスタイルのアウトラインボタン（サイドバー内用・アイコン専用化） */
.btn-rpg-outline {
    background: transparent;
    color: #c8a96e;
    border: 1px solid #6b4f1f;
    box-shadow: none;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    border-radius: 8px;
}

.btn-rpg-outline:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: #d4af37;
    color: #ffd700;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.2);
}

/* テストモード */
.test-mode-sidebar-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    border-top: 1px solid #3a2a0a;
}

.test-mode-label {
    display: none; /* 折り畳み時は非表示 */
}

/* テストモード インジケーター (発光は削除し、スイッチの状態のみに依存) */
body.test-mode-active .sidebar {
    border-right-color: #d4af37; /* または金色のまま */
}

/* ── メインコンテンツ ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-2xl);
    min-height: 100vh;
    overflow-y: auto;
    position: relative;
    width: calc(100vw - var(--sidebar-width)) !important;
    max-width: calc(100vw - var(--sidebar-width)) !important;
    transition: margin-left var(--transition-base), width var(--transition-base);
}

/* ── 全画面ページ（ショップ・ランキング等）の余白排除 ── */
body.is-page-shop .main-content,
body.is-page-ranking .main-content,
body.is-page-shop #main-content,
body.is-page-ranking #main-content {
    padding: 0 !important;
}

.page {
    display: none !important;
    animation: fadeIn 0.4s ease;
}

.page.active {
    display: block !important;
}

/* ── テストモード トグルスイッチ ── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    transition: all 0.3s ease;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #c8a96e;
    transition: all 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

input:checked + .toggle-slider {
    background-color: rgba(85, 239, 196, 0.25);
    border-color: var(--color-success);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background: var(--color-success);
    box-shadow: 0 0 6px rgba(85, 239, 196, 0.5);
}

/* ── レスポンシブ（スマホ） ── */
@media (max-width: 640px) {
    :root {
        --sidebar-width: 0px;
    }
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: var(--space-md);
        max-width: 100vw !important;
        width: 100vw !important;
    }
}


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 800;
    transition: all var(--transition-base);
    white-space: nowrap;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

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

.btn:active {
    transform: translateY(1px) scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
    background: var(--bg-input) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
    transform: none !important;
    pointer-events: none;
    border-color: transparent !important;
}

.btn-primary {
    background: var(--grad-primary);
    color: #fff;
}

.btn-accent {
    background: var(--grad-accent);
    color: #fff;
}

.btn-outline {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 2px solid var(--border-dim);
    box-shadow: none;
}

.btn-outline:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ── お知らせアイコン共通スタイル ── */
.news-icon-btn {
    background: rgba(42, 26, 10, 0.6);
    border: 1px solid #8b4513;
    border-radius: 50%;
    width: 48px !important;  /* 40px -> 48px */
    height: 48px !important; /* 40px -> 48px */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    padding: 0;
    color: #fdf5e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.news-icon-btn:hover {
    background: rgba(139, 69, 19, 0.8);
    transform: translateY(-2px);
    border-color: #d4af37;
}

.news-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6));
}

/* 一週間以内の新着がある場合 */
.news-icon-btn.has-new {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    animation: pulse-news 2s infinite;
}

.news-icon-btn.has-new .news-icon {
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.8));
}

@keyframes pulse-news {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

.news-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53935;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1a0f05;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* ============================================================
   📢 お知らせモーダル：リスト・詳細および羊皮紙（Parchment）テーマ
   ============================================================ */

/* リスト表示 */
.ann-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 5px;
}

.ann-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(139, 69, 19, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ann-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: #d4af37;
    transform: translateX(8px);
    box-shadow: -4px 0 15px rgba(212, 175, 55, 0.1);
}

.ann-item__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ann-item__title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.ann-item__date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.ann-item__arrow {
    font-size: 1.2rem;
    color: #d4af37;
    opacity: 0.6;
}

/* 詳細表示（羊皮紙テーマ） */
.ann-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.4s ease;
}

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

.ann-detail__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 12px;
}

.ann-detail__title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffd700;
}

.ann-detail__date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* 📜 本文エリア：羊皮紙風デザイン */
.ann-detail__body-container {
    background: #f4e4bc; /* 羊皮紙のベース色 */
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.2) 0%, transparent 100%),
        linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 100% 100%, 100% 28px; /* 罫線風 */
    border: 3px double #8b4513;
    border-radius: 4px;
    padding: 30px;
    position: relative;
    box-shadow: 
        inset 0 0 50px rgba(139, 69, 19, 0.2),
        0 8px 20px rgba(0,0,0,0.3);
    overflow: hidden;
}

/* 紙の端の焦げ・汚れエフェクト */
.ann-detail__body-container::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
    pointer-events: none;
}

.ann-detail__content {
    color: #2c1810; /* 濃い茶色のインク色 */
    font-size: 1.1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    font-family: 'Sawarabi Mincho', serif; /* 明朝体で高級感を出す */
    text-shadow: 0.5px 0.5px 0px rgba(0,0,0,0.1);
}

/* 戻るボタン */
.ann-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid #8b4513;
    color: #d4af37;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    transition: all 0.2s;
    margin-bottom: 5px;
}

.ann-back-btn:hover {
    background: rgba(139, 69, 19, 0.2);
    transform: translateX(-4px);
}
