/* ==========================================================================
   controls.css
   Buttons, interactive links, inputs and focus states
   ========================================================================== */

:where(button, .button, .custom-button, .github-link) {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

.button,
.custom-button,
.github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.7rem;
  padding: 0.68rem 1rem;
  color: #ffffff;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  background: var(--color-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-base),
    transform var(--transition-base);
}

.button:hover,
.custom-button:hover,
.github-link:hover {
  color: #ffffff;
  background: var(--color-accent-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-0.12rem);
}

.button:active,
.custom-button:active,
.github-link:active {
  transform: translateY(0);
}

.button--secondary,
.custom-button-flat {
  color: var(--color-text);
  background: var(--color-surface-2);
  border-color: var(--color-border);
}

.button--secondary:hover,
.custom-button-flat:hover {
  color: var(--color-accent);
  background: var(--color-surface-hover);
  border-color: var(--color-border-strong);
}

.button--small {
  min-height: 2.3rem;
  padding: 0.52rem 0.82rem;
  font-size: 0.9rem;
}

button:disabled,
.button[aria-disabled="true"],
.custom-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Header controls */
/* Shared styles for header and utility controls */
.theme-toggle,
.menu-button,
.scroll-to-top {
  align-items: center;
  justify-content: center;
  width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-base),
    transform var(--transition-base);
}

/* These controls are always available */
.theme-toggle,
.scroll-to-top {
  display: inline-flex;
}

.theme-toggle:hover,
.menu-button:hover,
.scroll-to-top:hover {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-color: var(--color-border-strong);
  box-shadow: 0 0 0 0.28rem var(--color-accent-soft);
  transform: scale(1.045);
}

.theme-toggle:active,
.menu-button:active,
.scroll-to-top:active {
  transform: scale(0.97);
}

.theme-toggle i,
.menu-button i,
.scroll-to-top i {
  pointer-events: none;
}

.scroll-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 900;
  color: #ffffff;
  background: var(--color-accent);
  border-color: transparent;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.75rem);
  pointer-events: none;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-to-top:hover {
  color: #ffffff;
  background: var(--color-accent-strong);
  transform: translateY(-0.15rem);
}

/* Form controls */
input.custom-textbox,
textarea.custom-textbox,
select.custom-textbox {
  width: 100%;
  padding: 0.8rem 0.9rem;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast);
}

input.custom-textbox::placeholder,
textarea.custom-textbox::placeholder {
  color: var(--color-text-muted);
  opacity: 0.8;
}

input.custom-textbox:focus,
textarea.custom-textbox:focus,
select.custom-textbox:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 0.25rem var(--color-accent-soft);
}

textarea.custom-textbox {
  min-height: 8rem;
  resize: vertical;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Accessible focus */
:where(
  a,
  button,
  input,
  textarea,
  select,
  [tabindex]:not([tabindex="-1"])
):focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

@media (max-width: 36rem) {
  .control-group {
    flex-direction: column;
  }

  .control-group > * {
    width: 100%;
  }

  .theme-toggle,
  .menu-button {
    width: 2.5rem;
    height: 2.5rem;
  }
}
