<?xml version="1.0" encoding="utf-8"?>
<rules xmlns="http://namespaces.plone.org/diazo"
       xmlns:css="http://namespaces.plone.org/diazo/css"
       xmlns:xhtml="http://www.w3.org/1999/xhtml"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:xi="http://www.w3.org/2001/XInclude">


    <theme href="backend.html" css:if-not-content="body.frontend"/>
    <theme href="contact.html" css:if-content="body.frontend.portaltype-formfolder"/>
    <theme href="post.html" css:if-content="body.frontend.portaltype-news-item"/>
    <theme href="index.html" css:if-content="body.frontend"/>

    <notheme css:if-not-content="#visual-portal-wrapper" />
      <rules css:if-content="#portal-top">
        <!-- Attributes -->
        <copy attributes="*" css:theme="html" css:content="html" />
        <!-- Base tag -->
        <before css:theme="head title" css:content="head base" />
        <!-- Title -->
        <replace css:theme="head title" css:content="head title" />
        <!-- Pull in Plone Meta -->
        <after css:theme-children="head" css:content="head meta" />
        <!-- dont use Plone icons, use the theme's -->
        <drop css:content="head link[rel='apple-touch-icon'], head link[rel='shortcut icon']" />
        <!-- CSS -->
        <after css:theme-children="head" css:content="head link" />
        <!-- Script -->
        <after css:theme-children="head" css:content="head script" />
      </rules>

      <!-- Copy over the id/class attributes on the body tag.
           This is important for per-section styling -->
      <copy attributes="*" css:content="body" css:theme="body" />

      <!-- toolbar -->
      <before
        css:theme-children="body"
        css:content-children="#edit-bar"
        css:if-not-content=".ajax_load"
        css:if-content=".userrole-authenticated"
        />

      <!--replace css:theme=".navbar-brand .brand-logo" css:content="#portal-logo"/>-->

      <!-- login link -->
      <!--<after
        css:theme-children="body"
        css:content="#portal-anontools"
        css:if-not-content=".ajax_load"
        css:if-content=".userrole-anonymous"
        />-->

      <!-- replace theme navbar-nav with Plone plone-navbar-nav -->
      <replace
        css:theme-children=".navbar-nav"
        css:content-children=".plone-navbar-nav" />

      <!-- Title and description -->
      <replace
        css:theme-children=".brand-name"
        css:content-children=".documentFirstHeading"
        method="raw" />
      <replace
        css:theme-children=".post-title"
        css:content-children=".documentFirstHeading"
        method="raw" />
      <replace
        css:theme-children=".documentFirstHeading"
        css:content-children=".documentFirstHeading"
        method="raw" />
      <replace
        css:theme=".documentDescription"
        css:content-children=".documentDescription"
        method="raw" />
      
      <drop css:content=".documentDescription"/>
      <drop css:content=".documentFirstHeading"/>

      <!-- viewlet-above-content -->
      <replace
        css:theme-children="#above-content"
        css:content-children="#viewlet-above-content-title"
        />

      <replace
        css:theme-children="#slickslideshow"
        css:content-children="#slickslideshow"
      />

      <drop css:content="#slickslideshow"/>

      <!-- Header -->
      <copy attributes="style" css:theme="header.intro-header" css:content="div.leadImageBackground"/>
      <drop css:content="div.leadImage"/>

      <!-- Post author / dates -->
      <replace
        css:theme-children="#author-container"
        css:content-children="#author-container"
        />

      <drop css:content="#author-container"/>

      <!-- full-width breadcrumb -->
      <!-- No breadcrumbs in this theme -->
      <drop css:content="#portal-breadcrumbs" />

      <!-- Alert message -->
      <replace
        css:theme-children="#global_statusmessage"
        css:content-children="#global_statusmessage"
        />

      <!-- Central column -->
      <replace css:theme="#content-container" method="raw">

          <xsl:variable name="central">
            <xsl:if test="//aside[@id='portal-column-one'] and //aside[@id='portal-column-two']">col-xs-12 col-sm-6</xsl:if>
            <xsl:if test="//aside[@id='portal-column-two'] and not(//aside[@id='portal-column-one'])">col-xs-12 col-sm-9</xsl:if>
            <xsl:if test="//aside[@id='portal-column-one'] and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-9</xsl:if>
            <xsl:if test="not(//aside[@id='portal-column-one']) and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12</xsl:if>
          </xsl:variable>

          <div class="{$central} no-padding">
            <div class="row no-margin">
                <div class="col-xs-12 col-sm-12 no-padding">
                  <xsl:apply-templates css:select="#content" />
                </div>
                <div class="clearfix"></div>
            </div>
            
            <section id="viewlet-below-content-body" class="row">
                <div class="col-xs-12 col-sm-12 no-padding">
                 <xsl:copy-of css:select="#viewlet-below-content" />
                </div>
                <div class="clearfix"></div>
            </section>

          </div><!--/row-->
      </replace>

      <!-- Left column -->
      <rules css:if-content="#portal-column-one">
        <replace css:theme="#column1-container">
            <div class="col-xs-6 col-sm-3 sidebar-offcanvas">
              <aside id="portal-column-one">
                 <xsl:copy-of css:select="#portal-column-one > *" />
              </aside>
            </div>
        </replace>
      </rules>

      <!-- Right column -->
      <rules css:if-content="#portal-column-two">
        <replace css:theme="#column2-container">
            <div class="col-xs-6 col-sm-3 sidebar-offcanvas" role="complementary">
              <aside id="portal-column-two">
                 <xsl:copy-of css:select="#portal-column-two > *"/>
              </aside>
            </div>
        </replace>
      </rules>

      <replace css:theme-children="footer .container" css:content-children="#portal-footer-wrapper" />
    
</rules>