/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --bg-card: #161616;
  --bg-elevated: #1e1e1e;
  --bg-input: #111111;
  --accent: #c9a84c;
  --accent-dim: #8a6e2e;
  --text-primary: #f0ede6;
  --text-secondary: #9a9690;
  --text-muted: #5a5854;
  --border: rgba(255,255,255,0.07);
  --border-accent: rgba(201,168,76,0.3);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'DM Sans', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* === APP SHELL === */
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
}

/* === HEADER === */
.header {
  padding: 3rem 0 1rem;
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.5rem;
}

.logo-mark {
  color: var(--accent);
  font-size: 18px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  font-weight: 300;
}

/* === SEARCH CARD === */
.search-section {
  margin-top: 1.5rem;
}

.search-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  position: relative;
}

.search-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

/* === CHIPS === */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.chips-row:not(:empty) {
  margin-bottom: 0.75rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(201,168,76,0.12);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  cursor: default;
  animation: chip-in 0.15s ease;
}

@keyframes chip-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.chip-remove {
  background: none;
  border: none;
  color: var(--accent-dim);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  transition: color var(--transition);
}

.chip-remove:hover { color: #ff6b6b; }

/* === INPUT ROW === */
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ingredient-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

.ingredient-input::placeholder { color: var(--text-muted); }

.ingredient-input:focus {
  border-color: var(--border-accent);
}

.add-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-accent);
  background: rgba(201,168,76,0.1);
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.add-btn:hover { background: rgba(201,168,76,0.2); }
.add-btn:active { transform: scale(0.93); }

/* === SUGGESTIONS === */
.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 1.25rem;
  right: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.suggestions.open { display: block; }

.suggestion-item {
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(201,168,76,0.1);
  color: var(--accent);
}

/* === FIND BUTTON === */
.find-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #0d0d0d;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity var(--transition), transform var(--transition);
  letter-spacing: 0.02em;
}

.find-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.find-btn:not(:disabled):hover { opacity: 0.88; }
.find-btn:not(:disabled):active { transform: scale(0.98); }

.find-btn-icon { font-size: 0.7rem; }

/* === LOADING === */
.loading {
  text-align: center;
  padding: 3rem 0;
}

.loading-dots {
  display: inline-flex;
  gap: 8px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-8px); opacity: 1; }
}

/* === RESULTS === */
.results-section {
  margin-top: 2rem;
}

.results-header {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.results-header strong {
  color: var(--accent);
  font-weight: 500;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* === RECIPE CARD === */
.recipe-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  animation: card-in 0.25s ease both;
}

.recipe-card:nth-child(1) { animation-delay: 0.04s; }
.recipe-card:nth-child(2) { animation-delay: 0.08s; }
.recipe-card:nth-child(3) { animation-delay: 0.12s; }
.recipe-card:nth-child(4) { animation-delay: 0.16s; }
.recipe-card:nth-child(5) { animation-delay: 0.20s; }
.recipe-card:nth-child(6) { animation-delay: 0.24s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.recipe-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

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

.card-img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: var(--bg-elevated);
  display: block;
}

.card-img-placeholder {
  width: 100%;
  aspect-ratio: 16/10;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
}

.card-body {
  padding: 0.9rem 1rem;
}

.card-name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-category {
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
}

.card-match {
  font-size: 0.72rem;
  color: var(--accent);
  margin-top: 0.5rem;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

.empty-state p { font-size: 0.9rem; }

/* === MODAL === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 0;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 90dvh;
  width: 100%;
  max-width: 560px;
  overflow-y: auto;
  position: relative;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 600px) {
  .modal {
    border-radius: var(--radius);
    transform: translateY(20px) scale(0.97);
    max-height: 85vh;
  }
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: sticky;
  top: 0.75rem;
  float: right;
  margin: 0.75rem 0.75rem 0 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  z-index: 10;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-content {
  padding: 0 1.25rem 1.5rem;
  overflow: hidden;
}

.modal-img {
  width: calc(100% + 2.5rem);
  margin: 0 -1.25rem;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  margin-bottom: 1.25rem;
  margin-top: -44px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.modal-tag {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-section-title {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.6rem;
  margin-top: 1.25rem;
}

.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ingredient-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.ingredient-row:last-child { border-bottom: none; }

.ingredient-name { color: var(--text-primary); }
.ingredient-measure { color: var(--text-muted); font-weight: 300; }

.instructions-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* === INSTALL BANNER === */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  z-index: 300;
}

.install-banner span { flex: 1; }

.install-banner #install-btn {
  background: var(--accent);
  color: #0d0d0d;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.install-banner #install-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

/* === RESPONSIVE === */
@media (max-width: 400px) {
  .logo-text { font-size: 1.8rem; }
  .results-grid { grid-template-columns: 1fr; }
}

/* === CARD TEXT IMPROVEMENTS === */
.card-name {
  color: #f0ede6 !important;
  font-size: 1.05rem !important;
}
.card-meta span {
  color: #9a9690 !important;
  font-size: 0.78rem !important;
}
.card-category {
  background: rgba(255,255,255,0.08) !important;
  color: #9a9690 !important;
}
.results-header {
  font-size: 0.85rem !important;
  color: #9a9690 !important;
  margin-bottom: 1.25rem !important;
}
