/* Magic Bento CSS - Standalone stylesheet */

:root {
  --hue: 27;
  --sat: 69%;
  --white: hsl(0, 0%, 100%);
  --purple-primary: rgba(132, 0, 255, 1);
  --purple-glow: rgba(132, 0, 255, 0.2);
  --purple-border: rgba(132, 0, 255, 0.8);
  --border-color: #392e4e;
  --background-dark: #060010;
}

.card-grid {
  display: grid;
  gap: 0.5em;
  padding: 0.75em;
  max-width: 54em;
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.5rem);
  margin: 0 auto;
}

.magic-bento-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  aspect-ratio: 4/3;
  min-height: 200px;
  width: 100%;
  max-width: 100%;
  padding: 1.25em;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--background-dark);
  font-weight: 300;
  overflow: hidden;
  transition: all 0.3s ease;

  --glow-x: 50%;
  --glow-y: 50%;
  --glow-intensity: 0;
  --glow-radius: 200px;
}

.magic-bento-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.magic-bento-card__header,
.magic-bento-card__content {
  display: flex;
  position: relative;
  color: var(--white);
}

.magic-bento-card__header {
  gap: 0.75em;
  justify-content: space-between;
}

.magic-bento-card__content {
  flex-direction: column;
}

.magic-bento-card__label {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

.magic-bento-card__title,
.magic-bento-card__description {
  --clamp-title: 1;
  --clamp-desc: 2;
}

.magic-bento-card__title {
  font-weight: 400;
  font-size: clamp(0.8rem, 3.5vw + 0.5rem, 1.8rem);
  margin: 0 0 0.25em;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.magic-bento-card__description {
  font-size: clamp(0.65rem, 2.5vw + 0.3rem, 1.2rem);
  line-height: 1.3;
  opacity: 0.9;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Dynamic font sizing based on card size - Larger cards get bigger text */
.magic-bento-card:nth-child(3) .magic-bento-card__title,
.magic-bento-card:nth-child(4) .magic-bento-card__title {
  font-size: clamp(1rem, 4vw + 0.5rem, 2.2rem);
}

.magic-bento-card:nth-child(3) .magic-bento-card__description,
.magic-bento-card:nth-child(4) .magic-bento-card__description {
  font-size: clamp(0.75rem, 3vw + 0.3rem, 1.4rem);
}

/* Optional: Keep text clipping as fallback for very long text */
.magic-bento-card--text-autohide .magic-bento-card__title,
.magic-bento-card--text-autohide .magic-bento-card__description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.magic-bento-card--text-autohide .magic-bento-card__title {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.magic-bento-card--text-autohide .magic-bento-card__description {
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

/* Mobile - 2x2 Grid Layout */
@media (max-width: 599px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    width: 95%;
    margin: 0 auto;
    padding: 0.5em;
    gap: 0.5em;
  }

  .magic-bento-card {
    width: 100%;
    min-height: 160px;
    aspect-ratio: 1;
    padding: 0.8em;
  }
  
  .magic-bento-card__title {
    font-size: clamp(0.75rem, 3.5vw, 1.2rem);
  }
  
  .magic-bento-card__description {
    font-size: clamp(0.65rem, 2.5vw, 0.9rem);
    -webkit-line-clamp: 2;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .magic-bento-card__label {
    font-size: clamp(0.6rem, 2vw, 0.8rem);
  }
  
  /* تأكد من ظهور جميع البطاقات في تخطيط 2x2 */
  .magic-bento-card:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
  }
}

/* شاشات صغيرة جداً - تحسينات إضافية */
@media (max-width: 400px) {
  .card-grid {
    width: 98%;
    gap: 0.4em;
  }
  
  .magic-bento-card {
    min-height: 140px;
    padding: 0.6em;
  }
}

/* Tablet */
@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .magic-bento-card:nth-child(3) {
    grid-column: span 2;
    grid-row: span 2;
  }

  .magic-bento-card:nth-child(4) {
    grid-column: 1 / span 2;
    grid-row: 2 / span 2;
  }

  .magic-bento-card:nth-child(6) {
    grid-column: 4;
    grid-row: 3;
  }
}

/* Border glow effect */
.magic-bento-card--border-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  padding: 6px;
  background: radial-gradient(
    var(--glow-radius) circle at var(--glow-x) var(--glow-y),
    rgba(132, 0, 255, calc(var(--glow-intensity) * 0.8)) 0%,
    rgba(132, 0, 255, calc(var(--glow-intensity) * 0.4)) 30%,
    transparent 60%
  );
  border-radius: inherit;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: subtract;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.magic-bento-card--border-glow:hover::after {
  opacity: 1;
}

.magic-bento-card--border-glow:hover {
  box-shadow:
    0 4px 20px rgba(46, 24, 78, 0.4),
    0 0 30px var(--purple-glow);
}

/* Particle effects */
.particle-container {
  position: relative;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(132, 0, 255, 1);
  box-shadow: 0 0 6px rgba(132, 0, 255, 0.6);
  pointer-events: none;
  z-index: 100;
}

.particle::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: rgba(132, 0, 255, 0.2);
  border-radius: 50%;
  z-index: -1;
}

.particle-container:hover {
  box-shadow:
    0 4px 20px rgba(46, 24, 78, 0.2),
    0 0 30px var(--purple-glow);
}

/* Global spotlight styles */
.global-spotlight {
  mix-blend-mode: screen;
  will-change: transform, opacity;
  z-index: 200 !important;
  pointer-events: none;
}

.bento-section {
  position: relative;
  user-select: none;
  padding: 60px 20px;
  background: #0a0a0a;
}

.bento-section h2 {
  text-align: center;
  margin-bottom: 40px;
  font-size: 2.5rem;
  background: linear-gradient(135deg, #b89bd3 0%, #d1d1d1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Drag and Drop Styles */
.magic-bento-card {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

/* Magnifier Lens */
.magnifier-lens {
  position: fixed;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  border: 5px solid rgba(132, 0, 255, 0.9);
  background: rgba(10, 0, 21, 0.99);
  backdrop-filter: blur(2px);
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
  box-shadow: 
    0 0 60px rgba(132, 0, 255, 1),
    0 0 30px rgba(255, 0, 170, 0.6),
    inset 0 0 40px rgba(132, 0, 255, 0.4);
  transition: opacity 0.3s ease;
  overflow: hidden;
  animation: lensGlow 2s ease-in-out infinite;
}

@keyframes lensGlow {
  0%, 100% {
    box-shadow: 
      0 0 60px rgba(132, 0, 255, 1),
      0 0 30px rgba(255, 0, 170, 0.6),
      inset 0 0 40px rgba(132, 0, 255, 0.4);
    border-color: rgba(132, 0, 255, 0.9);
  }
  50% {
    box-shadow: 
      0 0 80px rgba(132, 0, 255, 1),
      0 0 40px rgba(255, 0, 170, 0.8),
      inset 0 0 50px rgba(132, 0, 255, 0.6);
    border-color: rgba(255, 0, 170, 0.9);
  }
}

.magnifier-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.magnifier-content .magic-bento-card {
  border: none !important;
  box-shadow: none !important;
}

/* Magnified content styling */
.magnifier-content * {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: inherit;
  letter-spacing: 0.01em;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Smooth text in magnified view */
.magnifier-content h1,
.magnifier-content h2,
.magnifier-content h3,
.magnifier-content h4,
.magnifier-content h5,
.magnifier-content h6,
.magnifier-content p,
.magnifier-content span {
  text-shadow: none;
  filter: contrast(1.15) brightness(1.08) saturate(1.1);
  will-change: transform;
}

/* Enhance specific elements */
.magnifier-content .magic-bento-card__title,
.magnifier-content .magic-bento-card__description {
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}

/* Precision indicator in center - More visible */
.magnifier-lens::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(132, 0, 255, 0.4);
  box-shadow: 
    0 0 15px rgba(132, 0, 255, 1),
    0 0 8px rgba(255, 255, 255, 0.8),
    inset 0 0 8px rgba(255, 255, 255, 0.5);
  z-index: 100;
  pointer-events: none;
  animation: pulseCenter 2s ease-in-out infinite;
}

@keyframes pulseCenter {
  0%, 100% { 
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  50% { 
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 1;
  }
}

/* Responsive Magnifier */
@media (max-width: 768px) {
  .magnifier-lens {
    width: 170px;
    height: 170px;
    border-width: 4px;
  }
}

@media (max-width: 480px) {
  .magnifier-lens {
    width: 120px;
    height: 120px;
    border-width: 3px;
  }
}

/* Global Press Indicator */
.global-press-indicator {
  position: fixed;
  width: 0;
  height: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10001;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border: 3px solid rgba(132, 0, 255, 0.8);
  background: radial-gradient(circle, rgba(132, 0, 255, 0.3) 0%, rgba(255, 0, 170, 0.2) 50%, transparent 70%);
  box-shadow: 
    0 0 20px rgba(132, 0, 255, 0.6),
    inset 0 0 20px rgba(132, 0, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-press-indicator.active {
  opacity: 1;
}

.global-press-indicator.success {
  background: radial-gradient(circle, rgba(0, 255, 132, 0.5) 0%, rgba(0, 255, 132, 0.2) 50%, transparent 70%);
  border-color: rgba(0, 255, 132, 0.9);
  box-shadow: 
    0 0 30px rgba(0, 255, 132, 0.8),
    inset 0 0 30px rgba(0, 255, 132, 0.4);
}

/* Text inside indicator */
.press-indicator-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 
    0 0 10px rgba(132, 0, 255, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease, font-size 0.3s ease;
  pointer-events: none;
}

.global-press-indicator.active .press-indicator-text {
  opacity: 1;
  animation: textPulse 1s ease-in-out infinite;
}

.global-press-indicator.success .press-indicator-text {
  font-size: 18px;
  color: #00ff84;
  text-shadow: 
    0 0 15px rgba(0, 255, 132, 1),
    0 2px 4px rgba(0, 0, 0, 0.5);
  animation: none;
}

.press-indicator-text.deactivate {
  color: #ff4444;
}

@keyframes textPulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes globalPressExpand {
  0% {
    width: 0;
    height: 0;
    border-width: 3px;
  }
  50% {
    border-width: 4px;
  }
  100% {
    width: 200px;
    height: 200px;
    border-width: 5px;
  }
}

.magic-bento-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: scale(1.05);
  z-index: 1000;
  box-shadow: 0 15px 40px rgba(132, 0, 255, 0.4);
}

.magic-bento-card.drag-over {
  border: 2px dashed rgba(132, 0, 255, 0.8);
  background: rgba(132, 0, 255, 0.1);
}

.card-grid {
  position: relative;
}
