/* ============================================================
   Story Create Popup — create_popup.css
   ============================================================ */

/* Safety: [hidden] must never be overridden */
[hidden] { display: none !important; }

/* ---------- overlay ---------- */
.sp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.sp-overlay.sp--open {
  opacity: 1;
  visibility: visible;
}

/* ---------- modal container ---------- */
.sp-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 92dvh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
@media (max-width: 600px) {
  .sp-modal {
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    height: 100dvh;
  }
}

/* ---------- header ---------- */
.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.sp-header__title {
  font-size: 17px;
  font-weight: 700;
  color: #262626;
}
.sp-header__close,
.sp-header__back {
  background: none;
  border: none;
  font-size: 24px;
  color: #262626;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- panels ---------- */
.sp-panel {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== SELECT PANEL ===== */
.sp-type-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 16px;
}
.sp-type-card {
  background: #fafafa;
  border: 2px solid #eee;
  border-radius: 14px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.sp-type-card:hover,
.sp-type-card:focus-visible {
  border-color: #833AB4;
  transform: translateY(-2px);
}
.sp-type-card__icon {
  font-size: 40px;
  margin-bottom: 10px;
}
.sp-type-card__label {
  font-size: 15px;
  font-weight: 600;
  color: #262626;
}

/* ===== TEXT EDITOR PANEL ===== */
.sp-text-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sp-text-preview {
  flex: 1;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--sp-bg, #833AB4);
  transition: background .25s;
}
.sp-text-preview__input {
  width: 100%;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: none;
  border: none;
  outline: none;
  resize: none;
  line-height: 1.4;
  min-height: 100px;
  -webkit-user-modify: read-write-plaintext-only;
}
.sp-text-preview__input:empty::before {
  content: attr(data-placeholder);
  opacity: .55;
}

/* font sizes */
.sp-text-preview__input.sp-fs-small   { font-size: 16px; }
.sp-text-preview__input.sp-fs-medium  { font-size: 22px; }
.sp-text-preview__input.sp-fs-large   { font-size: 30px; }
.sp-text-preview__input.sp-fs-xlarge  { font-size: 40px; }

/* controls bar */
.sp-text-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
}
.sp-text-controls__label {
  font-size: 12px;
  font-weight: 600;
  color: #8e8e8e;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* colour swatches */
.sp-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sp-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  padding: 0;
}
.sp-swatch:hover { transform: scale(1.15); }
.sp-swatch.sp--active {
  border-color: #262626;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #262626;
}

/* font size btn */
.sp-btn-fontsize {
  background: #eee;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  color: #262626;
}

/* ===== IMAGE EDITOR PANEL ===== */
.sp-image-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sp-image-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 32px;
  gap: 12px;
}
.sp-image-upload__icon {
  font-size: 48px;
  opacity: .4;
}
.sp-image-upload__label {
  font-size: 15px;
  color: #8e8e8e;
}
.sp-image-upload__btn {
  background: #0095f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

/* canvas area */
.sp-canvas-area {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  max-height: 55dvh;
  background: #000;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sp-canvas-area__img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  pointer-events: none;
}

/* text overlay element */
.sp-text-el {
  position: absolute;
  padding: 6px 12px;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  text-align: center;
  background: rgba(0,0,0,.35);
  border-radius: 6px;
  cursor: grab;
  outline: none;
  touch-action: none;
  user-select: text;
  -webkit-user-select: text;
  min-width: 40px;
  min-height: 30px;
  white-space: pre-wrap;
  word-break: break-word;
  transform: translate(-50%, -50%);
  z-index: 2;
}
.sp-text-el:focus {
  box-shadow: 0 0 0 2px #0095f6;
}

/* delete zone */
.sp-delete-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 59, 48, .7);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 5;
}
.sp-delete-zone.sp--visible {
  opacity: 1;
}

/* image controls */
.sp-image-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
}
.sp-image-controls__btn {
  background: #eee;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  color: #262626;
}
.sp-image-controls__spacer {
  flex: 1;
}

/* text color row for image editor */
.sp-image-text-colors {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
}

/* ===== SUBMIT BAR ===== */
.sp-submit-bar {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
.sp-submit-btn {
  background: #0095f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: opacity .15s;
}
.sp-submit-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* loading overlay */
.sp-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #262626;
}

/* ===== VIDEO EDITOR PANEL ===== */
.sp-video-editor {
  display: flex;
  flex-direction: column;
  /* height: 100%; */
}

.sp-video-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 32px;
  gap: 12px;
}
.sp-video-upload__icon {
  font-size: 48px;
  opacity: .4;
}
.sp-video-upload__label {
  font-size: 15px;
  color: #8e8e8e;
  text-align: center;
}

.sp-video-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex: 1;
}
.sp-video-preview {
  width: 100%;
  max-height: 60dvh;
  border-radius: 10px;
  background: #000;
  object-fit: contain;
}
.sp-video-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 13px;
  color: #8e8e8e;
  gap: 8px;
}
.sp-video-info__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.sp-video-info__duration {
  flex-shrink: 0;
  font-weight: 600;
  color: #262626;
}

/* ---- video: choose source ---- */
.sp-video-choose {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 20px;
  flex: 1;
  min-height: 260px;
}
.sp-video-source-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  background: #fafafa;
  border: 2px solid #eee;
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
  text-align: left;
}
.sp-video-source-btn:hover,
.sp-video-source-btn:focus-visible {
  border-color: #833AB4;
  transform: translateY(-1px);
}
.sp-video-source-btn__icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.sp-video-source-btn__label {
  font-size: 15px;
  font-weight: 600;
  color: #262626;
}
.sp-video-choose__hint {
  font-size: 12px;
  color: #aaa;
  margin: 0;
}

/* ---- video: live camera ---- */
.sp-video-camera {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  max-height: 65dvh;
  background: #000;
  overflow: hidden;
  flex-shrink: 0;
}
.sp-video-live {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sp-video-camera__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 20px;
  gap: 12px;
}
.sp-video-timer {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: .03em;
}
.sp-video-camera__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

/* record button */
.sp-rec-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #ed4956;
  cursor: pointer;
  transition: transform .15s, background .15s;
  padding: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.sp-rec-btn:hover { transform: scale(1.08); }
.sp-rec-btn--recording {
  background: #fff;
  border-color: #fff;
  animation: sp-pulse 1.2s ease-in-out infinite;
}
.sp-rec-btn--recording::after {
  content: '';
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #ed4956;
  margin: auto;
}
@keyframes sp-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(237,73,86,.5); }
  50%       { box-shadow: 0 0 0 10px rgba(237,73,86,0); }
}

/* flip camera button */
.sp-flip-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
}
.sp-flip-btn:hover { background: rgba(255,255,255,.35); }

/* ---- video: retry button ---- */
.sp-video-retry-btn {
  background: none;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.sp-video-retry-btn:hover { border-color: #833AB4; color: #833AB4; }
