/* src/public/css/clock.css */

/* =========================================
   設定パネル（バグ修正・レイアウト改善版）
   ========================================= */
.clock-settings-panel {
    display: flex; flex-direction: column; gap: 15px; /* 上中下に並べる設定 */
    background: #fff; padding: 18px 22px; border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-bottom: 20px;
}
.settings-row {
    display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; width: 100%;
}
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-group.settings-actions { flex-direction: row; align-items: flex-end; margin-top: 5px; }
/* 💡 追加：オリジナルカラー設定（旧 style 属性の width 指定をここへ移動） */
.custom-color-group { width: 100%; }

.settings-label { font-size: 0.8rem; font-weight: bold; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.preset-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-btn {
    padding: 6px 14px; border: 2px solid #cbd5e1; border-radius: 20px;
    background: #f8fafc; color: #64748b; font-weight: bold; font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
}
.preset-btn.active { border-color: #2a5298; background: #2a5298; color: #fff; }
.settings-select { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #f8fafc; font-size: 0.9rem; cursor: pointer; min-width: 200px; }

/* オリジナルカラーピッカー */
.color-pickers {
    display: flex; gap: 20px; align-items: center; justify-content: flex-start; /* 左寄せ */
}
.picker-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: bold; color: #475569; }
.picker-item input[type="color"] { width: 32px; height: 32px; padding: 0; border: none; border-radius: 6px; cursor: pointer; background: transparent; }

/* 共通ボタン */
.alarm-sound-btn, .settings-btn {
    padding: 8px 14px; border: 2px solid #cbd5e1; border-radius: 8px;
    background: #f8fafc; color: #64748b; font-size: 0.85rem; font-weight: bold; cursor: pointer; transition: all 0.2s;
}
.alarm-sound-btn.active { border-color: #2a5298; background: #2a5298; color: #fff; }
.settings-btn:hover { border-color: #2a5298; color: #2a5298; }

/* =========================================
   時計コンテナ
   ========================================= */
.clock-container {
    padding: 50px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    text-align: center; min-height: 450px; display: flex; flex-direction: column;
    justify-content: center; align-items: center; transition: background-color 0.4s ease;
}

.mode-switch { margin-bottom: 30px; display: flex; gap: 6px; z-index: 10; }
.btn-switch {
    padding: 10px 25px; border: 2px solid rgba(100,116,139,0.3);
    background: rgba(255,255,255,0.1); color: inherit;
    cursor: pointer; font-weight: bold; border-radius: 50px; transition: 0.3s;
}
.clock-container[style*="background-color: #fff1f2"] .btn-switch,
.clock-container[style*="background-color: rgb(255, 241, 242)"] .btn-switch {
    border-color: rgba(244,63,94,0.3); color: #f43f5e;
}
.btn-switch.active { background: rgba(100,116,139,0.2); border-color: currentColor; }

/* ゾーンの重なりバグ修正 */
.clock-zone {
    width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative; z-index: 5;
}

/* アナログ時計専用オプション */
.styled-analog-options {
    background: rgba(255,255,255,0.1); padding: 12px 25px; border-radius: 12px;
    display: flex; gap: 25px; align-items: center; margin-bottom: 30px;
    border: 1px solid rgba(255,255,255,0.2); color: inherit; z-index: 10;
}
.option-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: bold; font-size: 0.9rem; }
.option-check input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.option-select-wrap { display: flex; align-items: center; gap: 8px; font-weight: bold; font-size: 0.9rem; }
.option-select-wrap select { background: rgba(255,255,255,0.2); color: inherit; border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; padding: 4px 8px; cursor: pointer; }
.option-select-wrap select option { background: #fff; color: #333; }

/* =========================================
   💡 アナログ時計（円を消す修正）
   ========================================= */
/* 💡 変更：display:none をここから外しました。
   表示・非表示は JS が hidden 属性で切り替えます（下の [hidden] 指定を参照）。
   表示中は .clock-zone の display:flex が効きます（中身はすべて絶対配置のため影響なし）。 */
.analog-display {
    position: relative; width: 320px; height: 320px;
    border: none; /* ← 円の枠線を削除 */
    border-radius: 50%;
}
.analog-display::before, .analog-display::after { display: none; }

.analog-date-window {
    position: absolute; top: 50%; right: 18%; transform: translateY(-50%);
    font-size: 1rem; font-weight: bold; color: inherit; padding: 2px 8px;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); border-radius: 4px; z-index: 2;
}

/* 針（画面サイズに合わせて伸縮するパーセント指定に変更） */
/* 💡 修正：針が白（#fff）固定だったため、背景が明るい「サクラ」テーマや
   オリジナルカラーで白系の背景を選ぶと、針が背景に溶けて見えませんでした。
   文字色（currentColor）に合わせることで、どのテーマでも見えるようにします。 */
.hand { position: absolute; bottom: 50%; left: 50%; transform-origin: bottom; background: currentColor; border-radius: 4px; z-index: 10; }
.hour-hand { width: 2.5%; height: 26%; margin-left: -1.25%; background: currentColor; }
.min-hand  { width: 1.5%; height: 38%; margin-left: -0.75%; background: currentColor; opacity: 0.8; }
.sec-hand  { width: 0.6%; height: 42%; margin-left: -0.3%; background: #f87171 !important; z-index: 11; }
.center-dot { position: absolute; top: 50%; left: 50%; width: 5%; height: 5%; background: #f87171; border-radius: 50%; transform: translate(-50%, -50%); z-index: 12; }

/* 動的目盛り（これも画面サイズに合わせて伸縮） */
.analog-markings-layer { position: absolute; width: 100%; height: 100%; top: 0; left: 0; z-index: 1; }
.analog-wrapper { position: absolute; width: 100%; height: 100%; top: 0; left: 0; }
.tick { position: absolute; left: 50%; transform: translateX(-50%); background: currentColor; }
.tick.thick { width: 1.5%; height: 5%; top: 3%; opacity: 0.9; }
.tick.thin { width: 0.6%; height: 3%; top: 4%; opacity: 0.5; }
.clock-number { position: absolute; left: 50%; font-weight: bold; display: flex; justify-content: center; align-items: center; color: inherit; }
.clock-number.hour-num { top: 12%; font-size: 1.6rem; }
/* 💡 修正：分の数字が水色固定だったため、明るいテーマでは薄くて読めませんでした。
   文字色を引き継ぎ、時の数字より控えめに見せるのは透明度で表現します。 */
.clock-number.min-num { top: 3%; font-size: 0.95rem; color: inherit; opacity: 0.7; }

/* 💡 全画面表示時の文字サイズの大幅自動拡大 */
/* 💡 修正：:fullscreen と :-webkit-full-screen を1つのセレクタにまとめて書くと、
   片方を知らないブラウザ（Firefox等）がその指定を「まるごと」無視してしまい、
   全画面にしても文字が大きくなりませんでした。ブラウザごとに分けて書きます。 */
#clock-fullscreen-target:fullscreen .clock-number.hour-num { font-size: 7vmin; top: 12%; }
#clock-fullscreen-target:-webkit-full-screen .clock-number.hour-num { font-size: 7vmin; top: 12%; }
#clock-fullscreen-target:fullscreen .clock-number.min-num { font-size: 3.5vmin; top: 2%; }
#clock-fullscreen-target:-webkit-full-screen .clock-number.min-num { font-size: 3.5vmin; top: 2%; }

/* =========================================
   デジタル時計・タイマー
   ========================================= */
.digital-display { font-size: 5.5rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 15px rgba(0,0,0,0.2); }
.date-display { font-size: 1.4rem; font-weight: bold; margin-bottom: 10px; }

/* タイマーボタン */
.timer-controls { margin-top: 25px; }
.timer-adj-group { display: flex; gap: 8px; justify-content: center; margin-bottom: 15px; }
.timer-adj-btn { padding: 8px 16px; border: 2px solid rgba(255,255,255,0.3); background: transparent; color: inherit; border-radius: 8px; cursor: pointer; font-weight: bold; }
.timer-action-group { display: flex; gap: 12px; justify-content: center; }
.timer-action-btn { padding: 12px 30px; border: none; border-radius: 50px; font-size: 1rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.2s; }
.timer-action-btn.start { background: #22c55e; color: #fff; }
.timer-action-btn.start:hover { background: #16a34a; }
/* 💡 追加：カウントダウン中（一時停止できる状態）のスタートボタン。
   これまでは JS が style.background を直接書き込んでいたため、
   インライン指定が :hover より強く、マウスを乗せても色が変わりませんでした。 */
.timer-action-btn.start.running { background: #f59e0b; }
.timer-action-btn.start.running:hover { background: #d97706; }
.timer-action-btn.reset { background: rgba(255,255,255,0.15); color: inherit; border: 2px solid rgba(255,255,255,0.3); }

/* =========================================
   全画面
   ========================================= */
#clock-fullscreen-target:fullscreen { padding: 80px; }
#clock-fullscreen-target:fullscreen .digital-display { font-size: 15vw; }
#clock-fullscreen-target:fullscreen .analog-display { width: 80vmin; height: 80vmin; }

/* 💡 擬似全画面（iPhone/iPad等）でも同様に拡大表示する */
#clock-fullscreen-target.pseudo-fullscreen { padding: 40px 20px; }
#clock-fullscreen-target.pseudo-fullscreen .digital-display { font-size: 14vw; letter-spacing: normal; }
#clock-fullscreen-target.pseudo-fullscreen .analog-display { width: 80vmin; height: 80vmin; }
#clock-fullscreen-target.pseudo-fullscreen .clock-number.hour-num { font-size: 7vmin; top: 12%; }
#clock-fullscreen-target.pseudo-fullscreen .clock-number.min-num { font-size: 3.5vmin; top: 2%; }

/* =========================================
   💡 追加：hidden 属性で隠すための指定
   ========================================= */
/* これらの要素は CSS 側で display:flex 等を持っているため、
   hidden 属性を付けただけでは隠れません。明示的に指定します。 */
.clock-zone[hidden],
.styled-analog-options[hidden],
.settings-group[hidden] {
    display: none;
}

/* 💡 追加：タブレット・iPad（〜768px）対応
   設定パネルとアナログ時計が横幅からはみ出していました */
@media (max-width: 768px) {
    .clock-container { padding: 35px 20px; min-height: 380px; }
    .digital-display { font-size: 3.5rem; letter-spacing: 3px; }
    .settings-row { gap: 14px; }
    .settings-select { min-width: 0; width: 100%; }
    .settings-group { width: 100%; }
    .settings-group.settings-actions { width: auto; }
    .color-pickers { flex-wrap: wrap; gap: 14px; }
    .styled-analog-options { flex-wrap: wrap; gap: 14px; justify-content: center; padding: 12px 16px; }
    .analog-display { width: 300px; height: 300px; }
    .timer-adj-group { flex-wrap: wrap; }
    .timer-action-group { flex-wrap: wrap; }
    .timer-action-btn { padding: 12px 24px; }
    /* 全画面時の hidden 指定も同じように効かせる（@media 内の上書き対策） */
    .clock-zone[hidden],
    .styled-analog-options[hidden],
    .settings-group[hidden] { display: none; }
}

/* スマホ対応 */
@media (max-width: 600px) {
    /* 💡 iPhone縦向きで桁があふれる不具合の対策：コンテナ余白と文字サイズ・字間を縮小 */
    .clock-container { padding: 30px 15px; }
    .digital-display { font-size: 2.5rem; letter-spacing: 2px; }
    .date-display { font-size: 1.1rem; }
    .mode-switch { flex-wrap: wrap; justify-content: center; }
    .btn-switch { padding: 8px 18px; }
    .analog-display { width: 280px; height: 280px; }
    .styled-analog-options { gap: 10px; padding: 10px; }
}

/* トースト通知 */
.clock-toast-area { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.clock-toast-msg { background: rgba(30, 41, 59, 0.9); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 0.9rem; font-weight: bold; opacity: 0; transform: translateX(20px); transition: all 0.3s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.clock-toast-msg.show { opacity: 1; transform: translateX(0); }