.site-header__settings {
  position: relative;
}

.theme-icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  background-color: currentColor;
  -webkit-mask: url("../../img/nav/palette.svg") center / contain no-repeat;
  mask: url("../../img/nav/palette.svg") center / contain no-repeat;
}

.theme-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: min(21rem, calc(100vw - 2rem));
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 1.5rem 3rem -1rem rgb(0 0 0 / 0.55);
  animation: theme-pop 0.25s ease both;
}

.theme-panel[hidden],
.theme-hint[hidden] {
  display: none;
}

@keyframes theme-pop {
  from { opacity: 0; transform: translateY(-0.5rem) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.theme-panel__title {
  font-size: var(--text-lg);
}

.theme-panel__options {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.theme-panel__note {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  text-align: left;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.theme-option:hover {
  background-color: var(--color-accent-soft);
}

.theme-option[aria-pressed="true"] {
  background-color: var(--color-accent-soft);
  border-color: var(--color-accent);
}

.theme-option__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  line-height: 1.3;
}

.theme-option__text small {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.theme-option__check {
  color: var(--color-accent);
  font-weight: 700;
  opacity: 0;
}

.theme-option[aria-pressed="true"] .theme-option__check {
  opacity: 1;
}

.theme-swatch {
  position: relative;
  flex: none;
  width: 2.8rem;
  height: 2.8rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: linear-gradient(165deg, var(--sky-top), var(--sky-bottom));
}

.theme-swatch::before {
  content: "";
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background-color: var(--moon);
  box-shadow: 0 0 0.5rem var(--moon-glow);
}

.theme-swatch::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1.05rem;
  background:
    radial-gradient(circle at 45% 38%, var(--window-lit) 0 0.09rem, transparent 0.1rem),
    var(--building);
  clip-path: polygon(0 100%, 0 45%, 14% 45%, 14% 18%, 32% 18%, 32% 55%, 46% 55%, 46% 28%, 62% 28%, 62% 62%, 78% 62%, 78% 22%, 92% 22%, 92% 50%, 100% 50%, 100% 100%);
}

@keyframes theme-hint-in {
  from { opacity: 0; transform: translateY(-0.6rem); }
  to   { opacity: 1; transform: none; }
}

.theme-hint {
  position: absolute;
  top: calc(100% + 0.9rem);
  right: -0.2rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  width: min(19rem, calc(100vw - 2rem));
  padding: var(--space-md);
  font-size: var(--text-sm);
  background-color: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  box-shadow: 0 0 2rem -0.5rem var(--orb-glow), 0 1.5rem 3rem -1rem rgb(0 0 0 / 0.5);
  animation: theme-hint-in 0.5s ease both;
}

.theme-hint::before {
  content: "";
  position: absolute;
  top: -0.5rem;
  right: 0.9rem;
  width: 0.9rem;
  height: 0.9rem;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-accent);
  border-left: 1px solid var(--color-accent);
  transform: rotate(45deg);
}

.theme-hint__title {
  padding-right: 2rem;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
}

.theme-hint p {
  color: var(--color-text-muted);
}

.theme-hint .theme-hint__title {
  color: var(--color-text);
}

.theme-hint__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.9rem;
  height: 1.9rem;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--color-text-muted);
}

.theme-hint__close:hover {
  background-color: var(--color-accent-soft);
}

.theme-hint__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

html.theme-changing,
html.theme-changing *,
html.theme-changing *::before,
html.theme-changing *::after {
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease,
    box-shadow 0.5s ease, fill 0.5s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .theme-panel,
  .theme-hint {
    animation: none;
  }
}
