<% accent_color = HexComparer.new([@tag.bg_color_hex, @tag.text_color_hex]).biggest %>
<% color = HexComparer.new([@tag.bg_color_hex, @tag.text_color_hex]).brightness(1.4) %>
<% dark_color = HexComparer.new([@tag.bg_color_hex, @tag.text_color_hex]).brightness(0.7) %>
<% not_so_rand = Random.new(@tag.id) # Using ID as seed ensures we get the same "random" numbers on each page load, Improves caching %>
<style>
  body {
    background: white;
    margin: 0;
    padding: 0;
  }

  .preview-div-wrapper {
    overflow: hidden;
    position: relative;
  }

  .circle {
    border-radius: 1000px;
    background: <%= accent_color %>;
    position: absolute;
  }

  .circle1 {
    height: 40vw;
    width: 40vw;
    right: -<%= not_so_rand.rand(2..15) %>vw;
    bottom: -<%= not_so_rand.rand(2..15) %>vw;
  }

  .circle2 {
    height: 30vw;
    width: 30vw;
    left: <%= not_so_rand.rand(2..16) %>vw;
    bottom: -<%= not_so_rand.rand(2..15) %>vw;
  }

  .circle3 {
    height: 24vw;
    width: 24vw;
    left: -8vw;
    top: -<%= not_so_rand.rand(2..6) %>vw;
  }

  .preview-div {
    background: #fff;
    border: 0.25vw solid<%= dark_color %>;
    box-shadow: 0.8vw 1vw 0px<%= dark_color %>;
    width: 88vw;
    height: 44vw;
    margin: 2.5vw auto 5vw;
    overflow: hidden;
    position: relative;
  }

  h1 {
    color: <%= dark_color %>;
    width: 92%;
    margin: 10vw auto 0vw;
    font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
    font-size: 12vw;
  }

  h1 img {
    border-radius: 100vw;
    height: 15vw;
    width: 15vw;
    vertical-align: -4.3vw;
    border: 0.55vw solid<%= dark_color %>;
  }

  h2 {
    color: black;
    width: 92%;
    margin: 0vw auto 1vw;
    font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
    font-size: 6vw;
  }

  .preview-dev-logo {
    position: absolute;
    bottom: 2.1vw;
    right: 2.1vw;
    text-align: right;
  }

  .logo {
    height: 6vw;
    fill: <%= dark_color %>;
  }
</style>
<div class="preview-div-wrapper">
  <div class="circle circle1"></div>
  <div class="circle circle2"></div>
  <div class="circle circle3"></div>
  <div class="preview-div">
    <h1>
      #<%= @tag.name %>
    </h1>
    <% if @tag.pretty_name %>
      <h2>
        <%= @tag.pretty_name %>
      </h2>
    <% end %>
    <div class="preview-dev-logo">
      <%= inline_svg_tag("devplain.svg", class: "logo", size: "9vw * 9vw", aria: false, title: "DEV logo") %>
    </div>
  </div>
</div>
