/* Rural Roots Hub — custom styles */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 4.5rem;
  --header-earth: #5C4033;
  --meadow: #2F5F2F;
  --cream: #FBF7F0;
}

html, body {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.pt-safe { padding-top: var(--safe-top); }
.pb-safe { padding-bottom: max(0.4rem, var(--safe-bottom)); }
.safe-top { padding-top: max(0.25rem, var(--safe-top)); }

/* ─── Bottom nav ─── */
#bottom-nav {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.96);
}

.nav-btn {
  position: relative;
  color: #A67C52;
  transition: color 0.18s ease, background 0.18s ease, transform 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}

.nav-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 2rem;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: #2F5F2F;
  transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.nav-btn.active {
  color: #2F5F2F;
  background: linear-gradient(to top, rgba(220, 239, 220, 0.95), transparent 70%);
}

.nav-btn.active::before {
  transform: translateX(-50%) scaleX(1);
}

.nav-btn.active svg {
  stroke-width: 2.35;
  transform: translateY(-1px);
}

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

.nav-btn svg {
  transition: transform 0.18s ease, stroke-width 0.18s ease;
}

/* ─── Tab transitions ─── */
.view {
  animation: viewIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.view.view-out {
  animation: viewOut 0.16s ease-in both;
}

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

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

/* Cards */
.card {
  background: #fff;
  border: 1px solid #E8D5B7;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(92, 64, 51, 0.06);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-lift:active {
  box-shadow: 0 1px 4px rgba(92, 64, 51, 0.08);
}

/* Large senior-friendly buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0.75rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 0.875rem;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  border: none;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: #2F5F2F;
  color: #fff;
  box-shadow: 0 2px 6px rgba(47, 95, 47, 0.25);
}
.btn-primary:hover:not(:disabled) { background: #264D26; }

.btn-secondary {
  background: #F5EDE0;
  color: #5C4033;
  border: 2px solid #D4B896;
}
.btn-secondary:hover:not(:disabled) { background: #E8D5B7; }

.btn-accent {
  background: #D4920A;
  color: #fff;
  box-shadow: 0 2px 6px rgba(212, 146, 10, 0.3);
}
.btn-accent:hover:not(:disabled) { background: #B87A00; }

.btn-ghost {
  background: transparent;
  color: #5C4033;
  border: 2px solid transparent;
}
.btn-ghost:hover:not(:disabled) { background: #F5EDE0; }

.btn-danger {
  background: #fff;
  color: #b45309;
  border: 2px solid #fcd34d;
}

/* Form controls — large */
.input, .select, .textarea {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  color: #3D2B1F;
  background: #fff;
  border: 2px solid #D4B896;
  border-radius: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: #5A9E5A;
  box-shadow: 0 0 0 3px rgba(90, 158, 90, 0.25);
}
.textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.5;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235C4033'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

.field-label {
  display: block;
  font-weight: 600;
  color: #5C4033;
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.field-hint {
  font-size: 0.85rem;
  color: #A67C52;
  margin-top: 0.25rem;
}

/* Alert chips */
.alert-urgent {
  border-left: 4px solid #dc2626;
  background: #fef2f2;
}
.alert-weather {
  border-left: 4px solid #4A8BA8;
  background: #E8F4F8;
}
.alert-market {
  border-left: 4px solid #D4920A;
  background: #fffbeb;
}
.alert-info {
  border-left: 4px solid #5A9E5A;
  background: #F0F7F0;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-green  { background: #DCEFDC; color: #264D26; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #E8F4F8; color: #1e4a5c; }
.badge-brown  { background: #F5EDE0; color: #5C4033; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* Chat bubbles */
.chat-box {
  background: linear-gradient(180deg, #FBF7F0 0%, #F5EDE0 100%);
}
.chat-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.chat-row-user {
  justify-content: flex-end;
}
.chat-row-bot {
  justify-content: flex-start;
}
.chat-avatar {
  margin-bottom: 0.15rem;
}
.chat-user {
  background: linear-gradient(135deg, #2F5F2F, #264D26);
  color: #fff;
  border-radius: 1.15rem 1.15rem 0.3rem 1.15rem;
  box-shadow: 0 2px 8px rgba(47, 95, 47, 0.2);
}
.chat-bot {
  background: #fff;
  color: #3D2B1F;
  border: 1px solid #E8D5B7;
  border-radius: 1.15rem 1.15rem 1.15rem 0.3rem;
  box-shadow: 0 1px 4px rgba(92, 64, 51, 0.05);
}
.chat-bot-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
}
.chat-bot .chat-meta {
  font-size: 0.75rem;
  color: #A67C52;
  margin-top: 0.5rem;
  font-weight: 600;
}
.chat-bot-error .chat-meta {
  color: #b91c1c;
}
.chat-attach {
  border-radius: 0.75rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
  margin: -0.15rem -0.15rem 0.5rem;
}
.chat-attach img {
  display: block;
  max-height: 11rem;
  width: 100%;
  object-fit: cover;
}
.chat-thinking {
  color: #A67C52;
  font-style: italic;
}
.ai-banner {
  border-radius: 0.75rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  line-height: 1.4;
}
.ai-banner-warn {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fcd34d;
}
.ai-banner code {
  font-size: 0.8em;
  background: rgba(255, 255, 255, 0.55);
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(42, 29, 20, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.18s ease;
  padding: 0;
}
@media (min-width: 480px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
}
.modal-sheet {
  background: #FBF7F0;
  width: 100%;
  max-width: 32rem;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  overscroll-behavior: contain;
}
@media (min-width: 480px) {
  .modal-sheet {
    border-radius: 1.25rem;
    padding-bottom: 1.25rem;
  }
}
@keyframes slideUp {
  from { transform: translateY(40%); opacity: 0.6; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-handle {
  width: 2.5rem;
  height: 0.3rem;
  background: #D4B896;
  border-radius: 9999px;
  margin: 0 auto 1rem;
}

/* Listing hero image */
.listing-hero {
  position: relative;
  height: 9.5rem;
  overflow: hidden;
  background: #E8D5B7;
}

.listing-hero svg,
.listing-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.listing-hero .hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(42, 29, 20, 0.55) 0%, transparent 55%);
  pointer-events: none;
}

.listing-hero .hero-emoji {
  position: absolute;
  bottom: 0.65rem;
  right: 0.75rem;
  font-size: 1.75rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  line-height: 1;
}

.listing-hero .hero-qty {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: rgba(255,255,255,0.92);
  color: #3D2B1F;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* Scene SVG containers */
.scene-bg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Typing dots */
.typing-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: #A67C52;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Feed avatar */
.avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

/* Scrollbar polish */
#main-content {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
#main-content::-webkit-scrollbar { width: 5px; }
#main-content::-webkit-scrollbar-thumb {
  background: #D4B896;
  border-radius: 3px;
}

/* Focus visible for keyboard users */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #5A9E5A;
  outline-offset: 2px;
}

/* Category pill filter */
.pill {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  border: 2px solid #D4B896;
  background: #fff;
  color: #5C4033;
  transition: all 0.18s ease;
  cursor: pointer;
  flex-shrink: 0;
}
.pill.active {
  background: #2F5F2F;
  border-color: #2F5F2F;
  color: #fff;
  box-shadow: 0 2px 6px rgba(47, 95, 47, 0.2);
}
.pill:hover:not(.active) {
  background: #F5EDE0;
  border-color: #C4A574;
}

.pill-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pill-scroll::-webkit-scrollbar { display: none; }

/* Photo sim preview */
.photo-preview {
  border: 2px dashed #C4A574;
  border-radius: 1rem;
  background: #F5EDE0;
  min-height: 7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.photo-preview.has-image {
  border-style: solid;
  border-color: #5A9E5A;
  min-height: auto;
}
.photo-preview img {
  max-height: 11rem;
  width: 100%;
  object-fit: cover;
  display: block;
}
.photo-preview .photo-empty {
  text-align: center;
  padding: 1.25rem;
  color: #8B6914;
}
.photo-preview .photo-empty .icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.35rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 200;
  background: #3D2B1F;
  color: #FBF7F0;
  padding: 0.85rem 1.35rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: min(90vw, 28rem);
  text-align: center;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Quick prompt chips for AI */
.prompt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #fff;
  border: 2px solid #D4B896;
  color: #5C4033;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.prompt-chip:hover, .prompt-chip:active {
  background: #DCEFDC;
  border-color: #5A9E5A;
  color: #264D26;
}

/* Search input with icon */
.search-wrap {
  position: relative;
}
.search-wrap .search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #A67C52;
  pointer-events: none;
  width: 1.25rem;
  height: 1.25rem;
}
.search-wrap .input {
  padding-left: 2.75rem;
}

/* Price tag on listing */
.price-tag {
  font-variant-numeric: tabular-nums;
}

/* Contact modal seller card */
.seller-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem;
  background: #fff;
  border: 1px solid #E8D5B7;
  border-radius: 0.875rem;
  margin-bottom: 1rem;
}

/* Home hero scene */
.home-hero-scene {
  height: 5.5rem;
  margin: -0.25rem -0.25rem 0.85rem;
  border-radius: 0.75rem;
  overflow: hidden;
}

/* Line clamp utility if Tailwind misses it */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Prevent iOS zoom on focus for inputs at 16px+ already set */
/* Sticky filter bar shadow */
.sticky-filters {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(to bottom, #FBF7F0 70%, rgba(251, 247, 240, 0));
  padding-bottom: 0.5rem;
  margin: -0.25rem -0.15rem 0;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
  padding-top: 0.25rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: #A67C52;
}
.empty-state .icon {
  font-size: 2.75rem;
  display: block;
  margin-bottom: 0.75rem;
}

/* Offline banner animation */
#offline-banner:not(.hidden) {
  animation: slideDown 0.25s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .view, .view.view-out, .modal-sheet, .modal-backdrop, .nav-btn, .btn, .toast {
    animation: none !important;
    transition: none !important;
  }
}

/* ─── Premium / account ─── */
.badge-premium {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border: 1px solid #f59e0b;
  text-transform: none;
  letter-spacing: 0.02em;
}
.badge-premium-sm {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
}

.card-premium {
  border-color: #f59e0b;
  box-shadow: 0 2px 10px rgba(212, 146, 10, 0.12);
}

.avatar-sm {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.8rem;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 9999px;
  padding: 0.25rem 0.55rem 0.25rem 0.25rem;
  color: #FBF7F0;
  cursor: pointer;
  max-width: 9.5rem;
  transition: background 0.15s;
}
.profile-btn:hover { background: rgba(255,255,255,0.2); }
.profile-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  overflow: hidden;
  background: #F5EDE0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.15;
}
.profile-name {
  font-size: 0.8rem;
  font-weight: 700;
  max-width: 5.5rem;
}

.free-tier-note {
  background: #F5EDE0;
  border: 1px dashed #C4A574;
  border-radius: 0.875rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: #5C4033;
  margin-bottom: 0.5rem;
}

.link-premium {
  background: none;
  border: none;
  padding: 0;
  color: #B87A00;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
}

.upgrade-reason {
  background: #fffbeb;
  border-left: 4px solid #D4920A;
  padding: 0.75rem 1rem;
  border-radius: 0 0.75rem 0.75rem 0;
  font-size: 0.95rem;
  color: #5C4033;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.upgrade-benefits {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.upgrade-benefits li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 1rem;
  color: #3D2B1F;
  line-height: 1.4;
}
.upgrade-benefits .ub-icon {
  font-size: 1.35rem;
  line-height: 1.2;
  flex-shrink: 0;
}

.upgrade-price-card {
  background: linear-gradient(135deg, #fffbeb, #F5EDE0);
  border: 2px solid #E8A838;
  border-radius: 1rem;
  padding: 1.1rem 1.25rem;
  text-align: center;
}

.btn-oauth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 3.35rem;
  padding: 0.75rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 0.875rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s;
}
.btn-oauth:active { transform: scale(0.97); }
.btn-oauth:disabled { opacity: 0.55; cursor: wait; }

.btn-oauth-google {
  background: #fff;
  color: #3D2B1F;
  border-color: #D4B896;
  box-shadow: 0 2px 6px rgba(92, 64, 51, 0.08);
}
.btn-oauth-google:hover:not(:disabled) { background: #FBF7F0; }

.btn-oauth-facebook {
  background: #1877F2;
  color: #fff;
  border-color: #1877F2;
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
}
.btn-oauth-facebook:hover:not(:disabled) { background: #166fe5; }

code {
  font-size: 0.85em;
  background: #F5EDE0;
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}
