:root {
  /* Palette claire — blanc #efedea, bleu #07199b, orange #ff8212 */
  --bg: #efedea;
  --bg-soft: #e5e2db;
  --card: #ffffff;
  --card-hi: #f6f4f0;
  --line: #dcd6cd;
  --text: #14173a;
  --muted: #6d7080;
  --accent: #ff8212;
  --accent-soft: #ff9a40;
  --blue: #07199b;
  --blue-soft: #e8eaf7;
  --danger: #e0524e;
  --radius: 22px;
  --shadow: 0 20px 42px -22px rgba(7, 25, 155, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Garantit que l'attribut [hidden] cache toujours, meme quand une classe
   definit un display (ex : .overlay { display: grid }). */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

h1,
h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  margin: 0;
}

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: linear-gradient(180deg, var(--bg) 65%, transparent);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(255, 130, 18, 0.7);
}

.brand h1 {
  font-size: 30px;
  letter-spacing: -0.5px;
  color: var(--blue);
}

.icon-btn {
  border: none;
  background: var(--card);
  color: var(--text);
  width: 60px;
  height: 60px;
  border-radius: 18px;
  font-size: 22px;
  cursor: pointer;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease),
    color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.icon-btn:active {
  transform: scale(0.9);
  background: var(--card-hi);
}

.icon-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.icon-btn.ghost {
  background: transparent;
  border-color: transparent;
}

/* Trois points dessines en CSS -> centrage parfait, sans metriques de police */
.dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------------- Views ---------------- */
.view {
  padding: 8px 28px 60px;
}

/* ---------------- Manage banner ---------------- */
.manage-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--blue-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 20px;
  color: var(--blue);
  font-size: 15px;
  font-weight: 500;
  animation: dropIn 0.35s var(--ease);
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ---------------- Barre de filtres ---------------- */
.filter-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 16px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.16s var(--ease), background 0.16s var(--ease),
    color 0.16s var(--ease), border-color 0.16s var(--ease);
}

.filter-chip:active {
  transform: scale(0.94);
}

.filter-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.chip-emoji {
  font-size: 17px;
  line-height: 1;
}

/* ---------------- Grille de plats ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 26px;
  cursor: pointer;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  overflow: hidden;
  box-shadow: 0 10px 26px -20px rgba(7, 25, 155, 0.28);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
    border-color 0.2s var(--ease);
  animation: cardIn 0.4s var(--ease) both;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none; /* ne doit jamais intercepter les clics des boutons */
  background: radial-gradient(
    120% 90% at 80% 0%,
    rgba(255, 130, 18, 0.14),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.card:hover::after {
  opacity: 1;
}

.card:active {
  transform: scale(0.97);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

.card-emoji {
  font-size: 58px;
  line-height: 1;
  filter: drop-shadow(0 6px 12px rgba(7, 25, 155, 0.18));
}

.card-name {
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.card-meta {
  color: var(--muted);
  font-size: 13px;
}

/* Badge catégorie */
.card-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  padding: 5px 12px;
}

/* Boutons de gestion sur la carte */
.card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2; /* au-dessus de l'emoji / du contenu de la carte */
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none; /* non cliquable hors mode gestion */
  transform: translateY(-6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.card.managing .card-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.card.managing {
  cursor: default;
}

.mini-btn {
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(7, 25, 155, 0.6);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.mini-btn:active {
  transform: scale(0.85);
}

.mini-btn.del {
  background: var(--danger);
}

/* ---------------- Vue detail ---------------- */
.detail {
  padding: 8px 28px 80px;
}

.detail-back {
  border: none;
  background: var(--card);
  color: var(--text);
  height: 56px;
  padding: 0 24px 0 18px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  transition: transform 0.16s var(--ease), background 0.16s var(--ease);
}

.detail-back:active {
  transform: scale(0.94);
  background: var(--card-hi);
}

.detail-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 34px;
}

.detail-emoji {
  font-size: 92px;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(7, 25, 155, 0.2));
}

.detail-badge {
  position: static;
  margin-bottom: 10px;
}

.detail-title {
  font-size: 40px;
  letter-spacing: -0.6px;
  color: var(--blue);
}

.section-label {
  text-transform: uppercase;
  letter-spacing: 1.6px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 16px;
  font-weight: 700;
}

.ing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}

.ing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 22px;
  animation: cardIn 0.35s var(--ease) both;
}

.ing-name {
  font-size: 17px;
  font-weight: 500;
}

.ing-qty {
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.recipe-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 600;
  padding: 20px 32px;
  border-radius: 18px;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
  box-shadow: 0 14px 28px -12px rgba(255, 130, 18, 0.75);
}

.recipe-link:active {
  transform: scale(0.96);
}

/* ---------------- Boutons generiques ---------------- */
.btn {
  border: none;
  border-radius: 15px;
  padding: 15px 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease),
    opacity 0.15s var(--ease);
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px -12px rgba(255, 130, 18, 0.75);
}

.btn-soft {
  background: var(--blue-soft);
  color: var(--blue);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

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

/* ---------------- Etat vide ---------------- */
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  margin-top: 80px;
}

/* ---------------- Overlay / modale ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 23, 58, 0.35);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: end center;
  animation: fade 0.25s var(--ease);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  width: min(760px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 30px 30px 0 0;
  padding: 26px 30px 34px;
  box-shadow: 0 -20px 60px -30px rgba(7, 25, 155, 0.4);
  animation: slideUp 0.35s var(--ease);
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.sheet-head h2 {
  font-size: 26px;
  color: var(--blue);
}

/* ---------------- Formulaire ---------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.3px;
}

input,
textarea {
  font-family: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  outline: none;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 130, 18, 0.18);
}

input::placeholder {
  color: #a7a294;
}

.field-row {
  display: flex;
  gap: 16px;
}

.field-emoji {
  width: 120px;
  flex: 0 0 auto;
}

.field-emoji input {
  text-align: center;
  font-size: 26px;
}

.field-grow {
  flex: 1;
}

/* ---------------- Sélecteur de catégorie (formulaire) ---------------- */
.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease),
    color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.cat-pill:active {
  transform: scale(0.94);
}

.cat-pill.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ---------------- Ingredients dynamiques ---------------- */
.ingredients-block {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.ingredients-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ingredients-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ing-row {
  display: flex;
  gap: 12px;
  align-items: center;
  animation: cardIn 0.25s var(--ease) both;
}

.ing-row input {
  flex: 1;
}

.ing-row .q {
  flex: 0 0 34%;
}

.ing-row .remove {
  border: none;
  background: var(--card-hi);
  color: var(--muted);
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 13px;
  font-size: 20px;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: transform 0.15s var(--ease), color 0.15s var(--ease),
    background 0.15s var(--ease);
}

.ing-row .remove:active {
  transform: scale(0.85);
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

/* ---------------- Confirm ---------------- */
.confirm {
  place-self: center;
  width: min(420px, 90%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s var(--ease);
}

.confirm p {
  font-size: 19px;
  margin: 0 0 24px;
}

.confirm .form-actions {
  justify-content: center;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--blue);
  color: #fff;
  padding: 14px 26px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------- Ecran de démarrage ---------------- */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 200;
}

.brand-dot.big {
  width: 26px;
  height: 26px;
  animation: pulse 1.1s var(--ease) infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.6);
    opacity: 0.5;
  }
}

/* ---------------- Barre d'actions topbar + bouton compte ---------------- */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-btn {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 22px;
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ---------------- Ecran d'authentification ---------------- */
.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
  animation: slideUp 0.4s var(--ease);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand h1 {
  font-size: 28px;
  color: var(--blue);
}

.auth-sub {
  color: var(--muted);
  margin: 10px 0 24px;
  font-size: 15px;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--bg-soft);
  border-radius: 14px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 13px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.auth-tab.active {
  background: var(--card);
  color: var(--blue);
  box-shadow: 0 4px 10px -6px rgba(7, 25, 155, 0.4);
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.btn-block {
  width: 100%;
}

/* ---------------- View Transitions ---------------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.4s;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
