/**
 * Reviews & Poll for individual card posts
 */

/* ===== 評価軸サマリー(レーダー + バー) ===== */
.cg-axis-summary {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    justify-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px 20px;
    margin: 0 0 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.cg-axis-chart-wrap {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;   /* 1:1 を維持しつつ親に追従。古いブラウザは下の padding-bottom hack にフォールバック */
    margin: 0 auto;
}
/* aspect-ratio 非対応環境用フォールバック */
@supports not (aspect-ratio: 1 / 1) {
    .cg-axis-chart-wrap {
        height: 0;
        padding-bottom: 100%;
    }
}

.cg-axis-chart-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.cg-axis-bars {
    width: 100%;
    min-width: 0;
}

@media (max-width: 767px) {
    .cg-axis-summary {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 14px 14px;
    }
    .cg-axis-chart-wrap {
        max-width: 280px;
    }
}

.cg-axis-row {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.cg-axis-label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cg-axis-bar {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    min-width: 0;
}

.cg-axis-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffaa00, #ff6633);
    transition: width 0.4s;
}

.cg-axis-value {
    text-align: right;
    font-weight: 700;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .cg-axis-row {
        grid-template-columns: 72px minmax(0, 1fr) 40px;
        gap: 8px;
    }
    .cg-axis-label {
        font-size: 12px;
    }
    .cg-axis-value {
        font-size: 13px;
    }
}

.cg-review-empty {
    background: #fafafa;
    border: 1px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #888;
    margin: 0 0 20px;
}

/* ===== 投稿トリガーボタン & モーダル ===== */
.cg-review-form-trigger-wrap {
    text-align: center;
    margin: 0 0 24px;
}
.cg-review-trigger-btn {
    display: inline-block;
    padding: 14px 32px;
    background: #3366cc;
    color: #fff;
    border: none;
    border-radius: 28px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(51, 102, 204, 0.3);
    transition: all 0.15s;
}
.cg-review-trigger-btn:hover {
    background: #1e4799;
    transform: translateY(-2px);
}

.cg-review-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    visibility: hidden;
    pointer-events: none;
}
.cg-review-modal.is-open {
    visibility: visible;
    pointer-events: auto;
}
.cg-review-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.25s;
}
.cg-review-modal.is-open .cg-review-modal-backdrop {
    opacity: 1;
}
.cg-review-modal-sheet {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: 620px;
    max-width: calc(100% - 24px);
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s;
}
.cg-review-modal.is-open .cg-review-modal-sheet {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.cg-review-modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    padding-top: max(14px, env(safe-area-inset-top));
    border-bottom: 1px solid #eee;
    background: #fff;
}
/* タイトル列: flex内で縮められるように min-width:0 と overflow を付与 */
.cg-review-modal-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}
.cg-review-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #222;
    line-height: 1.3;
}
.cg-review-modal-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cg-review-modal-close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}
.cg-review-modal-close:hover { background: #e5e5e5; }
.cg-review-modal-close:active { background: #d5d5d5; }
.cg-review-modal-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
body.cg-review-modal-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .cg-review-modal-sheet {
        width: 100%;
        max-width: 100%;
        /* iOS Safari の 100vh がアドレスバー込みで超過する問題の回避:
           dvh サポート環境では dvh、未対応環境では 100vh にフォールバック */
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
    }
    .cg-review-modal.is-open .cg-review-modal-sheet {
        transform: none;
    }
    .cg-review-modal-header {
        padding: 12px 14px;
        padding-top: max(12px, env(safe-area-inset-top));
    }
    .cg-review-modal-title {
        font-size: 15px;
    }
    .cg-review-modal-close {
        width: 44px;
        height: 44px;
        font-size: 26px;
    }
    .cg-review-modal-body {
        padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
    }
}

.cg-field {
    margin-bottom: 18px;
}

.cg-field > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.cg-required {
    color: #d9534f;
    font-size: 11px;
    margin-left: 6px;
    font-weight: 700;
}

.cg-input,
.cg-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa;
}

.cg-input:focus,
.cg-textarea:focus {
    outline: none;
    border-color: #3366cc;
    background: #fff;
}

.cg-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== スライダー評価入力(0.1刻み) ===== */
.cg-slider-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cg-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #ffe9bd 0%, #ffaa00 100%);
    outline: none;
    cursor: pointer;
}
.cg-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3366cc;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}
.cg-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3366cc;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}
.cg-slider-stars {
    color: #ffaa00;
    font-size: 16px;
    letter-spacing: 1px;
    min-width: 80px;
}
.cg-slider-val {
    font-weight: 800;
    font-size: 16px;
    color: #333;
    min-width: 30px;
    text-align: right;
}
.cg-slider-wrap--small .cg-slider-stars {
    font-size: 13px;
    min-width: 60px;
}
.cg-slider-wrap--small .cg-slider-val {
    font-size: 13px;
}

.cg-axis-input-group {
    background: #fafafa;
    padding: 12px;
    border-radius: 6px;
}

.cg-axis-input-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.cg-axis-input-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

@media (max-width: 600px) {
    .cg-axis-input-row {
        grid-template-columns: 70px 1fr;
        gap: 8px;
    }
}

.cg-form-actions {
    text-align: center;
    margin-top: 18px;
}

.cg-submit-btn {
    padding: 12px 32px;
    background: #3366cc;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.cg-submit-btn:hover {
    background: #1e4799;
}

.cg-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cg-form-msg {
    margin-top: 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    min-height: 18px;
}

.cg-form-msg.is-success {
    color: #2e7d32;
}

.cg-form-msg.is-error {
    color: #d9534f;
}

/* ===== 口コミ一覧 ===== */
.cg-review-list {
    margin-top: 28px;
}

.cg-review-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.cg-review-list-head .cg-review-list-h3 {
    margin: 0 !important;
}
.cg-review-visible-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #555;
}
.cg-review-visible-label {
    font-weight: 600;
}
.cg-review-visible {
    padding: 4px 24px 4px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    color: #333;
    cursor: pointer;
}
.cg-review-item[hidden],
.cg-review-item.is-hidden {
    display: none;
}

.cg-review-list-h3 {
    font-size: 1rem !important;
    font-weight: 700 !important;
    margin: 0 0 16px !important;
    padding: 0 !important;
    color: #222 !important;
    background: transparent !important;
    border: none !important;
}

.cg-review-list-h3::before,
.cg-review-list-h3::after {
    display: none !important;
    content: none !important;
}

.cg-review-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 12px;
}

.cg-review-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.cg-review-stars {
    color: #ffaa00;
    font-size: 16px;
    letter-spacing: 1px;
}

.cg-review-rating {
    font-weight: 700;
    color: #333;
}

.cg-review-author {
    color: #555;
    font-weight: 600;
}

.cg-review-date {
    color: #888;
    font-size: 12px;
    margin-left: auto;
}

.cg-review-body {
    color: #333;
    line-height: 1.7;
    font-size: 14px;
    margin-bottom: 10px;
}

.cg-review-foot {
    text-align: right;
}

.cg-helpful-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
}

.cg-helpful-btn:hover {
    background: #eee;
    border-color: #ccc;
}

.cg-helpful-btn.is-voted {
    background: #eef3fb;
    border-color: #3366cc;
    color: #3366cc;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .cg-review-form-wrap {
        padding: 16px;
    }
    .cg-review-item {
        padding: 12px 14px;
    }
}

/* ============================================================
   将来予測アンケート (Poll)
   ============================================================ */
.cg-poll-wrap {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 18px 20px;
}

.cg-poll-total {
    font-size: 12px;
    color: #888;
    text-align: right;
    margin-bottom: 10px;
}

.cg-poll-total-count {
    font-weight: 700;
    color: #3366cc;
}

.cg-poll-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cg-poll-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    overflow: hidden;
    text-align: left;
    transition: all 0.15s;
    width: 100%;
}

.cg-poll-option:hover:not(:disabled) {
    border-color: #3366cc;
    background: #f6f9ff;
}

.cg-poll-option:disabled {
    cursor: default;
}

.cg-poll-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #e8f0ff, #c9dcf7);
    transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 0;
}

.cg-poll-option.is-voted .cg-poll-bar {
    background: linear-gradient(90deg, #bbd4fa, #7aa7ef);
}

/* 投票前はバー非表示(wrapに is-voted クラスがない間) */
.cg-poll-wrap:not(.is-voted) .cg-poll-bar {
    width: 0 !important;
}
.cg-poll-wrap:not(.is-voted) .cg-poll-pct {
    display: none;
}

.cg-poll-option.is-voted {
    border-color: #3366cc;
}

.cg-poll-label {
    position: relative;
    z-index: 1;
    flex: 1;
}

.cg-poll-pct {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: 700;
    color: #1e4799;
    white-space: nowrap;
}

.cg-poll-count {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    margin-left: 4px;
}

.cg-poll-msg {
    margin-top: 14px;
    text-align: center;
    font-size: 12px;
    color: #888;
}

@media (max-width: 600px) {
    .cg-poll-wrap {
        padding: 14px 16px;
    }
    .cg-poll-option {
        padding: 10px 14px;
        font-size: 13px;
    }
}
