/*
 * This is a manifest file that'll be compiled into application.css.
 */

/* Meme Font Style */
.meme-text {
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  font-size: 3em;
  color: white;
  text-transform: uppercase;
  text-align: center;

  /* Black outline */
  text-shadow:
    -2px -2px 0 #000,  
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000;

  line-height: 1.2 !important;
}

.meme-text-hack {
  text-shadow: 1px 1px 0 #000,
          -1px -1px 0 #000,
          1px -1px 0 #000,
          -1px 1px 0 #000,
          0px 1px 0 #000,
          1px 0px 0 #000,
          0px -1px 0 #000,
          -1px 0px 0 #000;
}

/* 
  Styles for the meme list page PREVIEWS.
  This is the new section that fixes the positioning.
*/

.meme-preview-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  min-height: 360px;
  max-height: 360px;
  /* THE FIX: Added flex properties to ensure centering */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* REMOVED: The pseudo-element that forced a 1:1 aspect ratio. */

.meme-preview-canvas {
  /* UPDATED: The canvas is now relative so overlays are positioned correctly */
  position: relative; 
  width: 100%;
  /* height will be set by the inline aspect-ratio style */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

/* General caption overlay style used by both index and editor */
.meme-caption-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px; /* Small padding for previews */
  box-sizing: border-box;
  /* overflow: hidden; */
}


/* --- START: Meme Editor Styles --- */

.meme-editor-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.meme-canvas-container {
  position: absolute;
  top: 50%;
  left: 50%;
  /* REMOVED: Fixed width and height. These are now set by Stimulus JS. */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  user-select: none;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--canvas-scale, 1));
}


.meme-caption-box {
  position: absolute;
  cursor: move;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  box-sizing: border-box;
  /* overflow: hidden; */
}

.black-border {
  border: 4px solid black !important;
}

.meme-caption-box.is-active {
  border: 2px dashed #007bff;
  z-index: 10;
}

.meme-caption-box .meme-text {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background-color: #007bff;
  border: 1px solid white;
  border-radius: 50%;
  z-index: 20;
  display: none;
}

.meme-caption-box.is-active .resize-handle {
  display: block;
}

.resize-handle-br {
  bottom: -6px;
  right: -6px;
  cursor: se-resize;
}

.caption-editor-group {
  padding: 1rem;
  border: 1px solid hsl(var(--b2));
  border-radius: 0.5rem;
  transition: all 0.2s ease-in-out;
}

.caption-editor-group.is-active {
  border-color: hsl(var(--p));
  box-shadow: 0 0 0 2px hsl(var(--p));
}
/* --- END: Meme Editor Styles --- */

/* --- START: Template Selection Modal Styles --- */
.template-card .check-icon {
  display: none;
}

.template-card.is-selected {
  border-color: hsl(var(--p)); /* Primary color border */
  transform: scale(0.95);
}

.template-card.is-selected .check-icon {
  display: flex;
}

.template-card.is-selected img {
  opacity: 0.8;
}

.btn-group > .btn.btn-active {
  background-color: hsl(var(--p));
  color: hsl(var(--pc));
  border-color: hsl(var(--p));
}
/* --- END: Template Selection Modal Styles --- */

/* --- START: Generator Page UI/UX v4 Styles --- */
.mode-card {
  border-color: #ffffff1a;
}
.mode-card.is-active {
  border-color: hsl(var(--p));
  background-color: hsl(var(--b1));
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.preview-item {
  position: relative;
  aspect-ratio: 1 / 1;
}

.preview-remove-btn {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  /* display: none; */
  /* background-color: hsl(var(--b1)); */
  border-radius: 9999px;
  line-height: 1;
  border: 1px solid white;
  opacity: 0.7;
  z-index: 10;
}

.preview-item:hover .preview-remove-btn {
  display: flex; /* Show on hover */
}

.preview-remove-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}
/* --- END: Generator Page UI/UX v4 Styles --- */


/* --- START: Homepage Hero Animation Styles --- */
.meme-grid-container {
  display: flex;
  gap: 1.5rem; /* 24px */
  height: 500px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
}

.meme-grid-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem; /* 24px */
  min-width: 150px;
  animation: scroll-up 30s linear infinite;
}

@keyframes scroll-up {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-50%);
  }
}

.meme-grid-column:nth-child(2) {
  animation-duration: 40s;
}

.meme-grid-column:nth-child(3) {
  animation-duration: 25s;
}

.meme-grid-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 1rem; /* 16px */
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
/* --- END: Homepage Hero Animation Styles --- */

html {
  scroll-behavior: smooth;
}