/*
 * CKEditor 5 で作成した本文（お知らせ・固定ページ等）を、管理画面の編集中と
 * 同じ見た目で公開ページに表示するためのスタイル。
 * 適用対象は .ck-content を付けた要素の中だけなので、他のページには影響しない。
 */

/* ---- 基本 ---- */
.ck-content {
    word-wrap: break-word;
    line-height: 1.8;
}

/* 左右寄せ（回り込み）にした画像は float するため、これが無いと本文の高さに
 * 画像が含まれず、白背景の枠（.content-section）から画像がはみ出して
 * 「背景が白くならない」状態になる */
.ck-content::after {
    content: "";
    display: block;
    clear: both;
}

.ck-content h2 {
    font-size: 1.5em;
    margin: 1.2em 0 0.5em;
}

.ck-content h3 {
    font-size: 1.25em;
    margin: 1.1em 0 0.5em;
}

.ck-content h4 {
    font-size: 1.1em;
    margin: 1em 0 0.5em;
}

.ck-content p {
    margin: 0 0 1em;
}

.ck-content ul,
.ck-content ol {
    margin: 0 0 1em;
    padding-left: 1.8em;
}

/* ---- 引用 ---- */
.ck-content blockquote {
    border-left: 5px solid #ccc;
    margin: 1em 0;
    padding: 0.5em 0 0.5em 1.2em;
    font-style: italic;
}

/* ---- 水平線・ページ区切り ---- */
.ck-content hr {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 1.5em 0;
}

.ck-content .page-break {
    page-break-after: always;
    position: relative;
    clear: both;
    padding: 1em 0;
}

.ck-content .page-break__label {
    display: none;
}

/* ---- 表（CKEditor は figure.table でラップして出力する） ---- */
.ck-content .table {
    margin: 1em auto;
    display: table;
}

.ck-content .table table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    height: 100%;
    border: 1px solid #808080;
}

.ck-content .table table td,
.ck-content .table table th {
    min-width: 2em;
    padding: 0.4em;
    border: 1px solid #808080;
}

.ck-content .table table th {
    font-weight: bold;
    background: rgba(0, 0, 0, 0.05);
}

/* エディタ側でセルに指定した背景色・罫線を打ち消さない */
.ck-content .table table td[style],
.ck-content .table table th[style] {
    background-color: inherit;
}

/* ---- 画像（figure.image） ---- */
.ck-content .image {
    display: table;
    clear: both;
    text-align: center;
    margin: 1em auto;
    max-width: 100%;
}

.ck-content .image img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    min-width: 50px;
}

.ck-content .image > figcaption {
    display: table-caption;
    caption-side: bottom;
    word-break: break-word;
    color: #333;
    background-color: #f7f7f7;
    padding: 0.6em;
    font-size: 0.85em;
    outline-offset: -1px;
}

.ck-content .image-style-block-align-left,
.ck-content .image-style-block-align-right {
    max-width: calc(100% - 1.5em);
}

.ck-content .image-style-align-left,
.ck-content .image-style-block-align-left {
    float: left;
    margin-right: 1.5em;
}

.ck-content .image-style-align-right,
.ck-content .image-style-block-align-right {
    float: right;
    margin-left: 1.5em;
}

.ck-content .image-style-block-align-right {
    margin-right: 0;
    margin-left: auto;
}

.ck-content .image-style-block-align-left {
    margin-left: 0;
    margin-right: auto;
}

.ck-content .image-style-side {
    float: right;
    margin-left: 1.5em;
    max-width: 50%;
}

.ck-content .image-inline {
    display: inline-flex;
    max-width: 100%;
    align-items: flex-start;
}

.ck-content .image-inline img {
    flex-grow: 1;
    flex-shrink: 1;
    max-width: 100%;
}

/* 画像リサイズ（%指定）を反映 */
.ck-content .image.image_resized {
    max-width: 100%;
    display: block;
    box-sizing: border-box;
}

.ck-content .image.image_resized img {
    width: 100%;
}

.ck-content .image.image_resized > figcaption {
    display: block;
}

/* ---- 動画・iframe 埋め込み（レスポンシブ） ---- */
.ck-content .media {
    clear: both;
    margin: 1em 0;
    display: block;
    min-width: 15em;
}

.ck-content iframe {
    max-width: 100%;
}

/* ---- チェックリスト（todoList） ---- */
.ck-content .todo-list {
    list-style: none;
    padding-left: 0;
}

.ck-content .todo-list li {
    margin-bottom: 5px;
    position: relative;
    padding-left: 1.6em;
}

.ck-content .todo-list li input[type="checkbox"] {
    position: absolute;
    left: 0;
    top: 0.35em;
}

/* ---- コード ---- */
.ck-content code {
    background-color: rgba(0, 0, 0, 0.06);
    padding: 0.15em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
}

.ck-content pre {
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1em;
    overflow-x: auto;
}

.ck-content pre code {
    background: none;
    padding: 0;
}

/* ---- 蛍光ペン（highlight） ---- */
.ck-content .marker-yellow { background-color: #fdfd77; }
.ck-content .marker-green  { background-color: #62f962; }
.ck-content .marker-pink   { background-color: #fc7899; }
.ck-content .marker-blue   { background-color: #72ccfd; }
.ck-content .pen-red       { color: #e71313; background-color: transparent; }
.ck-content .pen-green     { color: #128a00; background-color: transparent; }

/* ---- インデント ---- */
.ck-content[dir="ltr"] .ck-indent { margin-left: 2.5em; }

/* 「スタイル」ドロップダウン用のクラスは ck-custom-styles.css に定義してある
 * （管理画面のエディタ内でも同じ見た目にするため、そちらは
 *   CKEDITOR_5_CUSTOM_CSS 経由で編集画面にも読み込まれる） */

/* ---- スマホ ---- */
@media (max-width: 576px) {
    .ck-content .image-style-side,
    .ck-content .image-style-align-left,
    .ck-content .image-style-align-right {
        float: none;
        margin: 1em auto;
        max-width: 100%;
    }

    .ck-content .table {
        display: block;
        overflow-x: auto;
    }

    /* 縮小指定した画像はスマホだと小さくなりすぎて読めないため幅いっぱいに戻す
     * （例: 本文幅の50%指定 → PCで約395px、スマホでは約155pxにしかならない） */
    .ck-content .image.image_resized {
        width: 100% !important;
    }
}
