<!doctype html>
<html lang="<%= I18n.locale %>">
  <head>
    <title><%= content_for?(:title) ? yield(:title) : t(:project_name) %></title>
    
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="turbo-prefetch" content="false">
    <meta name="turbo-cache-control" content="no-cache">
    <%= tag.meta name: "description", content: content_for?(:meta_description) ? yield(:meta_description) : (@node.present?? @node.page_description : "") %>

    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>    
    
    <link rel="apple-touch-icon" href="/ikea-favicon-300x300.png">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" sizes="16x16 32x32">
    <link rel="icon" sizes="192x192" href="/ikea-favicon-300x300.png">    

    <%= stylesheet_link_tag "reset", "application" %>  
    <%= frontend_javascript_importmap_tags %w[application @hotwired/turbo-rails @hotwired/stimulus language_menu_controller carousel_controller intro_controller chance_controller share_controller] %>
  </head>
  <body>
    <%= content_for :header %>

    <% if respond_to?(:current_player) && current_player %>
      <aside class="debug-score">
        <details open>
          <summary>Debug score (<%= current_player.score %>)</summary>
          <dl>
            <dt>Overall</dt><dd><%= current_player.score %></dd>
            <dt>Food Waste</dt><dd><%= current_player.score_for(:food_waste) %></dd>
            <dt>Emissions</dt><dd><%= current_player.score_for(:emissions) %></dd>
            <dt>Income</dt><dd><%= current_player.score_for(:income) %></dd>
            <dt>Done</dt><dd><%= current_player.is_done %></dd>
          </dl>
        </details>
      </aside>
    <% end %>

    <%= tag.main class: [@result_node, @node].compact.map { |n| n.template }.first,
                data: {
                  controller: content_for(:main_controller)
                } do %>
      <%= yield %>
    <% end %>

  </body>
</html>
