@import "util";
@import "color-map";

/*
 * Sidebar
 *
 * Flexible banner for housing site name, intro, and "footer" content. Starts
 * out above content in mobile and later moves to the side with wider viewports.
 */

.sidebar {
  padding: 1rem;
  color: rgba(255, 255, 255, .5);
  background-color: #202020;
  height: 100%;
  .recent ul {
    padding-left: 0;
    list-style: none;
  }
  @include hasSmall {
    padding: 1rem;
  }
}

@include hasWide {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 18rem;
    text-align: left;
  }
}

/* Sidebar links */
.sidebar a {
  color: #fff;
}

/* About section */
.sidebar-about h1 {
  color: #fff;
  margin-top: 0;
  font-family: "Abril Fatface", serif;
  font-size: 3.25em;
}

/* Sidebar nav */
.sidebar-nav {
  margin-bottom: 1em;
  @media (max-height: 820px) {
    font-size: 90%;
  }
}

.sidebar-nav-item {
  display: block;
}

a.sidebar-nav-item:hover,
a.sidebar-nav-item:focus {
  text-decoration: underline;
}

.sidebar-nav-item.active {
  font-weight: bold;
}

/* Sticky sidebar
 *
 * Add the `sidebar-sticky` class to the sidebar's container to affix it the
 * contents to the bottom of the sidebar in tablets and up.
 */

@include hasWide {
  .sidebar-sticky {
    position: absolute;
    right: 1em;
    bottom: 1em;
    left: 1em;
  }
}

@include hasWide {
  .recent-posts {
    font-size: 80%;
    li {
      margin: 0.5em 0;
    }
  }
}

/* Sidebar links */
.sidebar a {
  color: white;
  &:hover {
    color: #95ade0;
  }
}

.profile {
  img {
    display: block;
    width: 128px;
    height: 128px;
    margin: 0 auto;
    border-radius: 64px;
  }
  h2 {
    color: #ffffff;
    margin: 0;
    text-shadow: 1px 1px #000;
  }
  @include hasWide {
    h2 {
      text-align: center;
    }
  }
  @include hasSmall {
    & {
      display: inline-table;
      margin-right: 16px;
    }
    img {
      width: 48px;
      height: 48px;
      border-radius: 24px;
      margin-right: 16px;
      vertical-align: middle;
    }
    h2 {
      vertical-align: middle;
      display: table-cell;
    }
  }

}

.social {
  text-align: center;
  padding: 10px;
  a, img {
    width: 32px;
    height: 32px;
  }
  img {
    margin: 0 1rem;
  }
  a {
    &.twitter {
      &:hover {
        background: lighten(#1da1f2, 10%);
      }
      background: #1da1f2;
    }
    &.bluesky {
      &:hover {
        background: lighten(skyblue, 10%);
      }
      background: skyblue;
    }
    &.github {
      &:hover {
        background: lighten(black, 30%);
      }
      background: black;
    }
    &.rss {
      &:hover {
        background: lighten(orange, 20%);
      }
      background: orange;
    }
    color: #000;
    text-decoration: none;
    border: 1px solid #5b5b5b;
    &:hover {
      background: $link-color;
    }
  }
}

// モバイルの時は最近の投稿とカテゴリ一覧は隠す
@include hasSmall {
  .sidebar > .container {
    padding: 0; // 余計なマージは削る
  }
  .profile {
    float: left;
    height: 48px;
  }
  .social {
    height: 48px;
    padding: 0px;
    text-align: left;
    margin-left: 1rem;
    img {
      margin: 0 .5rem;
    }
  }
  .categories-list, .recent-posts {
    display: none;
  }
  .recent-posts-list-title, .categories-list-title {
    font-size: 1rem;
    margin: 0;
    &:before {
      content: "▶";
      margin-right: 1em;
    }
  }
}

// search

.search {
  $search-box-height: 1.5rem;
  margin: 1em 0;
  .search-box {
    position: relative;
    // search | submit
    // design idea from http://hail2u.net/blog/
    input[type="search"] {
      font-size: 1.0rem;
      width: 100%;
      right: 0;
      height: $search-box-height;
      margin: 0;
      padding: 0;
      border: 0px none;
      &:focus {
        box-sizing: border-box;
        box-shadow: 0 0 5px rgba(81, 203, 238, 1);
        border: 1px solid rgba(81, 203, 238, 1);
      }
    }
    input[type="submit"] {
      text-indent: -9999px;
      cursor: pointer;
      border: 0px none;
      padding: 0;
      right: 0px;
      bottom: 0px;
      position: absolute;
      width: $search-box-height;
      height: $search-box-height;
      background: rgb(202, 197, 190) url('../svg/search.svg') no-repeat center top;
      background-size: 100% auto;
    }
    input[type="search"]:focus + input[type="submit"] {
      background-color: #3598c3;
    }
  }
}
