/* ===================================================
   K-Food Buddy — style.css
   Mobile-first, max-width 480px
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  --color-primary:      #E24B4A;
  --color-primary-dark: #C43A39;
  --color-primary-soft: #FAE9E9;
  --color-bg:           #F5F5F0;
  --color-card:         #FFFFFF;
  --color-text:         #2C2C2A;
  --color-text-muted:   #888780;
  --color-border:       #E0DED8;
  --color-match-high:   #639922;
  --color-match-mid:    #BA7517;
  --color-match-low:    #E24B4A;
  --radius:             12px;
  --radius-sm:          8px;
  --max-width:          480px;
  --shadow:             0 2px 12px rgba(44,44,42,0.08);
  --shadow-card:        0 4px 20px rgba(44,44,42,0.10);
  --font-display:       'Sora', system-ui, -apple-system, sans-serif;
  --font-body:          system-ui, -apple-system, sans-serif;
  --transition:         0.18s ease;
}

/* ---------- Dark Mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:         #1A1A18;
    --color-card:       #252522;
    --color-text:       #F0EFE9;
    --color-text-muted: #807F78;
    --color-border:     #353530;
    --color-primary-soft: #3A1E1E;
    --shadow:           0 2px 12px rgba(0,0,0,0.3);
    --shadow-card:      0 4px 20px rgba(0,0,0,0.4);
  }
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  position: relative;
  overflow-x: hidden;
}

/* ---------- Screen System ---------- */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeSlideIn 0.22s ease both;
}
.screen.active { display: flex; }

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

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-icon {
  font-size: 26px;
  line-height: 1;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--color-primary);
  letter-spacing: -0.4px;
}

.plan-badge {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: none;
}
.plan-badge.visible { display: block; }
.plan-badge.pro {
  background: linear-gradient(135deg, #E24B4A, #ff8c00);
  color: #fff;
}

/* ---------- Hero Section ---------- */
.hero {
  padding: 24px 0 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.8px;
  color: var(--color-text);
  margin-bottom: 8px;
}

.hero-title span { color: var(--color-primary); }

.hero-sub {
  font-size: 15px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ---------- Form ---------- */
.form-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 16px;
}
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2px;
  color: var(--color-text);
  margin-bottom: 8px;
}

.field label .label-emoji {
  margin-right: 5px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.field input::placeholder {
  color: var(--color-text-muted);
  font-size: 14px;
}

.field input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(226,75,74,0.12);
}

/* ---------- Primary Button ---------- */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(226,75,74,0.35);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(226,75,74,0.40);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(226,75,74,0.3);
}

.btn-primary:disabled {
  background: var(--color-text-muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Secondary Button ---------- */
.btn-secondary {
  padding: 12px 20px;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.btn-secondary:hover {
  border-color: var(--color-text-muted);
  background: var(--color-bg);
}

/* ---------- Usage Counter ---------- */
.usage-bar-wrap {
  margin-bottom: 16px;
}

.usage-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

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

.usage-count {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
}

.usage-track {
  height: 4px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ---------- Popular Dishes ---------- */
.popular-section {
  margin-bottom: 28px;
}

.popular-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.popular-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 13px;
  background: var(--color-card);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

/* ============================
   SCREEN 2: LOADING
   ============================ */
#screen-loading {
  justify-content: center;
  align-items: center;
  gap: 24px;
  text-align: center;
  padding: 40px 0;
}

.loading-bowl {
  font-size: 56px;
  animation: bowlBounce 1.2s ease-in-out infinite;
}

@keyframes bowlBounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-12px) rotate(5deg); }
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

.loading-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  min-height: 28px;
  transition: opacity 0.3s;
}

.loading-sub {
  font-size: 14px;
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity 0.5s;
}
.loading-sub.show { opacity: 1; }

/* ============================
   SCREEN 3: RESULT
   ============================ */
.result-header {
  padding: 20px 0 16px;
}

.result-dish-kr {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.result-dish-en {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
  color: var(--color-text);
}

.result-servings {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Section titles */
.section-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

/* Substitution cards */
.sub-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.sub-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 3px solid transparent;
  transition: transform var(--transition);
}
.sub-card:active { transform: scale(0.99); }
.sub-card.high  { border-left-color: var(--color-match-high); }
.sub-card.mid   { border-left-color: var(--color-match-mid); }
.sub-card.low   { border-left-color: var(--color-match-low); }

.sub-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sub-original {
  font-size: 12px;
  color: var(--color-text-muted);
  text-decoration: line-through;
  margin-bottom: 2px;
}

.sub-substitute {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.match-badge {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 99px;
  white-space: nowrap;
}
.match-badge.high { background: #EAF3DC; color: var(--color-match-high); }
.match-badge.mid  { background: #FBF0DC; color: var(--color-match-mid); }
.match-badge.low  { background: var(--color-primary-soft); color: var(--color-match-low); }

@media (prefers-color-scheme: dark) {
  .match-badge.high { background: #1E2E10; }
  .match-badge.mid  { background: #2A2010; }
  .match-badge.low  { background: #3A1E1E; }
}

.sub-where {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.sub-where::before { content: '📍'; font-size: 12px; }

/* Recipe steps */
.recipe-steps {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 18px 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.step-item {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}
.step-item:last-child { margin-bottom: 0; }

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
}

/* Pro tip */
.pro-tip-box {
  background: var(--color-primary-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.pro-tip-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.pro-tip-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.pro-tip-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
}

/* Amazon section */
.amazon-section {
  margin-bottom: 20px;
}

.amazon-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: var(--color-text);
  transition: transform var(--transition), box-shadow var(--transition);
  margin-bottom: 8px;
}
.amazon-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.amazon-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.amazon-cta {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: #FF9900;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* AdSense placeholder */
.adsense-placeholder {
  background: var(--color-border);
  border-radius: var(--radius-sm);
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Result action buttons */
.result-actions {
  display: flex;
  gap: 10px;
  padding: 16px 0 32px;
}

.result-actions .btn-secondary {
  flex: 1;
}

.result-actions .btn-save {
  flex: 1;
}

/* ============================
   SCREEN 4: UPGRADE
   ============================ */
#screen-upgrade {
  justify-content: center;
  padding: 40px 0;
}

.upgrade-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  text-align: center;
}

.upgrade-emoji {
  font-size: 52px;
  display: block;
  margin-bottom: 16px;
}

.upgrade-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--color-text);
  margin-bottom: 8px;
}

.upgrade-sub {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.upgrade-benefits {
  list-style: none;
  text-align: left;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-benefits li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--color-text);
}

.benefit-check {
  width: 22px;
  height: 22px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.upgrade-price {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 4px;
}
.upgrade-price-sub {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

.btn-upgrade {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--color-primary), #ff8c00);
  color: #fff;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(226,75,74,0.35);
  transition: opacity var(--transition), transform var(--transition);
  margin-bottom: 14px;
}
.btn-upgrade:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.upgrade-back {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================
   TOASTS
   ============================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: var(--max-width);
}

.toast {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  animation: toastIn 0.2s ease both, toastOut 0.2s ease 2.8s both;
  pointer-events: auto;
}

.toast.success { background: var(--color-match-high); color: #fff; }
.toast.error   { background: var(--color-primary); color: #fff; }
.toast.warning { background: #f59e0b; color: #fff; }

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

/* ============================================================
   AdSense 슬롯
   ============================================================ */
.adsense-slot {
  min-height: 90px;
  background: var(--color-bg-card);
  border-radius: var(--radius-sm);
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* AdSense 로드 실패 시 빈 공간 콜낙 방지 */
.adsense-slot:empty,
.adsense-slot ins[data-ad-status="unfilled"] {
  display: none;
}

/* Amazon 면첸 문구 */
.amazon-disclosure {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 8px;
  line-height: 1.4;
}
