/* Tools — utility cooking apps for myroyalchef.com
   Follows the existing design tokens (warm dark + burnt orange).
   No cardocalypse, no decorative elements, no gradients.
   Mobile-first, functional, high information density. */

/* ── Tools Index ── */
.tools-index {
  padding: var(--space-10) 0 var(--space-12);
}

.tools-header {
  margin-bottom: var(--space-10);
}

.tools-kicker {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

.tools-title {
  font-size: var(--font-size-4xl);
  line-height: 1.1;
  margin-bottom: var(--space-4);
}

.tools-lead {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 62ch;
}

/* Tool cards — minimal, no icons, just hierarchy */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 768px) {
  .tools-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tool-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  text-decoration: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

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

.tool-card-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.tool-card h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

.tool-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 var(--space-4);
  flex: 1;
}

.tool-card-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-3);
}

/* ── Tool Page Shell ── */
.tool-page {
  padding: var(--space-8) 0 var(--space-12);
}

.tool-nav {
  margin-bottom: var(--space-6);
}

.tool-back {
  font-size: var(--font-size-sm);
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.tool-back:hover {
  text-decoration: underline;
}

.tool-header {
  margin-bottom: var(--space-6);
}

.tool-header h1 {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-3);
}

.tool-header p {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 60ch;
}

/* ── Tool Input Area ── */
.tool-input-area {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  margin-bottom: var(--space-6);
}

.tool-input-area label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  display: block;
}

.tool-input-area .hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  display: block;
}

.tool-input-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.tool-input-row input,
.tool-input-row select {
  flex: 1;
  margin-bottom: 0;
}

.tool-input-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .tool-input-row {
    flex-direction: column;
    align-items: stretch;
  }
  .tool-input-row .btn {
    width: 100%;
  }
}

/* ── Tool Results ── */
.tool-results {
  min-height: 120px;
}

.tool-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
}

.tool-empty strong {
  display: block;
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  margin-bottom: var(--space-2);
}

/* Result cards */
.tool-result-card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  margin-bottom: var(--space-4);
}

.tool-result-card:last-child {
  margin-bottom: 0;
}

.tool-result-card h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.tool-result-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.tool-result-card .tag {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  margin-right: var(--space-2);
  margin-bottom: var(--space-2);
}

.tag-excellent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.tag-good {
  background: rgba(96, 165, 250, 0.12);
  color: var(--info);
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.tag-works {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

/* ── Cost Calculator Specific ── */
.cost-table-wrap {
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.cost-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cost-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.cost-table td:last-child,
.cost-table th:last-child {
  text-align: right;
}

.cost-table tr:last-child td {
  border-bottom: none;
}

.cost-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-dim);
}

.cost-total-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.cost-total-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--accent);
}

.cost-per-serving {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.cost-per-serving-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.cost-per-serving-value {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Substitution Specific ── */
.sub-result {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  margin-bottom: var(--space-3);
}

.sub-result:last-child {
  margin-bottom: 0;
}

.sub-result-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.sub-result-ratio {
  font-size: var(--font-size-sm);
  color: var(--accent);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.sub-result-note {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.sub-result-best {
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.sub-result-best .sub-result-name {
  color: var(--accent);
}

/* ── Flavor Pairing Specific ── */
.flavor-input-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.flavor-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.flavor-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-size-sm);
  padding: 0;
  border-radius: 50%;
}

.flavor-tag-remove:hover {
  color: var(--error);
  background: var(--error-dim);
}

.flavor-pairing-group {
  margin-bottom: var(--space-5);
}

.flavor-pairing-group:last-child {
  margin-bottom: 0;
}

.flavor-pairing-group h3 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.flavor-pairing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.flavor-pairing-item {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.flavor-pairing-item h4 {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.flavor-pairing-item p {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ── Add ingredient row (for cost calculator) ── */
.ingredient-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: var(--space-2);
  align-items: end;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

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

.ingredient-row input,
.ingredient-row select {
  margin-bottom: 0;
}

.ingredient-row .btn-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-size-lg);
  padding: 0;
}

.ingredient-row .btn-remove:hover {
  border-color: var(--error);
  color: var(--error);
  background: var(--error-dim);
}

@media (max-width: 600px) {
  .ingredient-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }
  .ingredient-row .btn-remove {
    grid-column: 1 / -1;
    width: 100%;
  }
}

.tool-add-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.tool-add-row .btn {
  flex-shrink: 0;
}

/* ── Servings input ── */
.servings-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.servings-row label {
  margin-bottom: 0;
  white-space: nowrap;
}

.servings-row input {
  width: 80px;
  margin-bottom: 0;
}

/* ── Dietary filter chips ── */
.dietary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.dietary-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
  font-family: inherit;
}

.dietary-filter:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.dietary-filter.is-active {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .tools-title {
    font-size: var(--font-size-3xl);
  }
  .tool-header h1 {
    font-size: var(--font-size-2xl);
  }
  .flavor-pairing-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 480px) {
  .tools-index {
    padding: var(--space-6) 0 var(--space-8);
  }
  .tool-page {
    padding: var(--space-4) 0 var(--space-8);
  }
  .tool-input-area {
    padding: var(--space-4);
  }
}
