/*
 * CMS — assets/css/styles.css
 *
 * 流用の目安:
 * - 「公開コンポーネント」… クライアントサイトに貼るスニペットと一緒にそのまま使いやすい（BEM 接頭辞で衝突しにくい）。
 * - 「ページ枠・デモ用」… index プレビューや管理画面の外枠。既存サイトの body / レイアウトと競合する場合は省略・差し替え可。
 * - 「管理画面」… admin 専用。公開ページには不要なら読み込まなくてよい。
 */

/* =============================================================================
   デザイントークン（:root）
   色・余白・影など。公開コンポーネントも参照する。
   ============================================================================= */
:root {
    --bg-main: #f3f8ff;
    --bg-panel: #ffffff;
    --bg-muted: #eff4fb;
    --color-primary: #3a6ce1;
    --color-accent: #f5b700;
    --color-text: #1f2a44;
    --color-text-light: #6f7b97;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --shadow-lg: 0 32px 60px rgba(40, 78, 162, 0.12);
    --shadow-md: 0 16px 40px rgba(40, 78, 162, 0.1);
    --shadow-sm: 0 6px 20px rgba(40, 78, 162, 0.08);
    --transition-base: 0.3s ease;
    --transition-fast: 0.2s ease;
    --max-width: 1080px;
}

/* =============================================================================
   ベース・リセット（要素一般）
   body 以外はユニバーサルセレクタと要素タグのみ。
   ============================================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* -----------------------------------------------------------------------------
   ページ全体（body）
   既存サイトへ組み込む場合、フォント・背景はサイト側に合わせて上書きしてよい。
   ----------------------------------------------------------------------------- */
body {
    margin: 0;
    font-family: 'Noto Sans JP', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

/* =============================================================================
   ページ枠・デモ用レイアウト
   .layout / .header / .panel / .preview-grid / .btn
   公開スニペット単体では不要なブロックが多い。
   ============================================================================= */
.layout {
    width: min(var(--max-width), 100%);
    margin: 0 auto;
    padding: 32px clamp(16px, 4vw, 48px) 64px;
    display: grid;
    gap: 32px;
}

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.header__title {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 700;
}

.header__status {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #e6eeff;
    color: var(--color-primary);
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
}

.header__nav {
    display: flex;
    gap: 12px;
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 3vw, 32px);
    box-shadow: var(--shadow-lg);
}

.panel__title {
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    font-weight: 700;
    margin-bottom: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 600;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

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

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: rgba(31, 42, 68, 0.08);
}

.preview-grid {
    display: grid;
    gap: clamp(24px, 4vw, 40px);
}

/* =============================================================================
   公開コンポーネント — カルーセル部分
   .content-carousel … スニペット carousel.html / both.html と対応。
   ============================================================================= */
.content-carousel {
    background: linear-gradient(180deg, #edf3ff 0%, #f7faff 100%);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 4vw, 36px);
    display: grid;
    gap: 24px;
    position: relative;
}

.content-carousel__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.content-carousel__title {
    font-size: clamp(1.2rem, 2.8vw, 1.8rem);
    font-weight: 700;
}

.content-carousel__meta {
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.content-carousel__viewport {
    position: relative;
    overflow: hidden;
    border-radius: clamp(18px, 3vw, 24px);
    background: #dfe7f8;
    height: clamp(220px, 36vw, 360px);
    box-shadow: var(--shadow-md);
}

.content-carousel__track {
    display: flex;
    transition: transform 0.5s ease;
    height: 100%;
}

.content-carousel__slide {
    min-width: 100%;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.content-carousel__img {
    background: #c1cce6;
}

.content-carousel__body {
    display: grid;
    gap: 16px;
    background: #fff;
    padding: clamp(20px, 3vw, 28px);
}

.content-carousel__body h3 {
    margin: 0;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    line-height: 1.5;
}

.content-carousel__body p {
    margin: 0;
    color: var(--color-text-light);
}

.content-carousel__cta {
    justify-self: start;
    background: var(--color-primary);
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
}

.content-carousel__nav {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.content-carousel__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(58, 108, 225, 0.25);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.content-carousel__dot.is-active {
    background: var(--color-primary);
    transform: scale(1.2);
}

.content-carousel__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-sm);
    color: var(--color-primary);
}

.content-carousel__arrow[data-direction="prev"] {
    left: 18px;
}

.content-carousel__arrow[data-direction="next"] {
    right: 18px;
}

/* =============================================================================
   公開コンポーネント — リスト部分（お知らせ一覧）
   .content-list / .content-card … スニペット news-list.html / both.html と対応。
   ============================================================================= */
.content-list {
    display: grid;
    gap: 18px;
}

.content-card {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 18px;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.content-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.content-card__media {
    background: #d0daf0;
}

.content-card__body {
    padding: 16px 22px;
    display: grid;
    gap: 8px;
}

.content-card__title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 700;
}

.content-card__meta {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.content-card__excerpt {
    margin: 0;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

/* 空状態（カルーセル・一覧のプレースホルダ。公開・管理の両方で使用） */
.empty-state {
    padding: 24px;
    border-radius: var(--radius-md);
    background: rgba(58, 108, 225, 0.08);
    color: var(--color-text-light);
    text-align: center;
}

/* =============================================================================
   管理画面 — エディタフォーム・ツールバー（従来 .editor ブロック）
   editor.html のフィールド・ツールバー・旧 contenteditable 用。
   ============================================================================= */
.editor {
    display: grid;
    gap: 24px;
}

.editor__form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-weight: 600;
}

.field input,
.field select {
    border: none;
    background: var(--bg-muted);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.field__hint {
    margin: 0;
    color: var(--color-text-light);
    font-size: 0.85rem;
}

.editor__thumb-preview {
    width: min(280px, 100%);
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    box-shadow: inset 0 0 0 1px rgba(58, 108, 225, 0.12);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.toolbar button {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(31, 42, 68, 0.05);
    font-size: 0.85rem;
    transition: background var(--transition-fast);
}

.toolbar button:hover {
    background: rgba(31, 42, 68, 0.12);
}

.editor__body {
    min-height: 220px;
    padding: 20px;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(58, 108, 225, 0.08);
    overflow-y: auto;
}

.editor__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

/* トースト（管理画面の通知。任意で公開側にも流用可） */
.status-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 22px;
    background: #1c7c54;
    color: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.status-toast.is-show {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================================================
   レスポンシブ（カルーセル・カード・エディタ操作）
   ============================================================================= */
@media (max-width: 960px) {
    .content-card {
        grid-template-columns: 72px 1fr;
    }
}

@media (max-width: 720px) {
    .content-carousel__viewport {
        height: auto;
        min-height: 240px;
    }

    .content-carousel__body {
        padding: 18px;
    }

    .content-carousel__arrow {
        display: none;
    }

    .content-card {
        grid-template-columns: 1fr;
    }

    .content-card__media {
        height: 140px;
    }

    .editor__actions {
        justify-content: stretch;
    }

    .editor__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================================================
   管理画面 — 投稿一覧（タブ・行メニュー）
   admin/both 等の一覧画面専用。
   ============================================================================= */
.tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(31, 42, 68, 0.1);
    padding-bottom: 8px;
}

.tab-bar__item {
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--bg-muted);
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
}

.tab-bar__item.is-active {
    background: var(--color-primary);
    color: #fff;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.post-list-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.post-list {
    display: grid;
    gap: 12px;
}

.post-row {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
}

.post-row__thumb-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 80px;
    background: #d0daf0;
}

.post-row__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-row__title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
}

.post-row__status {
    display: inline-block;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 999px;
}

.post-row__status--published {
    background: #d4edda;
    color: #155724;
}

.post-row__status--draft {
    background: #fff3cd;
    color: #856404;
}

.post-row__menu summary {
    list-style: none;
    cursor: pointer;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: #fff;
}

.post-row__menu summary::-webkit-details-marker {
    display: none;
}

.post-row__dropdown {
    position: absolute;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    z-index: 20;
    padding: 8px;
    display: grid;
    gap: 4px;
}

.post-row__menu {
    position: relative;
}

.post-row__dropdown-item {
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.post-row__dropdown-item:hover {
    background: var(--bg-muted);
}

.post-row__dropdown-item--danger {
    color: #c0392b;
}

/* 管理画面 — エディタページ（sticky アクションバー・本文・ツールバー） */
.editor-page {
    display: grid;
    gap: 0;
    min-height: 100vh;
}

.editor-page .panel {
    border-radius: 0;
    box-shadow: none;
}

.editor__actions--sticky {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 0;
    background: var(--bg-panel);
    border-bottom: 1px solid rgba(31, 42, 68, 0.08);
}

.editor__actions--sticky .editor__actions-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.editor__scroll {
    padding-bottom: 120px;
}

#editorToolbar {
    position: sticky;
    bottom: 0;
    z-index: 25;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: var(--bg-panel);
    border-top: 1px solid rgba(31, 42, 68, 0.08);
}

.editor__textarea {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical;
    font-family: ui-monospace, monospace;
}

.editor__body-wrap {
    min-height: 200px;
}

/* 管理画面 — 確認モーダル（プレビュー・投稿する） */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.confirm-overlay.is-open {
    display: flex;
}

.confirm-modal {
    position: relative;
    width: 88%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.confirm-modal__card {
    position: relative;
    padding: 20px;
    padding-top: 48px;
}

.confirm-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-muted);
    font-size: 1.2rem;
    line-height: 1;
}

.confirm-modal__preview {
    margin-bottom: 16px;
}

.confirm-modal__submit-wrap {
    position: sticky;
    bottom: 0;
    padding-top: 12px;
    background: linear-gradient(180deg, transparent, #fff 30%);
}

/* モーダル内プレビュー用（公開カルーセルと同系。高さのみ調整） */
.content-carousel--modal .content-carousel__viewport {
    height: clamp(200px, 40vw, 320px);
}

/* 公開側 — 記事詳細ページ */
.article-detail {
    display: grid;
    gap: 16px;
}

.article-detail__meta {
    margin: 0;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.article-detail__title {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.4;
}

.article-detail__thumb {
    width: 100%;
    max-height: 420px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.article-detail__body {
    color: var(--color-text);
}

.article-detail__body :is(h1, h2, h3, h4) {
    margin-top: 1.3em;
}