/* =====================================================
   神厨养成系统 · 最终版样式（原生 CSS，替代 Element Plus）
   风格：卡通暖色 + emoji 占位图（计划约定：先占位，课前可换真图）
   M2 新增：卡片操作按钮 + 做饭教学页（进度条 / 步骤卡 / 完成页）
   M3 新增：步骤排序小游戏（打乱卡片 / 顺序角标 / 得分动画）+ 排行榜表格
   M4 新增：留言品鉴（写品鉴表单 / 星级按钮 / 留言列表 / 留言入口按钮）
   ===================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #fff7e6;               /* 奶油色背景 */
  color: #4a3728;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 92%; max-width: 960px; margin: 0 auto; padding-bottom: 32px; }

/* ---------- 顶部标题栏 ---------- */
.topbar {
  background: #ff9f43;               /* 主色：暖橙 */
  color: #fff;
  text-align: center;
  padding: 20px 16px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: 2px; }
.subtitle { margin: 6px 0 0; font-size: 13px; opacity: .92; }

.section-title { font-size: 20px; margin: 24px 4px 14px; }

/* ---------- 图鉴卡片列表 ---------- */
.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* 卡片：相当于 Element Plus 的 el-card，这里用原生 CSS 写
   （M2：卡片从 <a> 换成 <div>，整卡点击由 gallery.js 的事件委托处理，
   所以这里要补 cursor:pointer 提示"可以点"） */
.dish-card {
  display: block;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  border: 2px solid transparent;
  transition: transform .12s, border-color .12s;
  cursor: pointer;
}
.dish-card:hover { transform: translateY(-4px); border-color: #ff9f43; }

/* emoji 占位图：圆形色块，三张卡轮换三种底色 */
.dish-emoji {
  width: 84px; height: 84px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  margin: 0 auto 12px;
}
.dish-card:nth-child(3n+1) .dish-emoji { background: #ffe0b2; }  /* 鸡：浅橙 */
.dish-card:nth-child(3n+2) .dish-emoji { background: #d1ecf1; }  /* 蚝：浅蓝 */
.dish-card:nth-child(3n+3) .dish-emoji { background: #e2f0d9; }  /* 炊：浅绿 */

.dish-name { margin: 0 0 8px; font-size: 20px; text-align: center; }
.dish-story {
  font-size: 13px; line-height: 1.7; color: #7a6a5a;
  margin: 0 0 12px; min-height: 66px;
}

/* 难度标签：相当于 el-tag，颜色按难度区分 */
.tag {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: bold;
}
.tag-easy { background: #e6f5e9; color: #2e8b57; }   /* 简单=绿 */
.tag-mid  { background: #fff1dc; color: #d35400; }   /* 中等=橙 */
.tag-hard { background: #fdeaea; color: #c0392b; }   /* 困难=红 */

.card-bottom { text-align: center; margin-top: 10px; }

/* M2：卡片底部的两个操作按钮（查看详情 / 开始教学） */
.card-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
.card-actions a {
  font-size: 13px;
  font-weight: bold;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  transition: transform .12s;
}
.card-actions a:hover { transform: scale(1.06); }
.detail-btn { background: #fff1dc; color: #d35400; }   /* 详情：浅橙 */
.cook-btn   { background: #ff9f43; color: #fff; }      /* 教学：主色橙 */
.game-btn   { background: #e8f4fd; color: #2471a3; }   /* M3 挑战：浅蓝，和教学橙区分开 */

/* ---------- 详情页 ---------- */
.back-link {
  display: inline-block;
  margin: 20px 0 14px;
  color: #d35400;
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { text-decoration: underline; }

.detail-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}
.detail-head { text-align: center; margin-bottom: 18px; }
.detail-emoji { font-size: 72px; line-height: 1; }
.detail-head h2 { margin: 10px 0 8px; font-size: 26px; }

.detail-section { margin-top: 18px; }
.detail-section h3 {
  font-size: 15px;
  color: #d35400;
  border-left: 4px solid #ff9f43;
  padding-left: 8px;
  margin: 0 0 8px;
}
.detail-story { font-size: 15px; line-height: 1.9; margin: 0; }

/* 食材清单：两列小卡片 */
.ingredient-list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.ingredient-list li {
  background: #fff7e6;
  border: 1px dashed #ffcf9e;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  text-align: center;
}

/* 找不到菜品时的提示框 */
.not-found {
  background: #fdeaea;
  color: #c0392b;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: #9b8a77;
}
.badge {
  display: inline-block;
  background: #efe6d8;
  border-radius: 999px;
  padding: 3px 12px;
  margin-right: 8px;
  font-weight: bold;
}
.badge.source-api     { background: #e6f5e9; color: #2e8b57; }
.badge.source-fallback{ background: #fff1dc; color: #d35400; }
.hint { display: block; margin-top: 6px; }

/* ---------- M2：做饭教学页（cook.html） ---------- */

/* 详情页底部的"开始做这道菜"大按钮 */
.cook-entry { text-align: center; margin-top: 22px; }
.cook-btn.big {
  display: inline-block;
  background: #ff9f43;
  color: #fff;
  font-size: 17px;
  font-weight: bold;
  text-decoration: none;
  padding: 12px 34px;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(255,159,67,.45);
  transition: transform .12s;
}
.cook-btn.big:hover { transform: scale(1.05); }

/* 教学卡：整块白色圆角卡片，步骤内容都在里面 */
.cook-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  text-align: center;
}
.cook-dish-emoji { font-size: 54px; line-height: 1; }
.cook-head h2 { margin: 8px 0 14px; font-size: 24px; }

/* 进度条：第 X / N 步的文字 + 橙色填充条（点下一步会同步变化） */
.progress-line { font-size: 14px; color: #7a6a5a; margin-bottom: 8px; }
.progress-line b { color: #d35400; font-size: 18px; }
.progress-bar {
  width: 100%;
  height: 14px;
  background: #f3e8d8;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb26b, #ff9f43);  /* 渐变橙，前进感 */
  border-radius: 999px;
  transition: width .25s;   /* 宽度变化时平滑过渡 */
}

/* 当前步骤展示区：大图占位（emoji）+ 步骤文字 */
.step-stage {
  background: #fff7e6;
  border: 2px dashed #ffcf9e;
  border-radius: 14px;
  padding: 24px 20px;
  margin-bottom: 20px;
}
.step-emoji { font-size: 76px; line-height: 1.2; }
.step-text {
  font-size: 17px;
  line-height: 1.9;
  margin: 12px 0 0;
  color: #4a3728;
}

/* 上一步 / 下一步按钮 */
.cook-btns {
  display: flex;
  gap: 14px;
  justify-content: center;
}
.btn {
  font-size: 15px;
  font-weight: bold;
  padding: 10px 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;   /* 完成页的"回到图鉴"是 <a>，去掉下划线 */
  transition: transform .12s;
}
.btn:hover { transform: scale(1.05); }
.btn.prev { background: #efe6d8; color: #7a6a5a; }
.btn.next { background: #ff9f43; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* 完成页 */
.done-card { padding-top: 36px; }
.done-emoji { font-size: 84px; line-height: 1; }
.done-card h2 { margin: 14px 0 10px; font-size: 26px; color: #d35400; }
.done-text { font-size: 15px; line-height: 1.9; color: #7a6a5a; margin: 0 0 24px; }
.btn-link { display: inline-block; }   /* 让"回到图鉴"<a> 和按钮一样对齐 */

/* 教程筹备中（某道菜还没有步骤资料时的最小可交付提示） */
.not-found.preparing { background: #fff1dc; color: #d35400; }
.not-found.preparing a { color: #d35400; }

/* ---------- M3：步骤排序小游戏（game.html） ---------- */

/* 游戏卡沿用教学卡的白色圆角底，只是内容换成了题目 */
.game-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  text-align: center;
}
.game-tip { font-size: 14px; color: #7a6a5a; margin: 6px 0 18px; }

/* 打乱的步骤卡：网格铺开，hover 抬起提示"可以点" */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.quiz-card {
  position: relative;
  background: #fff7e6;
  border: 2px dashed #ffcf9e;
  border-radius: 14px;
  padding: 18px 14px 14px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, opacity .12s;
}
.quiz-card:hover { transform: translateY(-3px); border-color: #ff9f43; }

/* 已点选的卡：变实线 + 变淡，左上角盖上"第几张"的圆形角标 */
.quiz-card.picked { border-style: solid; border-color: #2471a3; opacity: .62; cursor: default; }
.quiz-order {
  position: absolute;
  top: -10px; left: -10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #2471a3;
  color: #fff;
  font-size: 14px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.quiz-emoji { font-size: 38px; line-height: 1.2; }
.quiz-text { font-size: 13px; line-height: 1.7; color: #4a3728; margin: 8px 0 0; }

/* 得分动画：数字从很小弹到正常大小（keyframes 里的 scale 变化） */
.score-anim {
  font-size: 52px;
  font-weight: bold;
  color: #d35400;
  margin: 6px 0 4px;
  animation: score-pop .5s ease-out;
}
@keyframes score-pop {
  0%   { transform: scale(.2); opacity: 0; }
  60%  { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); }
}

/* 提交昵称表单：一行排开，输入框圆角呼应整体风格 */
.name-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}
.name-form label { font-size: 14px; font-weight: bold; }
.name-form input {
  font-size: 15px;
  padding: 9px 14px;
  border: 2px solid #ffcf9e;
  border-radius: 999px;
  outline: none;
  width: 200px;
}
.name-form input:focus { border-color: #ff9f43; }
.form-msg { font-size: 13px; min-height: 18px; margin: 4px 0 14px; }
.form-msg.ok   { color: #2e8b57; }
.form-msg.warn { color: #c0392b; }

/* ---------- M3：排行榜（rank.html） ---------- */
.rank-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}
.rank-card h2 { margin: 0 0 18px; text-align: center; color: #d35400; }

/* 榜单表格：表头橙色底，隔行换色方便横向看行 */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.rank-table th {
  background: #ff9f43;
  color: #fff;
  padding: 10px 8px;
}
.rank-table td { padding: 10px 8px; text-align: center; border-bottom: 1px solid #f3e8d8; }
.rank-table tbody tr:nth-child(even) { background: #fffaf0; }   /* 隔行浅米色 */
.rank-medal { font-size: 18px; }
.rank-name  { font-weight: bold; }
.rank-score { color: #d35400; font-weight: bold; }
.rank-mistakes { color: #9b8a77; font-size: 13px; }
.rank-time  { color: #9b8a77; font-size: 12px; }

/* 详情页 / 完成页里的大号"挑战排序"按钮（和 .cook-btn.big 同尺寸） */
.game-btn.big {
  display: inline-block;
  background: #e8f4fd;
  color: #2471a3;
  font-size: 17px;
  font-weight: bold;
  text-decoration: none;
  padding: 12px 34px;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(36,113,163,.3);
  transition: transform .12s;
  margin-left: 12px;
}
.game-btn.big:hover { transform: scale(1.05); }

/* ---------- M4（第 10 课）：留言品鉴（comments.html + 图鉴/详情入口） ---------- */

/* 留言入口按钮：图鉴页中间的小入口 + 详情页底部的大按钮，浅绿和橙/蓝按钮区分开 */
.comment-btn {
  display: inline-block;
  background: #e6f5e9;
  color: #2e8b57;
  font-size: 13px;
  font-weight: bold;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  transition: transform .12s;
}
.comment-btn:hover { transform: scale(1.06); }
.comments-entry { text-align: center; margin-top: 22px; }
.comment-btn.big {
  font-size: 17px;
  padding: 12px 34px;
  box-shadow: 0 3px 8px rgba(46,139,87,.28);
  margin-left: 12px;
}
.comment-btn.big:hover { transform: scale(1.05); }

/* 留言页整体两栏：宽屏表单在左、留言列表在右；窄屏自动上下排 */
.comments-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 760px) {
  .comments-layout { grid-template-columns: 1fr; }
}

.comment-form-card,
.comment-list-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}
.comment-form-card h2,
.comment-list-card h2 { margin: 0 0 16px; font-size: 20px; color: #d35400; text-align: center; }

/* 表单行：label 在上、控件在下（label 是必要的表单标签，保留） */
.form-row { margin-bottom: 14px; }
.form-row > label {
  display: block;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 6px;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  font-size: 15px;
  font-family: inherit;
  padding: 9px 12px;
  border: 2px solid #ffcf9e;
  border-radius: 10px;
  outline: none;
  background: #fffdfa;
  color: #4a3728;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: #ff9f43; }
.form-row textarea { resize: vertical; min-height: 84px; }

/* 星级评分：5 颗可点的星星按钮，点亮的变金黄 */
.star-row { display: flex; gap: 4px; }
.star-btn {
  font-size: 30px;
  line-height: 1;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #e5d9c6;               /* 没点亮：浅灰米色 */
  transition: transform .12s, color .12s;
}
.star-btn:hover { transform: scale(1.15); }
.star-btn.on { color: #ffb400; }   /* 点亮：金黄 */

/* 留言列表：一条留言一张浅米卡片，新的在最上面 */
.comment-item {
  background: #fff7e6;
  border: 1px dashed #ffcf9e;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.comment-dish {
  font-size: 13px;
  color: #d35400;
  background: #fff1dc;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: bold;
}
.comment-stars { color: #ffb400; letter-spacing: 2px; font-size: 15px; }
.comment-author { font-weight: bold; font-size: 14px; }
.comment-text {
  font-size: 14px;
  line-height: 1.7;
  color: #4a3728;
  margin: 8px 0 0;
  word-break: break-word;      /* 很长的英文/网址也能正常换行 */
}
.comment-time { display: block; font-size: 12px; color: #9b8a77; margin-top: 6px; }
