/* ============================================================
   菜谱工坊 · Recipe Studio
   HTML + CSS + JS + Cloudflare
   ============================================================ */

:root {
  --primary: #e8590c;          /* 暖橙 —— 食欲色 */
  --primary-dark: #d9480f;
  --primary-soft: #fff4e6;
  --success: #2f9e44;
  --success-soft: #ebfbee;
  --danger: #e03131;
  --danger-soft: #fff5f5;
  --warn: #e67700;
  --warn-soft: #fff9db;
  --text: #2b2b2b;
  --text-muted: #868e96;
  --bg: #faf7f2;
  --card-bg: #ffffff;
  --border: #eee5da;
  --shadow: 0 2px 10px rgba(60, 40, 20, 0.08);
  --shadow-lg: 0 12px 40px rgba(60, 40, 20, 0.18);
  --radius: 14px;
  --radius-sm: 8px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
          "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden { display: none !important; }

/* ---------------- 顶部导航 ---------------- */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 6px rgba(60, 40, 20, 0.05);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 20px;
  cursor: pointer;
  user-select: none;
}

.brand-icon { font-size: 24px; }

.nav { display: flex; gap: 8px; }

/* ---------------- 按钮 ---------------- */
.btn {
  font-family: inherit;
  font-size: 15px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-dark); }

.btn.primary.big { font-size: 16px; padding: 12px 26px; border-radius: 10px; }

.btn.ghost {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #ffc9c9;
}
.btn.danger:hover { background: #ffe3e3; }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

/* 顶部导航按钮 */
.nav-btn {
  font-family: inherit;
  font-size: 15px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-btn:hover { border-color: var(--primary); color: var(--primary); }

.nav-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.nav-btn.primary:hover { background: var(--primary-dark); color: #fff; }

.nav-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ---------------- 模式提示条 ---------------- */
.mode-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid #ffe8a3;
  color: var(--warn);
  font-size: 13px;
  padding: 6px 0;
  text-align: center;
}

/* ---------------- 视图 ---------------- */
main { flex: 1; padding: 28px 0 48px; }

.view { animation: fade-in 0.25s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.list-head h1 { font-size: 26px; }

.count-badge {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 1px 8px;
  margin-left: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  font-size: 14px;
  vertical-align: middle;
}

/* ---------------- 菜谱卡片网格 ---------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.recipe-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: var(--primary-soft);
  display: block;
}

.card-img-placeholder {
  width: 100%;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  background: linear-gradient(135deg, var(--primary-soft), #ffe8cc);
}

.card-body { padding: 14px 16px 16px; }

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------------- 空状态 ---------------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 64px; margin-bottom: 14px; }

/* ---------------- 表单卡片 ---------------- */
.form-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.form-head h1 { font-size: 24px; }

.form-section { margin-bottom: 18px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  margin-bottom: 14px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

.section-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 12px; }

/* 图片上传区 */
.upload-area {
  position: relative;
  border: 2px dashed #e0b68f;
  border-radius: var(--radius);
  background: var(--primary-soft);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-align: center;
  overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover { border-color: var(--primary); background: #ffe8cc; }

.upload-area.has-image { border-style: solid; padding: 0; }

.upload-icon { font-size: 42px; }
.upload-hint .sub { font-size: 12px; color: var(--text-muted); }

.image-preview {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
}

.upload-area .btn.ghost {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.92);
}

/* 输入框 */
.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 89, 12, 0.15);
}

/* 动态行列表（食材 / 步骤） */
.row-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fade-in 0.2s ease;
}

.row-item .row-index {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-item input,
.row-item textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  transition: border-color 0.15s ease;
}

.row-item input:focus,
.row-item textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.row-item .ing-name { flex: 2; }
.row-item .ing-amount { flex: 1; min-width: 110px; }
.row-item textarea { flex: 1; resize: vertical; min-height: 60px; }

.row-remove {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease;
}

.row-remove:hover { background: #ffe3e3; }

.add-row-btn { width: 100%; }

/* 自检进度 */
.check-progress { margin-bottom: 14px; }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #f08c00);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-text { font-size: 13px; color: var(--text-muted); }

/* 自检报告 */
.check-report {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.check-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.check-item .check-icon { font-size: 17px; flex-shrink: 0; }
.check-item.ok   { color: var(--success); }
.check-item.fail { color: var(--danger); background: var(--danger-soft); }
.check-item.warn { color: var(--warn); background: var(--warn-soft); }
.check-item .check-detail { color: var(--text-muted); font-size: 13px; }

.check-verdict {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
  font-size: 16px;
}

.check-verdict.pass { color: var(--success); }
.check-verdict.fail { color: var(--danger); }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ---------------- 弹窗 ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 10, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.2s ease;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  z-index: 2;
  box-shadow: var(--shadow);
}

.modal-close:hover { background: #fff; color: var(--danger); }

.detail-image {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  background: var(--primary-soft);
  display: block;
}

.detail-image-placeholder {
  width: 100%;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  background: linear-gradient(135deg, var(--primary-soft), #ffe8cc);
}

.modal-body { padding: 22px 26px 26px; }

.modal-body h2 { font-size: 24px; margin-bottom: 6px; }

.detail-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

.modal-body h3 {
  font-size: 16px;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.detail-ingredients { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.detail-ingredients li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

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

.detail-steps { padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

.detail-steps li { padding-left: 4px; }

.detail-actions { margin-top: 24px; text-align: right; }

/* ---------------- Toast ---------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.toast {
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease;
  max-width: 90vw;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- 页脚 ---------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  padding: 16px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 560px) {
  .card-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-img, .card-img-placeholder { height: 120px; }
  .form-head { flex-wrap: wrap; }
  .row-item { flex-wrap: wrap; }
  .row-item .ing-name { flex: 1 1 100%; }
  .row-item .ing-amount { flex: 1; }
  .modal-body { padding: 18px; }
}
