/* ─── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  --color-terracotta: #C25B2A;
  --color-bois      : #4A2C1A;
  --color-herbe     : #4A6741;
  --color-creme     : #FDF6EE;
  --color-lin       : #E8D8C4;
  --color-blanc     : #FFFFFF;
  --nav-height      : 4rem; /* 64px – keep in sync with h-16 on <header> */
}

/* ─── Skip to content (accessibility) ──────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  background: var(--color-terracotta);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 0.75rem 0.75rem;
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* ─── Typography ────────────────────────────────────────────────────────── */
body            { font-family: 'Lato', sans-serif; }
.font-playfair  { font-family: 'Playfair Display', serif; }
.font-dancing   { font-family: 'Dancing Script', cursive; }
.font-lato      { font-family: 'Lato', sans-serif; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  background-color: var(--color-terracotta);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 0.75rem;
  border: 2px solid transparent;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn-primary:hover  { background-color: #A34B20; box-shadow: 0 4px 16px rgba(194,91,42,.4); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled,
.btn-primary[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading spinner inside btn-primary */
.btn-primary.loading::after {
  content: '';
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  background-color: white;
  color: var(--color-bois);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 0.75rem;
  border: 2px solid var(--color-lin);
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
  cursor: pointer;
  text-decoration: none;
}
.btn-secondary:hover { border-color: var(--color-terracotta); background-color: var(--color-creme); color: var(--color-terracotta); }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-bois);
  margin-bottom: 0.375rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 2px solid var(--color-lin);
  border-radius: 0.75rem;
  background-color: white;
  color: var(--color-bois);
  font-size: 1rem; /* min 16px prevents iOS zoom on focus */
  font-family: 'Lato', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.15s;
  outline: none;
}
.form-input:hover:not(:focus) { border-color: #cbb89e; }
.form-input:focus   { border-color: var(--color-terracotta); box-shadow: 0 0 0 3px rgba(194,91,42,.14); background-color: #fffcf9; }
.form-input::placeholder { color: #b8a898; }
select.form-input   { cursor: pointer; appearance: auto; }
textarea.form-input { resize: vertical; }

/* Validation states */
.form-input.is-invalid { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.1); }
.form-input.is-valid   { border-color: var(--color-herbe); box-shadow: 0 0 0 3px rgba(74,103,65,.1); }

/* Character counter */
.char-counter {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: right;
  margin-top: 0.25rem;
  transition: color 0.15s;
}
.char-counter.near-limit { color: #b45309; }
.char-counter.at-limit   { color: #dc2626; font-weight: 600; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1.5px solid var(--color-lin);
  border-radius: 1.25rem;
  padding: 1.5rem;
}

.recipe-card {
  background: white;
  border: 1.5px solid var(--color-lin);
  border-radius: 1.25rem;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s;
}
.recipe-card:hover {
  border-color: var(--color-terracotta);
  box-shadow: 0 8px 28px rgba(74,44,26,.14);
  transform: translateY(-3px);
}
.recipe-card:active { transform: translateY(-1px); }

/* Recipe card image placeholder per category */
.recipe-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-lin) 0%, var(--color-creme) 100%);
  font-size: 3rem;
  opacity: 0.5;
}

.info-card {
  background: var(--color-creme);
  border: 1.5px solid var(--color-lin);
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.info-card:hover { border-color: #cbb89e; box-shadow: 0 2px 8px rgba(74,44,26,.07); }

/* ─── Navigation ────────────────────────────────────────────────────────── */
.nav-link {
  padding: 0.375rem 0.75rem;
  border-radius: 0.625rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-bois);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
  position: relative;
}
.nav-link:hover      { background-color: var(--color-creme); color: var(--color-terracotta); }
.nav-link-active     { background-color: var(--color-creme); color: var(--color-terracotta); font-weight: 700; }
.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: -0.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1rem;
  height: 2px;
  background: var(--color-terracotta);
  border-radius: 9999px;
}

/* ─── Pills / Badges ────────────────────────────────────────────────────── */
.pill {
  padding: 0.25rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1.5px solid var(--color-lin);
  color: var(--color-bois);
  background: white;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
  cursor: pointer;
}
.pill:hover  { border-color: var(--color-terracotta); color: var(--color-terracotta); }
.pill-active { background-color: var(--color-terracotta); border-color: var(--color-terracotta); color: white; }

/* ─── Flash messages ────────────────────────────────────────────────────── */
#flash-message {
  animation: flash-in 0.3s ease;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.flash-success > div { background: #f0fdf4; border: 1.5px solid #bbf7d0; color: var(--color-herbe); }
.flash-error   > div { background: #fef2f2; border: 1.5px solid #fecaca; color: #dc2626; }
.flash-warning > div { background: #fffbeb; border: 1.5px solid #fde68a; color: #b45309; }
.flash-info    > div { background: #eff6ff; border: 1.5px solid #bfdbfe; color: #1d4ed8; }

/* ─── Toast notifications ───────────────────────────────────────────────── */
.toast {
  pointer-events: all;
  background: white;
  border: 1.5px solid var(--color-lin);
  border-left: 4px solid var(--color-terracotta);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(74,44,26,.15);
  font-size: 0.875rem;
  max-width: 320px;
  width: max-content;
  animation: toast-in 0.3s ease;
  color: var(--color-bois);
}
@media (max-width: 480px) {
  .toast { max-width: calc(100vw - 3rem); }
}
.toast.success { border-left-color: var(--color-herbe); }
.toast.error   { border-left-color: #dc2626; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ─── Ingredient rows ───────────────────────────────────────────────────── */
.ingredient-row-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1.5px solid var(--color-lin);
  border-radius: 0.75rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ingredient-row-form:focus-within {
  border-color: var(--color-terracotta);
  box-shadow: 0 0 0 3px rgba(194,91,42,.1);
}
.ingredient-row-form input,
.ingredient-row-form select {
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Lato', sans-serif;
  color: var(--color-bois);
  font-size: 0.9rem;
  min-height: 2rem;
}
.ingredient-row-form input:focus,
.ingredient-row-form select:focus { background: var(--color-creme); border-radius: 0.375rem; padding: 0 0.25rem; }
.ingredient-row-form .qty-input   { width: 70px; text-align: right; }
.ingredient-row-form .name-input  { flex: 1; }

/* ─── Step rows ─────────────────────────────────────────────────────────── */
.step-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1.5px solid var(--color-lin);
  border-radius: 0.75rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.step-row:focus-within {
  border-color: var(--color-terracotta);
  box-shadow: 0 0 0 3px rgba(194,91,42,.1);
}
.step-number {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--color-terracotta);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
  margin-top: 0.375rem;
  flex-shrink: 0;
}
.step-textarea {
  flex: 1;
  resize: vertical;
  min-height: 72px;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Lato', sans-serif;
  color: var(--color-bois);
  font-size: 0.9rem;
  line-height: 1.5;
}
.step-textarea:focus { background: var(--color-creme); border-radius: 0.5rem; padding: 0.375rem; }

/* ─── Tag chips ─────────────────────────────────────────────────────────── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.625rem;
  background: var(--color-creme);
  border: 1.5px solid var(--color-lin);
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: var(--color-bois);
}
.tag-chip button {
  color: #9ca3af;
  line-height: 1;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}
.tag-chip button:hover { color: #dc2626; }

/* ─── Password strength indicator ───────────────────────────────────────── */
.password-strength {
  height: 3px;
  border-radius: 9999px;
  background: var(--color-lin);
  margin-top: 0.5rem;
  overflow: hidden;
}
.password-strength-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease, background-color 0.3s;
  width: 0;
}
.strength-weak   .password-strength-bar { width: 33%; background: #ef4444; }
.strength-medium .password-strength-bar { width: 66%; background: #f59e0b; }
.strength-strong .password-strength-bar { width: 100%; background: var(--color-herbe); }
.password-strength-label {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  color: #9ca3af;
}
.strength-weak   .password-strength-label { color: #ef4444; }
.strength-medium .password-strength-label { color: #b45309; }
.strength-strong .password-strength-label { color: var(--color-herbe); }

/* ─── Mobile touch targets (min 44px) ───────────────────────────────────── */
@media (max-width: 768px) {
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }
  /* Ensure nav links are tappable */
  .nav-link { min-height: 40px; display: inline-flex; align-items: center; }
  /* Form inputs are already 44px+ due to padding + font size */
}

/* ─── Ingredient rows responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
  .ingredient-row-form {
    flex-wrap: wrap;
  }
  .ingredient-row-form .qty-input {
    width: 60px;
  }
}

/* ─── Utilities ─────────────────────────────────────────────────────────── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ingredient-check:checked ~ span { text-decoration: line-through; color: #9ca3af; }

/* ─── Breadcrumb ────────────────────────────────────────────────────────── */
nav[aria-label="Fil d'Ariane"] ol {
  list-style: none;
}

/* ─── Focus visible (accessibility) ────────────────────────────────────── */
:focus-visible {
  outline: 2.5px solid var(--color-terracotta);
  outline-offset: 3px;
  border-radius: 4px;
}
/* Remove default outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Smooth page transitions ────────────────────────────────────────────  */
main {
  animation: page-in 0.25s ease;
}
@keyframes page-in {
  from { opacity: 0.75; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Modal animations ──────────────────────────────────────────────────── */
.modal-backdrop {
  animation: backdrop-in 0.2s ease;
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-panel {
  animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Section dividers in forms ─────────────────────────────────────────── */
.form-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.125rem;
  color: var(--color-bois);
  border-bottom: 1.5px solid var(--color-lin);
  padding-bottom: 0.75rem;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  padding: 3.5rem 2rem;
  text-align: center;
  background: white;
  border: 1.5px dashed var(--color-lin);
  border-radius: 1.25rem;
}
.empty-state-icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 1rem;
  opacity: 0.8;
}
.empty-state-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--color-bois);
  margin-bottom: 0.5rem;
}
.empty-state-desc {
  font-size: 0.9375rem;
  color: #6b7280;
  max-width: 28rem;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

/* ─── Group card enhancements ────────────────────────────────────────────── */
.group-card {
  background: white;
  border: 1.5px solid var(--color-lin);
  border-radius: 1.25rem;
  padding: 1.5rem;
  text-decoration: none;
  display: block;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s;
}
.group-card:hover {
  border-color: var(--color-terracotta);
  box-shadow: 0 8px 28px rgba(74,44,26,.14);
  transform: translateY(-3px);
}

/* ─── Auth page layout ───────────────────────────────────────────────────── */
.auth-card {
  background: white;
  border: 1.5px solid var(--color-lin);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(74,44,26,.08);
}

/* ─── Recipe hero gradient overlay ──────────────────────────────────────── */
.recipe-hero-overlay {
  background: linear-gradient(to top, rgba(74,44,26,0.55) 0%, rgba(74,44,26,0.05) 60%, transparent 100%);
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-creme); }
::-webkit-scrollbar-thumb { background: var(--color-lin); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #c4a98a; }

/* ─── Print styles ───────────────────────────────────────────────────────── */
@media print {
  header, footer, .no-print { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #e5e7eb; }
}
