/* ToDoL8er Design System - 統一されたスタイル定義 */

/* ============================================
   レスポンシブブレークポイント・セーフエリア
   ============================================ */
:root {
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
}

/* 固定・スティッキーヘッダーのノッチ回避（env は未対応環境では 0） */
.safe-area-top {
  padding-top: env(safe-area-inset-top, 0);
}

/* スキップリンク（フォーカス時のみ表示、キーボード・スクリーンリーダー用） */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  padding: 0.75rem 1rem;
  background: #9333ea;
  color: #fff;
  font-weight: 500;
  border-radius: 0.5rem;
  text-decoration: none;
  transition: left 0.2s ease, top 0.2s ease;
}
.skip-link:focus {
  left: 0.5rem;
  top: max(0.5rem, env(safe-area-inset-top));
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ============================================
   ボタンスタイル
   ============================================ */

/* プライマリボタン（グラデーション） */
.btn-primary {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #9333ea 0%, #4f46e5 100%);
  color: white;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  box-shadow: 0 10px 25px -5px rgba(147, 51, 234, 0.4);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* セカンダリボタン（グレー） */
.btn-secondary {
  padding: 0.75rem 1.5rem;
  background: #f3f4f6;
  color: #374151;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.btn-secondary:active {
  background: #d1d5db;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 小さいボタン */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* 大きいボタン */
.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* 送信ボタン（特別なスタイル） */
.submit-btn {
  padding: 1rem 3rem;
  background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  color: white;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 1.125rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(139, 92, 246, 0.4);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 単色ボタン（アクション用） */
.btn-purple {
  background: #9333ea;
  color: white;
}

.btn-purple:hover {
  background: #7e22ce;
}

.btn-blue {
  background: #2563eb;
  color: white;
}

.btn-blue:hover {
  background: #1d4ed8;
}

.btn-pink {
  background: #ec4899;
  color: white;
}

.btn-pink:hover {
  background: #db2777;
}

.btn-green {
  background: #10b981;
  color: white;
}

.btn-green:hover {
  background: #059669;
}

.btn-red {
  background: #ef4444;
  color: white;
}

.btn-red:hover {
  background: #dc2626;
}

/* モバイル対応: タッチターゲットの最小サイズ */
@media (max-width: 640px) {
  .btn-primary,
  .btn-secondary,
  .btn-sm,
  .btn-lg,
  .btn-purple,
  .btn-blue,
  .btn-pink,
  .btn-green,
  .btn-red {
    min-height: 44px;
    min-width: 44px;
  }
  
  .btn-sm {
    padding: 0.75rem 1rem;
  }
}

/* ============================================
   カードスタイル
   ============================================ */

/* 基本カード */
.card {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
  padding: 1rem;
}

@media (min-width: 640px) {
  .card {
    padding: 1.5rem;
  }
}

/* ホバー効果付きカード */
.card-hover {
  transition: all 0.3s ease;
}

.card-hover:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* 日記カード（左側にオレンジボーダー） */
.diary-card {
  background: white;
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #f59e0b;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ============================================
   エラーメッセージ
   ============================================ */

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  padding: 1rem;
  color: #991b1b;
  font-size: 0.875rem;
}

.error-message strong {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

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

.loading-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #9333ea;
  border-right-color: #9333ea;
}

.loading-spinner-sm {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 2px;
}

.loading-spinner-md {
  width: 2rem;
  height: 2rem;
  border-width: 2px;
}

.loading-spinner-lg {
  width: 3rem;
  height: 3rem;
  border-width: 3px;
}

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

/* ローディングコンテナ */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 1rem;
}

.loading-container p {
  color: #6b7280;
  font-size: 0.875rem;
}

/* ============================================
   モーダル
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 42rem; /* max-w-2xl */
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0.5rem;
}

@media (min-width: 640px) {
  .modal {
    margin: 1rem;
  }
}

@media (max-width: 640px) {
  .modal {
    max-height: calc(100vh - 1rem);
    margin: 0.5rem;
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.modal-close {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ============================================
   フォーム入力欄
   ============================================ */

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 1rem; /* iOSズーム防止 */
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #9333ea;
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.25);
}

.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 1rem; /* iOSズーム防止 */
  resize: vertical;
  min-height: 120px;
  transition: all 0.2s ease;
}

@media (min-width: 640px) {
  .form-textarea {
    min-height: 192px; /* h-48相当 */
  }
}

.form-textarea:focus {
  outline: none;
  border-color: #9333ea;
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.25);
}

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

.form-label .required {
  color: #ef4444;
  margin-left: 0.25rem;
}

.form-hint {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* ============================================
   ユーティリティ
   ============================================ */

/* 横スクロール防止 */
.no-scroll-x {
  overflow-x: hidden;
  max-width: 100vw;
}

/* テキスト切り詰め */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 複数行テキスト切り詰め */
.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* コンテンツ内リンク: ホバーで下線（視認性向上） */
main a[href]:not(.no-underline):hover {
  text-decoration: underline;
}

