/* Base styles */
body { 
  font-family: Arial, sans-serif; 
  text-align: center; 
  padding: 1rem; 
  margin: 0;
  min-height: 100vh;
  box-sizing: border-box;
}

/* Main heading */
h1 {
  margin: 1rem 0;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

/* Search container */
.search-container {
  max-width: 600px;
  margin: 0 auto 2rem auto;
  padding: 0 1rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Push all content below search down when suggestions are visible */
.suggestions-visible #result,
.suggestions-visible .dialect-selector {
  margin-top: calc(250px + 1rem) !important;
  transition: margin-top 0.2s ease;
}

/* Dialect selector */
.dialect-selector {
  margin-top: 1rem;
  text-align: center;
  transition: margin-top 0.2s ease;
}

.dialect-selector label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #333;
}

#dialectSelect {
  width: min(300px, 90vw);
  max-width: 100%;
  padding: 8px 12px;
  font-size: 1em;
  border: 2px solid #ddd;
  border-radius: 8px;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

#dialectSelect:focus {
  outline: none;
  border-color: #007acc;
}

/* Search input - responsive width */
#search { 
  width: min(300px, 90vw);
  max-width: 100%;
  padding: 12px; 
  font-size: 1.2em; 
  border: 2px solid #ddd;
  border-radius: 8px 8px 0 0;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  background-color: white;
  transition: all 0.2s ease;
}

#search:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.1);
}

/* When no suggestions, round bottom corners */
#search.no-suggestions {
  border-radius: 8px;
}

/* Suggestions list - connected to input */
#suggestions { 
  list-style: none; 
  padding: 0; 
  margin: 0;
  width: min(300px, 90vw);
  max-width: 100%;
  text-align: left;
  border: 2px solid #ddd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  background-color: white;
  z-index: 1;
  max-height: 250px;
  overflow-y: auto;
  position: absolute;
  top: calc(100% - 2px);
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  display: block;
}

/* Hide suggestions when empty */
#suggestions:empty {
  display: none;
}

/* When search is focused, connect the borders */
#search:focus + #suggestions,
#suggestions:hover {
  border-color: #007acc;
}

#suggestions li { 
  background: white; 
  padding: 12px; 
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
  font-size: 1em;
}

#suggestions li:hover {
  background-color: #f8f9fa;
}

#suggestions li.highlight {
  background-color: #e3f2fd;
  color: #1976d2;
}

#suggestions li:last-child {
  border-bottom: none;
}

/* Form elements */
select { 
  margin: 0.5rem; 
  font-size: 1em;
  padding: 8px;
  border: 2px solid #ddd;
  border-radius: 4px;
  max-width: 100%;
}

button { 
  margin-top: 0.5rem; 
  padding: 0.5rem 1rem; 
  font-size: 1em;
  border: 2px solid #007acc;
  background-color: #007acc;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

button:hover {
  background-color: #005a99;
}

/* Audio player */
#audioEl {
  margin-top: 1rem;
  width: min(400px, 90vw);
  max-width: 100%;
}

/* Result container */
#result {
  margin-top: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* Sentence display */
#sentence {
  font-style: italic;
  margin: 1rem 0;
  padding: 1rem;
  background-color: #f9f9f9;
  border-left: 3px solid #007acc;
  border-radius: 0 8px 8px 0;
  text-align: left;
  white-space: normal;
  overflow-x: auto;
  word-break: normal !important;
  overflow-wrap: normal !important;
  hyphens: none !important;
  word-wrap: normal !important;
  -webkit-hyphens: none !important;
  -ms-hyphens: none !important;
  -moz-hyphens: none !important;
  line-break: strict;
  word-spacing: normal;
}

/* Labels */
label {
  display: block;
  margin: 1rem 0 0.5rem 0;
  font-weight: bold;
}

/* IPA text */
#result p {
  margin: 1rem 0;
  word-break: break-all;
}

/* Mobile-specific styles */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }
  
  h1 {
    font-size: 1.8rem;
    margin: 0.5rem 0;
  }
  
  .search-container {
    padding: 0 0.5rem;
  }
  
  #search {
    font-size: 1.1em;
    padding: 10px;
  }
  
  #dialectSelect {
    width: 95vw;
    font-size: 0.95em;
  }
  
  #suggestions {
    max-width: 95vw;
  }
  
  #suggestions li {
    padding: 10px;
    font-size: 0.95em;
  }
  
  #sentence {
    padding: 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.95em;
  }
  
  #result {
    margin-top: 1rem;
    padding: 0 0.5rem;
  }
  
  select {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }
}

/* Very small screens */
@media (max-width: 320px) {
  body {
    padding: 0.25rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  #search {
    width: 95vw;
    font-size: 1em;
  }
  
  #dialectSelect {
    width: 95vw;
    font-size: 0.9em;
  }
  
  #suggestions {
    max-width: 95vw;
  }
}
