/* =========================
   MOODBOARD STYLES - Where Do I Go From Here (Standalone)
========================= */

/* Import base styles from main CSS */
@import url('./style.css');

/* Moodboard Container */
.moodboard-container {
  max-width: none;
  margin: 10px 0 0;
  padding: 10px 10px;
}

body {
  background: var(--bg);
  color: var(--text);
}

.top-bar {
  background: rgba(255, 255, 255, 0.2);
  position: sticky;
  top: 0;
  z-index: 2000;
  backdrop-filter: blur(10px);
  box-shadow: none;
  border-bottom: none;
}

/* Grid Layout */
/* Grid Layout Base */
.moodboard-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 10px;
  margin: 10px auto 0;
  padding: 0;
  width: min(1600px, 100%);
  position: relative;
  /* Essential for absolute children */
}

/* Post Styles */
.moodboard-post {
  background: var(--bg);
  border: none;
  border-radius: 0;
  overflow: hidden;
  /* Spring easing for that Apple feel */
  transition: transform 0.5s cubic-bezier(.25, 1.5, .5, 1), box-shadow 0.3s ease, width 0.3s ease, height 0.3s ease;
  width: 10%;
  aspect-ratio: 3 / 4;
  position: absolute;
  /* Changed from relative to absolute for freeform grid */
  cursor: grab;
  touch-action: none;
}

.moodboard-post.dragging {
  transition: none !important;
  cursor: grabbing;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  z-index: 1000 !important;
}

.moodboard-post.resizing {
  transition: none !important;
  z-index: 1001 !important;
  box-shadow: 0 0 25px var(--accent);
}

/* Add a handle visual if needed, but let's keep it clean for now */
.moodboard-post::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 30px;
  height: 30px;
  cursor: nwse-resize;
  background: radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.4) 0%, transparent 40%);
  opacity: 0;
  z-index: 1001;
  transition: opacity 0.2s ease;
  pointer-events: auto;
}

.moodboard-grid.edit-mode .moodboard-post:hover::after {
  opacity: 1;
}

.moodboard-post.text-placeholder {
  background: #0a0a0a;
  border-radius: 6px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  opacity: 0.7;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.moodboard-post.text-placeholder:hover {
  opacity: 1;
}

.moodboard-post.text-placeholder .placeholder-body {
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  pointer-events: auto;
  transition: border-color 0.2s ease;
  padding: 5px 10px;
  text-transform: none;
}

.moodboard-post.photo-only,
.moodboard-post.photo-only img,
.moodboard-post.photo-only video {
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  transform-origin: center center;
}

.moodboard-post.photo-only:not(.dragging):not(.resizing):hover {
  transform: scale(2);
  z-index: 500;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

/* Disable hover scaling in edit mode for easier interaction */
.moodboard-grid.edit-mode .moodboard-post.photo-only:hover {
  transform: none;
  z-index: 100 !important;
}

.moodboard-grid.edit-mode .moodboard-post img,
.moodboard-grid.edit-mode .moodboard-post video {
  pointer-events: none;
}

.moodboard-post.photo-only:hover img,
.moodboard-post.photo-only:hover video {
  transform: scale(1);
}

.moodboard-post.text-break {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 200px;
  position: relative;
  overflow: visible;
  z-index: 100;
}

.moodboard-post.text-only,
.moodboard-post.wide-text {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.08);
  padding: 25px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 15px;
  min-height: 180px;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

.moodboard-post.text-only .text-only-content {
  width: 100%;
  min-height: 140px;
  font-size: var(--font-body);
  line-height: 1.5;
  color: var(--text);
  outline: none;
  cursor: text;
  text-transform: none;
  padding: 5px 10px;
  display: block;
  opacity: 0.85;
}

.moodboard-post.text-only .text-only-content:focus {
  opacity: 1;
  background: rgba(255, 255, 255, 0.95);
}

.moodboard-post.text-only h3,
.moodboard-post.wide-text h3 {
  font-size: clamp(16px, 2vw, 20px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.moodboard-post.text-only p,
.moodboard-post.wide-text p {
  margin: 0;
  color: rgba(0, 0, 0, 0.85);
}

.moodboard-post.text-break h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 15px;
  color: white;
}

.moodboard-post.text-break p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
}

.moodboard-post.text-break:hover,
.moodboard-post.text-only:hover {
  transform: scale(1.05) !important;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s cubic-bezier(.25, 1.5, .5, 1);
}

.moodboard-grid.edit-mode .moodboard-post.text-break:hover {
  transform: scale(1.02) !important;
  z-index: 100;
  position: relative;
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
  transition: transform 0.3s ease;
}

.moodboard-post .caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 20px 15px 15px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 5;
  pointer-events: none;
}

.moodboard-post:hover .caption,
.moodboard-grid.edit-mode .caption {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  /* Enable editing in edit mode */
}

.moodboard-post img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, z-index 0.3s ease;
  display: block;
  background: #f0f0f0;
  opacity: 0;
  animation: fadeIn 0.5s ease-in-out forwards;
  position: absolute;
  top: 0;
  left: 0;
}

.moodboard-post video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #f0f0f0;
  position: absolute;
  top: 0;
  left: 0;
}

.moodboard-post {
  overflow: hidden;
  position: relative;
  touch-action: none;
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.moodboard-post.text-only {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.text-only-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  word-break: break-word;
  overflow: hidden;
}

.moodboard-post.resizing {
  z-index: 1000 !important;
}

.moodboard-post.dragging {
  cursor: grabbing;
  transition: none !important;
  /* Live follow mouse */
  transform: scale(1.1) !important;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  pointer-events: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Intersection Observer for lazy loading */
.moodboard-post.lazy {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.moodboard-post.lazy.loaded {
  opacity: 1;
  transform: translateY(0);
}

/* Edit Mode Styles */
.edit-controls {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.edit-btn,
.save-btn,
.reset-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.edit-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.edit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.save-btn {
  background: #1a1a1a !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.save-btn:hover {
  background: #333 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.reset-btn {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

/* Override for Freeform/Layout Mode */
.moodboard-grid.edit-freeform {
  display: block;
  /* Break from CSS Grid to use absolute positioning */
  min-height: 2000px;
  gap: 0;
}

/* Show grid guides only when actually editing to keep viewer clean */
.moodboard-grid.edit-freeform.edit-mode {
  background-image:
    linear-gradient(to right, rgba(0, 51, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 51, 255, 0.05) 1px, transparent 1px);
  background-size: 10% 13.333vw;
  /* 10% width, 13.333vw height for portrait (10vw * 4/3) */
  border-left: 1px solid rgba(0, 51, 255, 0.05);
  border-top: 1px solid rgba(0, 51, 255, 0.05);
}

.moodboard-grid.edit-freeform .moodboard-post {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
  box-sizing: border-box;
  margin: 0;
  transition: transform 0.1s ease-out, width 0.1s ease-out, height 0.1s ease-out, box-shadow 0.3s ease;
}

.moodboard-grid.edit-mode .moodboard-post {
  border: 1px solid rgba(102, 126, 234, 0.3);
  cursor: move;
}

.moodboard-grid.edit-mode .moodboard-post:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 1000 !important;
}

.resize-handle {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: nwse-resize;
  font-size: 14px;
  z-index: 1001;
  pointer-events: auto;
  border-radius: 4px 0 0 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.moodboard-grid.edit-mode .resize-handle {
  opacity: 1;
}

.editable-caption {
  background: rgba(255, 255, 255, 0.9);
  padding: 5px;
  border-radius: 3px;
  border: 1px dashed #667eea;
  outline: none;
  font-size: 12px;
  min-height: 20px;
}

.resize-handle {
  display: none !important;
}

.resize-handle:hover {
  background: #667eea;
  transform: scale(1.1);
}

.moodboard-post[draggable="true"] {
  cursor: move;
}

.moodboard-post[draggable="true"]:hover {
  border-color: #667eea;
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.moodboard-content {
  padding: 20px;
}

.moodboard-content h3 {
  font-size: var(--font-heading);
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 600;
}

.moodboard-content p {
  font-size: var(--font-body);
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 15px;
}

.moodboard-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-meta);
  color: #888;
}

.moodboard-meta .date {
  font-weight: 500;
}

.moodboard-meta .tags {
  color: var(--accent);
  font-style: italic;
}

/* Header Styles */
.moodboard-header {
  text-align: center;
  margin-bottom: 40px;
}

.moodboard-header h1 {
  font-size: clamp(14px, 2.7vw, 45px);
  font-weight: 500;
  white-space: nowrap;
  color: var(--text);
  line-height: 0.9;
  margin-bottom: 20px;
  margin-left: 0;
  letter-spacing: -0.04em;
  font-family: Helvetica, sans-serif;
  cursor: pointer;
  transition: color 0.2s ease;
  transform: scaleY(1.5);
  transform-origin: left center;
  display: inline-block;
}

.moodboard-header p {
  font-size: var(--font-body);
  color: #666;
  max-width: 600px;
  margin: 0 auto;
}

.moodboard-post.text-break h3,
.moodboard-post.text-only h3,
.moodboard-post.wide-text h3 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  transform: scaleY(var(--display-scale-y));
  transform-origin: left center;
}

.moodboard-header p,
.moodboard-post.text-break p,
.moodboard-post.text-only p,
.moodboard-post.wide-text p {
  font-size: var(--font-body);
  letter-spacing: 0.02em;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  font-weight: 400;
}

/* Back Link */
.back-link {
  display: inline-block;
  margin-top: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: var(--font-body);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transform: none;
  transform-origin: unset;
  text-decoration: none;
}

/* Mobile Responsive */
@media (max-width: 1200px) {
  .moodboard-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .moodboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .moodboard-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .moodboard-post img,
  .moodboard-post.text-placeholder {
    min-height: 140px;
  }
}

@media (max-width: 576px) {
  .moodboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}