/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background: url('Images/alternative.jpg') no-repeat center center fixed !important;
  background-size: cover !important;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); /* semi-transparent black overlay */
  z-index: 0;
  pointer-events: none;
}

/* Accessibility */
.visually-hidden {
  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;
}

/* Header Styles */
header {
  text-align: center;
  padding: 2rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  margin-bottom: 2rem;
}

h1 {
  font-size: 3rem;
  color: white;
  margin-bottom: 0.1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  animation: slideInDown 0.8s ease-out;
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.0rem;
  animation: fadeIn 1s ease-out 0.3s both;
}

/* Main Content */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  flex: 1;
  position: relative;
  z-index: 1;
}

@media (max-width: 900px) {
    .search-section, .favorites-section {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      width: 100vw;
      box-sizing: border-box;
    }
    .search-container {
      flex-direction: column;
      align-items: stretch;
      gap: 0.5rem;
      width: 100%;
      max-width: 100vw;
      margin: 0;
      padding: 0;
    }
    #wInput, button[type="submit"] {
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
      font-size: 1.1rem;
      padding: 0.9rem 1rem;
      margin: 0;
    }
    .favorites-section h2 {
      font-size: 1.3rem;
      margin-bottom: 0.5rem;
    }
    #favoritesList {
      flex-direction: column;
      gap: 0.5rem;
      width: 100%;
      margin: 0;
      padding: 0;
    }
    .favorite-word {
      width: 100%;
      min-width: 0;
      font-size: 1rem;
      padding: 0.7rem 0.2rem;
      margin: 0;
      box-sizing: border-box;
    }
  main {
    max-width: 100vw;
    padding: 0 0.5rem;
  }
  .search-section, .favorites-section, .results-section {
    max-width: 99vw;
    padding: 1rem 0.5rem;
    margin: 1rem auto;
  }
  #result {
    max-width: 99vw;
    padding: 1rem;
    margin: 1rem auto;
  }
}

@media (max-width: 600px) {
  main {
    max-width: 100vw;
    padding: 0 0.2rem;
  }
  .search-section, .favorites-section, .results-section {
    max-width: 100vw;
    padding: 0.7rem 0.2rem;
    margin: 0.5rem auto;
  }
  #result {
    max-width: 100vw;
    padding: 0.5rem;
    margin: 0.2rem auto;
    font-size: 0.98rem;
  }
  .search-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
    max-width: 100vw;
  }
  #wInput, button[type="submit"] {
    width: 100%;
    font-size: 1rem;
    padding: 0.7rem 0.7rem;
    border-radius: 25px;
  }
  .favorite-word {
    width: 100%;
    font-size: 0.98rem;
    padding: 0.3rem 0.1rem;
  }
  .favorites-section h2 {
    font-size: 1.2rem;
  }
  h1 {
    font-size: 1.3rem;
  }
  .subtitle {
    font-size: 0.9rem;
  }
}
/* Search Section */
.search-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff !important;
  border: 2px solid #e0e0e0 !important;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  padding: 2rem 1.5rem;
  margin: 2rem auto;
  max-width: 600px;
}

.search-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  max-width: 500px;
  margin: 0 auto 1rem;
  animation: slideInUp 0.8s ease-out 0.5s both;
}

#wInput {
  flex: 1;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  border: none;
  border-radius: 50px;
  outline: none;
  background: #ffffff !important;
  color: #111111 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

#wInput:focus {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

button[type="submit"] {
  padding: 0.8rem 1.5rem;
  background: #052854 !important;
  color: #fff !important;
  border: 2px solid #fff !important;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: background 0.2s, color 0.2s;
  border-radius: 50px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
  #wInput, button[type="submit"] {
    border-radius: 50px;
  }

button[type="submit"]:hover {
  background: #2273c4 !important;
  color: #052854 !important;
}

/* Search Description */
.search-description {
  text-align: center;
  color: #fff !important;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* Results Section */
.results-section {
  margin-bottom: 3rem;
  position: relative;
  z-index: 1;
}

#result {
  background: white;
  margin: 2rem auto;
  padding: 2rem;
  width: 100%;
  max-width: 800px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  animation: slideInUp 0.6s ease-out;
  opacity: 0;
}

#result:not(:empty) {
  opacity: 1;
}

#result h2 {
  color: #ffffff !important;
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-transform: capitalize;
}

#result .pronunciation {
  background: #f8f9fa;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  display: inline-block;
  margin: 0.5rem 0;
  font-family: 'Courier New', monospace;
  color: #666;
}

#result .definition-item {
  background: #f8f9fa;
  padding: 1.5rem;
  margin: 1rem 0;
  border-radius: 15px;
  border-left: 4px solid #667eea;
  transition: transform 0.3s ease;
}

#result .definition-item:hover {
  transform: translateX(10px);
}

#result .part-of-speech {
  color: #764ba2;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

#result .definition {
  font-size: 1.1rem;
  margin: 0.5rem 0;
  line-height: 1.6;
}

#result .example {
  font-style: italic;
  color: #666;
  background: white;
  padding: 1rem;
  border-radius: 10px;
  margin: 0.5rem 0;
  border-left: 3px solid #ff6b6b;
}

#result .synonyms {
  margin-top: 1rem;
}

#result .synonym-tag {
  display: inline-block;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 0.3rem 0.8rem;
  margin: 0.2rem;
  border-radius: 20px;
  font-size: 0.9rem;
  transition: transform 0.3s ease;
}

#result .synonym-tag:hover {
  transform: scale(1.05);
}

#result audio {
  margin: 1rem 0;
  border-radius: 20px;
}


.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  padding: 0.8rem 1.5rem;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: white;
  color: #667eea;
}

/* Error Styles */
#error {
  color: #ffffff !important;
  background: #e5210c !important;
  border: 2px solid #e4240e !important;
  font-weight: normal !important;
  font-size: 1rem !important;
  padding: 1rem 1.5rem !important;
  border-radius: 10px !important;
}
#error:empty {
  display: none;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.7);
  background: #000;
  backdrop-filter: blur(5px);
  margin-top: auto;
}

/* Animations */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  border-top-color: #06134b;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  h1 {
    font-size: 2.2rem;
  }
  .search-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
  }
  #wInput {
    border-radius: 25px;
    margin-bottom: 0.5rem;
    width: 100%;
    font-size: 1rem;
    padding: 0.8rem 1rem;
  }
  button[type="submit"] {
    border-radius: 25px;
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
  }
  #result {
    padding: 1rem;
    margin: 0.5rem;
    font-size: 1rem;
  }
  #favoritesList {
    flex-direction: column;
    gap: 0.5rem;
  }
  .favorites-section, .search-section {
    padding: 1rem 0.5rem;
    margin: 1rem auto;
    max-width: 98vw;
  }
  .favorite-word {
    min-width: 0;
    width: 100%;
    font-size: 1rem;
    padding: 0.5rem 0.2rem;
  }
  .results-section {
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 0 0.2rem;
  }
  header {
    padding: 0.7rem 0.2rem;
  }
  h1 {
    font-size: 1.3rem;
  }
  .subtitle {
    font-size: 0.9rem;
  }
  .search-section, .favorites-section {
    padding: 0.7rem 0.2rem;
    margin: 0.5rem auto;
    max-width: 99vw;
  }
  #wInput, button[type="submit"] {
    font-size: 0.95rem;
    padding: 0.7rem 0.7rem;
  }
  #result {
    padding: 0.5rem;
    margin: 0.2rem;
    font-size: 0.95rem;
  }
  .favorite-word {
    font-size: 0.95rem;
    padding: 0.3rem 0.1rem;
  }
}

/* Favorites Section */
.favorites-section {
  background: #fff !important;
  border: 2px solid #e0e0e0 !important;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  padding: 2rem 1.5rem;
  margin: 2rem auto;
  max-width: 600px;
  color: #222 !important;
}

.favorites-section h2 {
  width: 100%;
  text-align: center;
  display: block;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
  align-items: center;
}

#favoritesList {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.favorite-word {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff !important;
  color: #111 !important;
  border: 1px solid #bbb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  cursor: pointer;
}
#favoritesList p {
  color: #ffffff !important;
}

.favorite-word:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: #333;
  border: 2px solid #333;
  padding: 0.8rem 1.5rem;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: #333;
  color: #fff;
}

/* Remove white backgrounds to show body background image */
.results-section, #result, .favorite-word, #favoritesList, .search-section, .favorites-section {
  background: transparent !important;
}

body, main, header, footer, h1, .subtitle {
  color: #ffffff !important;
}

.results-section,
.results-section h2,
.results-section p,
.results-section div,
.results-section span {
  color: #111111 !important;
}

.favorites-section {
  color: #111111 !important;
}

.favorites-section h2 {
  color: #ffffff !important;
}

.favorites-section p,
.favorites-section div,
.favorites-section span {
  color: #111111 !important;
}

input, textarea {
  background: #ffffff !important;
  color: #111111 !important;
  border: 1px solid #fff !important;
}

.search-container input {
  width: 100%;
  max-width: 400px;
}

button {
  color: #fff !important;
  background: rgba(3, 5, 82, 0.4) !important;
  border: 1px solid #fff !important;
}

.search-section, .favorites-section {
 width: 100%;
max-width: 600px; 
  min-height: 6cm;
  background: #052854 !important;
  border: 2px solid #060a1d !important;
}

.search-section *, .search-section {
  color: #fff !important;
}

#clearFavorites {
  display: flex !important;
  margin: 1rem auto 0 !important;
  width: fit-content !important;
}

/* Sye favourites button created in JavaScript */
button.favorite-btn {
  background: #FFA500 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;  /* change this line */
  border-radius: 50px !important;
  padding: 0.7rem 1.8rem !important;
  font-size: 1rem !important;
  font-weight: bold !important;
  cursor: pointer !important;
  margin-top: 1rem !important;
  transition: background 0.2s ease, transform 0.2s ease !important;
  display: inline-block !important;
}

button.favorite-btn:hover {
  background: #1558a0 !important;
  transform: translateY(-2px);
}

button.favorite-btn.favorited {
  background: #e74c3c !important;
}
.favorite-word {
  background: #ffffff !important;
  color: #111111 !important;
  border-radius: 50px !important;
  padding: 0.4rem 1rem 0.4rem 1.5rem !important;
  border: none !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem !important;
  font-weight: bold !important;
  font-size: 0.95rem !important;
  cursor: pointer !important;
  width: auto;
  min-width: 120px;
  max-width: 100%;
  height: auto;
  padding: 0.4rem 1rem;
  transition: all 0.2s ease !important;
}

.favorite-word:hover {
  background: #f0f0f0 !important;
  transform: translateY(-2px) !important;
}

.favorite-word strong {
  color: #111111 !important;
}

.remove-favorite {
  background: none !important;
  border: none !important;
  color: #e74c3c !important;
  font-size: 1.2rem !important;
  cursor: pointer !important;
  padding: 0.2rem !important;
  border-radius: 50% !important;
  width: 25px !important;
  height: 25px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.3s ease !important;
}
.remove-favorite:hover {
  background: #e74c3c !important;
  color: white !important;
  transform: scale(1.1) !important;
}
.source-info {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
  text-align: center;
}
.source-info a {
  color: #ffffff !important;
  text-decoration: none;
}
.source-info a:hover { text-decoration: underline; }

/* Center pronunciation and audio controls */
.word-header {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.word-header .pronunciation {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.word-header .audio-controls {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}