/*
 * 風城路報｜試用網頁 — 樣式
 *
 * 配色與圓角取自簡報（簡報原始檔/shared.css）。只用系統字型，不載入任何外部資源。
 * 手機優先：內容最寬 480px 置中；可點的地方至少 44px 高；360px 寬不會出現水平捲軸。
 */

/* ------------------------------------------------------------
   1. 設計變數（簡報配色）
   ------------------------------------------------------------ */
:root {
  --bg: #F8F9F5;           /* 頁面背景 */
  --green: #275849;        /* 主色：主要按鈕、標籤、照片上的膠囊 */
  --green-dark: #1F4D3E;   /* 強調文字 */
  --mint: #EEF3E8;         /* 柔和薄荷綠：草稿卡片、次要按鈕 */
  --mint-strong: #D8EAD2;  /* 重點薄荷綠：AI 辨識膠囊、位置列 */
  --ink: #12291E;          /* 標題 */
  --text: #17271E;         /* 內文 */
  --muted: #4B5A4F;        /* 次要文字 */
  --card: #FFFEF9;         /* 白色卡片 */
  --line: #DCE4D7;         /* 分隔線 */
  --field-line: #B9C9BD;   /* 輸入框邊框 */
  --photo-bg: #1A2922;     /* 照片底色（簡報手機外框色） */
  --warn-bg: #FEF9F3;      /* 提醒（簡報裡的橘色框） */
  --warn-line: #E9A86B;
  --warn-ink: #7A4A1C;
  --error: #9B2C1F;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(32, 64, 48, 0.07), 0 1px 3px rgba(32, 64, 48, 0.06);
  --font: system-ui, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;

  color-scheme: light;
}

/* ------------------------------------------------------------
   2. 基本設定
   ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 讓 hidden 屬性一定有效（避免被下面的 display 設定蓋掉） */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere; /* AI 回傳的長字串也會換行，不撐破版面 */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p,
figure,
dl,
dd {
  margin: 0;
}

a {
  color: var(--green);
}

:focus-visible {
  outline: 3px solid var(--green-dark);
  outline-offset: 2px;
}

/* 程式切換畫面時會把焦點移到標題（給螢幕報讀器），標題本身不需要外框 */
[tabindex="-1"]:focus {
  outline: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------
   3. 版面
   ------------------------------------------------------------ */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
}

.brand-name {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* 「黑客松原型・非新竹市政府官方服務」 */
.chip {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid #C5DCC0;
  border-radius: 999px;
  background: var(--mint-strong);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.screen-title {
  margin-bottom: 14px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--ink);
  text-wrap: balance; /* 避免最後一行只剩一兩個字（不支援的瀏覽器會忽略） */
}

.status-sheet p {
  text-wrap: pretty;
}

.section-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

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

.center {
  text-align: center;
}

.pre {
  white-space: pre-wrap; /* 保留內容裡的換行 */
}

/* 標題裡的一個短句：窄螢幕時整句一起換行，不從中間斷開 */
.phrase {
  display: inline-block;
}

/* ------------------------------------------------------------
   4. 按鈕
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

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

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 16px rgba(39, 88, 73, 0.22);
}

.btn-primary:hover {
  background: var(--green-dark);
}

.btn-soft {
  background: var(--mint);
  border-color: var(--line);
  color: var(--green-dark);
}

.btn-soft:hover {
  background: #E4ECDD;
}

.btn-block {
  width: 100%;
}

/* 首頁的大按鈕 */
.btn-big {
  width: 100%;
  min-height: 64px;
  border-radius: 20px;
  font-size: 19px;
}

.btn-big .icon {
  width: 26px;
  height: 26px;
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* 檔案選擇框藏起來，用 label 當按鈕；鍵盤移到選擇框時，讓 label 顯示外框 */
.file-input:focus-visible + .btn {
  outline: 3px solid var(--green-dark);
  outline-offset: 3px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.actions .btn {
  width: 100%;
  padding-left: 12px;
  padding-right: 12px;
}

.actions-stack {
  grid-template-columns: 1fr;
}

/* 草稿畫面最下面的「換一張照片」 */
.btn-retake {
  margin-top: 12px;
}

/* 左邊的按鈕被隱藏時（例如第 3 級沒有「修改內容」），右邊的按鈕佔滿整列 */
.actions > .btn[hidden] + .btn {
  grid-column: 1 / -1;
}

/* 線條圖示（顏色跟著文字） */
.icon {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------
   5. 首頁
   ------------------------------------------------------------ */
.home-lead {
  margin-bottom: 18px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.45;
  color: var(--ink);
  text-wrap: balance;
}

.upload {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* 有滑鼠的桌機不顯示「直接開啟相機」（桌機瀏覽器會忽略 capture） */
@media (hover: hover) and (pointer: fine) {
  .touch-only {
    display: none;
  }
}

.samples {
  margin-top: 28px;
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 420px) {
  .samples-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.sample-btn {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}

.sample-btn img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--mint);
}

.sample-title {
  display: block;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

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

/* 範例照片的小字來源 */
.sample-credit {
  margin-top: 4px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* ------------------------------------------------------------
   6. 卡片、照片
   ------------------------------------------------------------ */
.sheet {
  overflow: hidden;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.sheet-body {
  padding: 16px;
}

.photo {
  position: relative;
  background: var(--photo-bg);
}

.photo img {
  width: 100%;
  max-height: 52vh;
  object-fit: contain; /* 照片完整顯示，方便民眾核對 */
}

/* 草稿畫面的照片小一點，手機上才能早點看到草稿內容（分析中的畫面維持 52vh） */
#screen-result .photo img {
  max-height: min(38vh, 320px);
}

/* 照片左上角的膠囊（簡報：「AI 已幫你整理好通報內容」） */
.photo-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.photo-credit {
  padding: 6px 16px 0;
  color: var(--muted);
  font-size: 12px;
}

/* 分析中：照片變暗，中間放轉圈圈 */
.photo-analyzing {
  min-height: 220px;
}

.photo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 41, 30, 0.45);
}

.spinner {
  width: 52px;
  height: 52px;
  border: 5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.analyzing-text {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

/* ------------------------------------------------------------
   7. 草稿（比照簡報手機畫面的薄荷綠卡片）
   ------------------------------------------------------------ */
.draft {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--mint);
}

/* 「✦ AI 辨識：疑似道路坑洞」 */
.ai-pill {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--mint-strong);
  color: var(--green-dark);
  font-weight: 800;
  line-height: 1.5;
}

.ai-pill .icon {
  margin-top: 1px;
}

.rows {
  display: grid;
  gap: 12px;
}

/* 一列 = 左邊標籤 + 右邊內容 */
.row {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr);
  gap: 4px 12px;
  align-items: start;
}

/* 有輸入框的列改成上下排，輸入框可以用滿寬度 */
.row.row-stacked {
  grid-template-columns: minmax(0, 1fr);
}

.row dt {
  color: var(--green);
  font-weight: 800;
}

.row dd {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.value {
  color: var(--text);
  text-wrap: pretty; /* 避免最後一行只剩一兩個字（不支援的瀏覽器會忽略） */
}

.unit {
  color: var(--muted);
  font-size: 14px;
}

.summary .unit {
  display: block;
}

.item-unknown {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 14px;
}

.tag {
  display: inline-block;
  padding: 1px 10px;
  border: 1px solid var(--warn-line);
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

/* 輸入框、下拉選單（字級 16px：iOS 才不會在點選時自動放大畫面） */
.field {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 16px;
  line-height: 1.5;
}

textarea.field {
  min-height: 150px;
  resize: vertical;
}

select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23275849' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

.field:focus {
  border-color: var(--green);
  outline: 3px solid rgba(39, 88, 73, 0.25);
  outline-offset: 0;
}

.meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.form-error {
  margin-top: 12px;
  color: var(--error);
  font-weight: 700;
}

/* ------------------------------------------------------------
   8. 提醒框、確認頁、完成與錯誤
   ------------------------------------------------------------ */
.notice {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.55;
}

.notice strong {
  font-size: 16px;
}

.notice-warn {
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.notice-line {
  display: block;
}

.home-lead + .notice {
  margin-bottom: 18px;
}

.confirm-photo {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--photo-bg);
}

/* 「📍 位置：送出前由民眾在地圖上確認（示範版略過）」 */
.location {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--mint-strong);
  color: var(--green-dark);
  font-weight: 700;
}

.note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  text-wrap: pretty;
}

.status-sheet {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 28px 20px 24px;
  text-align: center;
}

.status-sheet .actions,
.status-sheet .btn-block {
  width: 100%;
  margin-top: 16px;
}

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin-bottom: 12px;
  border-radius: 50%;
}

.status-icon .icon {
  width: 36px;
  height: 36px;
  stroke-width: 2.4;
}

.status-icon-ok {
  background: var(--green);
  color: #fff;
}

.status-icon-warn {
  background: var(--warn-bg);
  border: 2px solid var(--warn-line);
  color: var(--warn-ink);
}

.error-message {
  color: var(--ink);
  font-weight: 700;
}

/* ------------------------------------------------------------
   9. 頁尾、本機測試標示
   ------------------------------------------------------------ */
.site-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.footer-title {
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 800;
}

.footer-list {
  margin: 0;
  padding-left: 1.2em;
}

/* 「本機測試用假資料」：只在本機預覽出現 */
.mock-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0;
  padding: 8px 16px;
  border-bottom: 2px dashed var(--warn-line);
  background: #FFF1DD;
  color: var(--warn-ink);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

/* ------------------------------------------------------------
   10. 減少動態效果（系統設定「減少動態效果」時）
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
