:root {
  color-scheme: dark;
  background: #080b12;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  margin: 0;
  padding: clamp(12px, 3vw, 32px);
  box-sizing: border-box;
  background: radial-gradient(ellipse at 50% 43%, #151e2f, transparent 65%);
}

#rd-card-preview {
  --ink: #edf2fb;
  --muted: #becadd;
  --foil-blue: #a7e8f4;
  font: 14px/1.45 system-ui, sans-serif;
}

#rd-card-preview * {
  box-sizing: border-box;
}

.rd-card {
  --rx: -4deg;
  --ry: -7deg;
  --lx: 30%;
  --ly: 26%;
  --shift: 0deg;
  --reflection: 0.64;
  --radius: 18px;
  width: min(86vw, clamp(204px, calc((100dvh - 56px) * 0.69), 348px));
  aspect-ratio: 5 / 7;
  perspective: 1050px;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.rd-card[data-dragging] {
  cursor: grabbing;
}

.rd-pitch,
.rd-turn {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.rd-pitch {
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 390ms cubic-bezier(0.19, 0.75, 0.32, 1);
}

.rd-card[data-tracking] .rd-pitch {
  transition-duration: 100ms;
}

.rd-turn {
  position: relative;
  border-radius: var(--radius);
  box-shadow: 0 23px 65px #02040bbe, 0 3px 8px #000b;
  transition: transform 580ms cubic-bezier(0.22, 0.72, 0.29, 1);
}

[data-side="back"] .rd-turn {
  transform: rotateY(180deg);
}

.rd-face {
  --shine-x: var(--lx);
  --finish-angle: calc(132deg + var(--shift));
  position: absolute;
  inset: 0;
  container-type: inline-size;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(1px);
  color: var(--ink);
  background: #0c1424;
}

.rd-back {
  --shine-x: calc(100% - var(--lx));
  --finish-angle: calc(132deg - var(--shift));
  transform: rotateY(180deg) translateZ(1px);
}

.rd-face::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at var(--shine-x) var(--ly), #f8ffff, transparent 56%),
    linear-gradient(var(--finish-angle), #adc8e0, #354f69 34%, #829ab9 62%, #d7bc91 84%, #536680);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.rd-face::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: 2;
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
  opacity: var(--reflection);
  background: radial-gradient(ellipse at var(--shine-x) var(--ly), #e3f7ff2e, transparent 53%);
  mix-blend-mode: screen;
}

.rd-foil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  visibility: hidden;
}

.rd-foil[data-rendered] {
  visibility: visible;
}

.rd-face:has(.rd-foil:not([data-rendered])) {
  background:
    repeating-linear-gradient(138deg, transparent 0 12%, #4f80b758 20%, #8fa9c17a 21%, #9077514a 23%, transparent 28%),
    radial-gradient(ellipse at 71% 21%, #283e63, #0b1322 65%);
  background-size: 145% 145%, 100% 100%;
  animation: rd-metal-flow 13s ease-in-out infinite alternate;
}

@keyframes rd-metal-flow {
  from { background-position: 0 20%, center; }
  to { background-position: 90% 60%, center; }
}

.rd-face-layout {
  position: absolute;
  inset: 5px;
  display: grid;
  padding: 7cqi;
  border: 1px solid #d5e5ff29;
  border-radius: calc(var(--radius) - 5px);
  grid-template-areas: "wordmark" "art" "identity" "controls";
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background:
    linear-gradient(180deg, #091323b5, transparent 27%, transparent 36%, #081323be 63%, #091323f5 96%),
    radial-gradient(ellipse at 58% 29%, transparent 15%, #0c14255d 74%);
}

.rd-wordmark {
  grid-area: wordmark;
  align-self: start;
  justify-self: start;
  color: #f0f3fb;
  font-size: clamp(9px, 3.2cqi, 12px);
  font-weight: 720;
  letter-spacing: 0.2em;
  white-space: nowrap;
  text-shadow: 0 1px 5px #021019;
}

.rd-wordmark span {
  color: #e6ca9e;
  margin-inline: 0.14em;
}

.rd-illustration {
  grid-area: art;
  display: grid;
  place-items: center;
  min-height: 0;
}

.rd-sign {
  position: relative;
  width: min(100%, 37cqi, 152px);
  aspect-ratio: 1 / 0.94;
  filter: drop-shadow(0 10px 12px #020619b8);
}

.rd-sign span {
  position: absolute;
  inset: var(--level) 0 auto;
  height: 65%;
  clip-path: polygon(50% 0, 100% 43%, 100% 56%, 50% 100%, 0 56%, 0 43%);
  background: linear-gradient(90deg, var(--edge-left) 50%, var(--edge-right) 50%);
}

.rd-sign span::before {
  content: "";
  position: absolute;
  inset: 0 0 13%;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background:
    radial-gradient(ellipse at var(--shine-x) var(--ly), #f8ffffac, transparent 63%),
    linear-gradient(var(--finish-angle), var(--glass-light), var(--glass-dark));
}

.rd-sign span:nth-child(1) {
  --level: 34%;
  --edge-left: #3d5a82;
  --edge-right: #1d3655;
  --glass-light: #9eb4d6;
  --glass-dark: #4a6f9b;
}

.rd-sign span:nth-child(2) {
  --level: 17%;
  --edge-left: #85735a;
  --edge-right: #4c4033;
  --glass-light: #ebdcc2;
  --glass-dark: #a99777;
}

.rd-sign span:nth-child(3) {
  --level: 0%;
  --edge-left: #42939f;
  --edge-right: #235567;
  --glass-light: #d7f0f0;
  --glass-dark: #6eaebd;
}

.rd-identity {
  grid-area: identity;
  text-shadow: 0 2px 12px #030816;
}

.rd-identity h1 {
  margin: 0;
  font-size: clamp(31px, 15.6cqi, 53px);
  font-weight: 645;
  line-height: 0.99;
  letter-spacing: -0.07em;
}

.rd-identity p {
  margin: 10px 0 0;
  color: var(--foil-blue);
  font-size: clamp(10px, 3.3cqi, 12px);
  font-weight: 680;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.rd-back .rd-face-layout {
  grid-template-areas: "wordmark" "services" "contact" "controls";
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background:
    linear-gradient(171deg, #0a1326f0, #0a1326db 56%, #0b1323a3 100%),
    linear-gradient(180deg, transparent, #0a132690);
}

.rd-services {
  grid-area: services;
  display: grid;
  align-self: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: clamp(12px, 4.1cqi, 15px);
  font-weight: 550;
  line-height: 1.2;
}

.rd-services li {
  padding-inline-start: 10px;
  border-inline-start: 1.5px solid #cbb085;
}

.rd-contact {
  grid-area: contact;
  display: grid;
  align-self: center;
  justify-items: start;
  gap: 4px;
  margin: 0;
  padding-top: 9px;
  border-top: 1px solid #d1e4ff39;
  font-style: normal;
  font-size: clamp(12px, 4.05cqi, 15px);
}

.rd-contact a {
  color: inherit;
  text-decoration-color: #b7c9df99;
  text-underline-offset: 0.18em;
}

.rd-contact a:hover {
  color: var(--foil-blue);
}

.rd-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.rd-controls {
  grid-area: controls;
  display: flex;
  align-self: end;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #d1e4ff39;
}

.rd-controls button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid #c7d9ee49;
  border-radius: 100px;
  padding: 0 12px;
  background: #0d1828bd;
  color: var(--ink);
  font: 620 11px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.rd-controls button::before {
  content: "↻";
  color: var(--foil-blue);
  font-size: 15px;
}

.rd-controls button:hover {
  background: #263d55;
  border-color: #b3d2e186;
}

.rd-face :is(button, a):focus-visible {
  outline: 2px solid var(--foil-blue);
  outline-offset: 2px;
}

.rd-quiet {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (orientation: landscape) {
  .rd-card {
    width: min(89vw, clamp(250px, calc((100dvh - 53px) * 1.43), 552px));
    aspect-ratio: 8 / 5;
  }

  .rd-face-layout {
    padding: 4.5cqi;
    grid-template-areas: "wordmark wordmark" "identity art" "controls controls";
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .rd-front .rd-face-layout {
    background:
      linear-gradient(90deg, #0a1326fa 0%, #0a1326e1 34%, transparent 79%),
      linear-gradient(0deg, #0a1326da, transparent 38%);
  }

  .rd-identity {
    align-self: center;
  }

  .rd-identity h1 {
    font-size: clamp(27px, 10.1cqi, 55px);
  }

  .rd-sign {
    width: min(80%, 31cqi, 145px);
  }

  .rd-back .rd-face-layout {
    grid-template-areas: "wordmark wordmark" "services contact" "controls controls";
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    column-gap: 4cqi;
  }

  .rd-contact {
    padding: 0;
    border: 0;
  }

  @container (max-width: 355px) {
    .rd-face-layout {
      padding: 3.5cqi;
    }

    .rd-services {
      gap: 5px;
      font-size: 11px;
    }

    .rd-contact,
    .rd-legal {
      font-size: 10px;
    }

    .rd-controls {
      padding-top: 5px;
      margin-top: 5px;
    }

    .rd-controls button {
      min-height: 30px;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .rd-pitch,
  .rd-card[data-tracking] .rd-pitch,
  .rd-turn {
    transition: none;
  }

  .rd-face:has(.rd-foil:not([data-rendered])) {
    animation: none;
  }
}
