/* =============================================================================
 * メッセージカード機能 共通スタイル
 *   - 申込フォームの受け取りトグル（.mc-toggle）
 *   - カード本体（画像＋テキスト重ね）（.msgcard）… 一覧・拡大・プレビューで共通
 *   - 会場マップの送信ダイアログ（.mc-modal-*, .mc-card-options, .mc-preview）
 *   - 受信一覧（.mc-received-*）／拡大表示（.mc-lightbox）
 *   - 贈った一覧（.mc-sent-*）／ページネーション（.mc-pagination）
 *
 * カード画像は幅1000px・高さ750px で統一。テキストは画像ごとの領域内に上下左右中央配置。
 * 文字サイズは画像幅に対して一定（CSS container query 単位 cqw）になるよう定義し、
 * PC・スマホで見た目の比率が変わらないようにする。
 * ========================================================================== */

/* -------------------------------------------------------------------------
 * カード本体（画像＋テキスト重ね）
 * ---------------------------------------------------------------------- */
.msgcard {
    position: relative;
    width: 100%;
    aspect-ratio: 1000 / 750;
    container-type: inline-size; /* cqw を msgcard 幅基準にする */
    border-radius: 8px;
    overflow: hidden;
    background: #f4f4f4;
}
.msgcard__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.msgcard__text {
    position: absolute;
    /* 画像ごとの表示領域（インラインの CSS 変数で指定。既定は中央寄りの安全値） */
    left: var(--mc-l, 20%);
    top: var(--mc-t, 33%);
    width: var(--mc-w, 60%);
    height: var(--mc-h, 34%);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    box-sizing: border-box;
}
.msgcard__text-inner {
    /* 画像幅基準の一定サイズ（端末非依存）。座標は後調整前提のため控えめに。
       cqw 非対応の旧ブラウザ向けに、まず可読な固定値→対応ブラウザは cqw で上書き。 */
    font-size: 16px;
    font-size: 4.4cqw;
    line-height: 1.4;
    color: #3a3a3a;
    font-weight: 700;
    /* 右端に達したら問答無用で改行（長い英字列も途中で折り返す）。
       overflow-wrap だと長い単語が単語境界まで折り返されず行数が増えるため break-all を使う。 */
    word-break: break-all;
    max-height: 100%;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.55);
}

/* -------------------------------------------------------------------------
 * 受け取りトグル（申込フォーム）
 * ---------------------------------------------------------------------- */
.mc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.mc-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.mc-toggle__track {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    background: #c4c8cf;
    border-radius: 999px;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.mc-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}
.mc-toggle input:checked + .mc-toggle__track {
    background: #2e9e6b;
}
.mc-toggle input:checked + .mc-toggle__track .mc-toggle__thumb {
    transform: translateX(20px);
}
.mc-toggle input:focus-visible + .mc-toggle__track {
    outline: 2px solid #2e9e6b;
    outline-offset: 2px;
}
.mc-toggle__text {
    font-size: 14px;
}

/* -------------------------------------------------------------------------
 * 受信件数バッジ（控えめ）
 * ---------------------------------------------------------------------- */
.mc-badge {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 6px;
    margin-left: 4px;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    color: #555;
    background: #e7e9ee;
    border-radius: 999px;
    vertical-align: middle;
}

/* -------------------------------------------------------------------------
 * 会場マップ：送信ボタン（お品書きダイアログ最上部）
 * ---------------------------------------------------------------------- */
.mc-send-btn-wrap {
    margin: 0 0 12px;
}
.mc-send-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: #8BC34A;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.mc-send-btn:hover {
    background: #7cb342;
}

/* -------------------------------------------------------------------------
 * 会場マップ：送信ダイアログ
 * ---------------------------------------------------------------------- */
.mc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10002; /* お品書きモーダルより前面 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.mc-modal-box {
    background: #fff;
    color: #222;
    padding: 18px;
    border-radius: 10px;
    max-width: 520px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
}
.mc-modal-title {
    margin: 0 0 6px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mc-modal-sub {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
}
.mc-modal-count {
    margin: 0 0 12px;
    font-size: 13px;
    color: #666;
}

/* カード選択（横3列×縦2行） */
.mc-card-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.mc-card-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: 2px solid #e2e5ea;
    border-radius: 8px;
    cursor: pointer;
    background: #fafbfc;
}
.mc-card-option.is-selected {
    border-color: #8BC34A;
    background: #f1f8e9;
}
.mc-card-option__radio {
    margin: 0;
}
.mc-card-option__img {
    width: 100%;
    aspect-ratio: 1000 / 750;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.mc-field-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 10px 0 4px;
}
.mc-message-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    font-family: inherit;
    font-size: 14px;
    border: 1px solid #c4c8cf;
    border-radius: 6px;
    resize: vertical;
}
.mc-message-counter {
    text-align: right;
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.mc-preview {
    max-width: 360px;
    margin: 4px auto 0;
}
.mc-modal-result {
    min-height: 1.3em;
    margin-top: 10px;
    font-size: 13px;
    color: #444;
}
.mc-modal-result--ok { color: #0a7a4b; }
.mc-modal-result--err { color: #c0392b; }

.mc-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}
.mc-btn {
    padding: 8px 18px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
}
.mc-btn--cancel {
    background: #eef0f3;
    border-color: #d4d8de;
    color: #333;
}
.mc-btn--send {
    background: #8BC34A;
    color: #fff;
}
.mc-btn--send:disabled {
    opacity: 0.6;
    cursor: default;
}

/* -------------------------------------------------------------------------
 * 受信一覧（自分の申込 > メッセージカード）
 * ---------------------------------------------------------------------- */
.mc-received-context {
    font-size: 14px;
    color: #555;
    margin: 0 0 12px;
}
.mc-received-context__event { color: #777; }
.mc-received-context__sep { margin: 0 6px; color: #aaa; }
.mc-received-context__booth { font-weight: 700; color: #333; }

/* イベント名リンク（受信一覧・贈った一覧 共通。リンクと分かるよう下線） */
.mc-event-link {
    color: #2e6f9e;
    text-decoration: underline;
}
.mc-event-link:hover { color: #1f527a; }

.mc-showhidden-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
    margin-bottom: 14px;
    cursor: pointer;
}

.mc-received-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* PC 4列 */
    gap: 14px;
}
@media (max-width: 768px) {
    .mc-received-grid {
        grid-template-columns: repeat(2, 1fr); /* スマホ 2列 */
        gap: 10px;
    }
}
.mc-received-item {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.mc-received-item:hover,
.mc-received-item:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
    outline: none;
}
.mc-received-item.is-hidden-card {
    opacity: 0.55;
}
.mc-received-item__tag {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 11px;
    padding: 2px 6px;
    color: #fff;
    background: rgba(60, 60, 60, 0.78);
    border-radius: 4px;
}

/* 拡大表示ライトボックス */
.mc-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.mc-lightbox__box {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    max-width: 640px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
}
.mc-lightbox__card {
    max-width: 600px;
    margin: 0 auto;
}
/* 拡大表示の送信者情報（アバター＋名前＋ユーザーコード＋受信日時） */
.mc-lightbox__sender {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 600px;
    margin: 12px auto 0;
    text-align: left;
}
.mc-lightbox__avatar {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #eee;
}
/* アバターは 3列×4行スプライト。AvatarPreview が canvas を差し込みアニメーション描画する。 */
.mc-lightbox__avatar canvas {
    display: block;
    width: 48px;
    height: 48px;
}
.mc-lightbox__sender-info { min-width: 0; }
.mc-lightbox__sender-name { font-weight: 700; font-size: 14px; word-break: break-word; }
.mc-lightbox__sender-code { font-size: 12px; color: #888; word-break: break-all; }
.mc-lightbox__sender-date { font-size: 12px; color: #888; }
.mc-lightbox__result {
    min-height: 1.2em;
    text-align: center;
    font-size: 13px;
    color: #444;
    margin-top: 8px;
}
.mc-lightbox__result--err { color: #c0392b; }
.mc-lightbox__actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 14px;
}
/* 操作ボタンは目立たせない（控えめ） */
.mc-light-btn {
    padding: 6px 14px;
    font-size: 13px;
    color: #666;
    background: #f1f2f5;
    border: 1px solid #d8dbe0;
    border-radius: 6px;
    cursor: pointer;
}
.mc-light-btn:hover { background: #e7e9ee; }
.mc-light-btn--danger { color: #b23b3b; }
.mc-light-btn--close { color: #333; }
.mc-light-btn:disabled { opacity: 0.6; cursor: default; }

/* -------------------------------------------------------------------------
 * 贈った一覧（イベント > 贈ったメッセージカード）
 * ---------------------------------------------------------------------- */
.mc-sent-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.mc-sent-item {
    padding: 12px 4px;
    border-bottom: 1px solid #ececec;
}
.mc-sent-item__meta {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}
.mc-sent-item__arrow { margin: 0 8px; color: #aaa; }
.mc-sent-item__booth { font-weight: 700; color: #333; }
.mc-sent-item__event.is-deleted,
.mc-sent-item__booth.is-deleted { color: #aa6; font-style: italic; font-weight: normal; }
.mc-sent-item__date {
    font-size: 12px;
    color: #999;
    margin-left: 8px;
    white-space: nowrap;
}
.mc-sent-item__message {
    font-size: 14px;
    color: #222;
    white-space: normal;
    word-break: break-word;
}

/* -------------------------------------------------------------------------
 * ページネーション（受信一覧・贈った一覧 共通）
 * ---------------------------------------------------------------------- */
.mc-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}
.mc-pagination__link {
    padding: 6px 14px;
    font-size: 14px;
    color: #2e6f9e;
    border: 1px solid #cdd6e0;
    border-radius: 6px;
    text-decoration: none;
}
.mc-pagination__link:hover { background: #eef3f8; }
.mc-pagination__status { font-size: 13px; color: #777; }
