/* Pantry — chalkboard pantry theme */

:root {
  --bg: #232925;
  --bg-card: #2c332e;
  --bg-card-hover: #343c36;
  --chalk: #f4f1e8;
  --chalk-dim: #c4c0b3;
  --accent: #d9a05b;
  --accent-soft: rgba(217, 160, 91, 0.18);
  --sage: #8fa998;
  --sage-soft: rgba(143, 169, 152, 0.18);
  --danger: #c1786b;
  --danger-soft: rgba(193, 120, 107, 0.18);
  --border: rgba(244, 241, 232, 0.12);
  --font-display: "Caveat", cursive;
  --font-body: "Work Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--chalk);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--chalk);
  letter-spacing: 0.02em;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.topbar nav {
  display: flex;
  gap: 1.25rem;
  font-weight: 500;
}

.topbar nav a {
  color: var(--chalk-dim);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.topbar nav a:hover,
.topbar nav a.active {
  color: var(--chalk);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.whoami-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--chalk-dim);
}

.whoami-label {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}

/* ---- Headings & text --------------------------------------------------- */

.chalk-heading {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  margin: 0.4rem 0 0.6rem;
  line-height: 1.1;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
}

h3 {
  margin: 0;
}

.subtle {
  color: var(--chalk-dim);
  margin: 0 0 1.25rem;
}

.stats-line {
  font-size: 0.8rem;
  color: var(--chalk-dim);
  margin: -0.5rem 0 1.5rem;
}

.error {
  color: var(--danger);
  font-weight: 500;
}

.empty-state {
  color: var(--chalk-dim);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.page-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.page-header h2 {
  margin: 0;
}

/* ---- Buttons & forms ---------------------------------------------------- */

button,
input,
select {
  font-family: var(--font-body);
  font-size: 1rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--chalk);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
}

input::placeholder {
  color: var(--chalk-dim);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
}

/* Shared base: applies to <a> and <button> alike so sizing is always identical */
.primary,
.secondary,
.btn-danger {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  vertical-align: middle;
  box-sizing: border-box;
}

.primary {
  background: var(--accent);
  color: #2a2114;
}

.primary:hover {
  background: #e6b06e;
  text-decoration: none;
}

.secondary {
  background: var(--sage-soft);
  color: var(--sage);
  border: 1px solid var(--sage);
}

.secondary:hover {
  background: var(--sage);
  color: #1c2620;
  text-decoration: none;
}

.btn-danger {
  background: var(--danger);
  color: var(--chalk);
}

.btn-danger:hover {
  background: #ce8679;
  color: var(--chalk);
  text-decoration: none;
}

.link-button {
  background: none;
  border: none;
  color: var(--chalk-dim);
  font-weight: 500;
  padding: 0;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--chalk);
}

.link-button.danger {
  color: var(--danger);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 360px;
}

.stack label {
  font-weight: 500;
  color: var(--chalk-dim);
}

/* ---- Centered cards (login / whoami) ------------------------------------ */

.centered-card {
  max-width: 420px;
  margin: 3rem auto;
  text-align: center;
}

.centered-card .stack {
  margin: 0 auto;
  text-align: left;
}

.who-button {
  width: 100%;
  background: var(--bg-card);
  color: var(--chalk);
  border: 1px solid var(--border);
  padding: 0.9rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.who-button:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

/* ---- Grocery list ------------------------------------------------------- */

.add-item-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.add-item-form input[type="text"]:first-child {
  flex: 2 1 200px;
}

.add-item-form input[name="notes"] {
  flex: 1 1 140px;
}

.banner {
  background: var(--sage-soft);
  color: var(--sage);
  border: 1px solid rgba(143, 169, 152, 0.4);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.store-group {
  margin-bottom: 2rem;
}

.store-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.store-group-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}

.copy-list-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  background: transparent;
  color: var(--chalk-dim);
  border: 1px solid var(--border);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}

.copy-list-btn:hover {
  color: var(--chalk);
  border-color: var(--chalk-dim);
}

.grocery-list,
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.grocery-item,
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.grocery-item-main,
.history-item-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
}

.grocery-item-name {
  font-size: 1.05rem;
  font-weight: 500;
}

.grocery-item-notes {
  color: var(--chalk-dim);
  font-size: 0.9rem;
}

.grocery-item-meta {
  color: var(--chalk-dim);
  font-size: 0.8rem;
}

.grocery-item-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.grocery-item-actions form {
  display: inline;
}

.action-button {
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-weight: 500;
}

.action-got-it {
  background: var(--sage-soft);
  color: var(--sage);
}

.action-got-it:hover {
  background: var(--sage);
  color: #1c2620;
}

.action-oos,
.action-changed-mind {
  background: transparent;
  color: var(--chalk-dim);
  border: 1px solid var(--border);
}

.action-oos:hover,
.action-changed-mind:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- Tags & stamps -------------------------------------------------------- */

.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.quick-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.quick-add-btn {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  line-height: 1.4;
}

.quick-add-btn:hover {
  filter: brightness(0.92);
}

.tag-store {
  background: var(--sage-soft);
  color: var(--sage);
}

.tag-difficulty {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--chalk-dim);
}

.pill-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0 0 1.5rem;
}

.stamp {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.6rem;
  border: 2px solid currentColor;
  border-radius: 4px;
  transform: rotate(-4deg);
}

.stamp-purchased {
  color: var(--sage);
}

.stamp-removed-oos,
.stamp-removed-changed-mind {
  color: var(--danger);
}

/* ---- Recipe library ------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.filter-search {
  flex: 1 1 180px;
}

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

.recipe-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--chalk);
  overflow: hidden;
}

.recipe-card-image {
  display: block;
  width: calc(100% + 2rem);
  margin: -1rem -1rem 0;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.recipe-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.recipe-card-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.recipe-card-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
}

.recipe-card-description {
  color: var(--chalk-dim);
  font-size: 0.9rem;
  margin: 0;
}

.recipe-card-meta {
  display: flex;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--chalk-dim);
}

.suggestion-card {
  border-style: dashed;
}

.suggestion-why {
  font-size: 0.85rem;
  color: var(--sage);
  font-style: italic;
  margin: 0;
}

/* ---- Recipe detail --------------------------------------------------------- */

.source-line {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.recipe-detail-image {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.recipe-description {
  color: var(--chalk-dim);
  max-width: 640px;
}

.recipe-meta-row {
  display: flex;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--chalk-dim);
  margin-bottom: 1.5rem;
}

.recipe-meta-row strong {
  color: var(--chalk);
  font-weight: 600;
}

.recipe-section {
  margin-bottom: 2rem;
}

.ingredients-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  color: var(--chalk-dim);
}

.servings-control #servings-count {
  color: var(--accent);
  font-weight: 700;
  min-width: 1.5em;
  text-align: center;
}

.servings-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--chalk);
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
}

.servings-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ingredient-list,
.step-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ingredient-list.compact {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--chalk-dim);
  gap: 0.2rem;
  list-style: disc;
  padding-left: 1.2rem;
}

.step-list {
  counter-reset: step;
}

.checkline {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  font-family: var(--font-mono);
}

.checkline input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.checkline:has(input:checked) {
  color: var(--chalk-dim);
  text-decoration: line-through;
}

.ingredient-amount {
  font-weight: 600;
  color: var(--accent);
}

/* ---- Star ratings --------------------------------------------------------- */

.ratings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.ratings-avg {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.rating-count {
  color: var(--chalk-dim);
}

.ratings-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.rating-person-name {
  width: 5rem;
  color: var(--chalk-dim);
  flex-shrink: 0;
}

.star-input,
.star-display {
  display: inline-flex;
  gap: 0.05rem;
}

.star-form {
  display: inline;
}

.star-btn {
  background: none;
  border: none;
  padding: 0 0.08rem;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--chalk-dim);
}

.star-btn.filled,
.star-btn:hover {
  color: var(--accent);
}

.star {
  font-size: 1.2rem;
  line-height: 1;
}

.star.filled {
  color: var(--accent);
}

.star.empty {
  color: var(--chalk-dim);
}

.rating-none {
  color: var(--chalk-dim);
  font-size: 0.78rem;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.rating-badge .star {
  font-size: 0.9rem;
}

.delete-form {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* ---- Recipe edit form ------------------------------------------------------ */

.edit-section {
  margin-bottom: 2.5rem;
}

.edit-section h2 {
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.edit-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.edit-field > span {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.edit-field input,
.edit-field select,
.edit-field textarea {
  width: 100%;
}

.edit-field textarea {
  resize: vertical;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--chalk);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

.edit-field-full {
  grid-column: 1 / -1;
}

.edit-row-header {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 2fr 1.5rem;
  gap: 0.5rem;
  padding: 0 0 0.3rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.edit-ing-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 2fr 1.5rem;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.edit-step-row {
  display: grid;
  grid-template-columns: 1fr 1.5rem;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.4rem;
}

.edit-step-row textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--chalk);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

.remove-row {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.2rem;
  align-self: center;
}

.edit-add-btn {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  padding: 0.4rem 0.85rem;
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .edit-meta-grid {
    grid-template-columns: 1fr;
  }

  .edit-field-full {
    grid-column: 1;
  }

  .edit-row-header {
    display: none;
  }

  .edit-ing-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .edit-ing-row input:first-child {
    grid-column: 1 / -1;
  }
}

/* ---- Responsive ----------------------------------------------------------- */

@media (max-width: 640px) {
  .topbar {
    gap: 0.75rem;
  }

  .chalk-heading {
    font-size: 2.1rem;
  }

  .grocery-item,
  .history-item {
    flex-direction: column;
    align-items: stretch;
  }

  .grocery-item-actions {
    width: 100%;
  }

  .grocery-item-actions form {
    flex: 1;
  }

  .action-button {
    width: 100%;
  }
}

/* ---- Meal plan ------------------------------------------------------------ */

.main-wide {
  max-width: 1100px;
}

.meal-plan-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.meal-plan-week-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--chalk);
  flex: 1;
  text-align: center;
}

.meal-plan-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.6rem;
  margin-bottom: 2rem;
}

.meal-plan-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 180px;
}

.meal-plan-day-header {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.meal-plan-day-name {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.meal-plan-day-date {
  font-size: 0.7rem;
  color: var(--chalk-dim);
}

.meal-plan-recipe {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.meal-plan-thumb {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
}

.meal-plan-recipe-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--chalk);
  text-decoration: none;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meal-plan-recipe-title:hover {
  color: var(--accent);
  text-decoration: none;
}

.meal-plan-clear-btn {
  margin-top: auto;
  font-size: 0.68rem;
  color: var(--chalk-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-body);
  text-align: left;
}

.meal-plan-clear-btn:hover {
  color: var(--danger);
}

.meal-plan-add-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.meal-plan-add-form select {
  width: 100%;
  font-size: 0.72rem;
  padding: 0.3rem 0.4rem;
  background: var(--bg);
  color: var(--chalk);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-body);
}

.meal-plan-add-form button {
  width: 100%;
  font-size: 0.72rem;
  padding: 0.3rem 0.4rem;
}

@media (max-width: 640px) {
  .meal-plan-grid {
    grid-template-columns: 1fr;
  }

  .meal-plan-day {
    min-height: auto;
  }

  .meal-plan-week-label {
    text-align: left;
  }
}
