:root {
  --cream: #fff3dc;
  --cream-2: #f9e3b8;
  --gold: #e8b04a;
  --caramel: #c98a3b;
  --crust: #8b5a2b;
  --choco: #4a2c17;
  --wood-1: #b8793d;
  --wood-2: #8d5524;
  --wood-3: #6b3e18;
  --grey: #8a8178;
  --red: #b5502a;
  --radius: 14px;
  --font-script: "Great Vibes", "Snell Roundhand", "Brush Script MT", cursive;
  --font-display: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --font-chalk: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --font-ui: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-variant-numeric: lining-nums;
  color: var(--choco);
  background:
    radial-gradient(ellipse at 50% -10%, #ffe9bd 0%, transparent 60%),
    linear-gradient(180deg, #f6d9a1 0%, #f0c987 100%);
  min-height: 100vh;
}

/* ---------- Façade ---------- */
.storefront { position: relative; }

.awning {
  height: 74px;
  background:
    repeating-linear-gradient(90deg, var(--caramel) 0 56px, var(--cream) 56px 112px);
  position: relative;
  box-shadow: 0 6px 14px rgba(74, 44, 23, 0.25);
}
.awning::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -22px;
  height: 22px;
  background:
    radial-gradient(circle at 28px 0, var(--caramel) 27px, transparent 28px) 0 0 / 112px 22px repeat-x,
    radial-gradient(circle at 84px 0, var(--cream) 27px, transparent 28px) 0 0 / 112px 22px repeat-x;
  filter: drop-shadow(0 4px 3px rgba(74, 44, 23, 0.25));
}

.sign {
  margin: 44px auto 6px;
  width: min(560px, 88vw);
  text-align: center;
  padding: 14px 24px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--choco), #351e0e);
  border: 5px solid var(--gold);
  box-shadow: 0 8px 18px rgba(74, 44, 23, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.sign h1 {
  margin: 0;
  font-family: var(--font-script);
  font-weight: 400;
  font-size: clamp(3.1rem, 11vw, 5rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--gold);
  text-shadow: 0 2px 0 #7a4a14, 0 0 18px rgba(232, 176, 74, 0.45);
}
.sign p {
  margin: 6px 0 0;
  color: var(--cream-2);
  font-family: var(--font-display);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: clamp(0.72rem, 2.4vw, 0.92rem);
  font-weight: 600;
}

/* ---------- Barre d'outils ---------- */
.toolbar {
  max-width: 1180px;
  margin: 22px auto 0;
  padding: 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
}
.search { flex: 1 1 240px; min-width: 200px; }
.search input {
  width: 100%;
  padding: 11px 16px;
  border-radius: 999px;
  border: 2px solid var(--caramel);
  background: #fffaf0;
  font: inherit;
  color: var(--choco);
  outline: none;
}
.search input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(232, 176, 74, 0.35); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 2 1 380px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--caramel);
  background: #fff7e6;
  color: var(--crust);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.chip:hover { transform: translateY(-1px); background: var(--cream-2); }
.chip[aria-pressed="true"] { background: var(--crust); color: var(--cream); border-color: var(--crust); }

.admin-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid var(--crust);
  background: #fff7e6;
  color: var(--crust);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.btn:hover { transform: translateY(-1px); background: var(--cream-2); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--crust); color: var(--cream); }
.btn-primary:hover { background: var(--choco); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fde3d6; }
.btn-lock { padding: 10px 13px; }
.btn-lock.is-admin { background: var(--gold); border-color: var(--crust); }

/* ---------- Vitrine ---------- */
.window-wrap { max-width: 1180px; margin: 22px auto 0; padding: 0 18px; }

.window {
  position: relative;
  border-radius: 20px;
  padding: 22px 22px 8px;
  background:
    linear-gradient(180deg, #fff8e8 0%, #fbe9c3 100%);
  border: 14px solid transparent;
  border-image: linear-gradient(180deg, var(--wood-1), var(--wood-3)) 1;
  box-shadow: 0 18px 36px rgba(74, 44, 23, 0.35), inset 0 0 40px rgba(201, 138, 59, 0.28);
}

.glass-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    linear-gradient(115deg, transparent 0 18%, rgba(255, 255, 255, 0.28) 18% 24%, transparent 24% 40%, rgba(255, 255, 255, 0.16) 40% 43%, transparent 43%);
}

.category { margin-bottom: 18px; }

.plaque {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 4px 0 10px;
  padding: 7px 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fffaf0, var(--cream-2));
  border: 2px solid var(--caramel);
  box-shadow: 0 3px 6px rgba(74, 44, 23, 0.2);
}
.plaque h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--choco);
}
.plaque span { color: var(--crust); font-family: var(--font-display); font-size: 1.1rem; font-style: italic; font-weight: 600; }

/* ---------- Grandes cases en osier ---------- */
.case {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
  padding: 12px;
  border-radius: 14px;
  background:
    linear-gradient(rgba(70, 35, 10, 0.2), rgba(70, 35, 10, 0.2)),
    url("/img/wicker.webp") center / 640px auto;
  box-shadow:
    inset 0 0 0 3px rgba(94, 56, 22, 0.6),
    inset 0 0 22px rgba(60, 32, 10, 0.5),
    0 10px 18px rgba(74, 44, 23, 0.35);
}

/* ---------- Petites cases ---------- */
.cell {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.02;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  font: inherit;
  cursor: pointer;
  outline: none;
  background: linear-gradient(180deg, #ecd8ac 0%, #fbf0d6 40%, #fff7e3 100%);
  box-shadow:
    inset 0 7px 10px rgba(70, 38, 12, 0.4),
    inset 4px 0 7px rgba(70, 38, 12, 0.2),
    inset -4px 0 7px rgba(70, 38, 12, 0.2);
}
.cell.is-empty { cursor: default; }
.cell:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.loaf {
  position: absolute;
  left: 50%;
  bottom: 28%;
  width: 72%;
  height: auto;
  mix-blend-mode: multiply;
  transform: translateX(-50%) rotate(calc(var(--base, 0deg) + var(--rot, 0deg))) scale(var(--scale, 1));
  transform-origin: 50% 90%;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  pointer-events: none;
  user-select: none;
}
.t-croustillant .loaf { width: 90%; bottom: 36%; --base: -30deg; }
.t-dore .loaf { width: 72%; }
.t-brioche .loaf { width: 60%; }
.t-brioche-sucree .loaf { width: 70%; }
.t-pain-perdu .loaf { width: 80%; --base: -4deg; }

.cell:not(.is-empty):hover .loaf,
.cell:focus-visible .loaf {
  transform: translateX(-50%) translateY(-8px) rotate(calc(var(--base, 0deg) + var(--rot, 0deg) * 0.4)) scale(calc(var(--scale, 1) * 1.07));
}

.front {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 38%;
  border-top: 5px solid #86521f;
  background:
    linear-gradient(180deg, rgba(255, 232, 185, 0.5) 0, rgba(255, 232, 185, 0) 16%, rgba(60, 30, 8, 0) 62%, rgba(60, 30, 8, 0.32) 100%),
    url("/img/wicker.webp") center / 440px auto;
  box-shadow: 0 -3px 6px rgba(50, 25, 5, 0.38), inset 0 2px 0 rgba(255, 225, 170, 0.5);
}

.slate {
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: 86%;
  height: 22%;
  min-height: 26px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  border: 3px solid #6b4220;
  border-radius: 4px;
  background: radial-gradient(ellipse at 30% 20%, #3b413d, #1e2220 72%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 0 8px rgba(0, 0, 0, 0.65);
  transition: transform 0.18s;
}
.chalk {
  max-width: 96%;
  padding: 0 4px 2px 3px;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-chalk);
  font-weight: 600;
  font-size: clamp(0.95rem, 1.6vw, 1.2rem);
  line-height: 1.1;
  color: #f6f2e6;
  opacity: 0.9;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.7), 0 0 5px rgba(255, 255, 255, 0.2);
  transition: opacity 0.15s;
}
.cell:not(.is-empty):hover .slate,
.cell:focus-visible .slate { transform: translateX(-50%) translateY(-1px); }
.cell:not(.is-empty):hover .chalk,
.cell:focus-visible .chalk { opacity: 1; }

.empty-all { text-align: center; padding: 40px 10px 50px; color: var(--crust); font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; }

.footer { text-align: center; padding: 26px 10px 36px; color: var(--crust); font-family: var(--font-display); font-style: italic; font-size: 1.1rem; font-weight: 600; }

/* ---------- Fenêtres modales ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(53, 30, 14, 0.62); backdrop-filter: blur(3px); animation: fade 0.2s ease; }
.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 20px;
  background: linear-gradient(180deg, #fffaf0, var(--cream));
  border: 4px solid var(--gold);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-card.narrow { width: min(420px, 100%); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(0.94); } }

.close {
  position: absolute;
  top: 10px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(139, 90, 43, 0.14);
  color: var(--crust);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
}
.close:hover { background: rgba(139, 90, 43, 0.28); }

/* Profil */
.profile { display: grid; grid-template-columns: 280px 1fr; }
.profile-photo {
  min-height: 360px;
  background: linear-gradient(160deg, var(--cream-2), var(--gold));
  display: grid;
  place-items: center;
}
.profile-photo { position: relative; overflow: hidden; }
.profile-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.profile-photo .initials {
  width: 150px; height: 150px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--crust);
  color: var(--cream);
  font-size: 3.2rem;
  font-weight: 700;
}
.profile-body { padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.profile-body h2 { margin: 0; font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.profile-job { margin: -6px 0 0; color: var(--crust); font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 1.45rem; }
.profile-desc { margin: 0; white-space: pre-wrap; font-family: var(--font-display); font-weight: 500; font-size: 1.3rem; line-height: 1.45; }
.profile-desc.muted { color: var(--grey); font-style: italic; }

.type-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 8px;
  border-radius: 14px;
  background: var(--cream-2);
  border: 2px solid var(--caramel);
  align-self: flex-start;
}
.type-badge .thumb { width: 64px; height: 52px; display: grid; place-items: center; background: #fff; border-radius: 10px; }
.type-badge .thumb img { max-width: 56px; max-height: 44px; object-fit: contain; mix-blend-mode: multiply; }
.type-badge strong { display: block; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.type-badge small { color: var(--crust); font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 1rem; }

.profile-actions { margin-top: auto; display: flex; gap: 10px; }

/* Formulaires */
.form { padding: 26px 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.form h2 { margin: 0 0 2px; font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field .label { font-weight: 700; font-size: 0.86rem; color: var(--crust); }
.field input[type="text"], .field input[type="password"], .field textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid var(--caramel);
  background: #fffdf7;
  font: inherit;
  color: var(--choco);
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232, 176, 74, 0.35); }
.field textarea { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.type-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.type-option {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 6px 10px;
  border-radius: 12px;
  border: 2px solid #e3cfa5;
  background: #fffdf7;
  font: inherit;
  color: var(--choco);
  cursor: pointer;
  text-align: center;
}
.type-option:hover { border-color: var(--caramel); }
.type-option[aria-pressed="true"] { border-color: var(--crust); background: var(--cream-2); box-shadow: 0 0 0 3px rgba(232, 176, 74, 0.5); }
.type-option .pic { width: 100%; height: 48px; display: grid; place-items: center; background: #fff; border-radius: 8px; }
.type-option .pic img { max-width: 90%; max-height: 42px; object-fit: contain; mix-blend-mode: multiply; }
.type-option b { font-size: 0.82rem; }
.type-option small { color: var(--grey); font-size: 0.72rem; line-height: 1.2; }

.photo-field { display: flex; align-items: center; gap: 14px; }
.photo-preview {
  width: 86px; height: 86px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: var(--cream-2) center / cover no-repeat;
  border: 2px dashed var(--caramel);
  display: grid; place-items: center;
  color: var(--crust); font-size: 1.6rem;
}
.photo-field .col { display: flex; flex-direction: column; gap: 6px; }
.photo-field input[type="file"] { font: inherit; font-size: 0.85rem; max-width: 100%; }
.check { display: flex; gap: 6px; align-items: center; font-size: 0.82rem; color: var(--grey); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.error { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 0; font-size: 0.88rem; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 30px);
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--choco);
  color: var(--cream);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 680px) {
  .profile { grid-template-columns: 1fr; }
  .profile-photo { min-height: 260px; max-height: 320px; }
  .row { grid-template-columns: 1fr; }
  .window { padding: 14px 10px 4px; border-width: 10px; }
  .admin-tools { margin-left: 0; }
}

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