/* ============================================================
   Fridge Oracle design system
   Palette family: forest green + cool off-white (light),
   green-tinted charcoal (dark). One accent: --brand.
   Radius rule: controls (buttons/inputs/chips) = --r-ctl,
   containers (cards/panels) = --r-card. No other radii.
   ============================================================ */

@font-face {
  font-family: "Outfit";
  src: url("/fonts/outfit-variable.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #ecefe9;
  --ink: #1b241e;
  --ink-soft: #47544c;
  --muted: #66746b;
  --line: #dbe2d8;
  --brand: #1e5c3f;
  --brand-hover: #174a32;
  --brand-ink: #f3f8f4;
  --brand-soft: rgba(30, 92, 63, 0.09);
  --danger: #a33a2a;
  --danger-soft: rgba(163, 58, 42, 0.09);
  --shadow: 0 1px 2px rgba(27, 36, 30, 0.05), 0 8px 28px rgba(27, 36, 30, 0.07);
  --r-ctl: 12px;
  --r-card: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121712;
    --surface: #1a211b;
    --surface-2: #222b23;
    --ink: #e8ede8;
    --ink-soft: #bcc7be;
    --muted: #8d9a90;
    --line: #2c362d;
    --brand: #2e7d52;
    --brand-hover: #369362;
    --brand-ink: #f3f8f4;
    --brand-soft: rgba(94, 190, 138, 0.12);
    --danger: #d97a68;
    --danger-soft: rgba(217, 122, 104, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; vertical-align: -0.25em; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: 0;
  border-radius: var(--r-ctl);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:not([disabled]):hover { background: var(--brand-hover); }

.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:not([disabled]):hover { background: var(--surface-2); color: var(--ink); }

.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; color: var(--ink-soft); }

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.field .hint { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--danger); display: none; }
.field.invalid .input { border-color: var(--danger); }
.field.invalid .error { display: block; }

.form-error {
  display: none;
  padding: 11px 14px;
  border-radius: var(--r-ctl);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}
.form-error.show { display: flex; align-items: center; gap: 8px; }

/* ---------- Auth gate (split screen) ---------- */

.gate {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(420px, 44%) 1fr;
}

.gate-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(24px, 6vw, 88px);
}

.gate-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 56px;
}
.gate-brand .logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  border-radius: var(--r-ctl);
}
.gate-brand .logo .icon { width: 20px; height: 20px; vertical-align: 0; }

.gate h1 { font-size: clamp(28px, 3.2vw, 38px); margin-bottom: 10px; }
.gate .lede { color: var(--muted); font-size: 16px; max-width: 40ch; margin-bottom: 36px; }

.gate form { display: grid; gap: 18px; max-width: 400px; }
.gate .swap { margin-top: 28px; font-size: 14.5px; color: var(--muted); }

.gate-visual { position: relative; overflow: hidden; }
.gate-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gate-visual::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(120deg, rgba(27, 36, 30, 0.35), rgba(27, 36, 30, 0) 55%);
}
.gate-quote {
  position: absolute;
  left: 40px; right: 40px; bottom: 36px;
  z-index: 1;
  color: #fff;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  max-width: 30ch;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
}

@media (max-width: 900px) {
  .gate { grid-template-columns: 1fr; }
  .gate-visual { display: none; }
  .gate-form { padding: 40px 24px; }
  .gate-brand { margin-bottom: 40px; }
}

/* ---------- App shell ---------- */

.nav {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(20px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.nav .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 16px; color: var(--ink);
}
.nav .brand:hover { text-decoration: none; }
.nav .brand .logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink);
  border-radius: 10px;
}
.nav .brand .logo .icon { width: 18px; height: 18px; vertical-align: 0; }
.nav .side { display: flex; align-items: center; gap: 14px; }
.nav .who { font-size: 14.5px; color: var(--muted); }
.nav .btn { padding: 9px 16px; font-size: 14px; }

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(20px, 4vw, 40px) 80px;
}

.page-head { margin-bottom: 32px; }
.page-head .back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--muted); margin-bottom: 18px;
}
.page-head .back:hover { color: var(--ink); text-decoration: none; }
.page-head h1 { font-size: clamp(26px, 3vw, 34px); }
.page-head .sub { color: var(--muted); margin-top: 8px; max-width: 52ch; }

/* ---------- Dashboard bento ---------- */

.hub { display: grid; grid-template-columns: 7fr 5fr; gap: 18px; }
.hub-side { display: grid; gap: 18px; }

.feature {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 200px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); text-decoration: none; }
.feature:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.feature .f-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: var(--r-ctl);
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 14px;
}
.feature h2 { font-size: 20px; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 14.5px; max-width: 34ch; }
.feature .go {
  position: absolute; top: 22px; right: 22px;
  color: var(--muted);
  transition: transform 0.25s var(--ease), color 0.25s;
}
.feature:hover .go { color: var(--brand); transform: translateX(3px); }

.feature-hero { min-height: 420px; justify-content: flex-end; border: 0; }
.feature-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.feature-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(18, 26, 20, 0.86) 0%, rgba(18, 26, 20, 0.35) 45%, rgba(18, 26, 20, 0.05) 70%);
}
.feature-hero .f-body { position: relative; z-index: 1; }
.feature-hero .f-icon { background: rgba(255, 255, 255, 0.14); color: #fff; backdrop-filter: blur(6px); }
.feature-hero h2 { color: #fff; font-size: 24px; }
.feature-hero p { color: rgba(255, 255, 255, 0.78); }
.feature-hero .go { color: rgba(255, 255, 255, 0.7); z-index: 1; }
.feature-hero:hover .go { color: #fff; }

@media (max-width: 820px) {
  .hub { grid-template-columns: 1fr; }
  .feature-hero { min-height: 300px; }
}

/* ---------- Chips ---------- */

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-ctl);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  font-weight: 500;
  border: 0;
  font-family: inherit;
}
@media (prefers-color-scheme: dark) {
  .chip { color: #9fd4b6; }
}
.chip button, .chip .x {
  display: grid; place-items: center;
  border: 0; padding: 0;
  background: none; color: inherit;
  cursor: pointer; opacity: 0.65;
}
.chip button:hover { opacity: 1; }
.chip .icon { width: 14px; height: 14px; }

.chip-suggest {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.chip-suggest:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Cards & recipes ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
}

.recipes { display: grid; gap: 16px; margin-top: 28px; }

.recipe { padding: 24px 26px; }
.recipe .r-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.recipe h3 { font-size: 19px; }
.recipe .r-time {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--brand);
  white-space: nowrap;
}
.recipe .r-ing { margin-top: 12px; display: grid; gap: 6px; font-size: 14.5px; }
.recipe .r-ing .lbl { color: var(--muted); }
.recipe .r-ing .lbl strong { color: var(--ink-soft); font-weight: 600; }
.recipe details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.recipe summary {
  cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--brand);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.recipe summary::-webkit-details-marker { display: none; }
.recipe ol { margin: 12px 0 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15px; color: var(--ink-soft); }

/* ---------- Skeletons / loading ---------- */

.skeleton {
  border-radius: var(--r-card);
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  height: 148px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty / status states ---------- */

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty .icon { width: 34px; height: 34px; color: var(--muted); margin-bottom: 12px; }
.empty h3 { color: var(--ink-soft); font-size: 17px; margin-bottom: 6px; }
.empty p { font-size: 14.5px; max-width: 44ch; margin: 0 auto; }

.notice {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding: 13px 16px;
  border-radius: var(--r-ctl);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14.5px;
}
.notice.show { display: flex; }

/* ---------- Chat ---------- */

.chat-page { display: flex; flex-direction: column; height: calc(100dvh - 68px); }
.chat-scroll { flex: 1; overflow-y: auto; }
.chat-inner { max-width: 780px; margin: 0 auto; padding: 32px 20px 16px; display: grid; gap: 18px; }

.msg { display: grid; gap: 4px; max-width: 85%; }
.msg .who { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.msg .bubble {
  padding: 12px 16px;
  border-radius: var(--r-card);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: break-word;
}
.msg-user { justify-self: end; }
.msg-user .bubble { background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; }
.msg-user .who { text-align: right; }
.msg-ai { justify-self: start; }
.msg-ai .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg-ai .bubble p { margin: 0 0 10px; }
.msg-ai .bubble p:last-child { margin-bottom: 0; }
.msg-ai .bubble ul, .msg-ai .bubble ol { margin: 0 0 10px; padding-left: 20px; }
.msg-ai .bubble code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

.composer { border-top: 1px solid var(--line); background: var(--bg); }
.composer-inner { max-width: 780px; margin: 0 auto; padding: 14px 20px 22px; display: flex; gap: 10px; }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
}
.composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer .btn { padding: 0 18px; align-self: stretch; }

/* ---------- Scan ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  padding: 36px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { width: 34px; height: 34px; color: var(--brand); }
.dropzone strong { color: var(--ink-soft); font-weight: 600; }
.dropzone span { font-size: 13.5px; }

.scan-preview { position: relative; border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line); }
.scan-preview img { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.scan-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.scan-items { margin-top: 32px; }
.scan-items h2 { font-size: 18px; margin-bottom: 14px; }
.conf-low { opacity: 0.6; }

/* ---------- QuickFoods controls ---------- */

.qf-bar { display: flex; gap: 10px; }
.qf-bar .input { flex: 1; }
.qf-options { display: flex; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.qf-options .field { min-width: 150px; }
select.input { appearance: none; cursor: pointer; }
.qf-submit { margin-top: 24px; }

/* ---------- Reveal animation ---------- */

.rise { animation: rise 0.55s var(--ease) both; }
.rise-2 { animation-delay: 0.07s; }
.rise-3 { animation-delay: 0.14s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .rise, .rise-2, .rise-3 { animation: none; }
  .skeleton { animation: none; }
  .typing i { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
