/* ==========================================================
   送迎予約テキスト作成 — style.css
   CSS変数でテーマ管理。設定値(UIサイズ/文字サイズ/フォント/配色/明暗)は
   すべて :root のカスタムプロパティ経由で切り替える。
========================================================== */

@font-face {
  /* no external fonts loaded; system stacks only */
}

:root {
  /* ---- レイアウトスケール (UIサイズ / 文字サイズ設定で上書き) ---- */
  --ui-scale: 1;
  --text-scale: 1;

  /* ---- アクセントカラー(プリセットで上書き) ---- */
  --accent: #c9a24b;
  --accent-rgb: 201, 162, 75;

  /* ---- ダークモード基本パレット(デフォルト) ---- */
  --bg: #0b0b0d;
  --bg-elevated: #141417;
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-solid: #17171b;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #f2f1ee;
  --text-secondary: #a7a6a2;
  --text-tertiary: #6f6e6b;
  --danger: #e0665f;
  --success: #6fbf8b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --overlay: rgba(0, 0, 0, 0.55);

  /* ---- フォント(フォント選択で上書き) ---- */
  --font-main: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

:root[data-theme="light"] {
  --bg: #f3f2ef;
  --bg-elevated: #ffffff;
  --bg-card: rgba(0, 0, 0, 0.025);
  --bg-card-solid: #ffffff;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.16);
  --text-primary: #1c1c1a;
  --text-secondary: #63625e;
  --text-tertiary: #97968f;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --overlay: rgba(0, 0, 0, 0.35);
}

/* ---- テーマカラー プリセット(6) ---- */
:root[data-preset="gold"] { --accent: #c9a24b; --accent-rgb: 201, 162, 75; }
:root[data-preset="blue"] { --accent: #5b8def; --accent-rgb: 91, 141, 239; }
:root[data-preset="green"] { --accent: #4caf82; --accent-rgb: 76, 175, 130; }
:root[data-preset="purple"] { --accent: #a17fe0; --accent-rgb: 161, 127, 224; }
:root[data-preset="red"] { --accent: #e0665f; --accent-rgb: 224, 102, 95; }
:root[data-preset="teal"] { --accent: #3fb8c4; --accent-rgb: 63, 184, 196; }

/* ---- フォント選択(4) ---- */
:root[data-font="gothic"] {
  --font-main: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
}
:root[data-font="mincho"] {
  --font-main: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
}
:root[data-font="maru"] {
  --font-main: "Hiragino Maru Gothic ProN", "UD Digi Kyokasho N-R",
    "Yu Gothic UI", sans-serif;
}
:root[data-font="mono"] {
  --font-main: ui-monospace, "SF Mono", "Menlo", "Yu Gothic UI", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: calc(15px * var(--text-scale));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* ダブルタップ拡大の防止 */
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ダブルタップ拡大の完全防止(補助) */
* { touch-action: manipulation; }

button, input, select {
  font-family: inherit;
  color: inherit;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.screen { display: none; flex-direction: column; flex: 1; min-height: 0; }
.screen.active { display: flex; }

/* ---- ヘッダー ---- */
.app-header {
  position: sticky;
  top: var(--safe-top);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(10px * var(--ui-scale));
  padding: calc(14px * var(--ui-scale)) calc(18px * var(--ui-scale));
  background: rgba(var(--accent-rgb), 0.06);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-size: calc(1.05em * var(--text-scale) / var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.app-title small {
  display: block;
  font-size: 0.6em;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(42px * var(--ui-scale));
  height: calc(42px * var(--ui-scale));
  min-width: 42px;
  min-height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.icon-btn:active { transform: scale(0.94); background: rgba(var(--accent-rgb), 0.14); }
.icon-btn svg { width: 20px; height: 20px; stroke: var(--text-primary); fill: none; }

/* ---- コンテンツ ---- */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(16px * var(--ui-scale)) calc(16px * var(--ui-scale))
    calc(28px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(16px * var(--ui-scale));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* ---- カード ---- */
.card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: calc(18px * var(--ui-scale));
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 0; }

.card-title {
  font-size: 0.95em;
  font-weight: 700;
  margin: 0 0 calc(12px * var(--ui-scale));
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ---- フォーム ---- */
.field { margin-bottom: calc(14px * var(--ui-scale)); }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.field-label .required { color: var(--accent); }
.field-label .warn-msg {
  color: var(--danger);
  font-size: 0.95em;
  font-weight: 600;
  margin-left: auto;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="date"],
.field select {
  width: 100%;
  padding: calc(11px * var(--ui-scale)) calc(13px * var(--ui-scale));
  min-height: 46px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1em;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a7a6a2' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 36px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.07);
}

.field.invalid input,
.field.invalid select {
  border-color: var(--danger);
}

.field-hint {
  font-size: 0.76em;
  color: var(--text-tertiary);
  margin-top: 5px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(10px * var(--ui-scale));
}

.divider-space { height: calc(6px * var(--ui-scale)); }

/* ---- プレビュー ---- */
.preview-box {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95em;
  line-height: 1.75;
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: calc(14px * var(--ui-scale));
  min-height: 120px;
  color: var(--text-primary);
}

.copy-row {
  display: flex;
  gap: 10px;
  margin-top: calc(12px * var(--ui-scale));
}

/* ---- ボタン ---- */
.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  min-height: 46px;
  font-size: 0.92em;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
  flex: 1;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #0b0b0d;
}
.btn-primary:active { filter: brightness(0.92); }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(224, 102, 95, 0.4);
  color: var(--danger);
}

.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 0.82em; flex: none; }

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: calc(4px * var(--ui-scale));
}

/* ---- トースト ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.86em;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- 開発者お知らせ ---- */
.notice-box {
  border-radius: 14px;
  padding: calc(13px * var(--ui-scale));
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  font-size: 0.88em;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- 設定: プリセットスウォッチ ---- */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  min-width: 34px;
}
.swatch[data-active="true"] {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---- トグル ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--border-strong);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle[data-on="true"] { background: var(--accent); }
.toggle[data-on="true"]::after { transform: translateX(22px); }

/* ---- フォント選択チップ ---- */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.chip {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.85em;
  text-align: center;
}
.chip[data-active="true"] {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
  font-weight: 700;
}

/* ---- スライダー ---- */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: var(--border-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elevated);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elevated);
  cursor: pointer;
}

.slider-reset {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.slider-reset svg { width: 15px; height: 15px; stroke: var(--text-secondary); fill: none; }

/* ---- 言語ボタン ---- */
.lang-row { display: flex; gap: 8px; }
.lang-btn {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85em;
}
.lang-btn[data-active="true"] {
  background: var(--accent);
  color: #0b0b0d;
  border-color: var(--accent);
}

/* ---- モーダル(確認) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal-sheet {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(20px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
  animation: sheet-up 0.2s ease;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 20px; }
}
@keyframes sheet-up {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-title { font-weight: 700; font-size: 1.02em; margin: 0 0 8px; }
.modal-text { color: var(--text-secondary); font-size: 0.88em; margin: 0 0 18px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; }

footer.app-footer {
  text-align: center;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  font-size: 0.72em;
  color: var(--text-tertiary);
}

/* ---- スクロールバー(最小限) ---- */
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }

/* ---- レスポンシブ ---- */
@media (min-width: 900px) {
  .content { max-width: 720px; }
}

@media (max-width: 360px) {
  .swatch-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 横画面での高さ確保 */
@media (max-height: 480px) and (orientation: landscape) {
  .card { padding: 12px; }
  .content { gap: 10px; padding: 10px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
