/*
  雲仙市ゴミの日お知らせくん - 受信設定画面

  デザインの方向性:
  ・行政文書でもSaaSダッシュボードでもない、生活インフラの落ち着いた信頼感
  ・「必須の通知設定」と「任意アンケート」を色と強弱で明確に分ける
  ・強い色（アクセントのオレンジ）は保存ボタンと選択状態にだけ使う
  ・375〜430px幅のLINE内ブラウザでの片手操作を最優先
*/

:root {
  /* --- 色 --- */
  --color-bg: #eef3ea;             /* 背景: やわらかい淡緑グレー */
  --color-surface: #ffffff;        /* フォーム全体の下地 */
  --color-primary: #1f5d4e;        /* 深い緑: 見出し・必須ラベル */
  --color-primary-dark: #163f35;
  --color-text: #1c2b27;
  --color-text-muted: #5b6b65;
  --color-border: #dde4d8;
  --color-border-strong: #c6d1c0;

  --color-accent: #db8a2b;         /* 夕方の通知をイメージした暖色。選択状態の縁取り */
  --color-accent-soft: #f8e9d2;    /* 選択状態の背景（薄） */
  --color-accent-strong: #a15d14;  /* 保存ボタン本体（コントラスト確保のため濃色） */
  --color-accent-strong-active: #8a4d10;

  --color-text-faint: #7c8a83;     /* 任意項目の見出し（必須より一段弱いトーン） */
  --color-muted-selected-bg: #e2ebe6;    /* 任意アンケートの選択状態の背景（控えめだが分かる） */
  --color-muted-selected-border: #9cb6ab; /* 任意アンケートの選択状態の縁取り */

  --color-error: #b3261e;
  --color-error-bg: #fbeae9;
  --color-success: #1f5d4e;
  --color-success-bg: #e6f0ea;

  /* --- 形状 --- */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-pill: 999px;

  /* --- 書体 --- */
  --font-base: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", "Yu Gothic", "Noto Sans JP", sans-serif;

  --shadow-soft: 0 1px 2px rgba(28, 43, 39, 0.06), 0 6px 16px rgba(28, 43, 39, 0.05);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ===== ヘッダー ===== */

.header {
  margin-bottom: 28px;
}

.header__title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-primary-dark);
}

.header__lede {
  margin: 0;
  font-size: 14.5px;
  color: var(--color-text-muted);
}

/* ===== フォーム全体 ===== */

.form {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 24px 20px 28px;
}

.field {
  padding: 20px 0;
  border-bottom: 1px solid var(--color-border);
}

.field:first-child {
  padding-top: 0;
}

.field:last-of-type {
  border-bottom: none;
}

.field__label {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
}

.field__label--muted {
  color: var(--color-text-faint);
  font-weight: 500;
  font-size: 14px;
}

.field__hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.field__error {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-error);
}

/* ===== セレクト（町・年代） ===== */

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 52px;
  padding: 0 40px 0 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}

.select-wrap select:focus-visible {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 2px;
}

.select-wrap--muted select {
  background: #fbfcfa;
}

/* 未選択（プレースホルダー）の文字色を少し弱める */
.select-wrap select:invalid,
.select-wrap select option[value=""] {
  color: var(--color-text-muted);
}

/* エラー時 */
.select-wrap select[aria-invalid="true"] {
  border-color: var(--color-error);
}

/* ===== 2択スイッチ（燃えるごみ通知） ===== */

.switch {
  display: flex;
  background: #f1f4ee;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 4px;
}

.switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.switch__option {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.switch__input:checked + .switch__option {
  background: var(--color-primary);
  color: #ffffff;
}

.switch__input:focus-visible + .switch__option {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 2px;
}

/* ===== 2×2グリッド選択（通知時間・性別） ===== */

.grid-choice {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.grid-choice__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.grid-choice__option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px 8px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.grid-choice__input:checked + .grid-choice__option {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  color: var(--color-primary-dark);
}

.grid-choice--muted .grid-choice__input:checked + .grid-choice__option {
  background: var(--color-muted-selected-bg);
  border-color: var(--color-muted-selected-border);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.grid-choice__input:focus-visible + .grid-choice__option {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 2px;
}

/* ===== 区切り（任意アンケート） ===== */

.divider {
  display: flex;
  align-items: center;
  margin: 18px 0 4px;
  color: var(--color-text-muted);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.divider__label {
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 600;
}

.optional-lede {
  margin: 0 0 2px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  text-align: center;
}

.field--optional {
  padding: 14px 0;
}

/* ===== 保存エリア ===== */

.save-area {
  margin-top: 26px;
}

.save-button {
  display: block;
  width: 100%;
  min-height: 54px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #ffffff;
  background: var(--color-accent-strong);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.save-button:hover {
  background: var(--color-accent-strong-active);
}

.save-button:focus-visible {
  outline: 2px solid var(--color-primary-dark);
  outline-offset: 2px;
}

.save-button:disabled {
  opacity: 0.65;
  cursor: default;
}

.status {
  margin: 14px 0 0;
  min-height: 1.4em;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.status--success {
  color: var(--color-success);
  background: var(--color-success-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.status--error {
  color: var(--color-error);
  background: var(--color-error-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ===== フッター ===== */

.footer {
  margin-top: 20px;
  min-height: 1px;
}

/* ===== アクセシビリティ配慮 ===== */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
