/* =============================================
   キッチンAI - スタイルシート
   style.css
   ============================================= */

:root {
  --bg:      #fff5f7;  /* メイン背景：淡いピンクホワイト */
  --bg2:     #ffffff;  /* カード背景：白 */
  --bg3:     #ffeef2;  /* 入力欄背景：薄ピンク */
  --surface: #ffdde5;  /* ボタン等の面：ピンク */
  --border:  rgba(220,100,130,0.15); /* 枠線：ピンクの半透明 */
  --text:    #3a1a22;  /* メインテキスト：濃いワインレッド */
  --text2:   #9a6070;  /* サブテキスト：くすみピンク */
  --text3:   #c4a0aa;  /* 薄いテキスト：薄ピンクグレー */
  --orange:  #e84d7a;  /* アクセント：ピンク */
  --orange2: #f47fa0;  /* アクセント明：薄ピンク */
  --green:   #5a9e6f;  /* バッジ：グリーン（そのまま） */
  --gold:    #c9704c;  /* 強調：テラコッタ */
  --red:     #c94c4c;  /* エラー：レッド（そのまま） */
  --safe: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ── Status bar spacer ── */
.status-bar {
  height: env(safe-area-inset-top, 44px);
  background: var(--bg);
  flex-shrink: 0;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 34px; height: 34px;
  background: var(--orange);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.logo-name {
  width: 100px;
}

.header-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.7rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  color: var(--green);
  letter-spacing: 0.1em;
}

/* ── Page system ── */
.pages {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s;
  -webkit-overflow-scrolling: touch;
}

.page.hidden-left  { transform: translateX(-100%); opacity: 0; pointer-events: none; }
.page.hidden-right { transform: translateX(100%);  opacity: 0; pointer-events: none; }
.page.active       { transform: translateX(0);     opacity: 1; }

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding-bottom: calc(var(--safe) + 0.4rem);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.65rem 0 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn .nav-icon { font-size: 1.3rem; transition: transform 0.2s; }
.nav-btn .nav-label { font-size: 0.6rem; color: var(--text3); letter-spacing: 0.05em; font-family: 'DM Mono', monospace; }
.nav-btn.active .nav-label { color: var(--orange); }
.nav-btn.active .nav-icon { transform: scale(1.15); }

/* ── Section card ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.65rem;
  font-family: 'DM Mono', monospace;
  color: var(--text3);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title::before {
  content: '';
  display: inline-block;
  width: 3px; height: 12px;
  background: var(--orange);
  border-radius: 2px;
}

/* ── Textarea ── */
.app-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 300;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.7;
}

.app-textarea::placeholder { color: var(--text3); font-weight: 300; }
.app-textarea:focus { border-color: var(--orange); }

/* ── Pill selectors ── */
.pill-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill {
  padding: 0.45rem 0.85rem;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: 'Noto Sans JP', sans-serif;
}

.pill.active {
  background: rgba(232,117,42,0.15);
  border-color: var(--orange);
  color: var(--orange2);
  font-weight: 500;
}

/* ── Theme emoji buttons ── */
.theme-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.theme-tile {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.2rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.theme-tile .t-emoji { font-size: 1.4rem; }
.theme-tile .t-label { font-size: 0.55rem; color: var(--text3); font-family: 'DM Mono', monospace; letter-spacing: 0.02em; }

.theme-tile.active {
  background: rgba(232,117,42,0.12);
  border-color: var(--orange);
}
.theme-tile.active .t-label { color: var(--orange); }

/* ── Generate button ── */
.gen-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--orange), #d4541a);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(232,117,42,0.35);
  position: relative;
  overflow: hidden;
}

.gen-btn:active { transform: scale(0.97); }
.gen-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.gen-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

/* ── Loading screen ── */
.chef-anim {
  font-size: 4rem;
  animation: chefBounce 1s ease-in-out infinite alternate;
}

@keyframes chefBounce {
  from { transform: translateY(0) rotate(-5deg); }
  to   { transform: translateY(-12px) rotate(5deg); }
}

.loading-bar-wrap {
  width: 200px;
  height: 3px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  border-radius: 2px;
  animation: loadBar 1.8s ease-in-out infinite;
}

@keyframes loadBar {
  0%   { width: 0%;   margin-left: 0; }
  50%  { width: 70%;  margin-left: 15%; }
  100% { width: 0%;   margin-left: 100%; }
}

.loading-text {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--text3);
  letter-spacing: 0.15em;
  text-align: center;
}

/* ── Loading page layout ── */
#loadingPage .loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1.5rem;
}

/* ── Result page ── */
.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.back-btn {
  width: 36px; height: 36px;
  background: var(--surface);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: var(--text);
  flex-shrink: 0;
  transition: background 0.2s;
}
.back-btn:active { background: var(--bg3); }

.result-title {
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--orange2), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Markdown rendering in result ── */
.result-body h1 {
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 1.05rem;
  color: var(--orange2);
  margin: 1.5rem 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(232,117,42,0.25);
  letter-spacing: 0.03em;
}

.result-body h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.2rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.result-body h2::before {
  content: '';
  display: inline-block;
  width: 3px; height: 0.9em;
  background: var(--orange);
  border-radius: 2px;
  flex-shrink: 0;
}

.result-body h3 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gold);
  margin: 1rem 0 0.4rem;
}

.result-body p {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.8;
  margin-bottom: 0.5rem;
  font-weight: 300;
}

.result-body ul, .result-body ol {
  padding-left: 1.25rem;
  margin-bottom: 0.6rem;
}

.result-body li {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.7;
  font-weight: 300;
  margin-bottom: 0.15rem;
}

.result-body strong { color: var(--text); font-weight: 700; }

/* ── Nutrition card ── */
.nutrition-card {
  background: linear-gradient(135deg, #1e1a10, #2a220e);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 16px;
  padding: 1.1rem;
  margin: 1rem 0;
}

.nut-head {
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}

.nut-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.nut-val {
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 1.2rem;
  color: var(--orange2);
  line-height: 1;
}

.nut-lbl {
  font-family: 'DM Mono', monospace;
  font-size: 0.5rem;
  color: var(--text3);
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
}

/* ── 広告エリア ── */
.ad-area {
  background: var(--bg2);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  text-align: center;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.55rem;
  color: var(--text3);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--safe) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--red);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.78rem;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Tips page ── */
.tips-heading {
  margin-bottom: 1.25rem;
}

.tips-heading h2 {
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
  background: linear-gradient(135deg, var(--orange2), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tips-heading p {
  font-size: 0.72rem;
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.1em;
}

.tip-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.tip-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 0.1rem; }
.tip-text h4 { font-size: 0.82rem; font-weight: 700; margin-bottom: 0.2rem; }
.tip-text p { font-size: 0.75rem; color: var(--text2); line-height: 1.6; font-weight: 300; }

/* ── Scrollbar ── */
.page::-webkit-scrollbar { width: 3px; }
.page::-webkit-scrollbar-track { background: transparent; }
.page::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 2px; }

/* ── Input page bottom padding ── */
#inputPage { padding-bottom: 2rem; }
