/* ==========================================================
   המתכונים של ליטוב — warm editorial kitchen UI, RTL, mobile first
   ========================================================== */

:root {
  --bg:        #fbf6f0;
  --bg-tint:   #f4ebe1;
  --surface:   #ffffff;
  --surface-2: #fdf8f3;
  --text:      #1d1613;
  --muted:     #7d6a5d;
  --line:      #ebdfd3;

  --accent:      #d9552b;   /* paprika */
  --accent-soft: #fdeee7;
  --accent-ink:  #a33c17;
  --herb:        #4d7c3f;
  --herb-soft:   #edf4e9;
  --amber:       #c9871f;
  --amber-soft:  #fdf3e0;

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;

  --shadow-sm: 0 1px 2px rgba(61, 37, 24, .05), 0 4px 14px rgba(61, 37, 24, .05);
  --shadow-md: 0 2px 6px rgba(61, 37, 24, .06), 0 14px 34px rgba(61, 37, 24, .09);
  --shadow-lg: 0 10px 44px rgba(61, 37, 24, .16);

  --sans:  'Assistant', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Frank Ruhl Libre', Georgia, serif;

  --tab-h: 78px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14100e;
    --bg-tint:   #1b1613;
    --surface:   #201a17;
    --surface-2: #262019;
    --text:      #f4ece5;
    --muted:     #a89383;
    --line:      #362c26;

    --accent:      #ff7a4d;
    --accent-soft: #33201a;
    --accent-ink:  #ffb094;
    --herb:        #8cbd72;
    --herb-soft:   #1e2a1a;
    --amber:       #e0a94a;
    --amber-soft:  #2e2415;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, .45), 0 16px 38px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 88% -12%, var(--accent-soft), transparent 62%),
    radial-gradient(900px 460px at 6% 4%, var(--herb-soft), transparent 58%);
  background-attachment: fixed;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

/* barely-there paper texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.22;
  margin: 0 0 10px;
}

h2 { font-size: 27px; }
h3 { font-size: 20px; }

p { margin: 0 0 12px; }

a { color: var(--accent-ink); }

code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: .88em;
  background: var(--bg-tint);
  padding: 2px 7px;
  border-radius: 7px;
}

.muted  { color: var(--muted); font-size: 15px; }
.center { text-align: center; }

.row    { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------------------------------------------------------
   Top bar
   --------------------------------------------------------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top)) 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

#page-title {
  flex: 1;
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .16s, background .16s;
}

.icon-btn:active { transform: scale(.9); }

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------
   Layout
   --------------------------------------------------------- */

#view {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  animation: rise .34s cubic-bezier(.2, .8, .3, 1);
}

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

@media (prefers-reduced-motion: reduce) {
  #view { animation: none; }
  * { transition: none !important; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.hero {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--r-lg);
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}

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

button,
.btn {
  font-family: var(--sans);
  font-size: 16.5px;
  font-weight: 700;
  padding: 13px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 16px color-mix(in srgb, var(--accent) 34%, transparent);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .16s, box-shadow .16s, filter .16s;
  -webkit-tap-highlight-color: transparent;
}

button:active,
.btn:active { transform: scale(.96); }

button:disabled {
  opacity: .5;
  pointer-events: none;
  box-shadow: none;
}

.btn-wide { width: 100%; }

.btn-sm {
  font-size: 15px;
  padding: 9px 17px;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--line);
  box-shadow: none;
}

.btn-quiet {
  background: var(--bg-tint);
  color: var(--accent-ink);
  box-shadow: none;
}

.btn-danger {
  background: transparent;
  color: #c0392b;
  border: 1.5px solid color-mix(in srgb, #c0392b 32%, transparent);
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .btn-danger { color: #ff8a7a; }
}

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

label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 0 7px;
}

input, textarea, select {
  width: 100%;
  font-family: var(--sans);
  font-size: 16.5px;
  color: var(--text);
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color .16s, box-shadow .16s;
}

input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.7;
}

input[type="search"] {
  border-radius: 999px;
  padding-inline-start: 46px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d6a5d' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 19px;
  background-position: right 16px center;
}

input[type="checkbox"] {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  accent-color: var(--herb);
  padding: 0;
}

input[type="file"] { padding: 12px; }

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

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

.chip {
  font-size: 14.5px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
  box-shadow: none;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* horizontal scroll strip for the category row */
.chips.strip {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-inline: -16px;
  padding-inline: 16px;
  scrollbar-width: none;
}

.chips.strip::-webkit-scrollbar { display: none; }

/* ---------------------------------------------------------
   Recipe cards
   --------------------------------------------------------- */

.recipe-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

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

.recipe-card {
  position: relative;
  display: block;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform .2s cubic-bezier(.2, .8, .3, 1), box-shadow .2s;
}

.recipe-card:active { transform: scale(.985); }

@media (hover: hover) {
  .recipe-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
  }
}

.recipe-card > img,
.recipe-card .no-img {
  width: 100%;
  height: 178px;
  object-fit: cover;
  display: block;
}

.recipe-card .no-img {
  display: grid;
  place-items: center;
  font-size: 52px;
  background: linear-gradient(140deg, var(--accent-soft), var(--herb-soft));
}

.recipe-card .body { padding: 15px 17px 17px; }

.recipe-card h3 {
  font-size: 19.5px;
  margin: 0 0 5px;
}

.recipe-card .chips { margin-top: 10px; }

.recipe-card .chip {
  font-size: 12.5px;
  padding: 4px 11px;
  background: var(--bg-tint);
  border-color: transparent;
}

/* ---------------------------------------------------------
   Ingredients & steps
   --------------------------------------------------------- */

.ingredients {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ingredients li {
  display: flex;
  align-items: baseline;
  gap: 11px;
  padding: 12px 4px;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
  transition: opacity .18s;
}

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

.ingredients li::before {
  content: '';
  flex: 0 0 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  transition: background .18s;
}

.ingredients li.done {
  opacity: .42;
  text-decoration: line-through;
}

.ingredients li.done::before {
  background: var(--accent);
}

.ingredients .qty {
  font-weight: 700;
  color: var(--accent-ink);
  white-space: nowrap;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 4px 0 22px 0;
  padding-inline-start: 48px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 50%;
}

/* connective line between step bullets */
.steps li:not(:last-child)::after {
  content: '';
  position: absolute;
  inset-inline-start: 16px;
  top: 37px;
  bottom: 8px;
  width: 2px;
  background: var(--line);
}

/* ---------------------------------------------------------
   Photos & comments
   --------------------------------------------------------- */

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.comment:last-of-type { border-bottom: 0; }

.comment .who  { font-weight: 700; font-size: 15px; }
.comment .when { color: var(--muted); font-size: 13px; }

.comment img {
  max-width: 190px;
  border-radius: var(--r-sm);
  margin-top: 8px;
  display: block;
}

/* ---------------------------------------------------------
   Shopping list
   --------------------------------------------------------- */

.aisle-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 22px 4px 9px;
  text-transform: uppercase;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.shop-item > span { flex: 1; }

.shop-item.done {
  opacity: .5;
  box-shadow: none;
}

.shop-item.done > span { text-decoration: line-through; }

.shop-item .del {
  background: transparent;
  color: var(--muted);
  padding: 4px 9px;
  box-shadow: none;
  font-size: 17px;
}

/* ---------------------------------------------------------
   Banners, toast, spinner, empty
   --------------------------------------------------------- */

.banner {
  padding: 13px 17px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: 15.5px;
  font-weight: 600;
  border: 1px solid transparent;
}

.banner.ok   { background: var(--herb-soft);   color: var(--herb);      border-color: color-mix(in srgb, var(--herb) 25%, transparent); }
.banner.warn { background: var(--amber-soft);  color: var(--amber);     border-color: color-mix(in srgb, var(--amber) 28%, transparent); }
.banner.err  { background: var(--accent-soft); color: var(--accent-ink);border-color: color-mix(in srgb, var(--accent) 28%, transparent); }

#toast {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
  z-index: 90;
  max-width: 460px;
  margin: 0 auto;
  padding: 15px 20px;
  border-radius: var(--r-md);
  background: #241b16;
  color: #fff8f2;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity .26s, transform .26s;
}

#toast.show { opacity: 1; transform: none; }

.spinner {
  width: 34px;
  height: 34px;
  margin: 44px auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 62px 20px;
  line-height: 1.8;
}

.empty .big {
  font-size: 62px;
  margin-bottom: 12px;
  filter: saturate(.85);
}

/* ---------------------------------------------------------
   Tab bar
   --------------------------------------------------------- */

#tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

#tabbar a {
  flex: 1;
  max-width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  transition: color .18s, background .18s;
}

#tabbar a svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#tabbar a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

#tabbar a:active { transform: scale(.94); }

/* ---------------------------------------------------------
   Cook mode — big, glanceable, hands-free
   --------------------------------------------------------- */

body.cooking {
  padding-bottom: 0;
  background: var(--bg-tint);
}

body.cooking #topbar,
body.cooking #tabbar { display: none; }

body.cooking #view {
  max-width: none;
  padding: 0;
}

.cook {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.cook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
}

.cook-head .muted {
  flex: 1;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  height: 5px;
  margin: 0 16px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress > div {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber), var(--accent));
  transition: width .35s cubic-bezier(.2, .8, .3, 1);
}

.cook-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 26px 24px;
}

.step-num {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .09em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.step-text {
  font-family: var(--serif);
  font-size: clamp(27px, 6.4vw, 40px);
  font-weight: 500;
  line-height: 1.42;
  margin: 0 0 26px;
}

.timers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cook-ing {
  margin-top: 26px;
  padding: 16px 18px;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.cook-nav {
  display: flex;
  gap: 12px;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
}

.cook-nav button {
  flex: 1;
  padding: 19px 20px;
  font-size: 18.5px;
}

.cook-nav button:first-child { flex: 0 0 38%; }

/* ---------------------------------------------------------
   Sticky save bar (review / edit screen)
   --------------------------------------------------------- */

.save-bar {
  position: sticky;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) - 4px);
  z-index: 30;
  margin: 18px -6px 0;
  padding: 12px 6px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
