/*
  Select 09 — Visual Option Select — standalone HTML/CSS/JS
  implementation. No build step, no framework, no external dependency:
  copy index.html, this file, and script.js into any project as-is.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --select-accent: #39ff14;
  --select-fg: oklch(0.145 0 0);
  --select-muted: oklch(0.5 0 0);
  --select-border: oklch(0.85 0 0);
  --select-chip: oklch(0.96 0 0);
  --select-check: oklch(0.145 0 0);
}

.visual-select {
  width: 100%;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
}

.visual-select__label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--select-fg);
}

.visual-select__field-wrap {
  position: relative;
}

.visual-select__trigger {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.625rem;
  border-radius: 0.75rem;
  border: 1px solid var(--select-border);
  background-color: #ffffff;
  padding: 0.375rem 0.75rem 0.375rem 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--select-fg);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color 150ms ease-out;
}

.visual-select__trigger:focus-visible {
  border-color: var(--select-accent);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--select-accent) 30%, transparent);
}

.visual-select__trigger-label {
  flex: 1 1 auto;
}

.visual-select__swatch {
  position: relative;
  display: block;
  height: 1.75rem;
  width: 1.75rem;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid var(--select-border);
  background-color: #f4f4f5;
}

.visual-select__swatch--trigger {
  height: 1.75rem;
  width: 1.75rem;
}

.visual-select__swatch-bar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 30%;
  background-color: #d4d4d8;
}

.visual-select__swatch-body {
  position: absolute;
  inset: 30% 0 0 0;
  background-color: #ffffff;
}

.visual-select__swatch[data-variant="dark"] {
  background-color: oklch(0.22 0 0);
}
.visual-select__swatch[data-variant="dark"] .visual-select__swatch-bar {
  background-color: oklch(0.28 0 0);
}
.visual-select__swatch[data-variant="dark"] .visual-select__swatch-body {
  background-color: oklch(0.16 0 0);
}
.visual-select__swatch[data-variant="system"] .visual-select__swatch-bar {
  background: linear-gradient(to right, #d4d4d8 50%, oklch(0.28 0 0) 50%);
}
.visual-select__swatch[data-variant="system"] .visual-select__swatch-body {
  background: linear-gradient(to right, #ffffff 50%, oklch(0.16 0 0) 50%);
}

.visual-select__chevron {
  height: 1rem;
  width: 1rem;
  flex-shrink: 0;
  color: var(--select-muted);
  transition: transform 180ms ease-out;
}

.visual-select__trigger[aria-expanded="true"] .visual-select__chevron {
  transform: rotate(180deg);
}

.visual-select__listbox {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: 0;
  z-index: 10;
  max-height: 20rem;
  width: 100%;
  overflow-y: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--select-border);
  background-color: #ffffff;
  padding: 0.375rem;
  animation: visual-select-listbox-in 160ms ease-out both;
}

.visual-select__listbox[data-open-upward="true"] {
  top: auto;
  bottom: calc(100% + 0.375rem);
}

.visual-select__listbox[hidden] {
  display: none;
}

@keyframes visual-select-listbox-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.visual-select__option {
  display: flex;
  cursor: default;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.5rem;
  padding: 0.5rem;
  transition: background-color 120ms ease-out;
}

.visual-select__option--active {
  background-color: var(--select-chip);
}

.visual-select__option-text {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.visual-select__option-label {
  font-size: 0.875rem;
  color: var(--select-fg);
}

.visual-select__option--selected .visual-select__option-label {
  font-weight: 600;
}

.visual-select__option-desc {
  font-size: 0.75rem;
  color: var(--select-muted);
}

.visual-select__check {
  display: flex;
  height: 1.25rem;
  width: 1.25rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  transform: scale(0.7);
  opacity: 0;
  transition:
    transform 160ms cubic-bezier(0.32, 0.72, 0, 1.1),
    opacity 160ms ease-out,
    background-color 160ms ease-out;
}

.visual-select__check svg {
  height: 0.75rem;
  width: 0.75rem;
  color: var(--select-check);
}

.visual-select__check--visible {
  transform: scale(1);
  opacity: 1;
  background-color: var(--select-accent);
}

@media (prefers-reduced-motion: reduce) {
  .visual-select__trigger,
  .visual-select__chevron,
  .visual-select__option,
  .visual-select__check {
    transition: none;
  }

  .visual-select__listbox {
    animation: none;
  }
}

/*
  Page layout — the canvas this resource is presented on. Adjust or drop it
  when placing the resource inside your own layout.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, #fafafa, #f4f4f5);
}
.select09-layout {
  display: flex;
  min-height: 24rem;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 2.5rem 1.5rem;
}
.select09-layout__panel {
  width: 100%;
  max-width: 20rem;
  border: 1px solid oklch(0.9 0 0);
  border-radius: 1rem;
  background: #ffffff;
  padding: 1.5rem;
}
