/* 1. bodyのスクロールバーを消し、画面いっぱいの高さに固定する */
/* 1. bodyのスクロールバーを消し、100%に固定 */
html, body {
 /*   height: 100%;   */
/*    overflow: hidden; */
    display: flex;
    flex-direction: column;
}

/* 2. containerも100%に広げる */
/* デフォルト（共通設定） */
#container {
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

/* 単体で開いたときのスタイル */
.standalone-mode {
    width: 80vw; /* 80%の幅で見やすく */
}

/* index.html に埋め込まれたときのスタイル */
.embedded-mode {
    width: 100%; /* 親のデザインに合わせて広げる */
}

/* 3. ナビゲーションバーは縮まないように固定 
nav {
    position : sticky;
    top : 0;
    border-radius : 10px;
}
*/

/* 4. main要素（中身）だけを独立してスクロールさせる */
#main__blog {
    flex-grow: 1;      /* 残りの高さをすべて使う */
/*    overflow-y: auto;    縦スクロールをここに持たせる */
    box-sizing: border-box;
}

/* ボタンの名称表示位置を常に真ん中に揃える */
body button {
   
}

/* mainにつけたmodeに応じてボタンの表示・非表示を切り替える */

#container[data-mode='list'] #listBtn{
      background-color : gray;
      color : white;
      pointer-events: none;
}

/* Editor basic styles */

#editBtn{
    white-space : nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
}

#view-editor:not('hidden') {
    /*将来ここでなにか設定するかも、しないかも */
    overflow-y: scroll;
 }

.editor-content {
    height : 100%; /*高さをめいいっぱい伸ばしたい */
    min-height: 450px;
    border: 1px solid #ddd;
    padding: 1.5rem;
    border-radius: 0.5rem;
    background: white;
    line-height: 1.8;
}

.editor-content:focus {
    outline: 2px solid #3b82f6;
    border-color: transparent;
}

/* Images in editor */
.editor-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* *******************************************
     toolbar
*********************************************/

#toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    /* 背景色を不透明にして、背後にスクロールした文字が透けないようにする */
    background-color: #f9fafb; /* bg-gray-50 と同色 */
    /* 固定時の視認性を上げるために影をつける */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#toolbar span{
    white-space : nowrap;
}

#toolbar .partition {
    flex : 1 1 0;
    display : flex;
    flex-direction : row;
    justify-content : space-between;
    column-gap : min(1rem, 5%);
}

/* Responsive design */
@media screen and (max-width : 767px) and (orientation: portrait){
    #toolbar {
        flex-direction : column;
	row-gap : 2px;
    }

    #toolbar .partition{
	flex: 0 0 100%;
	column-gap : 2px;
    }

     #toolbar  .partition{
	 justify-content : flex-start;
     }

    #toolbar .partition--fe button{
	padding : 2px 1rem;
    }
}


/* Post detail view */
#post-display-content{
    overflow-wrap: break-word; /*文字のはみ出し禁止 */
}

/* Modal background */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal.active {
    display: flex;
}

/*記事ないの画像のクラス*/
.postimg{
    margin: 10px 0px;
}

/* Toast message animation */
@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.toast-msg {
    animation: slideUp 0.3s ease-out;
    transition: opacity 0.5s ease;
}

/* Thumbnail crop settings */
.thumb-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* updateの表示 */

.update_p {
    display : none;
}

#post-display-update{
    display : none;
}

/* Post Detail View の記事一覧に戻るの表示 */

/* 1. コンテナ自体が画面からはみ出さないようにし、中身のスクロールを管理する */
#view-post:not(.hidden) {
    display: flex;
    flex-direction: column;
    height: 100%; /* 修正: mainの高さ100%に合わせる */
    overflow: hidden; 
}

/* 3. article部分だけをスクロール可能にする */
#view-post article {
    flex-grow: 1; /* 残りのスペースを全て使う */
    overflow-y: auto; /* ここだけスクロールさせる */
    padding: 2rem; /* 読みやすい余白 */
    box-sizing: border-box;
}

/* a Tag */
.linkInPost{
    color : blue;
    transition : 0.5s;
}

.linkInPost:hover{
/*	font-size : 1.5rem;  対して効果的でないので無効化 */
}

/* Draft */

#draft{
    border : 1px solid red;
    overflow : hidden;
    display : flex;
    flex-direction : column;
    gap : 2px;
    width : 100%;
    height : auto;
}

/* 記事の一時保管ファイル一覧から記事を削除するためのボタン等 */
.list-item-container{
    width : 100%;
    height : auto;
    display : flex;
    flex-direction : row;
    border : 1px #aaaaaa solid;
    border-radius : 5px;
    overflow : hidden;
 }

.listItem{
    display : flex;
    flex-direction : row;
    padding : 1rem;
    flex : 4 1 95%;
    overflow : hidden;
    cursor : pointer;
}

.killbtn{
    display : flex;
    flex-direction : row;
    justify-content : center;
    align-items : center;
    width : 1%;
    min-width : 2rem;
    background-color : red;
    overflow : hidden;
    transition : 0.5s;
}
    
.killbtn button{
    display: flex;
    justify-content: center;
    align-items: center;
    color : red;
    overflow : hidden;
    font-weight : 600;
}

.killbtn:hover {
    width : 10%;
}

.killbtn:hover  button{
	color : white;
}

/* 不活性化したボタンの表示 */
button:disabled{
    background-color : gray;
    color : white;
    cursor : defult;
}

/* btnwrapper */
#div__btnwrapper{
}

/* Administrator buttons */

#adminBtn{
    display : flex;
    flex-direction : row;
    column-gap : 1rem;
    justify-content : flex-end;
    align-items : center;
    width : 1rem;
    min-width : 1rem;
    background-color : #2563eb; 
    overflow : hidden;
    transition : 0.5s;
    border : 0px solid transparent;
    border-radius : 5px;
}
    
#adminBtn button{
    color : #2563eb;
    overflow : clip;
    font-weight : 600;
    white-space : nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action : none;
    user-select : none;
    -webkit-user-select : none;
}

/* ***********************************/

/* PCでのホバー、またはスマホでのタップ（フォーカス）で展開 */
#adminBtn:hover,
#adminBtn:focus-within {
    width : 25%;
    background-color : white;
}

#adminBtn:hover button,
#adminBtn:focus-within button {
    color : white;
}

/* スマホ用のメディアクエリ内も同様に */
@media screen and (max-width : 767px) and (orientation: portrait){
    #adminBtn:hover,
    #adminBtn:focus-within {
        width : 50%; /* ボタンが3つあるので、文字切れに注意してください */
    }
}

/* Extendable Button Group */

.btn-container{
    background-color : gray;
    border : 1px solid blue;
    border-radius : 5px;
    overflow : clip;
    display : flex;
    flex-direciton : row;
    justify-content  : space-between;
    align-items : center;
    padding : 0;
}

.btn-container   button{
	border-radius : 5px;
	overflow : clip;
	white-space : nowrap;
/*	border : 1px solid white; */
	flex : 1 0 auto;
	display: flex;
	justify-content: center;
	align-items: center;
}

.btn-container span{
    flex : 3 0 70%;
}

.btn-group{
    padding : 1px 1rem;
    width : fit-content;
    display : flex;
    flex : 2 0 auto;
    flex-direction : row;
    column-gap : 2rem;
    justify-content : space-between;
    background-color : skyblue;
    border : 0px solid transparent;
    border-radius : 5px;
}

.btn-group--extend{
    padding : 1px 1rem;
    width : 1%;
    display : flex;
    flex : 0 0 auto;
    flex-direction : row;
    column-gap : 1rem;
    background-color : red;
    border : 0px solid transparent;
    border-radius : 5px;
    overflow : clip;
    transition : 1s ease-in;
    flex-wrap : nowrap;
    justify-content : space-between;
}

.btn-group--extend btn-group{
    background-color : red;
}

.btn-group--extend button{
    color :red;
    overflow : hidden;
}

.btn-group--extend:hover{
    width : 15%;
}

 .btn-group--extend:hover button{
	color :white;
}

 /* blognavのタイトル部分のflex割合の指定  */

 #div__topmenu{
     justify-content : flex-end;
     flex : 0 1 45%;
 }

.flex--3-0-50{
    flex : 0 1 50%;
}

.video-icon-inline {
  width: 50px;
  height: 50px;

  /* SVGコードを直接埋め込み */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='100' height='100' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2' ry='2' /%3E%3Cpolygon points='10,8 16,12 10,16' /%3E%3C/svg%3E");
  
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Responsive design */
@media screen and (max-width : 767px) and (orientation: portrait){
    #container {
        width : 100%;
    }
    
    #blognav{
        flex-direction : row;
        align-items : center;
        padding : 0 0;
        flex-wrap : wrap;
    }
    
    #titleBox{
        flex : 0 0 100%;
	display : none;
    }
    
    #div__topmenu{
        max-width : 100%;
        justify-content : flex-start;
        flex : 1 1 20%;
	margin : 5px 0;
    }

    #div__topmenu button{
        white-space : nowrap;
        flex : 0 1 auto;
    }

    #reloadBtn{
        display : none;
    }

    #adminBtn:hover,#adminBtn:focus-within {
        width : 50%; /* ボタンが3つあるので、文字切れに注意してください */
    }
    
    #adminBtn button{
        white-space : nowrap;
    }

    #adminBtn:hover button{
        color : white;
    }

    .killbtn:hover {
	width : 20%;
    }
    
    /* 💡 Post Log Viewer 用の設定を、正しくスマホ用の@mediaの中に移動します */
    #log-nav{
        flex-direction : column; /* スマホ時は縦並びに */
    }

    #log-list{
        width : 100%; /* スマホ時のみ、幅を100%にして全幅表示にする */
    }
    
    #view-chart{
        height : auto;
    }
} 

/*------- Auth-modal ----------- */

#auth-modal{
    z-index : 2000;
}


/* --- 横並び画像プレースホルダー用のスタイル --- */
.image-placeholder-container {
    display: flex;
    gap: 1rem;
    width: 100%;
    margin: 1rem 0;
}

.image-placeholder-box {
    flex: 1;
    border: 2px dashed #d1d5db; /* 点線枠 */
    background-color: #f9fafb;
    min-height: 150px; /* ドロップしやすいように最低限の高さを確保 */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* 画像がはみ出た部分をカット */
    cursor: pointer;
}

/* ① CSSで案内テキストを表示する（HTML内には文字データを持たない） */
.image-placeholder-box::before {
    content: "画像を挿入できます";
    color: #9ca3af;
    font-size: 0.9rem;
    pointer-events: none; /* テキストがクリックの邪魔をしないようにする */
    text-align: center;
    padding: 1rem;
}

/* ② 画像 (img) が中に入ったときの状態変化（ :has() を使用 ） */
.image-placeholder-box:has(img) {
    border: none; /* 画像が入ったら点線枠を消す */
    background-color: transparent;
}

/* ③ 画像 (img) が中に入ったら、案内テキストを消去する */
.image-placeholder-box:has(img)::before {
    display: none;
}

/* ④ 挿入された画像を枠いっぱいに広げる */
.image-placeholder-box img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 縦横比を保ちつつ、枠を埋め尽くす */
    display: block;
}

/* スマホ時の強制リセット */
@media screen and (max-width: 767px) {
    /* 画面全体を横幅に収める */
    html, body {
        overflow-x: hidden;
        width: 100vw;
    }

    #container {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* はみ出しの原因となる要素の固定幅をリセット */
    #adminBtn, .killbtn, .btn-group--extend {
        transition: none !important;
        width: auto !important;
        min-width: 0 !important;
    }

    /* 記事一覧の幅を強制的に画面内に収める */
    #blog-list {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0 10px !important;
    }

    /* ページネーション全体を折り返し可能にし、中央寄せにする */
    #pagination-controls {
        flex-wrap: wrap; /* 画面幅が足りない時にボタンを折り返す */
        justify-content: center;
        gap: 0.5rem;    /* ボタン間の隙間を調整 */
        padding: 0 10px;
    }

    /* ボタンが長すぎてはみ出すのを防ぐ */
    #pagination-controls button {
        min-width: 2rem; /* 最小幅を確保 */
        padding: 0.5rem;
    }
}
