/* Keep the grid still; only the two faces turn in their own 3D space. */
.topic.tile,
.topic.tile:first-of-type {
  --tile-flip-duration: 480ms;
  overflow: visible;
  background: transparent;
  perspective: 1100px;
  perspective-origin: 50% 50%;
  cursor: default;
}

.topic.tile[data-open="true"] {
  z-index: 3;
}

.topic.tile[data-open="false"][data-turning] {
  z-index: 2;
}

.tile-flipper {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform: rotateY(0deg);
  transform-origin: 50% 50%;
  transition: transform var(--tile-flip-duration) cubic-bezier(.22, .72, .12, 1);
  will-change: transform;
}

.topic.tile[data-open="true"] .tile-flipper {
  transform: rotateY(180deg);
}

.tile-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tile-front {
  display: block;
  margin: 0;
  padding: 0;
  background: linear-gradient(-75deg, #040505, #0e0e0e);
  color: inherit;
  font: inherit;
  text-align: left;
  transform: rotateY(0deg) translateZ(.1px);
  touch-action: pan-y;
  cursor: pointer;
}

.tile-front::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .025);
  pointer-events: none;
  content: "";
}

.tile-front:focus-visible {
  outline: 2px solid rgb(79 133 255 / .55);
  outline-offset: -3px;
}

.tile-back {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 100% 0%, rgb(255 255 255 / .055), transparent 65%),
    linear-gradient(145deg, #151515, #080808 74%);
  box-shadow: none;
  color: #e8e8e8;
  font: 400 12px / 1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
  text-transform: none;
  white-space: normal;
  transform: rotateY(180deg) translateZ(.1px);
  pointer-events: none;
  cursor: pointer;
  touch-action: pan-y;
}

.topic.tile[data-open="true"] .tile-front {
  pointer-events: none;
}

.topic.tile[data-open="true"] .tile-back {
  pointer-events: auto;
}

.tile-back:focus {
  outline: none;
}

.tile-back-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 17px 14px 15px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #414141 transparent;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overflow-wrap: anywhere;
}

.tile-back-content:focus-visible {
  outline: 1px solid rgb(255 255 255 / .3);
  outline-offset: -4px;
}

.tile-back-title {
  margin: 0 0 12px;
  color: #f3f3f3;
  font: 900 clamp(13px, 5cqw, 19px) / 1.25 "Home Topic Inter", Inter, sans-serif;
  letter-spacing: -.02em;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.tile-back-subtitle {
  margin: 0 0 12px;
  color: #a2a2a2;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.tile-back-copy p {
  margin: 0;
  color: #c5c5c5;
  font-size: clamp(12px, 3.8cqw, 14px);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tile-back-copy p + p {
  margin-top: 12px;
}

.tile-back-link {
  flex: 0 0 auto;
  align-self: flex-start;
  max-width: calc(100% - 28px);
  min-height: 35px;
  margin: 0 14px 14px;
  padding: 8px 12px;
  border: 1px solid rgb(255 255 255 / .16);
  border-radius: 10px;
  background: #202020;
  color: #e8e8e8;
  font: 400 12px / 1.4 Inter, sans-serif;
  white-space: normal;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.tile-back-link:hover {
  background: #2b2b2b;
}

@media (prefers-reduced-motion: reduce) {
  .tile-flipper {
    transition: none;
  }

  .tile-flipper {
    will-change: auto;
  }
}
