:root {
  --scope-scrim: #82705c66;
  --scope-shadow: #624c2924;
  --scope-control: #ffffff45;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-palette]) {
    --scope-scrim: #100d0ab8;
    --scope-shadow: #100b094a;
    --scope-control: #ffffff0b;
  }
}

:root[data-palette="taupe"] {
  --scope-scrim: #100d0ab8;
  --scope-shadow: #100b094a;
  --scope-control: #ffffff0b;
}

.scope-trigger {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  appearance: none;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.scope-trigger:disabled {
  opacity: 1;
  cursor: default;
}

.scope-trigger:focus-visible,
.scope-close:focus-visible,
.scope-return:focus-visible {
  outline: 2px solid var(--orange-light);
  outline-offset: 4px;
}

.scope-label {
  display: block;
  margin-top: 17px;
  font-size: 16px;
  font-weight: 550;
  line-height: 1.06;
  letter-spacing: -.025em;
}

/* Keep the source rectangles unrotated when they become the dialog surface. */
.scope-trigger .icon-island,
.scope-item:hover .scope-trigger .icon-island {
  transform: none;
}

.scope-trigger .icon-island svg,
.scope-item:hover .scope-trigger .icon-island svg {
  transform: none;
  transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}

.scope-trigger:not(:disabled):is(:hover, :focus-visible) .icon-island svg {
  transform: translateY(-5px);
}

.scope-trigger:focus-visible .icon-island {
  background: var(--surface-hover);
}

.scope-source-active .icon-island {
  visibility: hidden;
}

.scope-source-active .scope-label {
  opacity: 0;
}

.scope-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
}

.scope-dialog:not([open]) {
  display: none;
}

.scope-dialog::backdrop {
  background: var(--scope-scrim);
  opacity: 0;
  transition: opacity .4s;
}

.scope-dialog.scope-backdrop-visible::backdrop {
  opacity: 1;
}

#scope-surface {
  position: fixed;
  background: var(--surface);
  box-shadow: 0 30px 100px var(--scope-shadow);
  pointer-events: none;
}

#scope-travel-icon {
  position: fixed;
  z-index: 3;
  pointer-events: none;
}

.scope-reader {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(880px, calc(100% - 64px));
  max-height: calc(100dvh - 64px);
  border-radius: 78px 72px 72px 126px;
  transform: translate(-50%, -50%);
}

.scope-reader-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 56px 0 224px;
}

.scope-reader .eyebrow {
  margin: 0;
  color: var(--orange-light);
  font-size: 11px;
}

.scope-reader-content {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  gap: 32px;
  min-height: 0;
  padding: 12px 56px 48px 40px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: inherit;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}

.scope-reader-art {
  align-self: start;
  width: 152px;
  height: 152px;
  margin-top: 12px;
}

.scope-reader-art > svg {
  width: 100%;
  height: 100%;
  opacity: 0;
}

.scope-reader.icon-settled .scope-reader-art > svg {
  opacity: 1;
}

.scope-reader-copy {
  min-width: 0;
}

.scope-reader h2 {
  margin: 0 0 21px;
  font-size: 40px;
  font-weight: 550;
  line-height: 1.06;
  letter-spacing: -.05em;
  text-wrap: balance;
}

#scope-description {
  max-width: 62ch;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

#scope-description > p {
  margin: 0;
}

#scope-description > p + p {
  margin-top: 1em;
}

.scope-examples {
  margin-top: 25px;
  padding-top: 21px;
  border-top: 1px solid var(--edge);
  color: var(--text);
}

.scope-examples > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
}

.scope-examples ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scope-examples li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.scope-examples li::before {
  display: block;
  flex: none;
  width: 4px;
  height: 4px;
  margin-top: .6em;
  border-radius: 50%;
  background: var(--orange-light);
  content: '';
}

.scope-return {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 19px;
  padding: 12px 0 0;
  border: 0;
  background: transparent;
  color: var(--orange-light);
  font-size: 12px;
}

.scope-return > svg {
  flex: none;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s;
}

.scope-return:hover > svg {
  transform: translateX(-4px);
}

.scope-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  background: var(--scope-control);
  color: var(--muted);
}

.scope-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.scope-close > svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.scope-reveal {
  opacity: 0;
}

.scope-reader.is-revealed .scope-reveal {
  opacity: 1;
}

.scope-reader.is-closing .scope-reveal {
  opacity: 0;
  transition: opacity .12s;
}

@media (max-width: 1100px) {
  .scope-label {
    font-size: 14px;
  }
}

@media (max-width: 1000px) {
  .scope-reader-header,
  .scope-reader-content {
    padding-right: 48px;
  }
}

@media (max-width: 800px) {
  .scope-label {
    font-size: 17px;
  }
}

@media (max-width: 760px) {
  .scope-reader {
    width: calc(100% - 32px);
    max-width: 520px;
    max-height: calc(100dvh - 32px);
    border-radius: 48px 42px 42px 72px;
  }

  .scope-reader-header {
    padding: 24px 28px 0;
  }

  .scope-reader .eyebrow {
    font-size: 10px;
  }

  .scope-reader-content {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 8px 30px 32px;
  }

  .scope-reader-art {
    width: 88px;
    height: 88px;
    margin: 0;
  }

  .scope-reader h2 {
    margin-bottom: 17px;
    font-size: 32px;
    line-height: 1.12;
  }

  #scope-description {
    font-size: 15px;
    line-height: 1.65;
  }

  .scope-examples {
    margin-top: 20px;
    padding-top: 17px;
  }
}

@media (max-width: 650px) {
  .scope-label {
    margin-top: 10px;
    font-size: 13px;
    letter-spacing: -.03em;
  }
}

@media (max-width: 480px) {
  .scope-reader-header {
    padding: 20px 26px 0;
  }

  .scope-reader-content {
    padding: 8px 26px 29px;
  }

  .scope-reader-art {
    width: 86px;
    height: 86px;
  }

  .scope-reader h2 {
    font-size: clamp(28px, 7vw, 32px);
  }

  .scope-examples li {
    font-size: 13px;
  }
}

@media (max-width: 350px) {
  .scope-label {
    font-size: 12px;
  }
}

html.motion-paused .scope-dialog::backdrop,
html.motion-paused .scope-reveal {
  transition: none;
}

html.motion-paused .scope-trigger .icon-island svg,
html.motion-paused .scope-return > svg {
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html:not(.motion-enabled) .scope-dialog::backdrop,
  html:not(.motion-enabled) .scope-reveal {
    transition: none;
  }

  html:not(.motion-enabled) .scope-trigger .icon-island svg,
  html:not(.motion-enabled) .scope-return > svg {
    transform: none !important;
  }
}
