/* Shared hand-drawn frames for panels and smaller controls. */
:root {
  --pastel-frame: url('../img/green-pastel-frame.png');
}

.ingredient-selector,
.modal {
  border: 12px solid transparent;
  border-image: var(--pastel-frame) 9% / 12px / 0 stretch;
  border-radius: 0;
  background: url('../img/paper-grain.svg') repeat, var(--warm-white);
  background-clip: padding-box;
  box-shadow: none;
}

.ingredient-chip,
.btn-sm,
.view-toggle-btn,
.hero-kitchen .btn,
.nav-cta,
egg-scene button,
.modal-close,
.hero-kitchen .hero-badge,
.results-count,
.result-card .match-badge,
.recipe-card-tags .tag,
.recipe-card-body .ingredient-preview .mini-chip,
.modal-tags .tag,
.ingredients-list li,
.instructions-list li::before {
  border: 7px solid transparent;
  border-image: var(--pastel-frame) 9% / 7px / 0 stretch;
  border-radius: 0;
  /* Keep the transparent grain visible through all hover/selected fills. */
  background-clip: padding-box !important;
}

.nav-cta {
  border-radius: 0 !important;
}

.btn-sm:hover,
.hero-kitchen .btn:hover,
.nav-cta:hover {
  box-shadow: none;
}

.ingredient-chip {
  padding: 6px 9px;
  overflow-wrap: anywhere;
}

.ingredient-chip.spice-chip.checked {
  color: var(--charcoal);
}

.recipe-card-tags .tag,
.recipe-card-body .ingredient-preview .mini-chip,
.modal-tags .tag,
.result-card .match-badge {
  padding: 3px 7px;
}

.result-card h5 {
  padding-right: 76px;
}

.modal-close {
  width: 44px;
  height: 44px;
}

/* ============================================================
   TickTick integration — "Add to Meals" button
   ============================================================ */

/* The gear that opens the settings panel */
.tt-gear {
  background: none;
  border: none;
  padding: 4px 6px;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--charcoal-light);
  cursor: pointer;
  transition: color var(--transition), transform var(--transition);
}
.tt-gear:hover {
  color: var(--primary);
  transform: rotate(30deg);
}

/* Buttons stay hidden until a token has been installed, so visitors
   to the public site never see them. */
.tt-card-btn,
.tt-modal-btn {
  display: none;
}
body.tt-connected .tt-card-btn,
body.tt-connected .tt-modal-btn {
  display: inline-flex;
}

.tt-card-btn,
.tt-modal-btn {
  align-items: center;
  gap: 5px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  color: var(--primary-dark);
  background: url('../img/paper-grain.svg') repeat, var(--warm-white);
  border: 5px solid transparent;
  border-image: var(--pastel-frame) 9% / 5px / 0 stretch;
  border-radius: 0;
  background-clip: padding-box;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tt-card-btn:hover,
.tt-modal-btn:hover {
  background: var(--sage-light);
  color: var(--charcoal);
}
.tt-card-btn[data-state="done"],
.tt-modal-btn[data-state="done"] {
  background: var(--sage-light);
  color: var(--sage-dark);
}
.tt-card-btn:disabled,
.tt-modal-btn:disabled {
  cursor: default;
  opacity: 0.75;
}

/* On a recipe card: pinned to the top-right of the photo */
.tt-card-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  padding: 4px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
}

/* In the recipe modal: sits under the tags */
.tt-modal-btn {
  padding: 9px 16px;
  font-size: 0.85rem;
  margin-bottom: 24px;
}

/* --- Settings panel --- */
.tt-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(61, 52, 43, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.tt-panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  background: url('../img/paper-grain.svg') repeat, var(--warm-white);
  border: 12px solid transparent;
  border-image: var(--pastel-frame) 9% / 12px / 0 stretch;
  border-radius: 0;
  background-clip: padding-box;
}

.tt-panel h3 {
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.tt-panel-status {
  font-size: 0.85rem;
  margin-bottom: 18px;
  color: var(--charcoal-light);
  overflow-wrap: anywhere;
}
.tt-panel-status.ok { color: var(--sage-dark); }
.tt-panel-status.error { color: var(--red-accent); }

.tt-panel label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--charcoal-light);
}
.tt-panel input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--charcoal);
  background: #fff;
  border: 1px solid var(--primary-light);
  border-radius: 0;
}
.tt-panel input:focus {
  outline: none;
  border-color: var(--primary);
}

/* The groceries opt-in is a checkbox, so undo the full-width input styling. */
.tt-panel .tt-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--charcoal-light);
  cursor: pointer;
}
.tt-panel .tt-check input {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--sage-dark);
}

.tt-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.tt-panel-note {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--charcoal-light);
}

.tt-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  color: var(--charcoal-light);
  background: var(--warm-white);
  border: 1px solid var(--primary-light);
  border-radius: 0;
  cursor: pointer;
}
.tt-panel-close:hover { color: var(--primary-dark); }

/* --- Toast --- */
.tt-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 400;
  max-width: 90vw;
  padding: 12px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  color: var(--warm-white);
  background: var(--charcoal);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
  transition: opacity var(--transition), transform var(--transition);
}
.tt-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tt-toast.ok { background: var(--sage-dark); }
.tt-toast.error { background: var(--red-accent); }

@media (max-width: 600px) {
  .ingredient-selector {
    padding: 20px 12px;
  }
  .tt-panel {
    padding: 20px 16px;
  }
  .tt-card-btn {
    font-size: 0.68rem;
    padding: 3px 6px;
  }
}
