<h3>Vote for Notebook.ai's first community feature!</h3>

<div class="row">
  <div class="col s12">
    <p class="light">
      Worldbuilding is better with a world of diverse experiences and ideas. For the first time, all Premium users have been given a vote to decide what Notebook.ai's first community-based feature will be!
    </p>
    <p class="light">
      Love an idea and want to make sure it wins? You earn an additional vote with each user you refer to Notebook.ai that signs up for a Premium subscription. <%= link_to 'Learn more.', friends_landing_path %>
    </p>
  </div>
</div>

<div class="row">
  <div class="col s10 offset-s1">
    <div class="card light-blue">
        <div class="card-content white-text">
          <span class="card-title">This round of voting has concluded.</span>
          <p>
            A huge thank you to everyone that participated in the community drive!
          </p>
          <p style="padding-top: 20px;">
            Voting is now closed, but will return with a new round of features in the future. You can continue earning additional votes by <%= link_to 'sharing your referral code', subscription_path, class: 'blue-text text-lighten-5' %> for any upcoming feature vote rounds.
          </p>
          <p style="padding-top: 20px;">
            The winner of this round is <strong>Forums & Chat Rooms</strong>! You can expect to see this feature coming in the near future. A notable runner-up is <strong>Universe Collaboration</strong>, which you can expect to see shortly thereafter. Thanks again, everyone, for voting and helping to make Notebook.ai better for everyone!
          </p>
          <p style="padding-top: 20px;">
            Happy worldbuilding!
            <br /><br />
            - Andrew, Notebook.ai creator
          </p>
        </div>
      </div>
  </div>
</div>

<div class="row">

  <%
    if user_signed_in?
      total_votes = current_user.votes.count
      free_votes  = current_user.votes.where(votable_id: nil).count
      cast_votes  = current_user.votes.where.not(votable_id: nil).count

      # Override free vote counts so no one can vote in this round anymore:
      free_votes = 0

      disabled_voting_message = if cast_votes > 0
        "You'll get an additional vote for every friend you refer that signs up for Premium."
      else
        "You'll get your first vote when you sign up for a Premium account."
      end
    end
  %>

  <% Votable.all.each_with_index do |votable, i| %>
    <% if i == 2 %>
      </div>
      <div class="row">
    <% end %>

    <div class="col s12 m6">
      <div class="hoverable card" style="height: 280px;">
        <div class="card-content">
          <div class="row">
            <div class="col s12 m4">
              <div class="center"><i class="material-icons blue-text" style="font-size: 55px;"><%= votable.icon %></i></div>
              <h5 class="center"><%= votable.name %></h5>
              <p class="center">
                <% if user_signed_in? && free_votes.zero? %>
                  <span class="tooltipped"
                        data-delay="100"
                        data-tooltip="<%= disabled_voting_message %>">
                <% end %>
                <%=
                  link_to 'Vote',
                    cast_vote_path(votable),
                    class: "btn btn-primary blue #{'disabled' if !user_signed_in? || free_votes.zero?}"
                %>
                <% if user_signed_in? && free_votes.zero? %>
                  </span>
                <% end %>
                <br />
              </p>
              <p class="blue-text center" style="margin-top: 10px;">
                <%= pluralize votable.votes.count, 'vote' %>
              </p>
            </div>
            <div class="col s12 m8">
              <div class="spaced-paragraphs">
                <%= votable.description.html_safe %>
              </div>
              <% if user_signed_in? && cast_votes > 0 %>
                <p class="grey-text center" style="margin-top: 30px;">
                  You've voted for this feature <%= pluralize current_user.votes.where(votable: votable).count, 'time' %>.
                </p>
              <% end %>
            </div>
          </div>
        </div>
      </div>
    </div>
  <% end %>

  <h5 class="center">
    You have <span class="blue-text"><%= pluralize free_votes, 'vote' %></span> remaining.
  </h5>
  <div class="center">
    <%= link_to 'Earn more by sharing Notebook.ai with your friends.', friends_landing_path %>
  </div>
</div>

<div class="section">
  <div class="row">
    <div class="col s12">
      <h4>Frequently asked questions</h4>
      <ul class="collapsible" data-collapsible="expandable">
        <li>
          <div class="collapsible-header"><i class="material-icons">help_outline</i>When will voting be over?</div>
          <div class="collapsible-body"><span>
            Voting will end at noon UTC on June 15, 2017. At that time, the feature with the most votes will "win" and will be included in a feature release shortly after.
          </span></div>
        </li>
        <li>
          <div class="collapsible-header"><i class="material-icons">help_outline</i>How can I earn more votes?</div>
          <div class="collapsible-body"><span>
            When you sign up for a Premium subscription, you are given one vote to cast however you'd like. Whenever you <%= link_to 'refer a friend to Notebook.ai', friends_landing_path %> that signs up for Premium, you'll automatically be given two more feature votes (and an extra one for your friend).
          </span></div>
        </li>
        <li>
          <div class="collapsible-header"><i class="material-icons">help_outline</i>What will happen to the ideas that don't win?</div>
          <div class="collapsible-body"><span>
            Based on voting, the other features will be prioritized accordingly. If two features are neck-and-neck, you can expect to see the runner-up make it into a future feature update sooner rather than later, but only the winning feature is guaranteed to be released first after voting.
          </span></div>
        </li>
        <li>
          <div class="collapsible-header"><i class="material-icons">help_outline</i>What if I have a different idea?</div>
          <div class="collapsible-body"><span>
            To ensure that every idea has ample time to shine during voting, the options for this vote are closed. However, if you have other feature requests or feedback for Notebook.ai, <%= link_to "feedback is always much appreciated", 'https://docs.google.com/forms/d/e/1FAIpQLScOhSMdDqWqJu9HGPQdmd0R9s90_AcSo0g6_Nc1qNjQIbSaXA/viewform' %> (and may make it into future voting rounds if voting goes well!).
          </span></div>
        </li>
        <li>
          <div class="collapsible-header"><i class="material-icons">help_outline</i>Have any other questions?</div>
          <div class="collapsible-body"><span>
            I'm always happy to chat! Feel free to send me an email directly at an<span>d</span>re<strong></strong>w@<em></em>indent<span></span>labs<strong></strong>.c<em></em>om.
          </span></div>
        </li>
      </ul>
    </div>
  </div>
</div>