/**
 * 同窓会WEBアンケートサイト - カスタムCSS
 *
 * Tailwind CDN と組み合わせて使用するカスタムスタイル
 */

/* ============================================================
 * アニメーション定義
 * ============================================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

/* ============================================================
 * アニメーションクラス
 * ============================================================ */

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out both;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out both;
}

.animate-fade-in-down {
    animation: fadeInDown 0.35s ease-out both;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out both;
}

/* 連続アニメーション用の遅延 */
.delay-75  { animation-delay: 75ms;  }
.delay-100 { animation-delay: 100ms; }
.delay-150 { animation-delay: 150ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* ============================================================
 * カードコンポーネント
 * ============================================================ */

.card {
    background-color: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08), 0 2px 16px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(14, 165, 233, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card-hover:active {
    transform: translateY(-1px);
}

/* ============================================================
 * フォーム要素
 * ============================================================ */

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    background-color: #ffffff;
    color: #1e293b;
    font-size: 0.9375rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #94a3b8;
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

/* エラー状態 */
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-error-msg {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* 成功状態 */
.form-input.is-valid {
    border-color: #10b981;
}

/* form-label */
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-label .required {
    margin-left: 0.25rem;
    font-size: 0.75rem;
    color: #ef4444;
    font-weight: 500;
}

/* ============================================================
 * ○△× 回答ボタン
 * ============================================================ */

.answer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    background-color: #f8fafc;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
                background-color 0.15s ease, border-color 0.15s ease,
                color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.answer-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.answer-btn:active {
    transform: scale(0.96);
}

/* ○ ボタン選択済み (スカイブルー) */
.answer-btn.selected-maru,
.answer-btn[data-value="maru"].selected {
    background-color: #0ea5e9;
    color: #ffffff;
    border-color: #0284c7;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.5);
    transform: scale(1.05);
}

/* △ ボタン選択済み (アンバー) */
.answer-btn.selected-sankaku,
.answer-btn[data-value="sankaku"].selected {
    background-color: #f59e0b;
    color: #ffffff;
    border-color: #d97706;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
    transform: scale(1.05);
}

/* × ボタン選択済み (レッド) */
.answer-btn.selected-batsu,
.answer-btn[data-value="batsu"].selected {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
    transform: scale(1.05);
}

/* 回答ボタングループ */
.answer-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ============================================================
 * トースト通知
 * ============================================================ */

#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 22rem;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    animation: fadeInUp 0.3s ease-out both;
    pointer-events: auto;
    word-break: break-word;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.toast:hover {
    opacity: 0.9;
}

.toast-icon {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.125rem;
}

.toast-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.toast-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.toast-info {
    background-color: #e0f2fe;
    color: #0c4a6e;
    border-left: 4px solid #0ea5e9;
}

.toast-warning {
    background-color: #fef3c7;
    color: #78350f;
    border-left: 4px solid #f59e0b;
}

/* ============================================================
 * ボタンコンポーネント
 * ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease,
                transform 0.1s ease, border-color 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled,
.btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary ボタン */
.btn-primary {
    background-color: #0ea5e9;
    color: #ffffff;
    border-color: #0ea5e9;
}
.btn-primary:hover {
    background-color: #0284c7;
    border-color: #0284c7;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.4);
}
.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.35);
}

/* Secondary ボタン */
.btn-secondary {
    background-color: #ffffff;
    color: #0369a1;
    border-color: #bae6fd;
}
.btn-secondary:hover {
    background-color: #f0f9ff;
    border-color: #7dd3fc;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
}

/* Danger ボタン */
.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}
.btn-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

/* ============================================================
 * バッジ / ラベル
 * ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-primary {
    background-color: #e0f2fe;
    color: #0369a1;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #78350f;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ============================================================
 * ローディング
 * ============================================================ */

.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

.spinner-primary {
    border-color: rgba(14, 165, 233, 0.2);
    border-top-color: #0ea5e9;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
 * ページレイアウト
 * ============================================================ */

.page-content {
    animation: fadeInUp 0.45s ease-out both;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0c4a6e;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.section-subtitle {
    font-size: 0.9375rem;
    color: #64748b;
    margin-bottom: 1.5rem;
}

/* ============================================================
 * アラートボックス
 * ============================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.625rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.alert-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
}

.alert-error {
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert-success {
    background-color: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.alert-info {
    background-color: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #0c4a6e;
}

.alert-warning {
    background-color: #fef3c7;
    border: 1px solid #fcd34d;
    color: #78350f;
}

/* ============================================================
 * テーブル
 * ============================================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background-color: #f0f9ff;
    color: #0369a1;
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid #bae6fd;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background-color: #f0f9ff;
    transition: background-color 0.1s ease;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
 * 集計結果グラフ
 * ============================================================ */

.result-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.result-bar-label {
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
    font-size: 1.25rem;
}

.result-bar-bg {
    flex: 1;
    background-color: #e2e8f0;
    border-radius: 9999px;
    height: 0.75rem;
    overflow: hidden;
}

.result-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-bar-fill-maru     { background-color: #0ea5e9; }
.result-bar-fill-sankaku  { background-color: #f59e0b; }
.result-bar-fill-batsu    { background-color: #ef4444; }

.result-bar-count {
    flex-shrink: 0;
    width: 3rem;
    text-align: right;
    font-size: 0.875rem;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
 * モバイル最適化
 * ============================================================ */

@media (max-width: 640px) {
    .answer-btn {
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    #toast-container {
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}

/* ============================================================
 * アクセシビリティ
 * ============================================================ */

:focus-visible {
    outline: 3px solid #0ea5e9;
    outline-offset: 2px;
    border-radius: 4px;
}

/* モーション設定を尊重する */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration:   0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration:  0.01ms !important;
    }
}
