/* Site-wide search: header trigger, command palette, results list.
   Colours follow the site palette (--acid / --bg) with local fallbacks so the
   palette still reads correctly if it loads before styles.css. */

/* ------------------------------------------------------------ trigger --- */

.mw4-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: 18px;
  padding: 8px 12px;
  border: 1px solid #ffffff33;
  background: #151a17;
  color: #b9bdb2;
  cursor: pointer;
  font: 800 12px 'DM Sans', Arial, sans-serif;
  letter-spacing: 0.06em;
  transition: border-color 0.18s, color 0.18s;
}

.mw4-search-trigger:hover {
  border-color: var(--acid, #d9ef5c);
  color: var(--acid, #d9ef5c);
}

.mw4-search-trigger i {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
  flex: none;
}

.mw4-search-trigger i::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.mw4-search-trigger kbd {
  font: 800 10px 'DM Sans', Arial, sans-serif;
  color: #7f8779;
  border: 1px solid #ffffff26;
  padding: 2px 5px;
  line-height: 1;
}

@media (max-width: 900px) {
  .mw4-search-trigger span,
  .mw4-search-trigger kbd { display: none; }
  .mw4-search-trigger { margin-right: 10px; padding: 8px 10px; }
}

/* The mobile drawer carries its own row, because the header trigger is
   dropped on narrow screens. */
.mw4-search-mobile {
  display: none;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-top: 1px solid #384037;
  background: none;
  cursor: pointer;
  font: 800 14px 'Barlow Condensed', Arial, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c5ccbf;
  text-align: left;
}

.mw4-search-mobile i {
  display: block;
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
  flex: none;
}

.mw4-search-mobile i::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

@media (max-width: 560px) {
  .mw4-search-trigger { display: none; }
  .mw4-search-mobile { display: flex; }
}

/* ------------------------------------------------------------ palette --- */

html.mw4-search-open { overflow: hidden; }

.mw4-search {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 20px 40px;
}

.mw4-search[hidden] { display: none; }

.mw4-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 9, 0.82);
  backdrop-filter: blur(3px);
}

.mw4-search-panel {
  position: relative;
  width: 100%;
  max-width: 680px;
  background: #151a15;
  border: 1px solid #3c4638;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
  animation: mw4-search-in 0.16s ease-out;
}

@keyframes mw4-search-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.mw4-search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #2e362c;
}

.mw4-search-glass {
  position: relative;
  display: block;
  width: 15px;
  height: 15px;
  border: 2px solid var(--acid, #d9ef5c);
  border-radius: 50%;
  flex: none;
}

.mw4-search-glass::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: -5px;
  width: 7px;
  height: 2px;
  background: var(--acid, #d9ef5c);
  transform: rotate(45deg);
}

.mw4-search-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  color: var(--ink, #f1f0e9);
  font: 400 17px 'DM Sans', Arial, sans-serif;
}

.mw4-search-input::placeholder { color: #6d7466; }
.mw4-search-input::-webkit-search-cancel-button { display: none; }

.mw4-search-esc {
  font: 800 10px 'DM Sans', Arial, sans-serif;
  color: #7f8779;
  border: 1px solid #ffffff26;
  padding: 3px 6px;
  line-height: 1;
}

.mw4-search-status {
  margin: 0;
  padding: 8px 18px;
  font: 800 10px 'DM Sans', Arial, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #78806f;
  border-bottom: 1px solid #2e362c;
}

.mw4-search-status:empty { display: none; }

.mw4-search-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 54vh;
  overflow-y: auto;
}

.mw4-search-label {
  padding: 12px 18px 6px;
  font: 800 10px 'DM Sans', Arial, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6d7466;
}

.mw4-search-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  grid-template-areas: 'kind title' 'kind sub';
  gap: 2px 12px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid #232a21;
  cursor: pointer;
}

.mw4-search-row:last-child { border-bottom: 0; }
.mw4-search-row.is-active { background: #1d251b; }

.mw4-search-kind {
  grid-area: kind;
  font: 800 9px 'DM Sans', Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--acid, #d9ef5c);
  border: 1px solid #3c4638;
  padding: 4px 0;
  text-align: center;
}

.mw4-search-title {
  grid-area: title;
  color: #e6e8dc;
  font: 700 15px 'DM Sans', Arial, sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw4-search-sub {
  grid-area: sub;
  color: #7f8779;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw4-search-title mark {
  background: none;
  color: var(--acid, #d9ef5c);
}

.mw4-search-empty {
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mw4-search-empty b {
  font: 800 13px 'DM Sans', Arial, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #dfe3d6;
}

.mw4-search-empty span {
  color: #7f8779;
  font-size: 13px;
}

.mw4-search-foot {
  display: flex;
  gap: 20px;
  padding: 11px 18px;
  border-top: 1px solid #2e362c;
  background: #12160f;
  color: #6d7466;
  font-size: 11px;
}

.mw4-search-foot kbd {
  font: 800 10px 'DM Sans', Arial, sans-serif;
  color: #9aa392;
  border: 1px solid #ffffff26;
  padding: 2px 5px;
  line-height: 1;
  margin-right: 3px;
}

@media (max-width: 560px) {
  .mw4-search { padding: 0; }
  .mw4-search-panel { max-width: none; border-left: 0; border-right: 0; }
  .mw4-search-list { max-height: 68vh; }
  .mw4-search-foot { display: none; }
  .mw4-search-row { grid-template-columns: 66px 1fr; }
}
