:root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px; /* Base font size for rem calculations */
  --title-color: #282F7F;
  --background-color-rgb: 34,42,124;
  --background-color: rgb(var(--background-color-rgb));
  --card-color: #ffffff;
  --border-color: #dee2e6;
  --call-to-action: #0056b3;
  --call-to-action-text: #fff;
  --call-to-action-hover: #007bff;
  --call-to-action-hover-text: #fff;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --error-color: #dc3545;
  --text-color: #212529;
  --text-muted: #6c757d;
  --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
  --border-radius: 0.5rem;
  --transition: all 0.3s ease;
  color: var(--text-color);
  background: rgba(var(--background-color-rgb), 0.15);
  
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1.25rem;
  line-height: 1.6;
  min-height: 90vh;
  
  
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 3.125rem;
  height: 3.125rem;
  border: 0.25rem solid var(--border-color);
  border-top: 0.25rem solid var(--call-to-action);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.25rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-message {
  font-size: 1.125rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Error messages */
.error-message {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-weight: 500;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-hover);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-1.25rem);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.error-message.error {
  background-color: var(--error-color);
  color: white;
}

.error-message.warning {
  background-color: var(--warning-color);
  color: var(--text-color);
}

.error-message.success {
  background-color: var(--success-color);
  color: white;
}

.content {
  max-width: 75rem; /* 1200px */
  margin: 0 auto;
  padding: 1.875rem;
  background: white;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.title-text {
  color: var(--title-color);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  margin-bottom: 0.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.title {
  color: var(--title-color);
  display: block;
  margin: 0;
}

.logo {
  height: 6rem;
  border-right: 2px solid var(--border-color);
  padding-right: 1rem;
  width: 6rem;
  transition: var(--transition);
}

.logo:hover {
  transform: scale(1.05);
}

.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.875rem;
  flex-wrap: wrap;
}

.subtitle {
  font-weight: 400;
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0;
}

.description {
  font-size: 1.125rem;
  margin-bottom: 1.875rem;
  color: var(--text-muted);
  text-align: center;
}

.school-search-form {
  background: rgba(var(--background-color-rgb), 0.15);
  padding: 1.75rem;
  border-radius: var(--border-radius);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), var(--shadow);
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
  position: relative;
}

.school-search-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--call-to-action), var(--call-to-action-hover));
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  display: block;
  font-weight: 600;
  color: var(--text-color);
  font-size: 1rem;
}

.form-help {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--call-to-action);
  box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.form-input:hover {
  border-color: var(--call-to-action);
}

.form-submit {
  align-self: flex-start;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-width: 7.5rem;
}

.form-submit {
  background-color: var(--call-to-action);
  color: var(--call-to-action-text);
}

.form-submit:hover:not(:disabled) {
  background-color: var(--call-to-action-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.form-submit:active {
  transform: translateY(0);
}

.form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.map-canvas {
  width: 100%;
  height: 60vh; /* Responsive height based on viewport */
  min-height: 25rem; /* Minimum height in rem */
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  position: relative;
  background: var(--background-color);
  box-shadow: var(--shadow);
  margin-bottom: 0;
}

.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 1.125rem;
  font-weight: 500;
}

.map-error {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-color);
  background: linear-gradient(135deg, #f8f9ff 0%, #e3f2fd 100%);
  border: 2px solid var(--call-to-action);
  border-radius: var(--border-radius);
  margin: 1.25rem;
  box-shadow: var(--shadow);
  max-width: 31.25rem;
  margin: 1.25rem auto;
}

.map-error h3 {
  color: var(--call-to-action);
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.map-error p {
  margin: 0 0 1rem 0;
  line-height: 1.5;
  color: var(--text-muted);
}

.map-error a {
  color: var(--call-to-action);
  text-decoration: none;
  font-weight: 600;
}

.map-error a:hover {
  text-decoration: underline;
}

/* Out of bounds message in results container */
.out-of-bounds-message {
  grid-column: 1 / -1;
  text-align: center;
  background: linear-gradient(135deg, #f8f9ff 0%, #e3f2fd 100%);
  border: 2px solid var(--call-to-action);
  border-radius: var(--border-radius);
  margin: 1.25rem 0;
  max-width: none;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}

.out-of-bounds-message::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--call-to-action), var(--call-to-action-hover));
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.out-of-bounds-message:hover::before {
  transform: translateX(0);
}

.out-of-bounds-message:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
  border-color: rgba(0, 86, 179, 0.3);
  background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
}

.out-of-bounds-message a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 2rem;
  width: 100%;
  height: 100%;
}

.out-of-bounds-message a:hover {
  text-decoration: none;
  color: inherit;
}

.out-of-bounds-message h3 {
  color: var(--call-to-action);
  margin: 0 0 1rem 0;
  font-size: 1.375rem;
  font-weight: 600;
  transition: var(--transition);
}

.out-of-bounds-message:hover h3 {
  color: var(--call-to-action-hover);
}

.out-of-bounds-message p {
  color: var(--text-muted);
  margin: 0 0 1rem 0;
  line-height: 1.6;
  font-size: 1rem;
}

.out-of-bounds-message p:last-child {
  margin-bottom: 0;
}

.out-of-bounds-message .highlight {
  color: var(--call-to-action);
  font-weight: 600;
}

.map-container {
  width: 100%;
}

.school-card {
  background: linear-gradient(135deg, var(--card-color) 0%, #fafbfc 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  transition: var(--transition);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.school-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--call-to-action), var(--call-to-action-hover));
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.school-card:hover::before {
  transform: translateX(0);
}

.school-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
  border-color: rgba(0, 86, 179, 0.3);
  background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
}

.school-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1.5rem;
  width: 100%;
  height: 100%;
  text-align: center;
}

.school-card-link:hover {
  text-decoration: none;
  color: inherit;
}

.school-card h3 {
  font-size: 1.125rem;
  margin: 0 0 0.5rem 0;
  color: var(--title-color);
  font-weight: 600;
  line-height: 1.3;
  transition: var(--transition);
}

.school-card:hover h3 {
  color: var(--call-to-action);
}

.school-card p {
  font-size: 0.875rem;
  margin: 0.5rem 0 0 0;
  color: var(--text-muted);
  line-height: 1.4;
}

.school-address {
  cursor: pointer;
  transition: var(--transition);
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background: rgba(0, 86, 179, 0.05);
  border: 1px solid transparent;
}

.school-address:hover {
  background: rgba(0, 86, 179, 0.1);
  border-color: rgba(0, 86, 179, 0.2);
  color: var(--call-to-action);
}

.school-grades {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--call-to-action);
  background: rgba(0, 86, 179, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.results-container {
  background: rgba(var(--background-color-rgb), 0.15);
  padding: 0 1.75rem;
  border-bottom-left-radius: 0.75rem;
  border-bottom-right-radius: 0.75rem;
  box-shadow: var(--shadow-hover);
  max-height: 0;
  opacity: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
              padding 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
  border-top: none;
  position: relative;
}

.results-container::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--call-to-action), var(--call-to-action-hover));
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.results-container.expanded {
  max-height: 50rem;
  opacity: 1;
  padding: 1.75rem;
}

.results-container-schools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
  gap: 1rem;
}

.results-container-title {
  color: var(--title-color);
  font-size: 1.5rem;
  margin: 0 0 1rem 0;
  text-align: center;
  font-weight: 700;
}

button {
  background: linear-gradient(135deg, var(--call-to-action), var(--call-to-action-hover));
  color: var(--call-to-action-text);
  border: none;
  border-radius: var(--border-radius);
  padding: 1rem 2rem;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  margin: 0.5rem 0.25rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 86, 179, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.03125rem;
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

button:hover::before {
  left: 100%;
}

button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--call-to-action-hover), #0066cc);
  transform: translateY(-2px);
  box-shadow: 0 0.375rem 1.25rem rgba(0, 86, 179, 0.4);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 86, 179, 0.3);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Google Places Autocomplete Styling */
.pac-container {
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--border-color);
  font-family: inherit;
  z-index: 1000;
}

.pac-item {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.pac-item:hover {
  background-color: rgba(0, 86, 179, 0.05);
}

.pac-item:first-child {
  border-top: none;
}

.pac-item-query {
  font-weight: 600;
  color: var(--text-color);
}

.pac-matched {
  font-weight: 700;
  color: var(--call-to-action);
}

/* Focus styles for accessibility */
button:focus,
.form-input:focus,
.form-submit:focus {
  outline: 2px solid var(--call-to-action);
  outline-offset: 2px;
}

/* Responsive design using em-based breakpoints */
@media only screen and (max-width: 48em) { /* 768px */
  body {
    padding: 0.625rem;
  }
  
  .content {
    padding: 1.25rem;
  }
  
  .header {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
  }
  
  .logo {
    border-right: none;
    border-bottom: 2px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  .form-group {
    text-align: center;
  }
  
  .form-submit {
    align-self: center;
    width: 100%;
    max-width: 12.5rem;
  }
  
  .map-canvas {
    height: 50vh;
    min-height: 20rem;
  }
  
  .results-container-schools {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .results-container.expanded {
    max-height: 62.5rem;
  }
  
  .school-card-link {
    padding: 1rem;
  }
  
  .title-text {
    font-size: clamp(1.125rem, 4vw, 1.375rem);
  }
  
  .description {
    font-size: 1rem;
  }
}

@media only screen and (min-width: 48.0625em) and (max-width: 64em) { /* 769px - 1024px */
  .form-group {
    text-align: center;
  }
  
  .form-submit {
    align-self: center;
    max-width: 12.5rem;
  }
  
  .results-container-schools {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .results-container.expanded {
    max-height: 56.25rem;
  }
}

@media only screen and (min-width: 64.0625em) { /* 1025px+ */
  .results-container-schools {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
  }
  
  .form-input,
  .school-card {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner {
    animation: none;
  }
}

/* Print styles */
@media print {
  .loading-overlay,
  .error-message,
  button,
  .form-submit {
    display: none !important;
  }
  
  .content {
    box-shadow: none;
    padding: 0;
  }
  
  .map-canvas {
    border: 1px solid #000;
    height: 18.75rem;
  }
}

.clear {
  clear: both;
}