/* stylelint-disable-next-line at-rule-no-unknown */
@tailwind base;
/* stylelint-disable-next-line at-rule-no-unknown */
@tailwind components;
/* stylelint-disable-next-line at-rule-no-unknown */
@tailwind utilities;

/* Modern, clean, elegant base styles */
* {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iPhone-specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific styles */
  input, textarea, select, button {
    font-size: 16px !important; /* Prevent zoom on input focus */
  }
  
  h1 { font-size: clamp(1.5rem, 5vw, 2rem) !important; }
  h2 { font-size: clamp(1.25rem, 4.5vw, 1.75rem) !important; }
  h3 { font-size: clamp(1.125rem, 4vw, 1.5rem) !important; }
  h4 { font-size: clamp(1rem, 3.5vw, 1.25rem) !important; }
  
  .text-xs { font-size: clamp(0.625rem, 2.5vw, 0.75rem) !important; }
  .text-sm { font-size: clamp(0.75rem, 3vw, 0.875rem) !important; }
  .text-base { font-size: clamp(0.875rem, 3.5vw, 1rem) !important; }
  .text-lg { font-size: clamp(1rem, 4vw, 1.125rem) !important; }
  .text-xl { font-size: clamp(1.125rem, 4.5vw, 1.25rem) !important; }
  .text-2xl { font-size: clamp(1.25rem, 5vw, 1.5rem) !important; }
  .text-3xl { font-size: clamp(1.5rem, 5.5vw, 1.875rem) !important; }
  .text-4xl { font-size: clamp(1.75rem, 6vw, 2.25rem) !important; }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: #f8f9fa;
  color: #212529;
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100vw;
}

html {
  overflow-x: hidden;
  max-width: 100vw;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
    monospace;
}

/* Modal overlay improvements */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  overflow: auto;
  padding: 1rem;
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 0.5rem;
  }
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
}

@media (max-width: 640px) {
  .modal-content {
    border-radius: 12px;
    max-height: 95vh;
  }
}

/* Typography - Modern and clean */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.5rem); }

/* Section 4: Typography weight increase - thicker fonts for lyrics/chords */
pre,
.lyrics-display,
.chords-display {
  font-weight: 600 !important;
}

.font-mono {
  font-weight: 600 !important;
}

/* Responsive Container Utilities */
.container-responsive {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

@media (min-width: 640px) {
  .container-responsive {
    padding: 1.5rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  /* Tablet-specific optimizations */
  .container-responsive {
    padding: 1.75rem;
    max-width: 900px;
  }
  
  .modal-content {
    max-width: 90%;
    margin: 0 auto;
  }
  
  /* Two-column layout for tablets */
  .tablet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  /* Optimized button groups for tablets */
  .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .btn-group .btn {
    min-width: auto;
    flex: 1 1 calc(50% - 0.25rem);
  }
}

@media (min-width: 1024px) {
  .container-responsive {
    padding: 2rem;
  }
}

/* Accessibility Improvements */
*:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 2px;
  border-radius: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  *:focus-visible {
    outline-width: 4px;
    outline-color: currentColor;
  }
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #667eea;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  z-index: 10000;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Modern Input Styles */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e9ecef;
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: white;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Modern Button Styles */
.btn {
  padding: 0.75rem 1.5rem;
  min-height: 44px; /* Touch target size - WCAG AAA compliance */
  min-width: 44px; /* Touch target size - WCAG AAA compliance */
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  position: relative;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Responsive button sizes for mobile */
@media (max-width: 640px) {
  .btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    min-height: 48px; /* Larger for mobile touch */
  }
}

/* Tablet button optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
  .btn {
    padding: 0.7rem 1.4rem;
    font-size: 0.975rem;
  }
}

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

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

/* Modern Card Styles */
.card {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

/* Responsive Grid System */
.grid-responsive {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-responsive {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

@media (min-width: 1280px) {
  .grid-responsive {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Mobile-First Responsive Navigation */
.mobile-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .mobile-menu {
    flex-direction: row;
    gap: 1.5rem;
  }
}

/* Touch-Friendly Spacing */
@media (max-width: 767px) {
  .btn {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
  }
  
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  textarea,
  select {
    padding: 1rem;
    font-size: 1.1rem;
  }
}

/* Modal Responsive Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  overflow-y: auto;
}

.modal-content {
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

@media (max-width: 640px) {
  .modal-content {
    padding: 1.5rem;
    max-width: 95vw;
  }
}

/* Smooth Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Custom Scrollbar for Modal - Enhanced styling with rounded edges */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #a78bfa #f3f4f6;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 10px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
  margin: 20px 0; /* Creates padding from top/bottom edges */
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #a78bfa 0%, #8b5cf6 100%);
  border-radius: 10px;
  border: 2px solid rgba(248, 249, 250, 0.8);
  background-clip: padding-box;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
  border-radius: 10px;
  border: 2px solid rgba(248, 249, 250, 0.8);
  background-clip: padding-box;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Responsive Display Utilities */
.hidden {
  display: none;
}

@media (min-width: 768px) {
  .md\:flex {
    display: flex !important;
  }
  .md\:hidden {
    display: none !important;
  }
  .md\:block {
    display: block !important;
  }
}

@media (max-width: 767px) {
  .md\:flex {
    display: none !important;
  }
}

/* Enhanced tablet breakpoints */
@media (min-width: 640px) and (max-width: 1023px) {
  .tablet\:grid-cols-3 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .tablet\:text-lg {
    font-size: 1.125rem !important;
  }
}

/* Mobile-specific enhancements for Song Database */
@media (max-width: 768px) {
  /* Optimize tap targets */
  button, a, [role="button"], .cursor-pointer {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Prevent text selection on double-tap */
  .bg-white.border {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  
  /* Ensure profile song cards display properly - 2 columns on mobile */
  .profile-songs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
    overflow: visible;
  }

  /* Smooth scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile modal optimization */
  .fixed.inset-0 {
    overscroll-behavior: contain;
  }

  /* Larger touch targets for mobile forms */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="date"],
  textarea,
  select {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}
