/* ==========================================================================
   Tandem — Demo "Style options" switcher           *** DEMO ONLY ***
   Safe to remove: delete this <link> and js/switcher.js. See switcher.js
   for how to bake options permanently with data-td-* attributes.
   Uses the page's own tokens, so it follows every preset and dark mode.
   ========================================================================== */

.td-switcher {
  --sw-gap: 16px;
  position: fixed;
  z-index: 150;
  left: 0;
  bottom: 0;
  font-family: var(--font-sans);
  color: var(--ink);
}

/* Edge tab toggle — flush left, vertically centred, so it never sits on top
   of the hero buttons or the mobile menu button. */
.td-switcher__toggle {
  position: fixed;
  left: 0;
  top: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 52px;
  padding: 0 0 0 2px;
  border: 1px solid color-mix(in srgb, var(--on-dark) 18%, transparent);
  border-left: 0;
  border-radius: 0 16px 16px 0;
  transform: translateY(-50%);
  background: var(--plum);
  color: var(--on-dark);
  box-shadow: var(--shadow-md), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  cursor: pointer;
  transition: transform 0.4s var(--spring), opacity 0.3s var(--ease), visibility 0s;
}

.td-switcher__toggle svg {
  width: 24px;
  height: 24px;
}

/* Phones: a slim tab that mostly sits in the page gutter. */
@media (max-width: 639.98px) {
  .td-switcher__toggle {
    width: 34px;
    height: 48px;
    padding: 0;
    border-radius: 0 12px 12px 0;
    box-shadow: var(--shadow-md);
  }

  .td-switcher__toggle svg {
    width: 18px;
    height: 18px;
  }
}

/* Hover only on real hover devices — on touch, :hover sticks after a tap. */
@media (hover: hover) {
  .td-switcher__toggle:hover {
    transform: translateY(-50%) translateX(3px);
  }

  .td-switcher__toggle:hover svg {
    transform: rotate(-30deg);
  }
}

.td-switcher__toggle svg {
  transition: transform 0.4s var(--spring);
}

.td-switcher__toggle:focus-visible,
.td-switcher :focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.td-switcher.is-open .td-switcher__toggle {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* The menu overlay owns the screen while it is open. */
html.nav-locked .td-switcher {
  display: none;
}

/* Panel — bottom sheet on phones */
.td-switcher__panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: min(78svh, 680px);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-card) var(--r-card) 0 0;
  background: var(--cream);
  box-shadow: 0 -30px 80px -30px color-mix(in srgb, var(--shadow-c) 55%, transparent);
  visibility: hidden;
  transform: translateY(104%);
  transition: transform 0.5s var(--ease-out), visibility 0s linear 0.5s;
}

.td-switcher.is-open .td-switcher__panel {
  visibility: visible;
  transform: none;
  transition: transform 0.5s var(--ease-out), visibility 0s;
}

.td-switcher__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px 22px;
  border-bottom: 1px solid var(--line);
}

.td-switcher__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: var(--display-weight);
  line-height: 1.1;
}

.td-switcher__badge {
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--sage-tint);
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage-ink);
}

.td-switcher__close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.td-switcher__close svg {
  width: 20px;
  height: 20px;
}

.td-switcher__body {
  padding: 18px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.td-switcher__group + .td-switcher__group {
  margin-top: 18px;
}

.td-switcher__label {
  margin-bottom: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.td-switcher__options {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--white);
}

.td-switcher__option {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

.td-switcher__option:hover {
  background: var(--cream-2);
}

.td-switcher__option.is-active {
  background: var(--plum);
  color: var(--on-dark);
}

/* Swatches */
.td-switcher__options--swatch {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: var(--r-inner);
}

.td-switcher__swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 64px;
  padding: 8px 4px;
  border-radius: var(--r-inner);
  text-align: center;
}

.td-switcher__dot {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #FFFFFF 70%, transparent), 0 0 0 1px var(--line-strong);
}

.td-switcher__swatch.is-active {
  background: var(--plum);
  color: var(--on-dark);
}

.td-switcher__swatch-label {
  font-size: 0.76rem;
  line-height: 1.1;
}

/* In dark mode the plum fill is close to the panel, so use the accent. */
:root[data-td-theme="dark"] .td-switcher__option.is-active {
  background: var(--accent-btn);
  color: #FFFFFF;
}

.td-switcher__note {
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--muted);
}

.td-switcher__reset {
  width: 100%;
  min-height: 48px;
  margin-top: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.td-switcher__reset:hover {
  border-color: var(--plum);
  background: var(--plum);
  color: var(--on-dark);
}

.td-switcher__listing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 10px;
  border-radius: var(--r-pill);
  background: var(--accent-btn);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.td-switcher__foot {
  margin-top: 14px;
  font-size: 0.74rem;
  text-align: center;
  color: var(--muted);
}

/* Side panel from tablet up */
@media (min-width: 640px) {
  .td-switcher__panel {
    top: 92px;
    left: var(--sw-gap);
    right: auto;
    bottom: var(--sw-gap);
    width: 344px;
    max-height: none;
    border-bottom: 1px solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-lg);
    transform: translateX(calc(-100% - 40px));
  }
}

/* Short landscape screens: use the full height instead of starting below the header. */
@media (min-width: 640px) and (max-height: 520px) {
  .td-switcher__panel {
    top: var(--sw-gap);
  }
}
