/* Reset & base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  font-size: 14px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  gap: 20px;
  position: relative;
}

header a {
  text-decoration: none;
  color: var(--text-color-light);
  font-size: 14px;
  font-weight: 500;
}

header a:hover {
  text-decoration: underline;
}

main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: 100px; /* Space for fixed footer */
}

.nav-links {
  display: flex;
  gap: 15px;
  align-items: center;
  position: static;
}

.logo {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 60px;
  font-weight: 700;
  margin-bottom: 30px;
  color: var(--logo-color);
}

.logo .prompt-char {
  margin-right: 0.1em;
}

.logo .cursor {
  animation: blink 1s step-end infinite;
  opacity: 1;
}

@keyframes blink {
  from,
  to {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.button-container {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.search-button {
  text-decoration: none;
  color: var(--button-text-color);
  background-color: var(--button-bg-color);
  border: 1px solid var(--button-border-color);
  padding: 8px 24px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-block;
}

.search-button:hover {
  background-color: var(--button-hover-bg-color);
  color: var(--button-hover-text-color);
  border-color: var(--button-hover-bg-color);
}

footer {
  background-color: var(--footer-bg-color);
  padding: 20px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease-in-out;
  z-index: 50;
}

footer.hidden {
  transform: translateY(100%);
}

.footer-links {
  text-align: center;
}

.footer-links p {
  color: var(--text-color-muted);
  font-size: 13px;
}

.theme-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.theme-toggle-button,
.random-theme-button,
.css-chaos-button {
  background-color: transparent;
  border: 1px solid var(--toggle-border-color);
  color: var(--toggle-text-color);
  padding: 8px 12px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  transition: transform 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .theme-toggle-button:hover,
  .random-theme-button:hover,
  .css-chaos-button:hover {
    background-color: var(--button-hover-bg-color);
    border-color: var(--button-hover-bg-color);
    transform: scale(1.05);
    color: var(--button-hover-text-color);
  }
}

.theme-toggle-button:active,
.random-theme-button:active,
.css-chaos-button:active {
  transform: scale(0.95);
}

.icon {
  display: block;
  line-height: 1;
}

/* icon visibility */
[data-theme="light"] .moon-icon {
  display: none;
}
[data-theme="light"] .sun-icon {
  display: block;
}
[data-theme="dark"] .sun-icon {
  display: none;
}
[data-theme="dark"] .moon-icon {
  display: block;
}

.theme-transitions-active body {
  transition: background-color 0.4s ease-in-out, color 0.4s ease-in-out;
}
.theme-transitions-active header a {
  transition: color 0.2s ease-in-out;
}
.theme-transitions-active .logo {
  transition: color 0.4s ease-in-out;
}
.theme-transitions-active .search-button {
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.theme-transitions-active footer {
  /* Re-adds the full transition rule */
  transition: background-color 0.4s ease-in-out, transform 0.3s ease-in-out;
}
.theme-transitions-active .footer-links p {
  transition: color 0.2s;
}
.theme-transitions-active .theme-toggle-button,
.theme-transitions-active .random-theme-button,
.theme-transitions-active .css-chaos-button {
  /* Re-adds the full transition rule */
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s,
    color 0.2s;
}

/* Responsive */
@media (max-width: 600px) {
  .logo {
    font-size: 44px;
  }
  header {
    padding: 12px 10px;
    gap: 15px;
  }
  footer {
    flex-direction: column-reverse;
    align-items: center;
    padding: 20px 15px;
  }
  main {
    padding-bottom: 24px;
  }
  .theme-controls {
    position: fixed;
    top: 12px;
    right: 10px;
    display: flex;
    flex-direction: column; /* vertical stack */
    gap: 8px;
    z-index: 100; /* stay above content */
  }
  /* Give the header some space so links don't sit under the buttons */
  header {
    padding-right: 68px; /* ~40px button + padding + gap */
  }
  /* Slightly smaller placeholder on medium mobile screens */
  .search-bar-container input[type="text"] {
    font-size: 14px;
  }
  .search-bar-container input::placeholder {
    font-size: 14px;
  }

  /* Hide elements when search is active on mobile */
  /*body.search-active .logo,*/
  body.search-active .nav-links,
  body.search-active .theme-controls {
    display: none;
  }
}
@media (max-width: 400px) {
  .button-container {
    justify-content: center;
    padding: 0 20px;
  }
  .search-bar-container input[type="text"] {
    font-size: 13px;
  }
  .search-bar-container input::placeholder {
    font-size: 13px;
  }
}

/* Extra-short screens in landscape (e.g. phones turned sideways) */
@media (max-height: 500px) and (orientation: landscape) {
  main {
    justify-content: flex-start;
    padding-top: 80px; /* space for header + logo */
  }

  /* Shrink + float logo near the header line */
  .logo {
    font-size: 32px;
    margin-bottom: 12px;
    position: fixed;
    top: 8px;            /* ↓ lowered from 10px to align with header */
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
  }

  /* Keep header compact so everything shares the same “line” */
  header {
    padding: 8px 20px;    /* no big extra top padding */
  }

  header a {
    font-size: 13px;
  }

  body.chaos-rainbow .search-wrapper,
  body.chaos-rainbow .search-bar-container {
    width: 100% !important;
    max-width: 600px !important;   /* EXACT main-page width */
    margin: 0 auto !important;     /* center horizontally */
  }

  body.chaos-rainbow #search-input {
    width: 100% !important;
  }
}
