/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Mobile Responsive Styles for Absurdity */
@media (max-width: 768px) {
  /* Input section optimization */
  #sentence-input {
    height: 120px !important;
    font-size: 16px !important;
    -webkit-appearance: none;
  }

  #submit-btn {
    padding: 16px !important;
    font-size: 18px !important;
    min-height: 50px;
    -webkit-tap-highlight-color: rgba(33, 150, 243, 0.3);
  }

  label[for="sentence-input"] {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
  }

  #char-counter {
    float: none !important;
    text-align: left;
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  #sentence-input {
    height: 80px !important;
  }
}

/* Pulse and fade-in animations for new content */
@keyframes fadeInPulse {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes scorePulse {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Animation classes */
.new-sentence {
  animation: fadeInPulse 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.new-score {
  animation: scorePulse 0.7s ease-out;
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .new-sentence,
  .new-score,
  .fade-in {
    animation: none;
    opacity: 1;
    transform: none;
  }

  @keyframes fadeInPulse,
  @keyframes fadeIn,
  @keyframes scorePulse {
    from, to {
      opacity: 1;
      transform: none;
    }
  }
}

/* ===== UX POLISH ENHANCEMENTS ===== */

/* Button Hover States - Add juice to all buttons */
a[href*="path"],
button,
input[type="submit"],
.btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

a[style*="background-color"]:hover:not(:active),
button:hover:not(:disabled):not(:active),
input[type="submit"]:hover:not(:disabled):not(:active) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  filter: brightness(1.1);
}

a[style*="background-color"]:active,
button:active:not(:disabled),
input[type="submit"]:active:not(:disabled) {
  transform: translateY(0px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Focus states for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Disabled state for buttons */
button:disabled,
input[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Submit button enhancement */
#submit-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

#submit-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

#submit-btn:hover::before {
  width: 300px;
  height: 300px;
}

#submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4) !important;
}

#submit-btn:active {
  transform: translateY(0px);
}

/* Loading spinner for submit button */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

/* Text input enhancements */
#sentence-input {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sentence-input:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(33, 150, 243, 0.3) !important;
}

/* Smooth card animations */
@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.story-card-enter {
  animation: slideInFromBottom 0.4s ease-out;
}

/* Pulse animation for new content */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.pulse-animation {
  animation: pulse 0.6s ease-in-out;
}

/* Score number counter animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.score-display {
  display: inline-block;
  transition: all 0.3s ease;
}

.score-update {
  animation: countUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Character counter enhancement */
#char-counter {
  transition: all 0.3s ease;
}

#char-counter.warning {
  color: #f57c00 !important;
  font-size: 14px !important;
  font-weight: bold;
}

#char-counter.danger {
  color: #d32f2f !important;
  font-size: 15px !important;
  font-weight: bold;
  animation: pulse 1s ease-in-out infinite;
}

/* Leaderboard table row hover */
tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  background-color: rgba(102, 126, 234, 0.05) !important;
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Trophy icons animation */
@keyframes trophy-shine {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.3) drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
  }
}

tbody tr:first-child:hover .text-2xl,
tbody tr:nth-child(2):hover .text-2xl,
tbody tr:nth-child(3):hover .text-2xl {
  animation: trophy-shine 1s ease-in-out;
}

/* Navigation improvements */
nav, header {
  transition: all 0.3s ease;
}

/* Footer link hover enhancement */
footer a {
  transition: all 0.2s ease;
  position: relative;
}

footer a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: #2196f3;
  transition: width 0.3s ease;
}

footer a:hover::after {
  width: 100%;
}

/* Card shadow enhancement */
.shadow-lg {
  transition: box-shadow 0.3s ease;
}

.shadow-lg:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

/* Smooth scrolling for the entire page */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Typography enhancements */
body {
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Better spacing for headings */
h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* Improved readability for paragraphs */
p {
  line-height: 1.6;
}

/* Loading state overlay */
@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeInOverlay 0.3s ease-out;
}

.loading-overlay-content {
  text-align: center;
  color: #667eea;
  font-weight: bold;
  font-size: 18px;
}

.loading-overlay-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(102, 126, 234, 0.2);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 15px;
}

/* Tooltip-style hints */
.tooltip-hint {
  position: relative;
  display: inline-block;
}

.tooltip-hint::after {
  content: attr(data-hint);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1000;
}

.tooltip-hint:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* Enhanced focus indicator for keyboard navigation */
*:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Skip to content link for accessibility */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #667eea;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  transition: top 0.3s ease;
  z-index: 10000;
}

.skip-to-content:focus {
  top: 0;
}

/* Mobile-specific enhancements */
@media (max-width: 768px) {
  /* Better touch targets */
  button, a[style*="background-color"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Reduce animations on mobile for performance */
  @media (prefers-reduced-motion: no-preference) {
    * {
      animation-duration: 0.3s !important;
      transition-duration: 0.2s !important;
    }
  }

  /* Better mobile spacing */
  body {
    line-height: 1.7;
  }
}

/* Print styles */
@media print {
  /* Hide interactive elements */
  button, nav, footer, .no-print {
    display: none !important;
  }

  /* Better print layout */
  body {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
    color: black;
  }
}
