/* ==========================================================================
   ご縁計算機 - スタイル定義
   テーマ: 和モダン・プレミアム・ダーク
   ========================================================================== */

/* 変数定義 (デザインシステム) */
:root {
  /* カラーパレット */
  --bg-color: #0c0e12;
  --bg-gradient: linear-gradient(135deg, #0c0e12 0%, #151821 100%);
  --panel-bg: rgba(26, 29, 38, 0.7);
  --panel-border: rgba(212, 175, 55, 0.15);
  --panel-border-focus: rgba(212, 175, 55, 0.4);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* ゴールド（真鍮色・5円玉） */
  --gold-light: #f7e09a;
  --gold-primary: #d4af37;
  --gold-dark: #aa7c11;
  --gold-gradient: linear-gradient(135deg, #f7e09a 0%, #d4af37 50%, #aa7c11 100%);
  
  /* 朱赤（アクセント・神社） */
  --vermilion: #e63946;
  --vermilion-hover: #ff4d5a;
  
  /* UIシステムカラー */
  --white: #ffffff;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  
  /* トランジション */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 基本リセット & タイポグラフィ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  line-height: 1.6;
}

/* スクリーンリーダー用ユーティリティ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* アプリケーションコンテナ */
.app-container {
  width: 100%;
  max-width: 1100px;
  margin: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px;
}

/* --------------------------------------------------------------------------
   ヘッダー
   -------------------------------------------------------------------------- */
.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 25px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 15px;
}

.title-wrapper h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-wrapper .subtitle {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: -2px;
}

.five-yen-coin-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold-gradient);
  position: relative;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.five-yen-coin-mini::before {
  content: '';
  width: 8px;
  height: 8px;
  background-color: var(--bg-color);
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
}

/* --------------------------------------------------------------------------
   メインレイアウト
   -------------------------------------------------------------------------- */
.app-main {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 30px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 25px;
  transition: border-color var(--transition-normal);
}

.panel:hover {
  border-color: rgba(212, 175, 55, 0.25);
}

/* --------------------------------------------------------------------------
   電卓パネル（左側）
   -------------------------------------------------------------------------- */

/* ディスプレイ */
.display-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.price-input-wrapper {
  background: rgba(10, 12, 17, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  transition: all var(--transition-normal);
}

.price-input-wrapper:focus-within,
.price-input-wrapper.active {
  border-color: var(--gold-primary);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

.currency-symbol {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--gold-primary);
}

#price-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  padding-right: 10px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: translateY(1px);
}

/* コントロール（税率・端数） */
.controls-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.control-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* 税率タイルボタン */
.radio-tile-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.radio-tile-label {
  cursor: pointer;
}

.radio-tile-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-tile-label .tile {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
}

.radio-tile-label input:checked + .tile {
  background: rgba(212, 175, 55, 0.08);
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
}

.tile-percentage {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.radio-tile-label input:checked + .tile .tile-percentage {
  color: var(--gold-light);
}

.tile-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* セグメントコントロール（端数） */
.segmented-control {
  display: flex;
  background: rgba(10, 12, 17, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 4px;
}

.segment-label {
  flex: 1;
  cursor: pointer;
}

.segment-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.segment-btn {
  display: block;
  text-align: center;
  padding: 8px 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  transition: all var(--transition-normal);
}

.segment-label input:checked + .segment-btn {
  background: var(--gold-gradient);
  color: var(--bg-color);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* アクションボタンとコンテナ */
.action-container {
  margin-top: 10px;
}

.btn-primary {
  width: 100%;
  background: var(--gold-gradient);
  border: none;
  border-radius: 16px;
  color: var(--bg-color);
  font-family: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 16px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
  transition: all var(--transition-normal);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.35);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
}

.btn-primary svg {
  stroke: var(--bg-color);
}

/* --------------------------------------------------------------------------
   結果パネル（右側）
   -------------------------------------------------------------------------- */
.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  border-left: 3px solid var(--gold-primary);
  padding-left: 10px;
  line-height: 1;
}

/* リアルタイム結果ボックス */
.calculation-result-box {
  background: rgba(10, 12, 17, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.result-value-wrapper {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.result-unit {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.primary-result .result-value {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  width: 100%;
}

/* お釣り提案カードエリア */
.goen-cards-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* メインの5円お釣りカード */
.goen-card.highlighted {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.12) 0%, rgba(170, 124, 17, 0.04) 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 16px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 60px 1.5fr;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.goen-card.highlighted::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--gold-gradient);
}

.goen-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.goen-card .badge {
  background: var(--vermilion);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
  letter-spacing: 0.05em;
}

.goen-card .card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-light);
}

/* コインのアニメーション・スタイリング */
.goen-coin-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.five-yen-coin {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gold-gradient);
  position: relative;
  box-shadow: 
    inset 0 1px 2px rgba(255,255,255,0.6), 
    0 4px 10px rgba(0,0,0,0.4),
    0 0 15px rgba(212, 175, 55, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal);
}

/* 稲穂などのコイン装飾の簡略モックアップ */
.five-yen-coin::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 36px;
  border: 1px dashed rgba(170, 124, 17, 0.4);
  border-radius: 50%;
}

.five-yen-coin .coin-hole {
  width: 13px;
  height: 13px;
  background-color: #12141a; /* 背後の暗色 */
  border-radius: 50%;
  z-index: 2;
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.8), 0 1px 1px rgba(255,255,255,0.3);
}

.goen-card.highlighted:hover .five-yen-coin {
  transform: rotate(30deg) scale(1.08);
}

.goen-payment-info {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.payment-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.payment-value-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 2px;
}

.payment-unit {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold-primary);
}

.payment-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.02em;
}

/* サブお釣りカード（50円/500円） */
.sub-goen-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.goen-card.mini {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all var(--transition-fast);
}

.goen-card.mini:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(212, 175, 55, 0.15);
}

.goen-card.mini .card-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.goen-card.mini .payment-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   買い物リスト（カート）セクション
   -------------------------------------------------------------------------- */
.cart-section {
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex: 1;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--vermilion);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.btn-text:hover:not(:disabled) {
  background: rgba(230, 57, 70, 0.1);
}

.btn-text:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* カートリストコンテナ */
.cart-list-container {
  max-height: 180px;
  overflow-y: auto;
  padding-right: 6px;
}

/* スクロールバーカスタム */
.cart-list-container::-webkit-scrollbar {
  width: 6px;
}

.cart-list-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.cart-list-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.cart-list-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cart-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-empty-message {
  text-align: center;
  padding: 30px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* カートアイテム */
.cart-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-price {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-total-after {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.btn-delete:hover {
  color: var(--vermilion);
  background: rgba(230, 57, 70, 0.1);
}

/* カート合計エリア */
.cart-summary {
  background: rgba(212, 175, 55, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.08);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.total-row {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
}

.total-row .total-price {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  color: var(--white);
}

/* カート5円お釣り行の特別デザイン */
.goen-total-row {
  border-top: 1px dashed rgba(212, 175, 55, 0.15);
  padding-top: 10px;
  color: var(--gold-light);
}

.goen-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.five-yen-coin-micro {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-gradient);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.five-yen-coin-micro::before {
  content: '';
  width: 4px;
  height: 4px;
  background-color: var(--bg-color);
  border-radius: 50%;
}

.goen-total-price {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gold-primary);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

/* --------------------------------------------------------------------------
   フッター
   -------------------------------------------------------------------------- */
.app-footer {
  text-align: center;
  padding: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   アニメーション用クラス
   -------------------------------------------------------------------------- */
@keyframes pulseNum {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); color: var(--gold-light); }
  100% { transform: scale(1); }
}

.pulse-num {
  animation: pulseNum 0.2s ease-out;
}

/* --------------------------------------------------------------------------
   レスポンシブ (メディアクエリ)
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .app-container {
    margin: 10px;
  }
  
  .app-main {
    grid-template-columns: 1fr; /* 1カラム化 */
    gap: 16px;
  }
  
  .panel {
    padding: 20px;
    gap: 20px;
  }
  
  #price-input {
    font-size: 1.8rem;
  }
  
  .key {
    padding: 14px 0;
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 12px 16px;
  }
  
  .title-wrapper h1 {
    font-size: 1.2rem;
  }
  
  .goen-card.highlighted {
    grid-template-columns: 1.2fr 48px 1.5fr;
    padding: 12px 14px;
  }
  
  .five-yen-coin {
    width: 40px;
    height: 40px;
  }
  
  .five-yen-coin::after {
    width: 30px;
    height: 30px;
  }
  
  .five-yen-coin .coin-hole {
    width: 10px;
    height: 10px;
  }
  
  .payment-value {
    font-size: 1.5rem;
  }
  
  .sub-goen-cards {
    grid-template-columns: 1fr; /* 小さすぎる画面では縦並び */
  }
}
