/* app.css — mobile-first, RTL, large touch targets. Built for a phone on a kitchen counter. */

:root {
  --bg: #fdfaf6;
  --surface: #ffffff;
  --ink: #2a211c;
  --ink-soft: #6d6058;
  --line: #e9dfd5;
  --brand: #c4562f;
  --brand-soft: #fbeee7;
  --ok: #2e7d5b;
  --warn: #b8860b;
  --danger: #b3392a;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(80, 55, 40, .08);
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18140f;
    --surface: #241e18;
    --ink: #f3ece5;
    --ink-soft: #b3a49a;
    --line: #3a3129;
    --brand: #e87a4d;
    --brand-soft: #35251c;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Rubik', 'Assistant', -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

/* ---------- top bar ---------- */

#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px calc(12px) 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

#page-title {
  flex: 1; margin: 0;
  font-size: 20px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  display: grid; place-items: center;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--ink);
  font-size: 22px; cursor: pointer;
}
.icon-btn:active { background: var(--brand-soft); }

/* ---------- layout ---------- */

#view { padding: 16px 14px 24px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--ink-soft); font-size: 15px; }
.center { text-align: center; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 22px 0 10px; }

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

button, .btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 0; border-radius: 12px;
  background: var(--brand); color: #fff;
  font: inherit; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
button:active, .btn:active { filter: brightness(.92); }
button:disabled { opacity: .5; cursor: default; }

.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--line); }
.btn-quiet { background: var(--brand-soft); color: var(--brand); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--line); }
.btn-wide { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 15px; }

input, textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
label { display: block; font-size: 15px; font-weight: 600; margin: 14px 0 6px; }

/* ---------- recipe cards ---------- */

.recipe-grid { display: grid; gap: 12px; }

.recipe-card {
  display: flex; gap: 12px; align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden; text-decoration: none; color: inherit;
}
.recipe-card img {
  width: 104px; min-height: 104px; object-fit: cover; flex: none; background: var(--brand-soft);
}
.recipe-card .no-img {
  width: 104px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-soft); font-size: 34px;
}
.recipe-card .body { padding: 12px 4px 12px 0; flex: 1; min-width: 0; }
.recipe-card h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.35; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
  border: 0; min-height: 0; cursor: pointer;
}
.chip.plain { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.chip[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* ---------- ingredients & steps ---------- */

ul.ingredients { list-style: none; padding: 0; margin: 0; }
ul.ingredients li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
}
ul.ingredients li:last-child { border-bottom: 0; }
ul.ingredients .qty { font-weight: 700; color: var(--brand); white-space: nowrap; min-width: 62px; }
ul.ingredients li.done { opacity: .45; text-decoration: line-through; }

ol.steps { padding: 0; margin: 0; list-style: none; counter-reset: s; }
ol.steps li {
  counter-increment: s;
  display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
ol.steps li:last-child { border-bottom: 0; }
ol.steps li::before {
  content: counter(s);
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}

.section-label {
  font-weight: 700; color: var(--brand);
  margin: 14px 0 2px; font-size: 15px;
}

/* ---------- cook mode ---------- */

body.cooking { background: #12100e; color: #f6f1ea; padding-bottom: 0; }
body.cooking #topbar, body.cooking #tabbar { display: none; }
body.cooking #view { max-width: 100%; padding: 0; }

.cook {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
}
.cook .cook-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cook .cook-head .icon-btn { color: #f6f1ea; }
.cook .progress { height: 6px; border-radius: 3px; background: #332c25; margin: 14px 0 0; overflow: hidden; }
.cook .progress > div { height: 100%; background: var(--brand); transition: width .25s; }
.cook .cook-body { flex: 1; display: grid; align-content: center; gap: 20px; padding: 24px 0; }
.cook .step-num { color: #a08e7f; font-size: 16px; font-weight: 600; }
.cook .step-text { font-size: clamp(26px, 6.5vw, 40px); line-height: 1.45; font-weight: 600; margin: 0; }
.cook .cook-nav { display: flex; gap: 12px; }
.cook .cook-nav button { flex: 1; min-height: 64px; font-size: 19px; }
.cook .cook-ing {
  background: #1e1a16; border: 1px solid #332c25; border-radius: 12px;
  padding: 12px 14px; font-size: 16px; color: #d9cec3;
}
.cook .timers { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- shopping ---------- */

.aisle-title {
  font-size: 15px; font-weight: 700; color: var(--brand);
  margin: 18px 0 6px; display: flex; align-items: center; gap: 8px;
}
.shop-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.shop-item input[type="checkbox"] { width: 26px; height: 26px; min-height: 0; flex: none; accent-color: var(--brand); }
.shop-item.done span { text-decoration: line-through; opacity: .45; }
.shop-item .del { margin-inline-start: auto; background: none; color: var(--ink-soft); min-height: 34px; padding: 0 8px; }

/* ---------- misc ---------- */

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }

.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment .who { font-weight: 700; font-size: 15px; }
.comment .when { color: var(--ink-soft); font-size: 13px; }
.comment img { max-width: 180px; border-radius: 10px; margin-top: 8px; display: block; }

.hero { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius); margin-bottom: 14px; background: var(--brand-soft); }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-soft); }
.empty .big { font-size: 52px; margin-bottom: 10px; }

.banner { border-radius: 12px; padding: 12px 14px; font-size: 15px; margin-bottom: 14px; }
.banner.ok   { background: #e6f4ed; color: #1c5e42; }
.banner.warn { background: #fdf3d9; color: #7a5a05; }
.banner.err  { background: #fbe9e7; color: #8d2b1e; }
@media (prefers-color-scheme: dark) {
  .banner.ok { background: #14301f; color: #8fd9b4; }
  .banner.warn { background: #332a10; color: #e8c968; }
  .banner.err { background: #351a16; color: #f0a294; }
}

.spinner {
  width: 30px; height: 30px; margin: 30px auto;
  border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tab bar ---------- */

#tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-soft); text-decoration: none;
  font-size: 12px; font-weight: 600;
}
#tabbar a span { font-size: 23px; }
#tabbar a.active { color: var(--brand); }

/* ---------- toast ---------- */

#toast {
  position: fixed; inset-inline: 16px; bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 50;
  background: #2a211c; color: #fff;
  padding: 13px 16px; border-radius: 12px;
  text-align: center; font-size: 15px;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (min-width: 640px) {
  .recipe-grid { grid-template-columns: 1fr 1fr; }
}
