/*
 * The stage: layout and canvas chrome only. Everything a component looks like
 * comes from exactly one library stylesheet (material, fluent, geist, kendo).
 */

:root {
  color-scheme: light;
  --chrome: rgb(16 17 20 / 0.45);
  --chrome-accent: #2563eb;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --mask-check-thin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --mask-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --mask-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --chrome: rgb(255 253 250 / 0.45);
  --chrome-accent: #60a5fa;
}

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

html,
body {
  margin: 0;
  overflow: hidden;
  background: transparent;
}

body {
  padding: 26px 18px 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

p,
fieldset {
  margin: 0;
}

fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

button,
input,
select {
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

.switch,
.checkbox,
.radio,
.slider,
.progress,
.select select {
  appearance: none;
  -webkit-appearance: none;
}

.switch,
.checkbox,
.radio {
  position: relative;
  flex: none;
  margin: 0;
  cursor: pointer;
}

.icon {
  flex: none;
  width: var(--icon-size, 20px);
  height: var(--icon-size, 20px);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke, 2);
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Layout: three loose columns of stickers ---------- */

.stage {
  display: flex;
  align-items: flex-start;
  gap: 26px;
}

.col {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 30px;
  min-width: 0;
}

.col:nth-child(2) {
  padding-top: 34px;
}

.col:nth-child(3) {
  padding-top: 8px;
}

.sticker {
  position: relative;
  rotate: var(--tilt, 0deg);
  translate: var(--nudge, 0 0);
  transition: rotate 0.45s var(--ease), scale 0.45s var(--ease);
}

.sticker:is(:hover, :focus-within) {
  z-index: 2;
  rotate: 0deg;
  scale: 1.015;
}

/* Figma-style frame name above each sticker; each library names its components its own way. */
.sticker__name {
  margin: 0 0 7px 1px;
  color: var(--chrome);
  font: 400 11px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0;
  white-space: nowrap;
  transition: color 0.2s;
}

.sticker:is(:hover, :focus-within) .sticker__name {
  color: var(--chrome-accent);
}

.sticker__name[data-name="buttons"]::before { content: var(--name-buttons, "Button"); }
.sticker__name[data-name="form"]::before { content: var(--name-form, "Input · Select · Checkbox"); }
.sticker__name[data-name="switch"]::before { content: var(--name-switch, "Switch"); }
.sticker__name[data-name="meters"]::before { content: var(--name-meters, "Slider · Progress"); }
.sticker__name[data-name="tabs"]::before { content: var(--name-tabs, "Tabs"); }
.sticker__name[data-name="profile"]::before { content: var(--name-profile, "Card · Avatar · Badge"); }
.sticker__name[data-name="filters"]::before { content: var(--name-filters, "Chip · Radio"); }
.sticker__name[data-name="toast"]::before { content: var(--name-toast, "Toast"); }

/* Structure every library shares; spacing values come from the library. */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--row-gap, 8px);
}

.row--end {
  justify-content: flex-end;
}

.spread {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.field,
.meter {
  display: grid;
}

.select {
  position: relative;
  display: grid;
}

.select select {
  width: 100%;
  cursor: pointer;
}

.select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--chevron-right, 10px);
  width: var(--chevron-size, 16px);
  height: var(--chevron-size, 16px);
  translate: 0 -50%;
  background: var(--chevron-color, currentColor);
  mask: var(--chevron-mask, var(--mask-chevron)) center / contain no-repeat;
  pointer-events: none;
}

.check {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--chip-gap, 8px);
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: block;
  flex: none;
  object-fit: cover;
  object-position: 50% 20%;
}

.btn--block {
  width: 100%;
}

.btn,
.icon-btn,
.chip,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.slider {
  display: block;
  width: 100%;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.progress {
  display: block;
  width: 100%;
  border: 0;
}

.tabs {
  display: flex;
}

.tabpanel[hidden] {
  display: none;
}

.token {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token__chip {
  flex: none;
  width: 22px;
  height: 22px;
}

.token code {
  font: 400 11.5px/16px "Geist Mono", ui-monospace, monospace;
  overflow-wrap: anywhere;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toast__action {
  flex: none;
}

/* ---------- Swapping a library: the new stylesheet wipes in over the old one ---------- */

/* The stage is transparent, so the old library is clipped away along the same edge instead of showing through. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: 0.75s var(--ease) both;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  animation-name: ds-wipe-out;
}

::view-transition-new(root) {
  animation-name: ds-wipe-in;
}

@keyframes ds-wipe-in {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes ds-wipe-out {
  from {
    clip-path: inset(0 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 100%);
  }
}

/* Two columns on mid widths, a swipeable strip on phones. */
@media (max-width: 759px) {
  .stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px 22px;
  }

  .col {
    display: contents;
  }

  .col:nth-child(n) {
    padding-top: 0;
  }
}

@media (max-width: 479px) {
  body {
    padding: 22px 0 18px;
  }

  .stage {
    display: flex;
    gap: 18px;
    padding: 4px 22px 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 22px;
    scrollbar-width: none;
  }

  .sticker {
    flex: 0 0 78%;
    scroll-snap-align: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sticker {
    transition: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}
