/* ============================================================================
   Ikaros Holidays — Visual in-place editor (owner only)
   Click a title to edit it, a photo to replace it, drag gallery to reorder.
   ========================================================================== */

/* Floating "Edit site" launcher (shown only when the owner is logged in) */
.ed-launch {
  position: fixed; right: 18px; bottom: 18px; z-index: 900;
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--grad-cta); color: #fff; border: 0; border-radius: var(--r-pill);
  padding: .8rem 1.3rem; font: 700 var(--fs-sm)/1 var(--font-body);
  box-shadow: var(--shadow-float); cursor: pointer;
}
.ed-launch svg { width: 18px; height: 18px; }
.ed-launch:hover { filter: brightness(1.05); }

/* Top toolbar shown in edit mode */
.ed-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 950; min-height: 56px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px var(--sp-4); padding: 8px var(--sp-5);
  background: #0A2530; color: #fff; box-shadow: var(--shadow-elevated);
  transform: translateY(-100%); transition: transform var(--dur-base) var(--ease-out);
}
body.edit-mode .ed-bar { transform: translateY(0); }
body.edit-mode { padding-top: 60px; }
.ed-bar__title { font-weight: 800; display: inline-flex; align-items: center; gap: .5rem; }
.ed-bar__title svg { width: 18px; height: 18px; color: var(--c-accent); }
.ed-bar__hint { font-size: var(--fs-sm); color: rgba(255,255,255,.7); flex: 1 1 220px; min-width: 0; }
.ed-lbl { display: inline; }
.ed-bar .ed-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: var(--r-pill);
  padding: .5rem 1rem; font: 700 var(--fs-sm)/1 var(--font-body); cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.ed-bar .ed-btn svg { width: 16px; height: 16px; }
.ed-bar .ed-btn:hover { background: rgba(255,255,255,.2); }
.ed-bar .ed-btn--done { background: var(--c-accent); color: #04231f; }
.ed-bar .ed-btn--done:hover { filter: brightness(1.06); }

/* Editable text: highlight + pencil affordance */
body.edit-mode [data-ed-text] {
  outline: 2px dashed transparent; outline-offset: 3px; border-radius: 4px;
  cursor: text; transition: outline-color var(--dur-fast), background var(--dur-fast); position: relative;
}
body.edit-mode [data-ed-text]:hover { outline-color: var(--c-accent); background: rgba(14,159,139,.06); }
body.edit-mode [data-ed-text][contenteditable="true"] {
  outline: 2px solid var(--c-accent); background: rgba(14,159,139,.1);
}

/* Editable images: outline works on <img>, label overlay on container elements */
body.edit-mode [data-ed-img] { cursor: pointer; outline: 3px dashed transparent; outline-offset: 2px; transition: outline-color var(--dur-fast); }
body.edit-mode [data-ed-img]:hover { outline-color: var(--c-accent); }
body.edit-mode .fleet-media[data-ed-img]::after {
  content: "📷 Changer la photo"; position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,42,54,.5); color: #fff; font: 700 var(--fs-sm)/1.2 var(--font-body); text-align: center;
  opacity: 0; transition: opacity var(--dur-fast); pointer-events: none;
}
body.edit-mode .fleet-media[data-ed-img]:hover::after { opacity: 1; }

/* Gallery figures keep their position context for the reorder buttons */
body.edit-mode .ikaria-gallery figure { position: relative; }

/* Gallery reorder buttons (work on touch + desktop) */
.ed-move { display: none; }
body.edit-mode .ed-move { position: absolute; bottom: 10px; right: 10px; z-index: 7; display: flex; gap: 5px; }
body.edit-mode .ed-move button { width: 36px; height: 36px; border-radius: 9px; border: 0; background: rgba(6,42,54,.82); color: #fff; font-size: 16px; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow-soft); }
body.edit-mode .ed-move button:disabled { opacity: .35; cursor: default; }
body.edit-mode .ed-move button:not(:disabled):hover { background: var(--c-accent); }

/* Theme panel (slides from the right) */
.ed-theme {
  position: fixed; top: 56px; right: 0; bottom: 0; width: 320px; max-width: 88vw; z-index: 940;
  background: var(--bg-raised); border-left: 1px solid var(--border); box-shadow: var(--shadow-float);
  transform: translateX(105%); transition: transform var(--dur-base) var(--ease-out);
  overflow-y: auto; padding: var(--sp-5);
}
.ed-theme.is-open { transform: translateX(0); }
.ed-theme h3 { font-size: 1.2rem; margin-bottom: var(--sp-4); }
.ed-theme .ed-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: .55rem 0; border-bottom: 1px solid var(--border); }
.ed-theme .ed-row label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-strong); }
.ed-theme input[type=color] { width: 54px; height: 32px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-page); cursor: pointer; padding: 2px; }
.ed-theme input[type=range] { width: 100%; accent-color: var(--c-accent); }
.ed-theme select { width: 100%; padding: .5rem; border: 1.5px solid var(--border); border-radius: var(--r-sm); background: var(--bg-page); color: var(--text-strong); font: 500 var(--fs-sm) var(--font-body); }
.ed-theme .ed-field { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.ed-theme .ed-field label { display: block; font-weight: 600; font-size: var(--fs-sm); color: var(--text-strong); margin-bottom: .4rem; }
.ed-theme .ed-reset { margin-top: var(--sp-4); width: 100%; background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); border-radius: var(--r-sm); padding: .6rem; font-weight: 700; cursor: pointer; }
.ed-theme .ed-reset:hover { background: var(--bg-surface); color: var(--text-strong); }

/* Toast note for edit mode */
.ed-note { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 960;
  background: #0A2530; color: #fff; padding: .7rem 1.2rem; border-radius: var(--r-pill); font: 600 var(--fs-sm)/1 var(--font-body);
  box-shadow: var(--shadow-float); opacity: 0; transition: opacity var(--dur-base); pointer-events: none; }
.ed-note.is-in { opacity: 1; }

/* Hide the language switch caveat while editing? keep visible. Reduce reveal animations in edit mode. */
body.edit-mode .reveal { opacity: 1 !important; transform: none !important; }

/* ---- Review fixes: mobile, touch, panel close ---- */
.ed-theme h3 { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.ed-close { background: transparent; border: 0; color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 9px; border-radius: 6px; }
.ed-close:hover { background: var(--bg-surface); color: var(--text-strong); }

/* Persistent affordances on touch devices (no :hover) */
@media (pointer: coarse) {
  body.edit-mode [data-ed-text] { outline-color: rgba(14,159,139,.5); }
  body.edit-mode [data-ed-img] { outline-color: rgba(14,159,139,.5); }
}

/* Launcher: respect the phone safe area + shrink a touch */
.ed-launch { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 720px) {
  body.edit-mode { padding-top: 96px; }
  .ed-bar { padding: 8px var(--sp-3); }
  .ed-bar .ed-lbl { display: none; }
  .ed-bar__hint { order: 5; flex-basis: 100%; font-size: var(--fs-xs); line-height: 1.35; }
  .ed-bar .ed-btn { min-height: 42px; padding: .6rem .8rem; }
  .ed-launch { padding: .7rem 1rem; font-size: var(--fs-xs); }
  .ed-theme { top: 96px; }
}
