*, *::before, *::after {
  box-sizing: border-box;
}

p {
  line-height: 1.5;
}

.skip-link {
  position: fixed;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  background-color: #1a3e68;
}

.skip-link:focus {
  transform: translateY(0);
  border-radius: 0 0 5px 5px;
  border: 3px solid #f1d787;
  border-top: none;
}

.navbar {
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  background-color: #1a3e68;
  box-shadow: 0 0 5px black;
  top: 0;
  margin-bottom: 0;
  width: 100%;
  z-index: 1000;
}

.navbar-item {
  color: #f0f0f0;
  text-decoration: none;
  padding: 8px 14px 10px;
  margin: 0 5rem 0 5rem;
  font-weight: bold;
  font-size: 1.1rem;
  min-width: 44px;
  min-height: 44px;
  align-content: center;
}

.navbar-item:focus,
.navbar-item:hover {
  color: #f1d787;
  outline: none;
}

h1, h3 {
  margin: 0.25rem 0;
}

#navbar-logo {
  flex-shrink: 0;
  font-size: 0.8rem;
}

body {
  background-color: #f9f4e5;
  font-family: Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
}

.banner-container {
  background-color: rgb(245, 245, 245);
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 0 20px rgba(0,0,0,0.1);
  padding-top: 175px; 
}

.hero {
  text-align: center;
  margin: -2rem 0 2rem 0;
  border-bottom: 1px solid #ddd;
  width: 100%;
}

.hero-tagline {
  font-size: 2rem;
  font-weight: bold;
  color: #1a3e68;
  margin: 0 0 0.6rem 0;
}

form, #output-container {
  background: #f5f5f5;
  padding: 1.5rem;
  border-radius: 10px;
  box-shadow: 0px 4px 12px rgba(0,0,0,0.3);
  width: 650px;
  min-height: 120px;
  box-sizing: border-box;
  margin: 0 auto 3rem;
  overflow-wrap: break-word;
}

/* Initially hide the output container */
#output-container {
  display: none;
}

/* Show the output container when it has the 'visible' class */
#output-container.visible {
  display: block;
}

input[type="text"], textarea {
  font-family: inherit;
  width: 100%;
  padding: 0.5rem;
  border: 2px solid #acacac;
  border-radius: 10px;
  font-size: 1rem;
  min-height: 100px;
}

button {
  background-color: #1a3e68;
  color: #f0f0f0;
  border: none;
  padding: 0.8rem 1.2rem;
  margin-top: 1rem;
  font-size: 1rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
}

button:focus,
button:hover {
  background-color: #235288;
  outline-color: #a0b8d3;
  outline-width: 3px;
}

button:disabled {
  background-color: gray;
  cursor: not-allowed;
  opacity: .7;
}

#output-label {
  font-weight: bold;
  margin-bottom: 0rem;
  margin-top: 0rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.1rem;
}

#download-buttons {
  display: none;
  gap: 0.5rem;
  min-height: 44px;
  margin-bottom: 5px;
}

/* ClassyFire streaming progress bar (top of the results) */
#cf-progress {
  margin: 0.25rem 0 0.75rem 0;
}

.cf-progress-track {
  width: 100%;
  height: 14px;
  background-color: #e9eef5;
  border-radius: 7px;
  overflow: hidden;
}

.cf-progress-fill {
  height: 100%;
  width: 0%;
  background-color: #1a3e68;
  border-radius: 7px;
  transition: width 0.3s ease;
}

.cf-progress-label {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: #444444;
}

.cf-queue {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  /* color: #444444; */
}

.cf-queue[hidden] {
  display: none;
}

/* Shared loading spinner: download buttons (while streaming) and the ClassyFire "Queued" placeholder. */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.download-spinner,
.inline-spinner {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 2px solid #c9d4e2;
  border-top-color: #1a3e68;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.download-spinner {
  display: none;
  align-self: center;
}

#download-buttons.loading .download-spinner {
  display: inline-block;
}

#download-buttons.loading .download-btn {
  opacity: 0.5;
  cursor: not-allowed;
}

#input-label {
  font-weight: bold;
  margin-bottom: 3rem;
  margin-top: 0rem;
}

#output-text {
  font-family: monospace;
  font-size: .95rem;
}

@keyframes ellipsis {
  0%   { content: "."; }
  33%  { content: ".."; }
  66%  { content: "..."; }
  100% { content: "."; }
}

.ellipsis-animate::after {
  content: ".";
  animation: ellipsis 1.2s steps(1, end) infinite;
}

/* Structured results styling */
.result-item {
  margin-bottom: 1.5rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1rem;
  background-color: #fff;
}

.doc-note {
  background-color: #fff9e6;
  border-left: 4px solid #ffc107;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 4px;
  color: #644d03;
}

.doc-note strong {
  color: #644d03;
}

.doc-note-blue {
  background-color: #f2f5fa;
  border-left: 4px solid #384e73;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 4px;
  color: #384e73;
}

.doc-note-blue strong {
  color: #384e73;
}

.doc-note-red {
  background-color: #ffebeb;
  border-left: 4px solid #8f0b0b;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 4px;
  color: #8f0b0b;
}

.doc-note-red strong {
  color: #8f0b0b;
}

/* ClassyFire toggle locked off because the service is unavailable */
.settings-row.cf-disabled {
  opacity: 0.55;
  cursor: pointer;
}

/* "ClassyFire is down" popup */
.cf-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.cf-modal[hidden] {
  display: none;
}

.cf-modal-box {
  position: relative;
  background: #ffffff;
  max-width: 420px;
  width: 100%;
  padding: 1.75rem;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.cf-modal-box h3 {
  margin: 0 0 0.75rem 0;
  color: #8f0b0b;
}

.cf-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  margin: 0;
  padding: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: none;
  border: 2px solid transparent;
  border-radius: 4px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #666666;
}

.cf-modal-close:hover,
.cf-modal-close:focus {
  background: none;
  color: #1a3e68;
}

.query-section h3 {
  margin: 0 0 0.5rem 0;
  color: #1a3e68;
  font-size: 1.1rem;
}

.query-details {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.query-type {
  background-color: #e6f3ff;
  padding: 0.3rem 0.6rem;
  border-radius: 15px;
  border: 1px solid #b3d9ff;
  color: #333;
}

.match-status {
  padding: 0.3rem 0.6rem;
  border-radius: 15px;
}

.match-status.no-match {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.match-status.exact-match {
  background-color: #d4edda;
  color: #0d3b18;
  border: 1px solid #c3e6cb;
}

.match-status.first-block-match {
  background-color: #fff3cd;
  color: #594503;
  border: 1px solid #ffeaa7;
}

.query-type-expandable-wrapper {
  display: inline-flex;
  flex-direction: column;
  background-color: #e6f3ff;
  border-radius: 15px;
  border: 1px solid #b3d9ff;
}

.query-type-expandable-wrapper:has(:focus-visible) {
  outline: 2px solid #7aabde;
  outline-offset: 2px;
}

.query-type-expandable-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  color: #333;
  border: none;
  padding: 0.3rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: normal;
  cursor: pointer;
  margin-top: 0;
  min-height: unset;
  min-width: unset;
  white-space: nowrap;
}

.query-type-expandable-btn:hover {
  background-color: #d0e9ff;
}

.query-type-expandable-btn:focus:not(:hover) {
  outline: none;
  background-color: transparent;
}

.query-type-expandable-btn:focus {
  outline: none;
}

.query-type-chevron {
  display: flex;
  align-items: center;
  color: #555;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.query-type-expandable-btn[aria-expanded="true"] .query-type-chevron {
  transform: rotate(180deg);
}

.query-type-conversion {
  padding: 0.25rem 0.6rem 0.35rem;
  border-top: 1px solid #b3d9ff;
  color: #333;
}

.match-level.exact {
  background-color: #d4edda;
  padding: 0.3rem 0.6rem;
  border-radius: 15px;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.match-level.first-block {
  background-color: #fff3cd;
  padding: 0.3rem 0.6rem;
  border-radius: 15px;
  border: 1px solid #ffeaa7;
  color: #745903;
}

.error-message {
  background-color: #f8d7da;
  color: #721c24;
  padding: 0.5rem;
  border-radius: 5px;
  margin-top: 0.5rem;
  border: 1px solid #f5c6cb;
}

.matches-section h4 {
  margin: 1rem 0 0.5rem 0;
  color: #1a3e68;
}

.match-item {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.match-header {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #495057;
}

.match-details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.match-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.match-field label {
  font-weight: bold;
  color: #465766;
  min-width: 140px;
  font-size: 0.85rem;
}

.match-field span {
  flex: 1;
  word-break: break-all;
}

.monospace {
  font-family: 'Courier New', monospace;
  background-color: #ebedf0;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85rem;
  min-height: 1.5rem;
  display: flex;
  align-items: center;
}

.small-text {
  font-size: 0.75rem;
}

.classyfire-heading {
  margin-top: 0.75rem;
}

.classyfire-heading label {
  font-weight: bold;
  color: #1a3e68;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: unset;
}

/* "Queued" placeholder shown under the ClassyFire heading until results stream in */
.cf-queued {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #555;
}

.cf-queued span {
  flex: 0 0 auto; /* keep label + spinner grouped, not stretched across the row */
}

.result-separator {
  border: none;
  height: 2px;
  background-color: #dee2e6;
  margin: 1.5rem 0;
}

.download-btn {
  background-color: #1a3e68;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1.0rem;
  margin: 0px 15px 0px 0px;
}

.download-btn:hover {
  background-color: #235288;
}

*:focus {
  outline: 2px solid #36679e;
  outline-offset: -1px;
}

/* Form actions row (Match button + cog) */
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.form-actions > button[type="submit"] {
  margin-top: 0;
}

.cog-wrapper {
  position: relative;
}

.cog-btn {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.5rem;
  margin-top: 0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  font-weight: normal;
  color: #777;
}

.cog-btn:hover,
.cog-btn:focus {
  background-color: #e0e0e0;
  outline-color: #a0b8d3;
}

.settings-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.9rem 1.1rem;
  min-width: 190px;
  z-index: 100;
}

.settings-panel.open {
  display: block;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.toggle-label input[type="checkbox"]:focus {
  outline: none;
}

.toggle-label input[type="checkbox"]:focus + .toggle-track {
  outline: 2px solid #36679e;
  outline-offset: 3px;
}

.toggle-track {
  position: relative;
  width: 2.6rem;
  height: 1.4rem;
  background-color: #acacac;
  border-radius: 999px;
  transition: background-color 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-label input[type="checkbox"]:checked + .toggle-track {
  background-color: #1a3e68;
}

.toggle-label input[type="checkbox"]:checked + .toggle-track::after {
  transform: translateX(1.2rem);
}

/* Responsive design for mobile devices */
/* Pagination */
#pagination-controls {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px solid #dee2e6;
  font-family: Arial, sans-serif;
}

.pagination-btn {
  margin-top: 0;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  min-height: 36px;
  white-space: nowrap;
}

.page-num-btn {
  padding: 0.4rem 0;
  width: 36px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.9rem;
}

.page-num-btn.active {
  background-color: #fff;
  color: #1a3e68;
  border: 2px solid #1a3e68;
  opacity: 1;
  cursor: default;
  font-weight: bold;
}

.page-info {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: center;
}

.page-ellipsis {
  width: 36px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.9rem;
  color: #495057;
  user-select: none;
}

.settings-panel select {
  background-color: #fff;
  border: 1px solid #acacac;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: #333;
}

.settings-panel select:focus {
  outline: 2px solid #36679e;
  outline-offset: 1px;
}

/* Collapsible result cards */
.query-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.query-header h3 {
  flex: 1;
  min-width: 0;
}

.collapse-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.25rem;
  margin: 0;
  min-height: unset;
  min-width: unset;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-weight: normal;
  font-size: 1rem;
  line-height: 1;
  transition: background-color 0.15s;
}

.collapse-btn:hover,
.collapse-btn:focus {
  background-color: #e0e0e0;
  outline-color: #a0b8d3;
}

.collapse-btn img {
  transition: transform 0.2s;
  display: block;
}

.result-item.collapsed .collapse-btn img {
  transform: rotate(-90deg);
}

.result-body {
  overflow: hidden;
}

.result-item.collapsed .result-body {
  display: none;
}

@media (max-width: 768px) {
  .banner-container {
    padding: 140px 10px 0 10px;
  }
  
  form, #output-container {
    width: calc(100vw - 40px);
    max-width: 600px;
    margin-left: 10px;
    margin-right: 10px;
  }
  
  .navbar {
    padding: 6px 8px;
    /* Keep flex-direction: row (default) for horizontal layout */
  }
  
  .navbar-item {
    margin: 0 0.8rem;
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  #navbar-logo {
    font-size: 0.62rem;
  }

  .query-details {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .match-field {
    flex-direction: column;
    gap: 0.2rem;
  }
  
  .match-field label {
    min-width: auto;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .banner-container {
    padding: 120px 5px 0 5px;
  }
  
  form, #output-container {
    width: calc(100vw - 30px);
    padding: 1rem;
  }
  
  .navbar {
    padding: 4px 6px;
    /* Keep horizontal layout */
  }
  
  .navbar-item {
    margin: 0 0.4rem;
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  #navbar-logo {
    font-size: 0.55rem;
  }

  .result-item {
    padding: 0.75rem;
  }
  
  .match-item {
    padding: 0.5rem;
  }
  
  .monospace {
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  #download-buttons {
    width: 100%;
    flex-wrap: wrap;
  }

  .download-btn {
    flex: 1;
    min-width: 120px;
  }

  #applied-settings-label {
    margin-top: 0.3rem !important;
  }
}
