/**
 * Basic responsive layout from http://www.adamkaplan.me/grid/
 *
 * The rem to px conversions don't seem to hold on my Dell 2408 display,
 * but do seem correct on iOS. Need to look into this.
 */

/* Small screen is the default set of styles */
@screen-iphone-landscape: 35.5rem; /* ~ 568px */
@screen-medium: 40rem; /* ~ 640px */
@screen-large: 64rem;  /* ~ 1024px */

body {
  font-size: 100%;
}

@media (min-width: @screen-medium) {
  body { font-size: 112%; }
}

@media (min-width: @screen-large) {
  body { font-size: 120%; }
}

*, *:before, *:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.container {
  margin: 0 auto;
  max-width: 48rem;
  width: 90%;
  padding: 0 constant(safe-area-inset-right) 0 constant(safe-area-inset-left);
}

@media (min-width: @screen-medium) {
  .column {
    float: left;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .column.full { width: 100%; }
  .column.two-thirds { width: 66.7%; }
  .column.half { width: 50%; }
  .column.third { width: 33.3%; }
  .column.fourth { width: 24.95%; }
  .column.flow-opposite { float: right; }
}


/**
 * Modern clearfix hack
 * http://nicolasgallagher.com/micro-clearfix-hack/
 */
.clearfix:before,
.clearfix:after {
    content: " ";
    display: table;
}
.clearfix:after {
    clear: both;
}


/**
 * Super barebones responsive images
 */

img {
  max-width: 100%;
}


/**
 * Site styles
 * Light mode is the default
 */

// colors
@light-background: #f7f7f7;
@light-text: #222;
@light-highlight: #a00;
@light-separator-grey: #ddd;

@dark-background: #000;
@dark-text: #ddd;
@dark-highlight: #900;
@dark-separator-grey: #ddd;

@email-white: #fff;
@rss-orange: #f60;
@twitter-blue: #4099ff;
@github-blue: #4183c4;

// font weight
@weight-thin: 400;

// main styles
body {
  background-color: @light-background;
  color: @light-text;
  font-family: 'museo-sans', 'Helvetica Neue', 'Verdana', 'Roboto', sans-serif;
  padding-bottom: constant(safe-area-inset-bottom);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Helvetica Neue', 'Verdana', sans-serif;
}

nav {
  font-family: 'Helvetica Neue', 'Roboto', 'Arial', sans-serif;
}

a {
  color: lighten(@light-highlight, 5%);
}

a:visited {
  color: @light-highlight;
}

hr {
  width: 55%;
  height: 0;
  margin: 0 auto;
  border: 0;
  border-top: 1px solid @light-separator-grey;
}

header.primary {
  background-color: darken(@light-text, 5%);
  color: @light-background;
  padding: 0.4rem 2.5rem;
  border-bottom: solid 1px lighten(@light-text, 40%);
  box-shadow: 0 0 12px 2px @light-text;

  .title {
    float: left;
  }

  h1, h4 {
    display: inline-block;
    margin: 0;
    padding: 0;
    word-wrap: break-word;
    font-family: 'museo-sans', 'Helvetica Neue', 'Verdana', 'Roboto', sans-serif;
    font-weight: normal;
  }

  h1 {
    height: 1.3rem;
    font-size: 1.3rem;

    a, a:visited {
      color: @light-background;
    }
  }

  h4 {
    height: 0.8rem;
    font-size: 0.8rem;
    color: darken(@light-background, 10%);
  }

  h4 a {
    color: darken(@light-background, 10%);
    text-decoration: none;
  }

  h4 a:hover {
    color: @light-background;
    text-decoration: underline;
  }

  nav {

    padding-top: 0.5rem;
    clear: left;

    @media (min-width: @screen-iphone-landscape) {
      float: right;
      clear: none;

      padding-top: 0.65rem;
      height: 1rem;
    }

    a, a:visited {
      color: lighten(@light-highlight, 7%);
    }

    ul {
      margin: 0;
      padding: 0;

      li {
        display: inline-block;
        list-style-type: none;
        padding: 0.2rem 0.4rem;
        font-size: 1.3rem;
      }

      li:first-child {
        padding-left: 0;
      }

      li:last-child {
        padding-right: 0;
      }

      li i.fa {
        font-size: 1.4rem;
        padding: 0.2rem;
      }

      li.email i.fa {
        color: darken(@email-white, 10%);
      }

      li.rss i.fa {
        color: desaturate(@rss-orange, 20%);
      }

      li.twitter i.fa {
        color: desaturate(@twitter-blue, 20%);
      }

      li.github i.fa {
        color: @github-blue;
      }

    } /* ul */
  } /* nav */
} /* header.primary */

footer {
  padding: 1rem 0;
  text-align: center;
  color: lighten(@light-text, 30%);
  font-family: 'Helvetica Neue', 'Verdana', 'Roboto', sans-serif;

  a, a:visited {
    color: lighten(@light-text, 30%);
  }
}

// dark mode
@media (prefers-color-scheme: dark) {
  body {
    background-color: @dark-background;
    color: @dark-text;
  }  

  a {
    color: lighten(@dark-highlight, 5%);
  }

  a:visited {
    color: @dark-highlight;
  }

  hr {
    border-top-color: @dark-separator-grey;
  }

  header.primary {
    background-color: lighten(@dark-background, 7%);
    color: @dark-text;
    border-bottom: solid 1px lighten(@dark-background, 30%);
    box-shadow: 0 0 12px 2px lighten(@dark-background, 25%);

    h1 {
      a, a:visited {
        color: @dark-text;
      }
    }

    h4 {
      color: darken(@dark-text, 10%);
    }

    h4 a {
      color: darken(@dark-text, 10%);
    }

    h4 a:hover {
      color: @dark-text;
    }
    
    nav {
      a, a:visited {
        color: lighten(@dark-highlight, 10%);
      }
    }
  }

  footer {
    color: darken(@dark-text, 30%);

    a, a:visited {
      color: darken(@dark-text, 30%);
    }
  }
}

/**
 * Archive
 */

ul.archive {
  padding-left: 0;
  margin-left: 5%;
  margin-bottom: 2rem;
  list-style-type: none;

  @media (min-width: @screen-medium) {
    margin-right: 5%;
  }

  li {
    margin: 0.8rem 0;

    a {
      text-decoration: none;
    }

    time {
      font-size: 80%;
      padding-left: 0.5rem;
      color: lighten(@light-text, 30%);
    }

  } /* li */

} /* ul.archive */

@media (prefers-color-scheme: dark) {
  ul.archive {
    li {
      time {
        color: darken(@dark-text, 30%);
      }
    }
  }
}

/**
 * Projects
 */

.project-listing {
  margin-bottom: 1rem;

  h4, p {
    margin: 0.5rem 0;
  }

}

.project-stats {
  text-align: center;
  margin: 2rem 0;

  a {
    padding: 0 0.3rem;
  }

}

body.projects:not(.index) .container {
  h2, h4 {
    text-align: center;
  }
}

.project-info {

  h3 {
    text-align: center;
    margin-bottom: 0.2rem;
  }

  .column {
    margin-bottom: 2rem;
  }

  ul {
    padding-left: 0;
    text-align: center;

    li {
      list-style-type: none;
    }

  }

}


/**
 * Posts
 */

article {

  word-wrap: break-word;

  header {

    h2 {
      word-wrap: break-word;
      margin-bottom: 0.3rem;
    }

    time {
      margin-top: 0.3rem;
      color: lighten(@light-text, 35%);
      font-family: 'Helvetica Neue', 'Verdana', sans-serif;
    }

  }

}

p.fin {
  text-align: center;
  color: darken(@light-background, 20%);
  margin: 1rem 0;
}

blockquote {
  margin-left: 6%;
  font-family: 'Helvetica Neue', 'Verdana', 'Roboto', sans-serif;
  font-style: italic;
  color: lighten(@light-text, 15%);
}

blockquote:before {
  content: '\201F'; // left double curly quote
  float: left;
  margin-top: -0.35rem;
  margin-left: -1rem;
  font-size: 150%;
}

ul.audio li {
  height: 2rem;
  margin: 0.5rem 0;
}

ul.audio audio {
   vertical-align: middle;
}

pre {
  background-color: darken(@light-background, 5%);
  padding: 0.5rem;
}

pre.line-numbers {
  float: left;
  margin-top: 0;
  color: #888;
}

@media (prefers-color-scheme: dark) {
  article {
    header {
      time {
        color: darken(@dark-text, 20%);
      }
    }
  }

  p.fin {
    color: lighten(@dark-background, 30%);
  }

  blockquote {
    color: darken(@dark-text, 15%);
  }

  pre {
    background-color: lighten(@dark-background, 8%);
  }
}

/**
 * Improve embedded Gist styles
 */

.gist {
  font-size: 0.8rem;
  line-height: 1.2rem;
  font-family: 'Menlo', 'Courier New', monospace;
}

