:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --results-bg: #f4f4f4;
  --error-color: #b00020;
  color-scheme: light;
}

:root[data-theme="obscurum"] {
  --bg: #121212;
  --fg: #e8e8e8;
  --results-bg: #1e1e1e;
  --error-color: #ff6b6b;
  color-scheme: dark;
}

:root[data-theme="caeruleum"] {
  --bg: #84c8f0;
  --fg: #5c5e60;
  --results-bg: #e4e3c0;
  --error-color: #b00020;
  color-scheme: blue;
}

:root[data-theme="aurorae"] {
  --bg: #f2bc75;
  --fg: #e35311;
  --results-bg: #742706;
  --error-color: #b70808;
  color-scheme: orange;
}

:root[data-theme="oceanum"] {
  --bg: #0000a1;
  --fg: #87dbe7;
  --results-bg: #06064d;
  --error-color: #ff6b6b;
  color-scheme: navy;
}

:root[data-theme="naturalis"] {
  --bg: #0a7135;
  --fg: #89e780;
  --results-bg: #2b4321;
  --error-color: #ff6b6b;
  color-scheme: chartreuse;
}

:root[data-theme="inferni"] {
  --bg: #4f0604;
  --fg: #c6110a;
  --results-bg: #1e170f;
  --error-color: #ff6b6b;
  color-scheme: red;
}

:root[data-theme="electricae"] {
  --bg: #949494;
  --fg: #6bff77;
  --results-bg: #030c04;
  --error-color: #b70808;
  color-scheme: green;
}

:root[data-theme="regalis"] {
  --bg: #f4efb9;
  --fg: #bb00ff;
  --results-bg: #daac7b;
  --error-color: #b70808;
  color-scheme: purple;
}

body {
  max-width: 40rem;
  margin: 1rem auto;
  padding: 0 1rem;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

h1 {
  font-size: 1.90rem;
  margin: 0.5rem 0;
  text-align: center;
}

h4 {
  font-size: 1.00rem;
  margin: 0.5rem 0;
  text-align: center;
}

#query-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.5rem 1rem;
  box-sizing: border-box;
  border: 3px solid var(--fg);
  border-radius: 1.5rem;
}

.hidden {
  display: none;
}

#search-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

#pos-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

#pos-label.hidden {
  display: none;
}

#theme-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

#toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

#toggle-row.hidden {
  display: none;
}

#direction-toggle, #mode-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-toggle-label {
  font-size: 0.95rem;
  order: -1;
}

#settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  background: none;
  border: none;
  padding: 0.25rem;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.switch {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  border-radius: 1.5rem;
  transition: background-color 0.2s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 1.1rem;
  width: 1.1rem;
  left: 0.2rem;
  bottom: 0.2rem;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background-color: #2e7d32;
}

.switch input:checked + .slider::before {
  transform: translateX(1.25rem);
}

.switch input:focus-visible + .slider {
  outline: 2px solid #2e7d32;
  outline-offset: 2px;
}

#direction-toggle .mode-toggle-label:last-of-type,
#mode-toggle .mode-toggle-label:last-of-type {
  display: none;
}

#direction-toggle:has(#direction-switch:checked) .mode-toggle-label:first-of-type,
#mode-toggle:has(#mode-switch:checked) .mode-toggle-label:first-of-type {
  display: none;
}

#direction-toggle:has(#direction-switch:checked) .mode-toggle-label:last-of-type,
#mode-toggle:has(#mode-switch:checked) .mode-toggle-label:last-of-type {
  display: inline;
}

#mode-caption {
  font-size: 0.85rem;
  color: #555;
  margin: 0.25rem 0 0.5rem;
}

#search-btn {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  margin-top: 0;
  color: var(--fg);
  background-color: var(--results-bg);
  border: 1px solid var(--fg);
  border-radius: 1.25rem;
}

#status[data-state="error"] {
  color: var(--error-color);
}

#results {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  background: var(--results-bg);
  color: var(--fg);
  padding: 1rem 1.15rem;
  border-radius: 1.25rem;
  min-height: 1.5rem;
}

  /* The container holding both the emoji and the message */
  .emoji-container {
    position: relative;
    display: inline-block;
    font-size: 32px; /* Changes the emoji size */
    cursor: pointer;
  }

  /* The hidden message box */
  .message-box {
    display: none; /* Keeps it hidden until hover */
    position: absolute;
    bottom: 130%;  /* Places the box right above the emoji */
    left: 50%;
    transform: translateX(-50%); /* Centers the box */
    
    /* Styling the message box */
    background-color: #222222;
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    white-space: nowrap; /* Prevents text from wrapping */
    box-shadow: 0px 4px 8px rgba(0,0,0,0.2);
    z-index: 10;
  }

  /* Show the message box ONLY when hovering over the container */
  .emoji-container:hover .message-box {
    display: block;
  }