/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ===========================================
   TikTok Text Overlay Styles
   =========================================== */

/* Base text container */
.text-overlay-container {
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
  margin: 0 auto;
}

/* Classic TikTok Style - White text with black stroke */
.text-style-classic {
  color: white !important;
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600; /* SemiBold to match ImageMagick rendering */
  background: transparent !important;
  padding: 0 !important;
  text-align: center;
  box-sizing: border-box;
  /* Toned down black stroke to match ImageMagick rendering */
  text-shadow:
    1.5px 1.5px 0 #000,
    -1.5px 1.5px 0 #000,
    1.5px -1.5px 0 #000,
    -1.5px -1.5px 0 #000 !important;
}

.text-style-classic.text-headline {
  font-size: 16px;
  line-height: 1.2;
  display:inline-block;
}

.text-style-classic.text-subtext {
  font-size: 12px;
  font-weight: 600; /* SemiBold to match headline */
  line-height: 1.3;
  display:inline-block;
}

/* Safe Content Area Border - Removed as too restrictive */
.slide-preview-container {
  position: relative;
  /* Allow resize handles to extend beyond container on mobile */
  overflow: visible !important;
}

/* Keep the rounded corners and background clipping */
.slide-preview-container > div:first-child {
  overflow: hidden;
  border-radius: inherit;
}

/* TikTok Highlight Style - Black text with white background per line */
.text-style-highlight {
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color: transparent !important;
  background: transparent !important;
  text-shadow: none !important;
  padding: 0 !important;
  max-width: 82%;
}

.text-style-highlight.text-headline {
  font-size: 16px;
  line-height: 2.2;
  margin-bottom: 12px;
  display: inline-block;
}

.text-style-highlight.text-subtext {
  font-size: 12px;
  line-height: 2;
  display: inline-block;
}

/* The magic span for line-by-line backgrounds */
.text-style-highlight .line-box {
  display: inline !important;
  background-color: white !important;
  color: black !important;
  padding: 4px 12px !important;
  border-radius: 8px !important;
  font-weight: 600 !important; /* SemiBold to match rendering */
  text-shadow: none !important;
  /* Critical properties for line wrapping */
  box-decoration-break: clone !important;
  -webkit-box-decoration-break: clone !important;
  -moz-box-decoration-break: clone !important;
  background-clip: padding-box !important;
  /* Ensure text stays visible */
  line-height: inherit !important;
}

.text-style-highlight.text-subtext .line-box {
  padding: 3px 10px !important;
  border-radius: 6px !important;
  font-weight: 600 !important; /* SemiBold to match headline */
}

.text-center-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-1px);
  background: rgba(59, 130, 246, 0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 30;
}

.text-center-guide.visible {
  opacity: 1;
}

.text-vertical-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(59, 130, 246, 0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 30;
}

.text-vertical-guide-20 {
  top: 20%;
  transform: translateY(-1px);
}

.text-vertical-guide-50 {
  top: 50%;
  transform: translateY(-1px);
}

.text-vertical-guide.visible {
  opacity: 1;
}

/* Small screen preview styles (for content ideas) */
/* Scale: 180px wide (vs 270px edit preview), so 0.67x */
.preview-small .text-style-classic.text-headline {
  font-size: 11.5px;  /* 17.5 * 0.67 */
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000 !important;
}

.preview-small .text-style-classic.text-subtext {
  font-size: 7.5px;  /* 11 * 0.67 */
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000 !important;
}

.preview-small .text-style-highlight.text-headline {
  font-size: 11.5px;
  line-height: 1.8;
}

.preview-small .text-style-highlight.text-subtext {
  font-size: 7.5px;
  line-height: 1.6;
}

.preview-small .text-style-highlight .line-box {
  padding: 2px 6px !important;
  border-radius: 4px !important;
}

/* Prevent image dragging */
.slide-preview-container img {
  user-select: none !important;
  -webkit-user-drag: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  pointer-events: none !important;
}

/* Draggable Text Styles */
[data-draggable="true"] {
  cursor: move;
  user-select: none;
  z-index: 20;
  position: absolute !important;
}

[data-draggable="true"]:hover {
  outline: 2px solid #FF006E;
  outline-offset: 2px;
}

[data-draggable="true"].dragging {
  outline: 3px solid #FF006E;
  outline-offset: 2px;
  z-index: 100;
  opacity: 0.9;
}

/* Text Width Resize Handles */
.text-resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #FF006E;
  border: 2px solid white;
  border-radius: 50%;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 25;
}

[data-draggable="true"]:hover .text-resize-handle {
  opacity: 1;
}

.text-resize-handle.right {
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
}

/* Mobile - always visible, larger touch target, positioned further right */
@media (max-width: 768px) {
  .text-resize-handle {
    width: 44px;
    height: 44px;
    opacity: 0.7;
  }

  .text-resize-handle.right {
    right: -30px; /* Move further right to avoid overlapping text */
  }
}

.text-width-indicator {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.resizing .text-width-indicator {
  opacity: 1;
}
