/* jimitas風 シンプル&クリーンなCSS設計 */

/* CSS変数定義 */
:root {
  /* メインカラーパレット */
  --primary-color: #4A90E2;      /* メインブルー */
  --secondary-color: #7ED321;    /* アクセントグリーン */
  --input-color: #5B9BD5;        /* 入力値（青系） */
  --result-color: #E94B3C;       /* 計算結果（赤系） */

  /* 背景・テキスト */
  --background: #F8F9FA;         /* 背景（薄いグレー） */
  --text-primary: #333333;       /* メインテキスト */
  --text-secondary: #666666;     /* サブテキスト */
  --border-color: #E0E0E0;       /* ボーダー */
  --shadow: rgba(0,0,0,0.1);     /* 影 */

  /* 特別な色 */
  --special-color: #FF6B35;      /* 特別メッセージ */
  --error-color: #E94B3C;        /* エラー */
  --success-color: #7ED321;      /* 成功 */

  /* フォント */
  --font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic Medium', 'Meiryo', sans-serif;
}

/* リセットCSS */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ベーススタイル */
body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 16px;
}

/* ヘッダー */
.app-header {
  background: linear-gradient(135deg, var(--primary-color), #6BA3F5);
  color: white;
  padding: 1.5rem 2rem;
  text-align: center;
  position: relative;
  box-shadow: 0 2px 10px var(--shadow);
}

.app-header h1 {
  font-size: 1.8rem;
  font-weight: 600;
  margin: 0;
}

.sound-control {
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
}

.sound-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.sound-btn.muted {
  opacity: 0.5;
}

/* タブナビゲーション */
.tab-nav {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.tab-btn {
  flex: 1;
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  min-width: 0;
}

.tab-btn:hover {
  color: var(--primary-color);
  background: rgba(74, 144, 226, 0.05);
}

.tab-btn.active {
  color: var(--primary-color);
  background: rgba(74, 144, 226, 0.1);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
}

/* メインコンテンツ */
.app-main {
  max-width: 1400px; /* 1000px → 1400px に拡大（1.4倍） */
  margin: 0 auto;
  padding: 2rem; /* 1.5rem → 2rem に拡大 */
}

/* 三角形表示エリア */
.triangle-display {
  background: white;
  border-radius: 12px;
  padding: 2rem; /* 1.5rem → 2rem に拡大 */
  margin-bottom: 0; /* 横並び時はmargin-bottom不要 */
  box-shadow: 0 4px 15px var(--shadow);
  text-align: center;
  flex: 1.4; /* 1.2 → 1.4 に拡大 */
  min-width: 450px; /* 320px → 450px に拡大 */
  order: 2; /* 中央に配置 */
}

#triangle-svg, .triangle-display svg {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #FEFEFE;
}

/* 全てのモードのSVGサイズを統一 */
.triangle-display svg {
  width: 550px !important; /* 強制的に同じサイズに */
  height: 450px !important; /* 強制的に同じサイズに */
  max-width: 100%;
  max-height: 450px;
}

/* SVGスタイル */
.side-label {
  font-size: 16px;
  font-weight: 600;
  fill: var(--text-primary);
}

.angle-label {
  font-size: 18px;
  font-weight: 600;
  fill: var(--input-color);
}

.input-value {
  fill: var(--input-color) !important;
}

.result-value {
  fill: var(--result-color) !important;
}

/* モードコンテンツ */
.mode-content {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mode-content.active {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem; /* 1.5rem → 2rem に拡大 */
  opacity: 1;
  align-items: flex-start;
}

/* 入力セクション */
.input-section {
  background: white;
  border-radius: 12px;
  padding: 2rem; /* 1.5rem → 2rem に拡大 */
  box-shadow: 0 4px 15px var(--shadow);
  flex: 1;
  min-width: 350px; /* 280px → 350px に拡大 */
  order: 1; /* 左側に配置 */
}

.input-section h2 {
  font-size: 1.5rem; /* 1.3rem → 1.5rem に拡大 */
  color: var(--primary-color);
  margin-bottom: 1.8rem; /* 1.5rem → 1.8rem に拡大 */
  display: flex;
  align-items: center;
}

.input-section h2::before {
  content: '📝';
  margin-right: 0.5rem;
  font-size: 1.1rem;
}

.input-group {
  margin-bottom: 2rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* スライダーコンテナ */
.slider-container {
  margin-bottom: 1rem;
  position: relative;
}

.angle-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, var(--input-color), var(--primary-color));
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.angle-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--input-color);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

.angle-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.angle-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--input-color);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* 数値入力 */
.number-input-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.angle-input, input[type="number"] {
  width: 80px;
  padding: 0.5rem;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  text-align: center;
  transition: all 0.3s ease;
}

.angle-input:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--input-color);
  box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.2);
}

/* ラジオボタングループ */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.radio-label:hover {
  background: rgba(74, 144, 226, 0.05);
}

.radio-label input[type="radio"] {
  margin-right: 0.5rem;
  accent-color: var(--input-color);
}

/* 結果セクション */
.result-section {
  background: white;
  border-radius: 12px;
  padding: 2rem; /* 1.5rem → 2rem に拡大 */
  box-shadow: 0 4px 15px var(--shadow);
  flex: 1;
  min-width: 350px; /* 280px → 350px に拡大 */
  order: 3; /* 右側に配置 */
}

.result-section h2 {
  font-size: 1.5rem; /* 1.3rem → 1.5rem に拡大 */
  color: var(--result-color);
  margin-bottom: 1.8rem; /* 1.5rem → 1.8rem に拡大 */
  display: flex;
  align-items: center;
}

.result-section h2::before {
  content: '🧮';
  margin-right: 0.5rem;
  font-size: 1.1rem;
}

.result-container {
  margin-bottom: 2rem;
}

.result-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: rgba(233, 75, 60, 0.05);
  border-radius: 8px;
  border-left: 4px solid var(--result-color);
}

.result-item.main-result {
  background: rgba(233, 75, 60, 0.1);
  font-size: 1.1rem;
  font-weight: 600;
}

.result-label {
  font-weight: 600;
  margin-right: 0.5rem;
  min-width: 80px;
}

.result-value {
  color: var(--result-color);
  font-weight: 700;
  font-size: 1.1rem;
  margin-right: 0.25rem;
}

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

/* 特別メッセージ */
.special-message {
  background: linear-gradient(135deg, #FF6B35, #F7931E);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  margin-top: 1rem;
  display: none;
  animation: specialAppear 0.5s ease;
}

.special-message.show {
  display: block;
}

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

/* 参考表示 */
.reference-ratios {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.reference-ratios h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.ratio-reference {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.calculation-method {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.5rem;
  white-space: pre-line; /* 改行文字（\n）を実際の改行として表示 */
  line-height: 1.4; /* 行間を少し広く */
}

/* エラーメッセージ */
.error-message {
  color: var(--error-color);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(233, 75, 60, 0.1);
  border-radius: 4px;
  display: none;
  animation: errorShake 0.5s ease;
}

.error-message.show {
  display: block;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* アニメーション */
.calculating {
  animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

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

/* コンパクトPC用レイアウト (1024px-1400px) */
@media (max-width: 1400px) and (min-width: 1024px) {
  .app-main {
    max-width: 1200px; /* 950px → 1200px に拡大 */
    padding: 1.5rem; /* 1rem → 1.5rem に拡大 */
  }

  .mode-content.active {
    gap: 1.5rem; /* 1rem → 1.5rem に拡大 */
  }

  .input-section, .result-section {
    padding: 1.75rem; /* 1.25rem → 1.75rem に拡大 */
    min-width: 320px; /* 少し拡大 */
  }

  .triangle-display {
    min-width: 400px; /* 280px → 400px に拡大 */
    flex: 1.3;
  }
}

/* レスポンシブデザイン - 改行対応 */
@media (max-width: 1023px) {
  .app-main {
    padding: 1rem;
  }

  .mode-content.active {
    flex-direction: column; /* 縦並びに変更 */
    gap: 1.5rem;
  }

  .input-section, .result-section, .triangle-display {
    order: unset; /* orderをリセット */
    flex: none;
    min-width: unset;
  }

  /* モバイルでは元の順序に戻す */
  .triangle-display {
    order: 0; /* 三角形を最初に */
  }

  .input-section {
    order: 1; /* 入力を2番目に */
  }

  .result-section {
    order: 2; /* 結果を最後に */
  }

  #triangle-svg {
    width: 100%;
    height: auto;
  }
}

@media (max-width: 767px) {
  .app-header {
    padding: 1rem;
  }

  .app-header h1 {
    font-size: 1.4rem;
  }

  .sound-control {
    right: 1rem;
  }

  .sound-btn {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .tab-nav {
    overflow-x: auto;
    white-space: nowrap;
  }

  .tab-btn {
    flex: none;
    min-width: 120px;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
  }

  .triangle-display {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  #triangle-svg {
    width: 100%;
    max-width: 350px;
  }

  .input-section, .result-section {
    padding: 1.5rem;
  }

  .radio-group {
    gap: 0.25rem;
  }

  .ratio-reference {
    flex-direction: column;
    gap: 0.5rem;
  }

  .result-item {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .app-main {
    padding: 0.5rem;
  }

  .input-section, .result-section {
    padding: 1rem;
  }

  .input-group {
    margin-bottom: 1.5rem;
  }

  .number-input-container {
    flex-wrap: wrap;
  }

  .angle-input, input[type="number"] {
    width: 70px;
    font-size: 0.9rem;
  }
}

/* プリント用スタイル */
@media print {
  .sound-control,
  .tab-nav {
    display: none;
  }

  .app-header {
    background: var(--primary-color) !important;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
  }

  .mode-content {
    display: block !important;
    opacity: 1 !important;
  }

  .input-section, .result-section {
    box-shadow: none;
    border: 1px solid var(--border-color);
  }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ハイコントラストモード */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #0066CC;
    --result-color: #CC0000;
    --text-primary: #000000;
    --background: #FFFFFF;
    --border-color: #000000;
  }
}