/* =================================================================
 * Page Specific Styles for Amidakuji (style.css)
 * ================================================================= */

/* --- 1. レイアウト --- */
.tool-results {
    display: flex;
    flex-direction: column;
}

.tool-results .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.tool-results .card-body>.h-100 {
    flex-grow: 1;
}

/* --- 2. あみだくじ専用スタイル --- */
.amida-container-wrapper {
    width: 100%;
    min-height: 480px; /* 300px から 480px に変更 */
    overflow-x: auto;      /* あみだくじが横にはみ出た場合、横スクロールできるようにする */
    overflow-y: hidden;    /* 縦スクロールは隠す */
    user-select: none;
    /* height: 100%; と position: relative; は削除 */
}

/* (★追加) 初期メッセージ表示エリアにも高さを確保 */
#initial-message-amida {
    min-height: 480px; /* 300px から 480px に変更 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.amida-svg-base {
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease;
}

.amida-svg-trace {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.amida-svg-base.dimmed {
    opacity: 0.3;
}

/* --- SVG要素のスタイル --- */
.amida-line {
    stroke: var(--bs-border-color);
    stroke-width: 3;
}

.amida-bridge {
    stroke: var(--bs-border-color);
    stroke-width: 3;
}

.amida-label {
    fill: var(--bs-body-color);
    font-size: 14px;
    font-weight: bold;
    text-anchor: middle;
    transition: all 0.3s ease;
    font-family: 'Noto Sans JP', sans-serif;
}

.amida-label-start {
    cursor: pointer;
}

.amida-label-start:hover {
    fill: var(--bs-primary);
}

.amida-trace-path {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 結果ラベルのハイライトアニメーション */
.amida-label-highlight {
    /* transform-boxとtransform-originを削除（iOSバグ回避のため） */
    animation: highlight-result 1.2s ease-out forwards;
}

@keyframes highlight-result {
    0% {
        font-size: 14px; /* 元のサイズ */
        fill: var(--bs-body-color);
    }
    30% {
        font-size: 21px; /* scale(1.5) の代用 */
        fill: #FFC107;
    }
    100% {
        font-size: 17px; /* scale(1.2) の代用 */
        fill: #FFC107;
    }
}


/* --- 3. 汎用コンポーネント --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1090;
    backdrop-filter: blur(3px);
}

/* --- 4. 行番号付きテキストエリア --- */
.line-numbered-textarea-wrapper {
    display: flex;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    background-color: var(--bs-body-bg);
}

.line-numbered-textarea-wrapper:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    z-index: 2;
}

.line-numbers {
    width: 45px;
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    text-align: right;
    padding: 0.375rem 0.5rem;
    font-family: var(--bs-body-font-family);
    font-size: 1rem;
    line-height: 1.5;
    border-right: 1px solid var(--bs-border-color);
    user-select: none;
    overflow: hidden;
    white-space: pre;
    flex-shrink: 0;
}

.line-numbered-textarea {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    resize: none;
    line-height: 1.5 !important;
    padding: 0.375rem 0.75rem;
    white-space: pre;
    overflow-y: scroll;
}

.line-numbered-textarea::-webkit-scrollbar {
    width: 8px;
}

.line-numbered-textarea::-webkit-scrollbar-thumb {
    background-color: var(--bs-secondary-bg);
    border-radius: 4px;
}

/* --- 5. Page Specific Overrides (index.phpからの移植) --- */
.amida-title-text {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.amida-desc-alert {
    max-width: 800px;
    font-size: 0.95rem;
}

.input-number-sm {
    width: 80px;
}

.preset-select-width {
    max-width: 180px;
}

/* =================================================================
 * Dark Mode Visibility Fix for Amida Lot (Additive Styles)
 * data-bs-theme="dark" が適用された際の視認性向上設定
 * ================================================================= */

/* --- 1. SVG (あみだくじ描画エリア) --- */
/* ダークモード時のあみだくじの線、文字、ラベルの配色調整 */
[data-bs-theme="dark"] text,
[data-bs-theme="dark"] .final-results text {
    fill: #f8f9fa !important; /* SVG内のテキストを明るい色に強制 */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); /* 暗い背景でも文字の輪郭をはっきりさせる */
}

/* 参加者名（開始テキスト）の配色 */
[data-bs-theme="dark"] .start-label {
    stroke: none; /* デフォルトのstroke設定を解除 */
    fill: #f8f9fa !important; /* 明るい文字色に */
}

/* 結果ラベル（終了ラベル）の配色 */
[data-bs-theme="dark"] .end-label {
    stroke: #f8f9fa !important; /* ラベルの枠線を明るい色に */
    fill: none; /* ラベル内部は透過（背景色のまま） */
}

[data-bs-theme="dark"] .start-text-btn:hover {
    font-weight: bold;
    fill: #f8f9fa !important;
}

/* あみだくじの「線」（縦線・横線）の配色 */
[data-bs-theme="dark"] .line {
    stroke: #f8f9fa !important; /* 明るいグレーに変更 */
    stroke-opacity: 0.9;
}

/* --- 2. 行番号付きテキストエリア --- */
/* ダークモード時の行番号（左側のグレー部分）の配色調整 */
[data-bs-theme="dark"] .line-numbers {
    background-color: var(--bs-dark-border-subtle) !important; /* 暗いグレーの背景 */
    border-right-color: var(--bs-border-color) !important;
    color: var(--bs-secondary-color) !important;
}

/* --- 3. その他 UI 要素 --- */
/* ローディングオーバーレイの背景を暗く */
[data-bs-theme="dark"] #loading-overlay {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

/* モード選択ボタンのホスト状態の配色調整（視認性確保） */
[data-bs-theme="dark"] #reset-all-btn,
[data-bs-theme="dark"] .tool-results .card-header .btn-outline-primary {
    color: var(--bs-secondary-color);
    border-color: var(--bs-secondary-color);
}
[data-bs-theme="dark"] #reset-all-btn:hover,
[data-bs-theme="dark"] .tool-results .card-header .btn-outline-primary:hover {
    background-color: var(--bs-secondary-bg) !important;
    color: #ffffff !important;
}

/* プリセット選択肢の配色調整（視認性確保） */
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .form-select option {
    background-color: #2b3035 !important; /* 暗い背景 */
    color: #f8f9fa !important;            /* 明るい文字色を強制 */
    border-color: #495057 !important;     /* 枠線も馴染むように調整 */
}

/* --- 4. 記事エリアの bg-*, text-* は Bootstrap の theme 機能に委ねる
   （bg-body-tertiary / 見出し継承を使用しているため、個別オーバーライド不要） --- */

/* --- スクロールバーの視認性向上 --- */
.amida-container-wrapper::-webkit-scrollbar {
    height: 8px;
}
.amida-container-wrapper::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg);
    border-radius: 4px;
}
.amida-container-wrapper::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-color);
    border-radius: 4px;
}
[data-bs-theme="dark"] .amida-container-wrapper::-webkit-scrollbar-thumb {
    background: var(--bs-gray-600);
}

/* --- 横スクロール常駐ヒントのスタイル（シンプル・通常配置） --- */
.amida-persistent-hint {
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    animation: fadeInHint 0.5s ease-in;
    /* 絶対配置や背景色などは使用しません */
}

/* アイコンを左右に小さく揺らすアニメーション */
.hint-arrow-anim {
    display: inline-block;
    animation: arrow-slide-horizontal 2s infinite ease-in-out;
}

@keyframes arrow-slide-horizontal {
    0% { transform: translateX(0); opacity: 0.7; }
    50% { transform: translateX(3px); opacity: 1; }
    100% { transform: translateX(0); opacity: 0.7; }
}

@keyframes fadeInHint {
    from { opacity: 0; }
    to { opacity: 1; }
}