/* ============================================
   品牌色（CSS 變數）
   ============================================ */
:root {
  --bg-cream: #FAF7F0;
  --text-primary: #6B4423;
  --text-secondary: #9C7B5C;
  --accent-gold: #C9A961;
  --accent-gold-dark: #A88947;
  --card-white: #FFFFFF;
  --border-light: #E8E0D5;
  --can-make: #7BA05B;
  --missing: #D49B4F;
}

/* ============================================
   全域微調
   ============================================ */
html {
  scroll-behavior: smooth;
}

body {
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* iOS 避免輸入框自動 zoom（字體 ≥ 16px） */
textarea, input {
  font-size: 16px;
}

/* 自訂 scrollbar（電腦版） */
@media (min-width: 768px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-track {
    background: var(--bg-cream);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
  }
}

/* ============================================
   快速食材 chips
   ============================================ */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 999px;
  border: 1.5px solid var(--border-light);
  background: var(--card-white);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--accent-gold);
  background: var(--bg-cream);
}

.chip-active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--card-white);
}

.chip-active:hover {
  background: var(--accent-gold-dark);
  border-color: var(--accent-gold-dark);
}

/* ============================================
   分類 tabs
   ============================================ */
.tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 999px;
  border: 1.5px solid var(--border-light);
  background: var(--card-white);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.tab-active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--card-white);
}

.tab-active:hover {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--card-white);
}

/* ============================================
   料理卡片
   ============================================ */
.recipe-card {
  background: var(--card-white);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(107, 68, 35, 0.08);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-card:hover {
  box-shadow: 0 4px 16px rgba(107, 68, 35, 0.12);
  transform: translateY(-2px);
  border-color: var(--border-light);
}

.recipe-card:focus {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.recipe-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 4px 0 0 0;
}

.recipe-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.recipe-meta {
  display: flex;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.recipe-ingredients {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-light);
  line-height: 1.5;
}

/* ============================================
   標籤 Badge
   ============================================ */
.badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  align-self: flex-start;
}

.badge-can-make {
  background: var(--can-make);
  color: var(--card-white);
}

.badge-missing {
  background: var(--missing);
  color: var(--card-white);
}

.badge-category {
  background: var(--bg-cream);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* ============================================
   Modal
   ============================================ */
.modal-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 12px 0 8px 0;
  line-height: 1.3;
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 12px 0;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.modal-meta span {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--bg-cream);
  border-radius: 999px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 8px;
  background: var(--bg-cream);
  border-radius: 4px;
}

.modal-section {
  margin-bottom: 28px;
}

.modal-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  padding-left: 12px;
  border-left: 4px solid var(--accent-gold);
}

/* 食材清單 */
.ingredients-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ingredients-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-light);
  font-size: 0.95rem;
}

.ingredients-list li:last-child {
  border-bottom: none;
}

.ing-name {
  color: var(--text-primary);
  font-weight: 500;
}

.ing-amount {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: right;
  margin-left: 12px;
}

.seasonings {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-cream);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* 作法步驟 */
.steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
}

.steps-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border-light);
  font-size: 1rem;
  line-height: 1.7;
}

.steps-list li:last-child {
  border-bottom: none;
}

.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gold);
  color: var(--card-white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 2px;
}

.step-text {
  flex: 1;
  color: var(--text-primary);
}

/* Tips 區塊 */
.modal-tips {
  background: linear-gradient(135deg, #FFF8E7, #FAF0DD);
  border: 1px solid #E8D9B0;
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 16px;
}

.modal-tips h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-gold-dark);
  margin: 0 0 8px 0;
}

.modal-tips p {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ============================================
   動畫
   ============================================ */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.input-shake {
  animation: shake 0.5s ease;
  border-color: var(--missing) !important;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modal 開啟動畫（手機從下、桌面淡入） */
#recipe-modal:not(.hidden) #modal-backdrop {
  animation: fadeIn 0.2s ease;
}

#recipe-modal:not(.hidden) #modal-panel {
  animation: slideUp 0.3s ease;
}

@media (min-width: 768px) {
  @keyframes slideRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
  }
  #recipe-modal:not(.hidden) #modal-panel {
    animation: slideRight 0.3s ease;
  }
}

/* ============================================
   使用教學 Overlay
   ============================================ */
.help-btn {
  position: absolute;
  top: 0;
  right: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-light);
  background: var(--card-white);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.help-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.tutorial-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(60, 40, 20, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.25s ease;
}

.tutorial-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--card-white);
  border-radius: 24px;
  padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: tutorialPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 92vh;
  overflow-y: auto;
}

@keyframes tutorialPop {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.tutorial-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-close:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.tutorial-step {
  text-align: center;
  padding: 8px 0 24px;
  animation: stepFade 0.3s ease;
}

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

.tutorial-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
  animation: iconBounce 0.5s ease 0.1s both;
}

@keyframes iconBounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.tutorial-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.tutorial-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0 0 20px 0;
}

.tutorial-tip {
  font-size: 0.825rem;
  color: var(--text-secondary);
  background: var(--bg-cream);
  padding: 10px 14px;
  border-radius: 12px;
  margin: 16px 0 0 0;
  text-align: left;
  line-height: 1.5;
}

/* Visual demos in tutorial */
.tutorial-visual {
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--bg-cream);
  border-radius: 16px;
  border: 1px dashed var(--border-light);
}

.visual-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--card-white);
  border: 1.5px solid var(--accent-gold);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-align: left;
}

.visual-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.visual-chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border-light);
  background: var(--card-white);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
}

.visual-chip-on {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--card-white);
}

.visual-button {
  padding: 12px 24px;
  background: var(--accent-gold);
  color: var(--card-white);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(201, 169, 97, 0.3);
}

.visual-badges {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

.visual-card {
  width: 100%;
  align-items: stretch;
  background: var(--card-white);
  border: 1px solid var(--border-light);
  padding: 14px 16px;
  gap: 4px;
  text-align: left;
}

.visual-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.visual-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.visual-card-step {
  font-size: 0.825rem;
  color: var(--text-primary);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-light);
}

/* Footer */
.tutorial-footer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.tutorial-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  cursor: pointer;
  transition: all 0.25s ease;
}

.dot.active {
  background: var(--accent-gold);
  width: 24px;
  border-radius: 4px;
}

.tutorial-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-skip {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 10px 4px;
  font-weight: 500;
}

.tutorial-skip:hover {
  color: var(--text-primary);
}

.tutorial-btn-primary,
.tutorial-btn-secondary {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.tutorial-btn-primary {
  background: var(--accent-gold);
  border: 1.5px solid var(--accent-gold);
  color: var(--card-white);
  flex: 1;
  max-width: 180px;
  margin-left: auto;
}

.tutorial-btn-primary:hover {
  background: var(--accent-gold-dark);
  border-color: var(--accent-gold-dark);
}

.tutorial-btn-secondary {
  background: var(--card-white);
  border: 1.5px solid var(--border-light);
  color: var(--text-primary);
}

.tutorial-btn-secondary:hover {
  border-color: var(--text-secondary);
}

/* ============================================
   無障礙：reduce motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
