/* Contest Minimal Styles - 最小構成UI */

/* ========================================
   Hero Section
   ======================================== */
.contest-hero {
  padding: 88px 0 72px;
  text-align: center;
}

.contest-hero__title {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--text-primary);
}

.contest-hero__subtitle {
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 32px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.contest-hero__actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
}

.btn--hero {
  font-size: 1.125rem;
  padding: 14px 32px;
  min-width: 200px;
}

.contest-hero__hint {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin: 0 0 28px;
}

.contest-hero__metrics {
  display: flex;
  gap: 28px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 8px;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.metric-icon {
  font-size: 1.125rem;
  opacity: 0.8;
}

.metric-value {
  font-weight: 500;
}

/* ========================================
   Section Common
   ======================================== */
.contest-section {
  padding: 64px 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.section-header__title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.section-header__icon {
  font-size: 1.5rem;
}

.section-header__link {
  font-size: 0.9375rem;
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 200ms;
}

.section-header__link:hover,
.section-header__link:focus-visible {
  opacity: 0.8;
  text-decoration: underline;
}

/* ========================================
   Sorting Tabs
   ======================================== */
.sort-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.sort-tab {
  position: relative;
  background: transparent;
  border: none;
  padding: 12px 20px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 200ms;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.sort-tab:hover {
  color: var(--text-primary);
}

.sort-tab[aria-selected="true"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

.sort-tab:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ========================================
   Public Posts Grid
   ======================================== */
.contest-public__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  padding-bottom: calc(20px + var(--popover-space, 0px)); /* [D-1] Dynamic spacer */
  transition: transform 200ms, box-shadow 200ms, padding-bottom 180ms; /* [5) 微調整] 統一 */
  contain: layout; /* [Step 6c-Ω] カード境界を安定化（丸め差抑制） */
  --popover-space: 0px; /* [D-1] Default: no extra space */
}

/* [D-1] Disable animations for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .post-card {
    transition: transform 200ms, box-shadow 200ms;
  }
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.post-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-primary);
  line-height: 1.4;
}

.post-card__audio {
  width: 100%;
  margin-bottom: 12px;
}

.post-card__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.post-card__actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  position: relative; /* ポップオーバーの親として機能 */
  transform: none !important; /* 祖先のtransformによる位置基準の破壊を防止 */
  will-change: auto;
  contain: layout; /* [Step 6c-Ω] アクション領域の境界安定化 */
}

/* Support Popover: カード内ポイント選択UI */
.support-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: none;
  min-width: 220px;
  max-width: 320px;
  max-height: calc(100vh - 16px); /* 安全余白2×8px */
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  background: rgba(20, 24, 28, 0.98);
  backdrop-filter: blur(10px);
  display: none;
  z-index: 9999; /* [Task B] Elevated for alert visibility */
  opacity: 0;
  transition: opacity 300ms;
}

.support-popover.is-open {
  display: block;
  opacity: 1;
}

/* [Step 6b] Y方向flip: 上側表示 */
.support-popover.is-flip-y {
  bottom: calc(100% + 8px);
  top: auto;
}

/* [Step 6b] X方向flip: 左寄せ表示 */
.support-popover.is-flip-x {
  left: 0;
  right: auto;
}

/* [Step 6b] X方向clamp: 横幅自動縮小 */
.support-popover.is-clamp-x {
  max-width: calc(100vw - 16px);
}

/* [Step 6b] 測定用: レイアウトは維持、表示は隠す */
.support-popover.is-measure {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* スマホ向け: 幅のみ調整 */
@media (max-width: 640px) {
  .support-popover {
    max-width: min(86vw, 320px);
    max-height: calc(100vh - 24px); /* 安全余白2×12px */
  }
  
  .support-popover.is-clamp-x {
    max-width: calc(100vw - 24px);
  }
}

.support-popover__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 8px;
}

.support-popover__amounts {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.support-popover__amounts .btn {
  flex: 1;
  font-size: 0.875rem;
  padding: 8px 12px;
}

.support-popover__balance {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 8px;
}

.support-popover__error {
  font-size: 0.8125rem;
  color: #f87171;
  padding: 6px 8px;
  background: rgba(239, 68, 68, 0.15);
  border-radius: 6px;
  margin-top: 8px;
  display: none;
}

.support-popover__error.visible {
  display: block;
}

.support-popover__ad {
  margin-top: 8px;
  font-size: 0.8125rem;
  padding: 6px 10px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: background 200ms;
}

.support-popover__ad:hover {
  background: rgba(99, 102, 241, 0.25);
}

.support-popover__ad.hidden {
  display: none;
}

/* Action Hint: カード内インライン通知 */
.action-hint {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 300ms, transform 300ms;
  pointer-events: none;
}

.action-hint--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.action-hint--success {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.action-hint--error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.action-hint__cta {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.8);
  color: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
  transition: all 150ms;
}

.action-hint__cta:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .action-hint {
    transition: opacity 200ms;
    transform: none;
  }
  
  .action-hint__cta {
    transition: opacity 150ms;
  }
}

.btn-report {
  font-size: 0.8125rem;
  padding: 6px 12px;
  color: var(--text-secondary);
  transition: color 150ms;
}

.btn-report:hover {
  color: #dc2626; /* Red on hover */
}

.empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
  font-size: 0.9375rem;
}

/* ========================================
   3 Steps Grid
   ======================================== */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  transition: transform 200ms;
}

.step-card:hover {
  transform: translateY(-4px);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand) 70%, #000));
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 50%;
  margin: 0 auto 16px;
}

.step-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.step-desc {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

/* ========================================
   Trust Grid
   ======================================== */
.trust-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.trust-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
}

.trust-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.trust-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.trust-desc {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

/* ========================================
   FAQ List
   ======================================== */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.faq-question {
  font-size: 1rem;
  font-weight: 600;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
  transition: background 200ms;
}

.faq-question:hover {
  background: color-mix(in oklab, var(--surface) 95%, var(--brand));
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--brand);
  transition: transform 200ms;
}

.faq-item[open] .faq-question::after {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 0 24px 20px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.faq-answer p {
  margin: 0;
  font-size: 0.9375rem;
}

/* ========================================
   Footer
   ======================================== */
.contest-footer {
  padding: 48px 0;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 50%, transparent);
}

.footer-text {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin: 0;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 200ms;
}

.footer-link:hover,
.footer-link:focus-visible {
  color: var(--brand);
  text-decoration: underline;
}

/* ========================================
   Mobile Fixed CTA
   ======================================== */
.mobile-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 28px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 16px));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: none; /* モバイルのみ表示 */
}

.mobile-cta.visible {
  transform: translateY(0);
}

/* ========================================
   Responsive Breakpoints
   ======================================== */

/* タブレット: 3列→2列 */
@media (max-width: 900px) {
  .contest-public__grid,
  .steps-grid,
  .trust-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .contest-hero__title {
    font-size: 2.25rem;
  }
}

/* モバイル横: 2列→1列 */
@media (max-width: 640px) {
  .mobile-cta {
    display: block; /* モバイルで表示 */
  }
  
  .contest-public__grid,
  .steps-grid,
  .trust-grid {
    grid-template-columns: 1fr;
  }
  
  .contest-hero {
    padding: 64px 0 56px;
  }
  
  .contest-hero__title {
    font-size: 1.875rem;
  }
  
  .contest-hero__subtitle {
    font-size: 1.0625rem;
  }
  
  .contest-hero__actions {
    flex-direction: column;
    width: 100%;
  }
  
  .btn--hero {
    width: 100%;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .section-header__title {
    font-size: 1.5rem;
  }
  
  .contest-section {
    padding: 48px 0;
  }
}

/* 極小モバイル */
@media (max-width: 375px) {
  .contest-hero__title {
    font-size: 1.625rem;
  }
  
  .contest-hero__metrics {
    gap: 20px;
  }
  
  .metric-item {
    font-size: 0.875rem;
  }
}

/* ========================================
   Report Dialog
   ======================================== */
.report-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.report-dialog__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.report-dialog__content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: dialog-slide-in 250ms ease-out;
}

@keyframes dialog-slide-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.report-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.report-dialog__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.report-dialog__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 150ms;
}

.report-dialog__close:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.report-dialog__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.report-dialog__body {
  padding: 24px;
}

.report-dialog__post-title {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
}

.form-field {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms;
}

.radio-label:hover {
  border-color: var(--brand);
  background: color-mix(in oklab, var(--surface) 97%, var(--brand));
}

.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
  font-weight: 600;
  color: var(--brand);
}

.form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-primary);
  resize: vertical;
  transition: border-color 150ms;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.report-dialog__warning {
  padding: 12px 16px;
  margin-bottom: 20px;
  background: color-mix(in oklab, var(--surface) 90%, #f59e0b);
  border: 1px solid color-mix(in oklab, var(--border) 70%, #f59e0b);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .report-dialog {
    padding: 12px;
  }
  
  .report-dialog__content {
    max-height: 95vh;
  }
  
  .form-actions {
    flex-direction: column-reverse;
  }
  
  .form-actions .btn {
    width: 100%;
  }
}

/* ========================================
   Focus Visible (A11y)
   ======================================== */
.faq-question:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .post-card,
  .step-card,
  .mobile-cta,
  .faq-question::after {
    transition: none;
  }
}

/* ========================================
   [Step 6e-B] Dev Metrics Panel (DevOnly)
   ======================================== */
.dev-metrics-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 320px;
  min-height: 200px;
  max-height: 500px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dev-metrics-panel.is-hidden {
  display: none;
}

.dev-metrics-panel__header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  user-select: none;
}

.dev-metrics-panel__title {
  font-size: 14px;
  margin: 0;
}

.dev-metrics-panel__close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.dev-metrics-panel__close:hover {
  opacity: 1;
}

.dev-metrics-panel__tabs {
  display: flex;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.02);
}

.dev-metrics-panel__tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  transition: all 0.2s;
}

.dev-metrics-panel__tab:hover {
  background: rgba(0, 0, 0, 0.04);
}

.dev-metrics-panel__tab.is-active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: white;
}

.dev-metrics-panel__content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  background: white;
}

.dev-metrics-tab-content {
  display: block;
}

.dev-metrics-tab-content.is-hidden {
  display: none;
}

.dev-metrics-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.dev-metrics-table th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dev-metrics-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dev-metrics-table td:last-child {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dev-metrics-table tr:hover {
  background: rgba(102, 126, 234, 0.05);
}

.dev-metrics-log {
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: #333;
  line-height: 1.6;
  max-height: 320px;
  overflow-y: auto;
}

.dev-metrics-log__entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 8px;
}

.dev-metrics-log__time {
  color: #999;
  flex-shrink: 0;
  width: 72px;
}

.dev-metrics-log__event {
  flex: 1;
  color: #667eea;
  font-weight: 500;
}

.dev-metrics-log__value {
  color: #e74c3c;
  font-weight: 600;
  flex-shrink: 0;
}

.dev-metrics-log__empty {
  color: #999;
  font-style: italic;
  text-align: center;
  padding: 24px;
}

.dev-metrics-panel__footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.dev-metrics-panel__info {
  font-size: 11px;
  color: #666;
}

.dev-metrics-panel__reset {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.dev-metrics-panel__reset:hover {
  background: #c0392b;
}

.dev-metrics-panel__reset:active {
  transform: scale(0.98);
}

@media (max-width: 768px) {
  .dev-metrics-panel {
    width: calc(100vw - 32px);
    max-width: 320px;
  }
}
