@tailwind base;
@tailwind components;
@tailwind utilities;

/* Apple-style Typography */
@layer base {
  html {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", 
                 "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
  }
}

/* 
 * Bento Grid System v2.1
 * Compact auto-placement grid with minimal spacing
 */

/* ===== BASE CONTAINER ===== */
.bento-container {
  container-type: inline-size;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0.5rem;
}

/* ===== GRID SYSTEM ===== */
.bento-grid-home {
  display: grid;
  gap: 0.25rem;
  grid-auto-flow: dense;
  grid-auto-rows: minmax(min-content, auto);
  align-items: stretch;
}

/* Mobile: 1 column */
.bento-grid-home {
  grid-template-columns: 1fr;
}

/* Small (640px): 2 columns */
@media (min-width: 640px) {
  .bento-container {
    padding: 0.5rem;
  }
  
  .bento-grid-home {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.375rem;
  }
}

/* Medium (768px): 4 columns */
@media (min-width: 768px) {
  .bento-container {
    padding: 0.75rem;
  }
  
  .bento-grid-home {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
  }
}

/* Large (1024px): 6 columns */
@media (min-width: 1024px) {
  .bento-container {
    padding: 1rem;
  }
  
  .bento-grid-home {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.375rem;
  }
}

/* Extra Large (1280px): 8 columns */
@media (min-width: 1280px) {
  .bento-container {
    padding: 1rem;
  }
  
  .bento-grid-home {
    grid-template-columns: repeat(8, 1fr);
    gap: 0.375rem;
  }
}

/* ===== BASE BOX STYLES ===== */
.bento-box {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 0.375rem;
  padding: 0.375rem;
  transition: all var(--transition-base);
  overflow: hidden;
  position: relative;
  color: var(--text-primary);
  
  /* Ensure content fills space efficiently */
  display: flex;
  flex-direction: column;
  min-height: 0;
  
  /* Text handling */
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Responsive padding - ultra minimal */
@media (min-width: 640px) {
  .bento-box {
    padding: 0.5rem;
    border-radius: 0.5rem;
  }
}

@media (min-width: 768px) {
  .bento-box {
    padding: 0.625rem;
    border-radius: 0.625rem;
  }
}

@media (min-width: 1024px) {
  .bento-box {
    padding: 0.75rem;
    border-radius: 0.75rem;
  }
}

@media (min-width: 1280px) {
  .bento-box {
    padding: 0.875rem;
    border-radius: 0.875rem;
  }
}

/* Hover effects */
.bento-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Text color inheritance */
.bento-box h1, .bento-box h2, .bento-box h3, 
.bento-box h4, .bento-box h5, .bento-box h6 {
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.bento-box p, .bento-box span, .bento-box div {
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

/* ===== SIZE VARIANTS ===== */
/* Mobile first - all boxes span full width */
.bento-1x1,
.bento-2x1,
.bento-1x2,
.bento-2x2,
.bento-3x1,
.bento-4x1 {
  grid-column: span 1;
  grid-row: span 1;
}

/* Small (640px) */
@media (min-width: 640px) {
  .bento-1x1 { 
    grid-column: span 1;
  }
  
  .bento-2x1 { 
    grid-column: span 2;
  }
  
  .bento-1x2 { 
    grid-column: span 1;
    grid-row: span 2;
  }
  
  .bento-2x2 { 
    grid-column: span 2;
    grid-row: span 2;
  }
}

/* Medium (768px) */
@media (min-width: 768px) {
  .bento-1x1 { 
    grid-column: span 1;
  }
  
  .bento-2x1 { 
    grid-column: span 2;
  }
  
  .bento-3x1 { 
    grid-column: span 3;
  }
  
  .bento-4x1 { 
    grid-column: span 4;
  }
  
  .bento-1x2 { 
    grid-column: span 1;
    grid-row: span 2;
  }
  
  .bento-2x2 { 
    grid-column: span 2;
    grid-row: span 2;
  }
}

/* Large (1024px) */
@media (min-width: 1024px) {
  .bento-1x1 { 
    grid-column: span 2;
  }
  
  .bento-2x1 { 
    grid-column: span 3;
  }
  
  .bento-3x1 { 
    grid-column: span 4;
  }
  
  .bento-4x1 { 
    grid-column: span 6;
  }
  
  .bento-1x2 { 
    grid-column: span 2;
    grid-row: span 2;
  }
  
  .bento-2x2 { 
    grid-column: span 3;
    grid-row: span 2;
  }
}

/* Extra Large (1280px) */
@media (min-width: 1280px) {
  .bento-1x1 { 
    grid-column: span 2;
  }
  
  .bento-2x1 { 
    grid-column: span 4;
  }
  
  .bento-3x1 { 
    grid-column: span 6;
  }
  
  .bento-4x1 { 
    grid-column: span 8;
  }
  
  .bento-1x2 { 
    grid-column: span 2;
    grid-row: span 2;
  }
  
  .bento-2x2 { 
    grid-column: span 4;
    grid-row: span 2;
  }
}

/* Full width variant for hero sections */
.bento-full {
  grid-column: 1 / -1;
  min-height: 80px;
}

@media (min-width: 768px) {
  .bento-full {
    min-height: 100px;
  }
}

@media (min-width: 1024px) {
  .bento-full {
    min-height: 120px;
  }
}

/* ===== CONTENT CONSTRAINTS ===== */
/* Ensure text remains readable */
.bento-box h3 {
  font-size: clamp(0.75rem, 2vw, 1.125rem);
  font-weight: 700;
  margin-bottom: 0.125rem;
}

.bento-box h4 {
  font-size: clamp(0.625rem, 1.5vw, 0.875rem);
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.bento-box p {
  font-size: clamp(0.5rem, 1vw, 0.625rem);
  margin-bottom: 0.125rem;
  line-height: 1.3;
}

.bento-box .text-xs {
  font-size: clamp(0.475rem, 0.8vw, 0.5625rem);
  line-height: 1.2;
}

/* Prevent content overflow */
.bento-box article,
.bento-box .content-wrapper {
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* ===== GRADIENT BACKGROUNDS ===== */
.bento-gradient-1 {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.1) 0%, rgba(90, 200, 250, 0.1) 100%);
}

.bento-gradient-2 {
  background: linear-gradient(135deg, rgba(191, 90, 242, 0.1) 0%, rgba(94, 92, 230, 0.1) 100%);
}

.bento-gradient-3 {
  background: linear-gradient(135deg, rgba(255, 55, 95, 0.1) 0%, rgba(255, 149, 0, 0.1) 100%);
}

/* ===== PROJECTS GRID ===== */
.bento-grid-projects {
  display: grid;
  gap: 0.5rem;
  grid-auto-flow: dense;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .bento-grid-projects {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

@media (min-width: 768px) {
  .bento-grid-projects {
    gap: 0.875rem;
  }
}

@media (min-width: 1024px) {
  .bento-grid-projects {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

@media (min-width: 1280px) {
  .bento-grid-projects {
    gap: 1.25rem;
  }
}

/* Project cards specific styles */
.bento-grid-projects .bento-box {
  min-height: 180px;
  cursor: pointer;
}

@media (min-width: 768px) {
  .bento-grid-projects .bento-box {
    min-height: 200px;
  }
}

@media (min-width: 1024px) {
  .bento-grid-projects .bento-box {
    min-height: 220px;
  }
}

.bento-grid-projects .bento-box:hover {
  transform: translateY(-4px) scale(1.01);
}

/* ===== SPECIAL BOXES ===== */
/* Skills box ultra compact layout */
.bento-skills .skill-item {
  padding: 0.125rem 0.25rem;
  margin-bottom: 0.0625rem;
}

@media (min-width: 768px) {
  .bento-skills .skill-item {
    padding: 0.1875rem 0.3125rem;
    margin-bottom: 0.125rem;
  }
}

/* Stats box ultra compact */
.bento-stats {
  padding: 0.125rem !important;
}

.bento-stats .stat-item {
  text-align: center;
  padding: 0;
}

/* Contact box */
.bento-contact {
  z-index: 1;
  overflow: visible;
}

.bento-contact a {
  padding: 0.0625rem 0;
}

/* ===== UTILITY CLASSES ===== */
/* Compact spacing utilities */
.space-y-1 > * + * {
  margin-top: 0.25rem;
}

.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.gap-1 {
  gap: 0.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

/* Animation utilities */
@keyframes blob {
  0%, 100% { transform: translate(0px, 0px) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.1; transform: scale(1); }
  50% { opacity: 0.2; transform: scale(1.1); }
}

.animate-blob {
  animation: blob 7s infinite;
}

.animation-delay-2000 {
  animation-delay: 2s;
}

.animation-delay-4000 {
  animation-delay: 4s;
}

/* Ensure glass morphism readability */
.glass-thick {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .glass-thick {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}