/**
 * common.css
 * 全ページ共通スタイル
 */

/* ── リセット・ベース ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --border: #e8e2d9;
  --text-primary: #2d2a25;
  --text-secondary: #7a7470;
  --text-muted: #b0aba5;
  --accent: #6b7280;
  --accent-hover: #4b5563;
  --accent-light: #f0f1f3;
  --danger: #e05252;
  --success: #4cae82;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.08);
  --font-sans: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  --transition: 0.18s ease;
  --key-accent: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ── レイアウトラッパー ── */
.page-wrapper {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── ヘッダー ── */
.page-header {
  display: flex;
  align-items: center;
  padding: 16px 0 12px;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

/* 戻るボタン：ボーダーなし、背景のみ */
.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border: none;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.btn-back:hover {
  background: var(--accent-light);
  box-shadow: none;
}

/* ── ボタン ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  line-height: 1.2;
  font-variant-emoji: text;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}

/* セカンダリボタン：ボーダーなし、シャドウで浮き上がり */
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--accent-light);
  box-shadow: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-lg {
  padding: 18px 32px;
  font-size: 1.15rem;
  border-radius: var(--radius-xl);
}

.btn-sm {
  padding: 10px 18px;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
}

.btn-full {
  width: 100%;
}

/* ── カード：ボーダーなし、シャドウのみ ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

/* ── セクション区切り ── */
.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  margin-top: 24px;
}

.section-title:first-child {
  margin-top: 0;
}

/* ── トグルスイッチ ── */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-wrap:last-child {
  border-bottom: none;
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.toggle-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toggle {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d0cbc4;
  border-radius: 14px;
  transition: background var(--transition);
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* ── セグメントコントロール：ボーダーなし ── */
.segment-control {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 3px;
}

.segment-control input[type="radio"] {
  display: none;
}

.segment-control label {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  line-height: 1.3;
}

.segment-control input[type="radio"]:checked + label {
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* ── スライダー ── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.slider-value {
  min-width: 48px;
  text-align: right;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 6px rgba(0,0,0,0.2);
  cursor: pointer;
}

/* ── +/- コントロール：ボーダーなし ── */
.number-control {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.number-control .nc-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--accent);
  cursor: pointer;
  transition: background var(--transition);
  touch-action: manipulation;
}

.number-control .nc-btn:hover {
  background: var(--accent-light);
}

.number-control .nc-val {
  min-width: 56px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── ユーティリティ ── */
.hidden {
  display: none !important;
}

.flex-1 {
  flex: 1;
}

.mt-auto {
  margin-top: auto;
}

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

.text-muted {
  color: var(--text-muted);
}

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