/* ===================================
   借金減額診断・債務整理ガイド
   モバイルファースト レスポンシブCSS - 2025年版
   iPhone SE最適化対応
   =================================== */

/* ===================================
   CSS Variables - モバイルファースト
   =================================== */
:root {
  /* Core Colors */
  --primary: #0052cc;
  --primary-dark: #003d99;
  --primary-light: #e3f2fd;
  --success: #008833;
  --success-light: #e8f5e8;
  --danger: #cc0000;
  --warning: #ff8800;
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  
  /* Text Colors */
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --text-light: #adb5bd;
  --text-white: #ffffff;
  
  /* Typography - clamp()で可変サイズ */
  --font-base: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-size-xs: clamp(12px, 2vw, 14px);
  --font-size-sm: clamp(14px, 2.5vw, 16px);
  --font-size-base: clamp(16px, 3vw, 18px);
  --font-size-lg: clamp(18px, 3.5vw, 20px);
  --font-size-xl: clamp(20px, 4vw, 24px);
  --font-size-2xl: clamp(24px, 5vw, 28px);
  --font-size-3xl: clamp(28px, 6vw, 36px);
  --font-size-4xl: clamp(32px, 7vw, 48px);
  
  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-base: 1.6;
  --line-height-relaxed: 1.8;
  
  /* Spacing - clamp()で可変余白 */
  --space-xs: clamp(4px, 1vw, 8px);
  --space-sm: clamp(8px, 2vw, 12px);
  --space-md: clamp(16px, 4vw, 24px);
  --space-lg: clamp(24px, 6vw, 40px);
  --space-xl: clamp(32px, 8vw, 64px);
  --space-2xl: clamp(48px, 12vw, 96px);
  
  /* Design Elements */
  --border-radius: clamp(6px, 1.5vw, 12px);
  --border-width: 1px;
  --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --box-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  
  /* Animation */
  --transition-fast: 0.15s ease-out;
  --transition-base: 0.3s ease-out;
  --transition-slow: 0.5s ease-out;
  
  /* Layout */
  --container-max-width: 1200px;
  --header-height: clamp(60px, 12vw, 80px);
}

/* ===================================
   Reset & Base Styles - モバイル優先
   =================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px; /* ベースサイズ - iPhone SEでも読みやすい */
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===================================
   Typography - モバイル最適化
   =================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  word-wrap: break-word;
  hyphens: auto;
}

h1 { 
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-lg);
}

h2 { 
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-lg);
}

h3 { 
  font-size: var(--font-size-2xl);
}

h4 { 
  font-size: var(--font-size-xl);
}

h5 { 
  font-size: var(--font-size-lg);
}

h6 { 
  font-size: var(--font-size-base);
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover, a:focus {
  color: var(--primary-dark);
  text-decoration: underline;
}

ul, ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

li {
  margin-bottom: var(--space-xs);
  word-wrap: break-word;
  line-height: var(--line-height-base);
}

/* ===================================
   Layout - CSS Grid & Flexbox
   =================================== */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: 1fr; /* モバイル: 1列 */
}

.flex {
  display: flex;
  gap: var(--space-md);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.flex-column {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

/* ===================================
   Header - ハンバーガーメニュー対応
   =================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-primary);
  border-bottom: var(--border-width) solid var(--bg-secondary);
  box-shadow: var(--box-shadow);
  height: var(--header-height);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  z-index: 1001;
}

.logo-icon {
  font-size: var(--font-size-xl);
}

/* ハンバーガーメニュー - モバイル専用 */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1001;
  position: relative;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  transition: all var(--transition-base);
  transform-origin: center;
}

.nav-toggle span:not(:last-child) {
  margin-bottom: 4px;
}

/* ハンバーガーメニューアクティブ状態 */
.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* ナビゲーションメニュー */
.nav-menu {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  background: var(--bg-primary);
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  z-index: 999;
  overflow-y: auto;
  
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  gap: var(--space-md);
  list-style: none;
}

.nav-menu.active {
  transform: translateX(0);
}

.nav-link {
  display: block;
  padding: var(--space-md);
  color: var(--text-primary);
  font-size: var(--font-size-lg);
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
  text-align: center;
  border: var(--border-width) solid transparent;
}

.nav-link:hover, .nav-link:focus {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* オーバーレイ */
.nav-overlay {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  background: var(--bg-overlay);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  z-index: 998;
}

.nav-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===================================
   Cards - モバイル最適化
   =================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  box-shadow: var(--box-shadow);
  margin-bottom: var(--space-lg);
  border: var(--border-width) solid var(--bg-secondary);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--box-shadow-lg);
}

.card-header {
  margin-bottom: var(--space-lg);
}

.card-title {
  font-size: var(--font-size-2xl);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  line-height: var(--line-height-tight);
}

.card-text {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
}

/* ===================================
   Buttons - タッチ最適化
   =================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  border: var(--border-width) solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px; /* アクセシビリティ基準 */
  min-width: 120px;
  word-wrap: break-word;
  hyphens: none;
  position: relative;
  overflow: hidden;
}

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

.btn-primary {
  background-color: var(--primary);
  color: var(--text-white);
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  color: var(--text-white);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--box-shadow-lg);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--text-muted);
  color: var(--text-white);
  text-decoration: none;
}

.btn-success {
  background-color: var(--success);
  color: var(--text-white);
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background-color: #006622;
  border-color: #006622;
  color: var(--text-white);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--box-shadow-lg);
}

.btn-large {
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--font-size-lg);
  font-weight: 700;
  min-height: 56px;
}

.btn-block {
  width: 100%;
  margin-bottom: var(--space-md);
}

/* ===================================
   Forms - モバイル入力最適化
   =================================== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-size-base);
}

.form-control {
  width: 100%;
  padding: var(--space-md);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 2px solid var(--bg-secondary);
  border-radius: var(--border-radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 48px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px 12px;
  padding-right: 40px;
}

/* ===================================
   Statistics Display - モバイル最適化
   =================================== */
.hero-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.stat-item {
  text-align: center;
  padding: var(--space-lg);
  background: var(--success-light);
  border-radius: var(--border-radius);
  border: var(--border-width) solid var(--success);
}

.stat-number {
  display: block;
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--success);
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===================================
   Diagnosis Results - モバイル最適化
   =================================== */
.diagnosis-result {
  display: none;
  margin-top: var(--space-xl);
  padding: var(--space-xl);
  background: linear-gradient(135deg, #f0f8ff 0%, #e8f4f8 100%);
  border-radius: var(--border-radius);
  border: 2px solid var(--primary);
}

.diagnosis-result.show {
  display: block;
  animation: slideInUp var(--transition-slow);
}

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

.diagnosis-result-title {
  color: var(--primary);
  font-size: var(--font-size-2xl);
  text-align: center;
  margin-bottom: var(--space-lg);
}

.reduction-estimate {
  background: var(--bg-primary);
  padding: var(--space-lg);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-lg);
  text-align: center;
  border: var(--border-width) solid var(--success);
}

.reduction-amount {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.amount-before,
.amount-after {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--border-radius);
  font-weight: 700;
  font-size: var(--font-size-lg);
  min-width: 150px;
  text-align: center;
}

.amount-before {
  background: var(--danger);
  color: var(--text-white);
}

.amount-after {
  background: var(--success);
  color: var(--text-white);
}

.arrow-icon {
  font-size: var(--font-size-2xl);
  color: var(--primary);
  font-weight: 700;
  transform: rotate(90deg);
}

/* ===================================
   Emergency Section - モバイル最適化
   =================================== */
.emergency-alert {
  margin: var(--space-xl) 0;
}

.alert-urgent {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  border: 2px solid var(--warning);
  text-align: center;
}

.emergency-phones {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.phone-item {
  text-align: center;
}

.phone-item h4 {
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-lg);
}

/* ===================================
   FAQ Section - モバイル最適化
   =================================== */
.faq-item {
  margin-bottom: var(--space-md);
  border: var(--border-width) solid var(--bg-secondary);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border: none;
  text-align: left;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question:hover {
  background-color: var(--primary-light);
}

.faq-question-text {
  flex: 1;
  line-height: var(--line-height-base);
}

.faq-icon {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--primary);
  margin-left: var(--space-md);
  transition: transform var(--transition-fast);
}

.faq-question[aria-expanded="true"] .faq-icon {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 0 var(--space-lg) var(--space-lg) var(--space-lg);
  background: var(--bg-primary);
  display: none;
}

.faq-answer.active {
  display: block;
  animation: fadeIn var(--transition-base);
}

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

/* ===================================
   Footer - モバイル最適化
   =================================== */
.footer {
  background: var(--text-primary);
  color: var(--text-white);
  margin-top: var(--space-2xl);
  padding: var(--space-xl) 0 var(--space-lg) 0;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr; /* モバイル: 1列 */
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  text-align: center;
}

.footer-links a {
  color: var(--text-light);
  font-size: var(--font-size-sm);
  padding: var(--space-sm);
  border-radius: var(--border-radius);
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--text-white);
  background-color: rgba(255, 255, 255, 0.1);
}

.copyright {
  text-align: center;
  color: var(--text-light);
  font-size: var(--font-size-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: var(--border-width) solid var(--text-muted);
}

/* ===================================
   Utility Classes
   =================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-5 { margin-top: var(--space-xl); }

/* ===================================
   Tablet Breakpoint: 768px+
   =================================== */
@media (min-width: 768px) {
  /* ハンバーガーメニューを非表示 */
  .nav-toggle {
    display: none;
  }
  
  /* PCナビゲーション表示 */
  .nav-menu {
    position: static;
    transform: none;
    width: auto;
    height: auto;
    background: transparent;
    flex-direction: row;
    padding: 0;
    overflow: visible;
  }
  
  .nav-link {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-base);
    text-align: left;
    border: none;
  }
  
  .nav-link:hover {
    background-color: var(--bg-secondary);
    color: var(--primary);
  }
  
  .nav-overlay {
    display: none;
  }
  
  /* 2列レイアウト */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
  
  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .emergency-phones {
    flex-direction: row;
    justify-content: center;
    max-width: 600px;
    margin: var(--space-lg) auto;
  }
  
  .phone-item {
    flex: 1;
  }
  
  .reduction-amount {
    flex-direction: row;
    justify-content: center;
  }
  
  .arrow-icon {
    transform: none;
  }
  
  .footer-content {
    grid-template-columns: repeat(2, 1fr); /* タブレット: 2列 */
  }
  
  .footer-links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .btn {
    width: auto;
  }
  
  .btn-block {
    width: auto;
    margin-bottom: 0;
  }
}

/* ===================================
   Desktop Breakpoint: 1024px+
   =================================== */
@media (min-width: 1024px) {
  /* 3列レイアウト */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  }
  
  .footer-content {
    grid-template-columns: repeat(4, 1fr); /* デスクトップ: 4列 */
  }
  
  /* コンテンツの最大幅調整 */
  .container {
    padding: 0 var(--space-xl);
  }
  
  /* ホバーエフェクト強化 */
  .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-lg);
  }
  
  .btn:hover:not(:disabled) {
    transform: translateY(-2px);
  }
  
  /* デスクトップ特有の調整 */
  .hero-stats {
    max-width: 800px;
    margin: var(--space-xl) auto;
  }
  
  .diagnosis-result {
    max-width: 900px;
    margin: var(--space-xl) auto 0 auto;
  }
}

/* ===================================
   Accessibility & User Preferences
   =================================== */

/* 高コントラストモード */
@media (prefers-contrast: high) {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #f0f0f0;
    --text-primary: #000000;
    --text-secondary: #000000;
    --primary: #0000ff;
    --border-width: 2px;
  }
  
  .btn {
    border-width: 2px;
  }
  
  .card {
    border-width: 2px;
  }
}

/* モーション削減設定 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ダークモード基本対応 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #242424;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    --text-light: #cccccc;
  }
}

/* ===================================
   Print Styles
   =================================== */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
  }
  
  .header,
  .nav-toggle,
  .nav-menu,
  .btn,
  .emergency-alert {
    display: none;
  }
  
  .container {
    max-width: none;
    padding: 0;
  }
  
  .card {
    break-inside: avoid;
    border: 1px solid #000;
    margin-bottom: 1rem;
  }
  
  h1, h2, h3, h4, h5, h6 {
    break-after: avoid;
  }
  
  p, li {
    break-inside: avoid;
  }
}