/* Fixed contact rail — matches the xyzchemical.com reference: black, square,
   53px items, thin collapse bar on top. */

/* Hidden by default, like the reference: it slides in when the pointer
   reaches the right edge, and stays open afterwards. */
.xy-rail {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translate(100%, -50%);
  transition: transform .5s ease;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: #000;
  border-radius: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .16);
}

.xy-rail.is-visible { transform: translate(0, -50%); }

/* Touch and narrow screens have no pointer edge to hover; always show it. */
@media (max-width: 1024px) {
  .xy-rail { transform: translate(0, -50%); }
}

/* The theme paints every <button> with its accent colour and border; reset it. */
.xy-rail button.xy-rail-min,
.xy-rail button.xy-rail-item {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #fff;
}
.xy-rail button.xy-rail-min:hover,
.xy-rail button.xy-rail-min:focus,
.xy-rail button.xy-rail-item:hover,
.xy-rail button.xy-rail-item:focus {
  background: #2b2b2b;
  color: #fff;
}
.xy-rail button.xy-rail-min:focus:not(:focus-visible),
.xy-rail button.xy-rail-item:focus:not(:focus-visible) { background: transparent; }

/* Collapse bar: 53 x 32, arrow points outwards when the rail is open. */
.xy-rail-min {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 53px;
  height: 32px;
  padding: 0 11px;
  margin: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .16);
  transition: background-color .18s ease;
}

.xy-rail-min:hover,
.xy-rail-min:focus-visible { background: #2b2b2b; }

.xy-rail-min:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -3px;
}

.xy-rail-min svg { width: 16px; height: 16px; transition: transform .25s ease; }

.xy-rail.is-collapsed .xy-rail-min svg { transform: rotate(180deg); }

.xy-rail-body { display: flex; flex-direction: column; }

.xy-rail.is-collapsed .xy-rail-body { display: none; }

.xy-rail-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 53px;
  height: 53px;
  padding: 0;
  border: 0;
  margin: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color .18s ease;
}

.xy-rail-item:hover,
.xy-rail-item:focus-visible {
  background: #2b2b2b;
  color: #fff;
}

.xy-rail-item:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -3px;
}

.xy-rail svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The label opens out of the rail on hover or keyboard focus. */
.xy-rail-label {
  position: absolute;
  top: 0;
  right: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  max-width: min(340px, 70vw);
  padding: 0 14px;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-radius: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  pointer-events: none;
}

.xy-rail-item:hover .xy-rail-label,
.xy-rail-item:focus-visible .xy-rail-label {
  opacity: 1;
  visibility: visible;
  transform: none;
}

@media (max-width: 640px) {
  .xy-rail-min { width: 44px; height: 28px; padding: 0 8px; }
  .xy-rail-min svg { width: 14px; height: 14px; }
  .xy-rail-item { width: 44px; height: 44px; }
  .xy-rail svg { width: 18px; height: 18px; }
  .xy-rail-label { display: none; }
}

/* Arabic and other RTL locales: the rail moves to the left edge. */
html[dir="rtl"] .xy-rail {
  right: auto;
  left: 0;
  transform: translate(-100%, -50%);
}
html[dir="rtl"] .xy-rail.is-visible { transform: translate(0, -50%); }
@media (max-width: 1024px) {
  html[dir="rtl"] .xy-rail { transform: translate(0, -50%); }
}
html[dir="rtl"] .xy-rail-label {
  right: auto;
  left: 100%;
  transform: translateX(-8px);
}
html[dir="rtl"] .xy-rail-min svg { transform: scaleX(-1); }
html[dir="rtl"] .xy-rail.is-collapsed .xy-rail-min svg { transform: scaleX(-1) rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  .xy-rail, .xy-rail-item, .xy-rail-label, .xy-rail-min svg { transition: none; }
}

@media print {
  .xy-rail { display: none; }
}