/* Maktub Kitchen 2.0 — Component & Layout Styles */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

[dir="rtl"] body {
  font-family: var(--font-ar);
}

body {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
}

img {
  display: block;
  max-width: 100%;
}

button, input, textarea, select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(169, 79, 50, 0.25);
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

[dir="rtl"] .brand-title {
  font-family: var(--font-ar);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-pill, .status-pill, .lang-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-pill);
  height: 36px;
  padding: 0 11px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.14s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.icon-pill {
  width: 36px;
  padding: 0;
}

.icon-pill:active, .status-pill:active, .lang-pill:active {
  transform: scale(0.95);
}

.lang-pill {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #B8ABA0;
}

.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

/* Main Container */
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px;
}

.view-enter {
  animation: fadeSlideIn 0.22s ease-out;
}

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

/* Home Hero — Enter Our Kitchen */
.hero-kitchen {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 22px 20px;
  background: linear-gradient(135deg, #39271D 0%, #7C3721 55%, #A94F32 100%);
  color: #FFFDF9;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

.hero-kitchen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--zellige-pattern);
  opacity: 0.9;
  pointer-events: none;
}

.hero-kitchen-inner {
  position: relative;
  z-index: 1;
}

.hero-greeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  font-size: 0.75rem;
  font-weight: 700;
  color: #FBF4E9;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.15;
}

[dir="rtl"] .hero-title {
  font-family: var(--font-ar);
  font-size: 1.55rem;
}

.hero-subtitle {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: rgba(251, 244, 233, 0.86);
  max-width: 44ch;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-kitchen-primary {
  flex: 1;
  min-width: 200px;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  background: var(--accent);
  color: #2A1C16;
  font-size: 0.96rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-kitchen-primary:active {
  transform: scale(0.98);
}

.btn-kitchen-secondary {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFDF9;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Section Headers */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 12px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

[dir="rtl"] .section-title {
  font-family: var(--font-ar);
  font-size: 1.15rem;
}

.section-link {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
}

/* Featured Recipe Card */
.featured-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.16s ease;
}

.featured-card:active {
  transform: scale(0.99);
}

.featured-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  overflow: hidden;
}

.featured-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.featured-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(26, 20, 17, 0.72) 0%, transparent 55%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
}

.featured-tag {
  align-self: flex-start;
  background: rgba(251, 244, 233, 0.92);
  color: #39271D;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.featured-body {
  padding: 14px 16px 16px;
}

.featured-title {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 0 0 4px;
}

.featured-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Horizontal Scroll Carousels */
.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }

.mini-recipe-card {
  flex: 0 0 210px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease;
}

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

.mini-thumb {
  position: relative;
  height: 124px;
  background: linear-gradient(135deg, var(--surface-soft), var(--accent-soft));
  overflow: hidden;
}

.mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  background-image: var(--zellige-pattern);
}

.mini-body {
  padding: 11px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.mini-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
}

.mini-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Quick Access Grid */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.quick-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.14s ease;
}

.quick-tile:active { transform: scale(0.98); }

.quick-tile-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.quick-tile-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.quick-tile-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Recipe Grid & Cards */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 0.92rem;
  color: var(--text);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active {
  background: var(--text);
  color: var(--text-inverse);
  border-color: var(--text);
}

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

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

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease;
}

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

.recipe-card-media {
  position: relative;
  height: 158px;
  background: linear-gradient(135deg, var(--surface-soft), var(--accent-soft));
  overflow: hidden;
}

.recipe-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text);
}

.badge.morocco {
  background: var(--secondary-soft);
  color: var(--secondary);
}

.badge.india {
  background: var(--accent-soft);
  color: #8A5D0B;
}

[data-theme="dark"] .badge.india {
  color: var(--accent);
}

.fav-float-btn {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  font-size: 1rem;
}

.cuisine-float-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
}

/* Detail & Cook View */
.back-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.detail-hero-media {
  position: relative;
  height: 220px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.detail-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-hero-body {
  padding: 16px 18px;
}

.detail-hero-body h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0 0 4px;
}

[dir="rtl"] .detail-hero-body h2 {
  font-family: var(--font-ar);
}

.scaler {
  display: inline-flex;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.scaler button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.scaler button.active {
  background: var(--primary);
  color: #fff;
}

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

.section-box h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.ing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface-soft);
}

.ing-item:last-child { border-bottom: none; }

.ing-left {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
}

.ing-left input {
  width: 18px;
  height: 18px;
  accent-color: var(--secondary);
}

.ing-left.checked span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.swap-btn {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--bg);
}

.step-card.active-step {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.timer-btn {
  border: none;
  background: var(--text);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.timer-btn.running {
  background: var(--secondary);
  color: #fff;
}

/* Floating Timer */
.floating-timer {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--text-inverse);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 35;
  font-weight: 700;
}

.floating-timer button {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  cursor: pointer;
  font-weight: 700;
}

/* 5-Tab Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  z-index: 40;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: var(--radius-md);
  transition: color 0.15s ease, transform 0.12s ease;
}

.nav-btn:active { transform: scale(0.94); }

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

.nav-btn.active {
  color: var(--primary);
}

.nav-btn.nav-kitchen.active {
  color: var(--primary);
}

.nav-kitchen-pill {
  width: 42px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.nav-btn.active .nav-kitchen-pill {
  background: var(--primary);
  color: #fff;
}

/* Empty, Error, & Skeleton States */
.state-box {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
}

.state-box-ico {
  font-size: 2rem;
  margin-bottom: 8px;
}

.state-box h4 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1rem;
}

.state-box p {
  margin: 0 0 14px;
  font-size: 0.86rem;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-soft) 25%, var(--surface-muted) 50%, var(--surface-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Forms, Buttons, Modals & Toast */
.primary-btn {
  width: 100%;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
}

.secondary-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.form-field { margin-bottom: 12px; }
.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.form-field input, .form-field textarea, .form-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.92rem;
  background: var(--bg);
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 20, 17, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 12px;
}

.modal-sheet {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  max-height: 86vh;
  overflow-y: auto;
}

.toast {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--text-inverse);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  font-weight: 700;
  z-index: 70;
  box-shadow: var(--shadow-md);
}

.stars {
  display: flex;
  gap: 8px;
  font-size: 1.6rem;
  margin: 8px 0;
}

.stars button {
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.35;
  padding: 0;
  font-size: 1.6rem;
  color: var(--accent);
}

.stars button.lit { opacity: 1; }
