/* Evotic Edge — Stories editor Instagram-style.
   Phase 13.3 fix : port du CSS legacy chat.html sc-* rules, adapté à --primary Edge.
*/

#story-create {
  position: fixed; inset: 0;
  background: #000;
  display: none;
  flex-direction: column;
  z-index: 9300;
}
#story-create.show { display: flex; }

/* Top bar (close + post) */
.sc-topbar {
  display: flex; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px;
  gap: 8px;
  flex-shrink: 0;
  background: rgba(0,0,0,.5);
  z-index: 2;
}
.sc-topbar .sc-cb {
  width: 40px; height: 40px;
  border: none;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.sc-topbar .sp { flex: 1; }
.sc-topbar .sc-post {
  padding: 9px 20px;
  border: none;
  border-radius: 20px;
  background: #6750A4;
  color: #fff;
  font-size: 14px; font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 14px rgba(103, 80, 164,.4);
  transition: transform .15s;
}
.sc-topbar .sc-post:active { transform: scale(.96); }
.sc-topbar .sc-post:disabled { opacity: .6; cursor: not-allowed; }

/* Stage (canvas + overlays) */
#sc-stage {
  flex: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#sc-canvas {
  width: 100%; height: 100%;
  display: none;
  touch-action: none;
  transform-origin: center center;
  object-fit: cover;
}
#sc-draw-layer {
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
}
#sc-draw-layer.active {
  pointer-events: auto;
  cursor: crosshair;
}
#sc-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 4;
}
#sc-overlay .ov {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  padding: 6px 10px;
  user-select: none; -webkit-user-select: none;
  border-radius: 6px;
  white-space: pre-wrap;
  max-width: 80%;
  word-break: break-word;
  transition: box-shadow .15s;
}
#sc-overlay .ov:active { box-shadow: 0 0 0 2px #6750A4; }
#sc-overlay .ov.stk {
  font-size: 48px;
  padding: 0;
  background: transparent !important;
}

/* Empty state (initial picker) */
#sc-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff;
  gap: 20px;
  padding: 40px;
  text-align: center;
  z-index: 1;
}
/* Direct-child combinator (not descendant) so the hero icon styling does NOT
   hijack the Font Awesome icons inside #sc-empty .btn (Galerie/Caméra/Fond).
   CLAUDE.md '.parent i' anti-pattern — see shop-feed-empty historical bug. */
#sc-empty > i { font-size: 56px; opacity: .4; }
#sc-empty .btn {
  padding: 14px 28px;
  border: none; border-radius: 14px;
  background: #6750A4;
  color: #fff;
  font-size: 15px; font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
#sc-empty .btn:active { transform: scale(.97); }

/* Text modal (input overlay) */
#sc-text-modal {
  position: absolute; inset: 0;
  z-index: 20;
  background: rgba(0,0,0,.7);
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px;
}
#sc-text-modal.show { display: flex; flex-direction: column; align-items: center; }

/* Phase Hub Pack 2 — @mention autocomplete popup */
.sc-mention-popup {
  width: 90%; max-width: 400px;
  background: rgba(28, 28, 46, .97);
  backdrop-filter: blur(14px);
  border-radius: 12px;
  padding: 6px;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
}
.sc-mention-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
}
.sc-mention-item.active { background: rgba(103, 80, 164, .25); }
.sc-mention-item:hover { background: rgba(255, 255, 255, .08); }
.sc-mention-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #FF3366, #6750A4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 900; font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.sc-mention-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sc-mention-init { color: #fff; }
.sc-mention-pseudo { color: #fff; font-weight: 800; font-size: 14px; }

#sc-text-modal textarea {
  width: 90%; max-width: 400px;
  padding: 16px;
  border: none; border-radius: 14px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 20px; font-weight: 700;
  font-family: 'Nunito', sans-serif;
  text-align: center;
  outline: none;
  resize: none;
  min-height: 60px; max-height: 200px;
}
#sc-text-modal .stm-done {
  margin-top: 12px;
  padding: 10px 28px;
  border: none; border-radius: 20px;
  background: #6750A4;
  color: #fff;
  font-size: 14px; font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
}
#sc-text-modal .stm-done:active { transform: scale(.96); }

/* Toolbar (bottom of stage) */
.sc-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(0,0,0,.8);
  justify-content: space-around;
  flex-shrink: 0;
}
.sc-toolbar button {
  width: 44px; min-width: 44px;
  border: none;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  border-radius: 12px;
  padding: 7px 4px;
  font-family: 'Nunito', sans-serif;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: background .15s, color .15s;
}
.sc-toolbar button.on { background: #6750A4; color: #fff; }
.sc-toolbar button:active { transform: scale(.94); }
.sc-toolbar button .tbl {
  font-size: 9px; display: block; margin-top: 1px;
  font-weight: 700; letter-spacing: .3px;
}

/* Sheets (sliding from bottom) */
.sc-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  background: rgba(15,15,25,.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px 16px 0 0;
  max-height: 55vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sc-sheet.show { transform: translateY(0); }
.sc-sheet-hdr {
  display: flex; align-items: center;
  padding: 14px 16px 8px;
  gap: 10px;
  position: sticky; top: 0;
  background: inherit;
  z-index: 1;
}
.sc-sheet-hdr .sh-title {
  flex: 1;
  font-size: 14px; font-weight: 800;
  color: #fff;
}
.sc-sheet-hdr .sh-close {
  width: 32px; height: 32px;
  border: none;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 14px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Gradients grid */
.sc-grad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
}
.sc-grad-item {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color .15s, transform .15s;
}
.sc-grad-item:active { transform: scale(.96); }
.sc-grad-item.on { border-color: #fff; }

/* Colors palette */
.sc-colors {
  display: flex; gap: 6px;
  padding: 8px 16px;
  flex-wrap: wrap;
}
.sc-colors .cc {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: border-color .1s, transform .1s;
}
.sc-colors .cc:active { transform: scale(.9); }
.sc-colors .cc.on {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,.3);
}
.sc-colors .cc-custom {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

/* Fonts row */
.sc-fonts {
  display: flex; gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sc-fonts::-webkit-scrollbar { display: none; }
.sc-fonts .fc {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: background .15s;
}
.sc-fonts .fc.on {
  background: #6750A4;
  border-color: #6750A4;
}

/* Slider row */
.sc-slider-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
}
.sc-slider-row label {
  font-size: 11px;
  color: rgba(255,255,255,.6);
  font-weight: 700;
  min-width: 60px;
}
.sc-slider-row input[type="range"] {
  flex: 1;
  accent-color: #6750A4;
  height: 4px;
}

/* Style row (bold/italic/align/bg) */
.sc-style-row {
  display: flex; gap: 6px;
  padding: 8px 16px 14px;
  flex-wrap: wrap;
}
.sc-style-row button {
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: #fff;
  font-size: 12px; font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.sc-style-row button.on {
  background: #6750A4;
  border-color: #6750A4;
}

/* Filters row */
.sc-flt-row {
  display: flex; gap: 8px;
  padding: 10px 16px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sc-flt-row::-webkit-scrollbar { display: none; }
.sc-flt-row .flt {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.sc-flt-row .flt-preview {
  width: 56px; height: 56px;
  border-radius: 10px;
  border: 2px solid transparent;
  background:
    linear-gradient(135deg, rgba(103, 80, 164,.5), rgba(232,85,0,.3)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 6px, rgba(255,255,255,0) 6px 12px);
  background-size: cover;
  background-position: center;
}
.sc-flt-row .flt.on .flt-preview { border-color: #6750A4; }
.sc-flt-row .flt-name {
  font-size: 9px;
  color: rgba(255,255,255,.6);
  font-weight: 700;
}

/* Stickers */
.sc-stk-cats {
  display: flex; gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sc-stk-cats::-webkit-scrollbar { display: none; }
.sc-stk-cats button {
  padding: 5px 12px;
  border-radius: 14px;
  border: none;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.7);
  font-size: 11px; font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.sc-stk-cats button.on {
  background: #6750A4;
  color: #fff;
}
.sc-stk-grid {
  display: flex; flex-wrap: wrap;
  gap: 4px;
  padding: 8px 16px 16px;
}
.sc-stk-grid button {
  width: 48px; height: 48px;
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
  border-radius: 8px;
  transition: background .1s, transform .1s;
}
.sc-stk-grid button:active {
  background: rgba(255,255,255,.1);
  transform: scale(.9);
}

/* Drawing modes */
.sc-draw-modes {
  display: flex; gap: 8px;
  padding: 10px 16px;
}
.sc-draw-modes button {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 12px; font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .15s;
}
.sc-draw-modes button.on { background: #6750A4; }
.sc-draw-modes button i { font-size: 13px; }
