/* ============================================================
   Recipe Box — Custom Styles
   Layered on top of Bootstrap 5. Keep this file thin:
   use Bootstrap utility classes in templates wherever possible.
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --rb-bg:          #FFF8F0;
  --rb-card-bg:     #FFFFFF;
  --rb-primary:     #C75B39;
  --rb-primary-light:#E8A08C;
  --rb-primary-dark: #9E4229;
  --rb-secondary:   #7A8B6F;
  --rb-secondary-light:#A8B89E;
  --rb-text:        #3D2C24;
  --rb-text-muted:  #7A6B63;
  --rb-border:      #E8DDD5;
  --rb-shadow:      0 2px 12px rgba(61,44,36,.08);
  --rb-radius-card: 12px;
  --rb-radius-btn:  8px;
  --rb-radius-pill: 999px;
  --rb-nav-height:  64px;
}

/* ── Base ──────────────────────────────────────────────────── */
html {
  background: var(--rb-bg);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  color: var(--rb-text);
  background: var(--rb-bg);
  line-height: 1.55;
  padding-bottom: calc(var(--rb-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .heading {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  color: var(--rb-text);
}

a {
  color: var(--rb-primary);
}
a:hover {
  color: var(--rb-primary-dark);
}

/* ── Cards ─────────────────────────────────────────────────── */
.rb-card {
  background: var(--rb-card-bg);
  border-radius: var(--rb-radius-card);
  box-shadow: var(--rb-shadow);
  border: none;
  overflow: hidden;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary,
.btn-rb {
  background-color: var(--rb-primary);
  border-color: var(--rb-primary);
  border-radius: var(--rb-radius-btn);
  color: #fff;
  font-weight: 600;
  min-height: 44px;
  padding: .5rem 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.btn-primary:hover, .btn-primary:focus,
.btn-rb:hover, .btn-rb:focus {
  background-color: var(--rb-primary-dark);
  border-color: var(--rb-primary-dark);
  color: #fff;
}

.btn-secondary,
.btn-rb-secondary {
  background-color: var(--rb-secondary);
  border-color: var(--rb-secondary);
  border-radius: var(--rb-radius-btn);
  color: #fff;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.btn-secondary:hover, .btn-secondary:focus,
.btn-rb-secondary:hover, .btn-rb-secondary:focus {
  background-color: #657A5B;
  border-color: #657A5B;
  color: #fff;
}

.btn-outline-rb {
  border: 2px solid var(--rb-primary);
  border-radius: var(--rb-radius-btn);
  color: var(--rb-primary);
  background: transparent;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.btn-outline-rb:hover, .btn-outline-rb:focus {
  background: var(--rb-primary);
  color: #fff;
}

/* ── Chips / pills ─────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: .35rem .9rem;
  border-radius: var(--rb-radius-pill);
  border: 2px solid var(--rb-border);
  background: var(--rb-card-bg);
  color: var(--rb-text);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  transition: all .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover {
  border-color: var(--rb-primary-light);
}
.chip.active, .chip[aria-pressed="true"] {
  background: var(--rb-primary);
  border-color: var(--rb-primary);
  color: #fff;
  animation: chipPulse .25s ease;
}
@keyframes chipPulse {
  0%   { transform: scale(1);   }
  50%  { transform: scale(1.05);}
  100% { transform: scale(1);   }
}
.chip .chip-remove {
  margin-left: .4rem;
  font-size: 1rem;
  line-height: 1;
  opacity: .7;
}
.chip .chip-remove:hover { opacity: 1; }

/* ── Badge helpers ─────────────────────────────────────────── */
.badge-cuisine {
  background: var(--rb-secondary-light);
  color: #3D2C24;
  border-radius: var(--rb-radius-pill);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .6rem;
}
.badge-effort {
  background: var(--rb-primary-light);
  color: #3D2C24;
  border-radius: var(--rb-radius-pill);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .6rem;
}

/* ── Form inputs ───────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--rb-radius-btn);
  border-color: var(--rb-border);
  min-height: 44px;
  color: var(--rb-text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--rb-primary);
  box-shadow: 0 0 0 .2rem rgba(199,91,57,.15);
}

/* ── Recipe browse cards ───────────────────────────────────── */
.recipe-card {
  position: relative;
  background: var(--rb-card-bg);
  border-radius: var(--rb-radius-card);
  box-shadow: var(--rb-shadow);
  overflow: hidden;
  margin: 0 auto 1.25rem;
  max-width: 100%;
  touch-action: pan-y;
  will-change: transform;
  transition: box-shadow .2s;
}
.recipe-card-img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
  display: block;
}
.recipe-card-body {
  padding: 1rem 1.25rem 1rem;
}
.recipe-card-title {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: .4rem;
}
.recipe-card-meta {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: .65rem;
  font-size: .85rem;
}
.recipe-card-actions {
  display: flex;
  justify-content: space-around;
  padding: .75rem .5rem .25rem;
  border-top: 1px solid var(--rb-border);
}
.recipe-card-actions .btn {
  border-radius: var(--rb-radius-pill);
  min-width: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Swipe overlays */
.swipe-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; font-weight: 800;
  border-radius: var(--rb-radius-card);
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
}
.swipe-overlay-right {
  background: rgba(122,139,111,.25);
  color: var(--rb-secondary);
}
.swipe-overlay-left {
  background: rgba(199,91,57,.15);
  color: var(--rb-primary);
}

/* ── Bottom navigation ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--rb-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--rb-card-bg);
  border-top: 1px solid var(--rb-border);
  display: flex;
  z-index: 1050;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--rb-text-muted);
  font-size: .65rem;
  font-weight: 600;
  gap: 2px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.bottom-nav-item svg {
  width: 22px; height: 22px;
}
.bottom-nav-item.active {
  color: var(--rb-primary);
}
.bottom-nav-item:hover {
  color: var(--rb-primary);
  text-decoration: none;
}

/* ── Grocery list ──────────────────────────────────────────── */
.grocery-dept-heading {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--rb-text-muted);
  padding: .65rem 0 .35rem;
  border-bottom: 1px solid var(--rb-border);
  margin-top: 1.25rem;
}
.grocery-dept-heading:first-child {
  margin-top: .5rem;
}
.grocery-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .25rem;
  min-height: 48px;
}
.grocery-item.checked {
  opacity: .45;
  text-decoration: line-through;
}
.grocery-item input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--rb-primary);
  flex-shrink: 0;
}

/* ── Rotation thumbnail card ───────────────────────────────── */
.rotation-card {
  display: flex;
  gap: .75rem;
  align-items: center;
  background: var(--rb-card-bg);
  border-radius: var(--rb-radius-card);
  box-shadow: var(--rb-shadow);
  padding: .875rem;
  margin-bottom: .75rem;
}
.rotation-card-thumb {
  width: 64px; height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.rotation-card-info { flex: 1; min-width: 0; }
.rotation-card-title {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quantity chip group */
.qty-chips {
  display: inline-flex;
  gap: .25rem;
}
.qty-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 32px;
  border-radius: var(--rb-radius-pill);
  border: 2px solid var(--rb-border);
  background: transparent;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.qty-chip.active {
  background: var(--rb-primary);
  border-color: var(--rb-primary);
  color: #fff;
}

/* ── Toast ─────────────────────────────────────────────────── */
.rb-toast {
  background: var(--rb-text);
  color: #fff;
  border-radius: var(--rb-radius-btn);
  padding: .65rem 1.25rem;
  font-weight: 600;
  font-size: .9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  animation: toastSlide .35s ease;
}
@keyframes toastSlide {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-card {
  max-width: 400px;
  margin: 2rem auto;
  background: var(--rb-card-bg);
  border-radius: var(--rb-radius-card);
  box-shadow: var(--rb-shadow);
  padding: 1.75rem;
}
.auth-card h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 1.25rem;
}
@media (max-width: 520px) {
  .auth-card {
    max-width: 100%;
    margin: 1rem 0;
    padding: 1.5rem 1.25rem;
  }
}

/* ── Misc ──────────────────────────────────────────────────── */
.page-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}
@media (max-width: 520px) {
  .page-container {
    max-width: 100%;
    padding: 0 .875rem 1.5rem;
  }
}

.placeholder-img {
  width: 100%;
  aspect-ratio: 3/2;
  background: var(--rb-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rb-text-muted);
  font-size: .85rem;
}

/* Search dropdown */
.ingredient-search-results {
  position: absolute;
  z-index: 1060;
  left: 0; right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--rb-card-bg);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius-btn);
  box-shadow: var(--rb-shadow);
}
.ingredient-search-results .result-item {
  padding: .5rem .75rem;
  cursor: pointer;
  font-size: .9rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.ingredient-search-results .result-item:hover {
  background: var(--rb-bg);
}
.ingredient-search-results .result-dept {
  color: var(--rb-text-muted);
  font-size: .75rem;
  margin-left: auto;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (min-width: 768px) {
  .page-container {
    max-width: 640px;
    padding: 0 1.5rem 2rem;
  }
  .recipe-card {
    max-width: 480px;
  }
}
