/* Keep top-controls compact even when wrapping */
.top-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  max-width: 1450px;
  margin: 0 auto;
  padding: 0.25rem 0.75rem; /* minimal breathing room */
  box-sizing: border-box;
/*  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;   
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  max-width: 1450px;
  box-sizing: border-box;
  padding: 0.25rem 0.75rem;
*/
    
}


/* ------------------------------------------------------------
   SEARCH BOX — Layout + Controls
------------------------------------------------------------ */

.site-search {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    width: 100%;
}

.site-search form {
    width: 100%;
}

/* Search area grows until space runs out */
.top-controls .site-search {
  flex: 1 1 500px; /* flexible width, minimum ~500px before wrapping */
  min-width: 325px;
  margin-right: 0.75rem; /* small gap before mode buttons */
}

/* Row containing input + buttons */
.search-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
}

/* Wrapper for input + internal clear button */
.search-wrapper {
    position: relative;
    flex: 1;
}

/* Search input */
#q {
    width: 100%;
    padding: 0.35rem 2rem 0.35rem 0.6rem; /* extra right padding for X */
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #222;
}

/* Clear button inside input */
.clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 1rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.clear-btn:hover {
    color: #000;
}

/* Search button (magnifying glass) */
.search-btn {
    background: #e8e8e8;
    border: none;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

/* Options below input */
.search-options {
    margin-top: 0.4rem;
}

/* Broad Match label */
.broad-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: inherit;
}

.broad-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: #0645ad;
    cursor: pointer;
}

/* Help text */
.search-help {
    margin-top: 0;
    font-size: 0.85rem;
    color: #555;
}

/* No results message */
.no-results {
    margin-top: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #b00000;
}

/* Hide the native webkit clear button (Chrome, Safari, Edge, Opera) */
#q::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* Hide the native Microsoft/IE clear button */
#q::-ms-clear {
    display: none;
    width: 0;
    height: 0;
}

#q:placeholder-shown ~ .clear-btn {
    display: none;
}

/* 💡 FIX: Align the checkbox label and helper text on the same line */
.broad-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem; /* space between Broad Match and the explanation text */
}

/* ------------------------------------------------------------
   DARK MODE
------------------------------------------------------------ */

body.dark-mode #q {
    background: #333;
    color: #fff;
    border-color: #555;
}

body.dark-mode .clear-btn {
    color: #aaa;
}

body.dark-mode .search-btn {
    background: #444;
    color: #fff;
}

body.dark-mode .broad-label {
    color: #e5e5e5;
}

body.dark-mode .broad-label input[type="checkbox"] {
    accent-color: #9ecbff;
}

/* ------------------------------------------------------------
   HIGH CONTRAST MODE
------------------------------------------------------------ */

body.high-contrast #q,
body.high-contrast .search-btn {
    background: #000;
    color: #fff;
    border: 2px solid #fff;
}

body.high-contrast .clear-btn {
    color: #fff;
}

body.high-contrast .broad-label {
    color: #ff0;
}

body.high-contrast .broad-label input[type="checkbox"] {
    accent-color: #ff0;
}

/* ------------------------------------------------------------
   SCREEN READER MODE
------------------------------------------------------------ */

body.sr-mode #q {
    font-size: 1.25rem;
    line-height: 1.8;
}

body.sr-mode .broad-label {
    font-size: 1.25rem;
    line-height: 1.8;
}

/* ------------------------------------------------------------
   MOBILE LAYOUT
------------------------------------------------------------ */

/* When screen gets narrow, stack vertically but keep compact height */
@media (max-width: 925px) {
  .top-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .top-controls .site-search {
    order: 2;
    width: 100%;
    flex: 0 1 auto;
    margin-right: 0;
  }

  .top-controls .mode-controls-top {
    order: 1;
    justify-content: flex-end; /* 💡 FIX: Keeps buttons pinned to the right */
    width: 100%;
  }
}
