/* Shared appearance selector for the home page and portfolio pages. */
#theme-dropdown {
  position: fixed;
  top: 84px;
  right: 24px;
  z-index: 60;
  width: min(320px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(25, 27, 35, 0.96), rgba(14, 16, 22, 0.92));
  backdrop-filter: blur(24px) saturate(110%);
  -webkit-backdrop-filter: blur(24px) saturate(110%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: #f4f4f6;
  font-family: 'Inter', 'Kanit', sans-serif;
  user-select: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out, visibility 0s 160ms;
}

#theme-dropdown.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 180ms ease-out, transform 240ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
}

.theme-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 18px;
}

.theme-selector-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.5;
}

.theme-selector-header p {
  margin: 3px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: #979ba9;
}

.theme-selector-count {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #a9adba;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

#theme-list-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: min(432px, calc(100dvh - 220px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 2px 0;
}

.theme-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  flex-shrink: 0;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #e7e8ed;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.theme-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.06);
}

@keyframes themeOptionIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
    filter: blur(3px);

  }
  65% {
    opacity: 1;

  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);

  }
}

#theme-dropdown.is-open .theme-dropdown-item {
  animation: themeOptionIn 500ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: calc(50ms + var(--theme-order, 0) * 48ms);
  will-change: transform, opacity, filter;
}

.theme-dropdown-item.is-active {
  background: color-mix(in srgb, var(--theme-color) 10%, transparent);
  border-color: color-mix(in srgb, var(--theme-color) 24%, transparent);
}

.theme-option-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--theme-color);
  background: color-mix(in srgb, var(--theme-color) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-color) 16%, transparent);
  font-size: 13px;
}

.theme-option-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.theme-option-name {
  font-size: 12px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.theme-option-description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1.4;
  color: #979ba9;
}

.theme-option-status {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--theme-color);
  font-size: 9px;
}

.theme-item-check { opacity: 0; }
.is-active .theme-option-status {
  border-color: color-mix(in srgb, var(--theme-color) 30%, transparent);
  background: color-mix(in srgb, var(--theme-color) 14%, transparent);
}
.is-active .theme-item-check { opacity: 1; }

.theme-dropdown-item:focus-visible {
  outline: 2px solid var(--theme-color);
  outline-offset: -2px;
}

.theme-selector-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 6px 0;
  padding: 12px 6px 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #979ba9;
  font-size: 9px;
}

.theme-selector-footer span { color: #787d8c; }

@media (min-width: 1024px) {
  #theme-dropdown { right: 64px; }
}

@media (max-width: 639px) {
  #theme-dropdown { top: 84px; right: 12px; }
  #theme-dropdown.theme-selector-home { top: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  #theme-dropdown,
  #theme-dropdown.is-open,
  .theme-dropdown-item { transition: none; transform: none; }
  #theme-dropdown.is-open .theme-dropdown-item { animation: none; }
  #theme-menu-chevron { transition: none !important; }
}
