// Copyright (C) 2020 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// -----------------------------------------------------------------------------
// Common + CSS reset
// -----------------------------------------------------------------------------
:root {
  --site-header-height: 52px;
  --home-highlights-height: 128px;
  --content-max-width: 1100px;
  --anim-ease: cubic-bezier(0.4, 0, 0.2, 1);

  // This is set to 1 by JS after onload. This is to prevent flickering on
  // page load on the nav bar and other entries while transitioning in their
  // initial state.
  --anim-enabled: 0;

  --anim-time: calc(0.15s * var(--anim-enabled));

  // Color system
  --color-primary: hsl(210, 30%, 16%);
  --color-primary-light: hsl(210, 25%, 22%);
  --color-accent: #ecba2a;
  --color-accent-hover: #d4a620;
  --color-text: #2d3748;
  --color-text-secondary: #5a6577;
  --color-text-muted: #8896a6;
  --color-border: #e2e8f0;
  --color-border-light: #edf2f7;
  --color-bg: #f7fafc;
  --color-bg-white: #fff;
  --color-link: #0e7c86;
  --color-link-hover: #0a9ba8;
  --color-link-visited: #7c4014;
}

$wide: "(max-width: 1100px)";
$mobile: "(max-width: 768px)";

@mixin minimal-scrollbar {
  &::-webkit-scrollbar {
    width: 6px;
    background-color: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 6px;
    &:hover {
      background-color: #a0aec0;
    }
  }
}

@media (max-aspect-ratio: 1/1) {
  :root {
    --home-highlights-height: 256px;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: none;
}

html {
  font-family: Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  padding: 0;
  margin: 0;
  overscroll-behavior-y: none;
}

h1,
h2,
h3 {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  padding: 0;
  margin: 0;
}

// -----------------------------------------------------------------------------
// Site header
// -----------------------------------------------------------------------------
.site-header {
  background-color: var(--color-primary);
  color: hsl(210, 17%, 98%);
  position: sticky; // Sticky so the .docs element below doesn't start @ 0.
  top: 0;
  width: 100%;
  --sh-padding-y: 6px;
  max-height: var(--site-header-height);
  padding: var(--sh-padding-y) 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  z-index: 10;
  transition: max-height var(--anim-ease) var(--anim-time);
  &.expanded {
    max-height: 100vh;
  }
  .brand {
    img {
      height: 40px;
      vertical-align: bottom;
    }
    font-weight: 200;
    font-size: 28px;
    flex-grow: 1;
    .brand-docs {
      text-transform: uppercase;
      font-size: 14px;
      color: var(--color-accent);
      vertical-align: bottom;
      line-height: 30px;
      font-weight: 400;
    }
  }
  > *:not(:first-child) {
    line-height: calc(var(--site-header-height) - var(--sh-padding-y) * 2);
    font-family: "Source Sans Pro", sans-serif;
    font-weight: 400;
    font-size: 1.1rem;
    margin: 0 20px;
    color: hsl(210, 17%, 85%);
    transition: color ease 0.15s;
  }
  a {
    text-decoration: none;
    &:hover {
      color: #fff;
    }
  }
  .menu {
    visibility: hidden;
    font-family: "Material Icons Round";
    font-size: 24px;
    text-align: center;
    position: absolute;
    right: 0;
    top: 0;
    line-height: var(--site-header-height);
  }

  @media #{$mobile} {
    flex-direction: column;
    > *:not(:first-child) {
      margin-left: 40px;
    }
    .menu {
      visibility: visible;
    }
  }
}

#search {
  position: relative;
  flex-grow: 0;
  transition:
    flex-grow cubic-bezier(1, 0.01, 1, 1) var(--anim-time),
    background-color ease var(--anim-time);
  padding: 0;
  &::before {
    visibility: hidden;
    user-select: none;
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    top: var(--site-header-height);
    bottom: 0;
    z-index: -100;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition:
      opacity ease var(--anim-time),
      visibility 0s;
  }
  &:focus-within {
    flex-grow: 1000;
    &::before {
      display: block;
      opacity: 1;
      visibility: visible;
    }
    #search-res {
      display: block;
    }
  }

  @media #{$mobile} {
    display: none;
  }

  #search-box {
    width: 100%;
    height: 32px;
    font-size: 1rem;
    color: #333;
    background-color: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background-image: url('data:image/svg+xml;utf-8,<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48" fill="%23999"><path d="M39.8 41.95 26.65 28.8q-1.5 1.3-3.5 2.025-2 .725-4.25.725-5.4 0-9.15-3.75T6 18.75q0-5.3 3.75-9.05 3.75-3.75 9.1-3.75 5.3 0 9.025 3.75 3.725 3.75 3.725 9.05 0 2.15-.7 4.15-.7 2-2.1 3.75L42 39.75Zm-20.95-13.4q4.05 0 6.9-2.875Q28.6 22.8 28.6 18.75t-2.85-6.925Q22.9 8.95 18.85 8.95q-4.1 0-6.975 2.875T9 18.75q0 4.05 2.875 6.925t6.975 2.875Z"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
    padding-left: 40px;
    outline: none;
    color: rgba(255, 255, 255, 0.9);
    transition: background-color ease 0.15s, border-color ease 0.15s;
    &::placeholder {
      color: rgba(255, 255, 255, 0.5);
    }
    &:hover {
      background-color: rgba(255, 255, 255, 0.18);
      border-color: rgba(255, 255, 255, 0.25);
    }
    &:focus {
      background-color: rgba(255, 255, 255, 0.95);
      border-color: var(--color-accent);
      color: #333;
    }
  }

  #search-res {
    display: none;
    background-color: rgba(255, 255, 255, 1);
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    color: #333;
    line-height: initial;
    margin-top: 4px;
    overflow-x: auto;
    position: fixed;
    top: var(--site-header-height);
    max-height: calc(100vh - var(--site-header-height));
    z-index: 10;
    > div {
      padding: 12px 16px;
      margin: 0;
      border-bottom: 1px solid var(--color-border-light);
      &:last-child {
        border-bottom: none;
      }
      &:hover {
        background-color: #f7fafc;
      }
    }
    .sr-title {
      color: var(--color-text);
      font-weight: 600;
    }
    .sr-snippet {
      color: var(--color-text-secondary);
      font-size: 0.9rem;
    }

    a {
      text-decoration: none;
    }
    a:hover {
      color: initial;
    }

    &:empty {
      visibility: hidden;
    }
  }
}

// -----------------------------------------------------------------------------
// Site footer
// -----------------------------------------------------------------------------

// Footer in the index page.
.site-footer {
  background-color: var(--color-primary);
  padding: 1.25em 0;
  font-size: 14px;
  color: #fff;
  text-align: center;
  ul {
    list-style: none;
    margin: 0;
    padding: 0;
    li {
      display: inline;
      padding: 0 10px;
      &:not(:last-child) {
        border-right: solid 1px rgba(255, 255, 255, 0.3);
      }
    }
  }
  a,
  a:visited {
    text-decoration: none;
    color: inherit;
  }
  .docs-footer-notice {
    display: none;
  }
}

// Footer overrides for the /docs/ page.
.docs .site-footer {
  grid-area: footer;
  background: transparent;
  color: var(--color-text-muted);
  text-align: left;
  margin: 0 20px;
  padding: 12px 0;

  .docs-footer-notice {
    padding: 0;
    margin: 0;
    display: block;
  }

  ul {
    display: none;
  }
}

// -----------------------------------------------------------------------------
// Site content
// -----------------------------------------------------------------------------
.site-content {
  .section-wrapper {
    border-bottom: solid 1px var(--color-border-light);
    &:nth-child(2n + 1) {
      background-color: var(--color-bg);
    }
  }
  section {
    display: block;
    position: relative;
    overflow: hidden;
    padding: 0 20px;
    margin: 0 auto;
    max-width: calc(var(--content-max-width) + 2 * 20px);
  }

  .banner {
    height: calc(
      100vh - var(--home-highlights-height) - var(--site-header-height)
    );
    @media (max-height: 639px) {
      // If the screen is too short (e.g. smartphone in landscape mode)
      // move the highlights sections (the four tiles) out of the visible
      // viewport.
      height: calc(100vh - var(--site-header-height));
    }
    min-height: 25vw;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr 5fr;
    h1,
    h2 {
      margin: auto;
      font-family: "Source Sans Pro", sans-serif;
      text-align: center;
      color: var(--color-text);
      span {
        white-space: nowrap;
      }
    }
    h1 {
      font-size: 2.5rem;
      font-size: calc(min(4rem, 8vw, 6vh));
      font-weight: 400;
      padding-top: calc(max(1rem, 2vh));
    }
    h2 {
      font-size: 1.25rem;
      font-size: calc(min(2rem, 6vw, 4vh));
      font-weight: 200;
      padding-top: 10px;
      color: var(--color-text-secondary);
    }
    .home-img {
      padding: 1rem 0;
      overflow: hidden;
      position: relative;
      display: flex;
      img {
        max-height: 100%;
        max-width: 100%;
        margin: auto;
        display: block;
      }
    }
  }

  .home-highlights {
    &:before {
      border-top: 1px solid var(--color-border);
    }
    height: var(--home-highlights-height);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr;
    background-color: #fff;
    z-index: 2;
    @media (max-aspect-ratio: 1/1) {
      grid-template-columns: repeat(2, 1fr);
    }
    > a {
      color: var(--color-text);
      font-size: 22px;
      font-weight: 400;
      text-align: center;
      padding: 20px 0;
      font-family: "Source Sans Pro", sans-serif;
      text-decoration: none;
      transition: background-color ease 0.15s;
      .icon {
        background-image: url("/assets/sprite.png");
        background-repeat: no-repeat;
        width: 64px;
        height: 64px;
        margin: auto;
        background-size: 256px 128px;
        filter: grayscale(1);
        transition: filter ease var(--anim-time);
      }
      &:nth-child(1) .icon {
        background-position: 0 -64px;
      }
      &:nth-child(2) .icon {
        background-position: -64px -64px;
      }
      &:nth-child(3) .icon {
        background-position: -128px -64px;
      }
      &:nth-child(4) .icon {
        background-position: -192px -64px;
      }
      &:hover {
        background-color: var(--color-bg);
        .icon {
          filter: grayscale(0);
        }
      }
    }
  }
  .home-section {
    min-height: calc(min(100vh - var(--site-header-height), 800px));
    padding: 5% 20px;
    display: grid;
    grid-template-rows: 1fr;
    grid-column-gap: 4vw;
    > img {
      grid-area: img;
      max-width: 100%;
      max-height: 55vh;
      margin: auto;
      margin-top: 40px;
    }
    h2,
    > div {
      grid-area: content;
    }
    h2 {
      font-family: "Source Sans Pro", sans-serif;
      font-weight: 600;
      font-size: 2.5rem;
      color: var(--color-text);
      text-align: center;
    }
    &:nth-child(2n) {
      grid-template-columns: 5fr 4fr;
      grid-template-areas: "content img";
      h2 {
        padding: 0 0 0 50px;
        text-align: left;
      }
    }
    &:nth-child(2n + 1) {
      grid-template-columns: 4fr 5fr;
      grid-template-areas: "img content";
      h2 {
        padding: 0 50px 0 0;
        text-align: left;
      }
    }
    @media (max-aspect-ratio: 1/1) {
      padding: 5vh 20px;
      &:nth-child(n) {
        grid-template-rows: auto auto;
        grid-template-columns: 1fr;
        grid-template-areas: "img" "content";
        grid-row-gap: 30px;
        h2 {
          padding: 0;
          text-align: center;
        }
      }
      > img {
        padding: 0 10vw;
      }
    }
    div {
      grid-area: content;
      .button {
        display: inline-block;
        background: var(--color-link);
        font-weight: 500;
        color: #fff;
        border-radius: 6px;
        font-size: 18px;
        padding: 10px 16px;
        transition: background-color ease 0.15s, transform ease 0.15s;
        text-decoration: none;
        &:hover {
          background: var(--color-link-hover);
          transform: translateY(-1px);
        }
      }
    }
    .home-item {
      display: grid;
      grid-template-rows: auto auto;
      grid-template-columns: 50px auto;
      grid-template-areas: "img title" "img label";
      grid-column-gap: 20px;
      padding: 20px 30px;
      margin: 10px 0;
      font-family: "Source Sans Pro", sans-serif;
      color: var(--color-text);
      transition:
        filter var(--anim-ease) var(--anim-time),
        background-color var(--anim-ease) var(--anim-time),
        transform var(--anim-ease) var(--anim-time),
        box-shadow linear var(--anim-time);
      border-radius: 8px;
      filter: opacity(0.6);
      &:hover {
        background-color: hsla(0, 0, 0, 0.02);
        filter: opacity(1);
        transform: scale(1.01);
      }
      > img,
      > i {
        grid-area: img;
        margin: auto;
        font-size: 50px;
        color: var(--color-text-muted);
      }
      > h3 {
        grid-area: title;
        font-size: 1.25rem;
        line-height: 20px;
        font-weight: 600;
      }
      > p {
        grid-area: label;
        font-size: 1rem;
        font-weight: 400;
        margin: 1em 0;
        color: var(--color-text-secondary);
      }
    }
  }
}

// -----------------------------------------------------------------------------
// Chinese docs banner
// -----------------------------------------------------------------------------
.cn-docs-banner {
  background-color: #e8f0fe;
  border-bottom: 1px solid #a8c7fa;
  color: #1a3966;
  font-family: "Source Sans Pro", sans-serif;
  padding: 8px 16px;
  text-align: center;
  a {
    color: #1967d2;
    text-decoration: underline;
    font-weight: 500;
  }
  button {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #1a3966;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    &:hover {
      color: #000;
    }
  }
}

// -----------------------------------------------------------------------------
// Docs
// -----------------------------------------------------------------------------
.docs {
  min-height: 100vh;
  display: grid;
  --nav-width: 260px;
  --toc-min-width: 180px;
  --toc-max-width: 320px;

  // 1665px is the clientWidth on a macbook pro. Adjust the layout so that
  // the max-width of the central .doc fits precisely when the browser is
  // full-screen on a macbook.
  --max-doc-width: calc(1665px - var(--toc-min-width) - var(--nav-width));

  grid-template-columns: var(--nav-width) minmax(auto, var(--max-doc-width)) minmax(var(
      --toc-min-width), 1fr);
  grid-template-rows: 1fr max-content;
  grid-template-areas: "nav doc toc" "nav footer toc";

  background-color: var(--color-bg);

  .nav {
    grid-area: nav;
    border-right: 1px solid var(--color-border);
    background-color: var(--color-bg-white);
    padding: 0 12px 12px 0;
    position: sticky;
    top: var(--site-header-height);
    height: calc(100vh - var(--site-header-height));
    overflow-y: auto;
    @include minimal-scrollbar;

    // ---- Audience filter (caption + chips) ----
    .audience-filter {
      padding: 10px 12px 10px 16px;
      border-bottom: 1px solid var(--color-border-light);
      margin-bottom: 4px;

      .audience-filter-caption {
        font-size: 0.72rem;
        line-height: 1.2;
        color: var(--color-text-muted);
        margin-bottom: 6px;
      }

      .audience-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
      }

      .audience-tag {
        font-family: inherit;
        font-size: 0.75rem;
        font-weight: 500;
        line-height: 1;
        padding: 4px 8px;
        border-radius: 999px;
        border: 1px solid var(--color-border);
        background-color: var(--color-bg-white);
        color: var(--color-text-secondary);
        cursor: pointer;
        transition: background-color 0.12s ease, color 0.12s ease,
                    border-color 0.12s ease;
        -webkit-tap-highlight-color: transparent;
        white-space: nowrap;
        &:hover {
          color: var(--color-text);
          border-color: var(--color-text-muted);
        }
        &.active {
          background-color: var(--color-link);
          border-color: var(--color-link);
          color: #fff;
        }
      }
    }

    // ---- Base reset for all lists and links ----
    ul {
      list-style: none;
      margin: 0;
      padding: 0;
      overflow: hidden;
      li {
        font-size: 1rem;
        font-weight: 400;
        font-family: "Source Sans Pro", sans-serif;
        color: #4a4a4a;
        max-width: 100%;
        margin: 0;
      }
      p { margin: 0; }
    }

    a {
      display: flex;
      align-items: center;
      color: var(--color-text-secondary);
      text-decoration: none;
      line-height: 1.4;
      padding: 5px 16px;
      border-radius: 0 6px 6px 0;
      transition: background-color 0.12s ease, color 0.12s ease;
      -webkit-tap-highlight-color: transparent;
      &[href]:hover {
        color: var(--color-text);
        background-color: var(--color-bg);
      }
      &.selected {
        background-color: var(--color-bg);
        color: var(--color-link);
        font-weight: 600;
      }
    }

    // ---- Top-level sections (Overview, Getting Started, etc.) ----
    > ul > li {
      padding: 10px 0 4px;
      & + li {
        border-top: 1px solid var(--color-border-light);
      }

      > p > a {
        font-weight: 700;
        color: var(--color-link);
        padding: 4px 16px;
        letter-spacing: 0.01em;
        text-transform: none;
        border-left: 3px solid var(--color-link);
      }
    }

    // ---- Category headers (Tutorials, Reference, etc.) ----
    // Use individual padding props here so the indentation ladder below can
    // control padding-left per depth without being masked by the shorthand.
    .compressible > p > a,
    a:not([href]) {
      font-weight: 600;
      color: var(--color-text);
      text-transform: uppercase;
      letter-spacing: 0.03em;
      padding-top: 6px;
      padding-right: 16px;
      padding-bottom: 4px;
    }

    // ---- Expand/collapse chevron ----
    .compressible {
      > p > a::after {
        content: "\25B4";
        font-size: 0.7em;
        flex-shrink: 0;
        width: 20px;
        text-align: center;
        margin-left: auto;
        color: #666;
        transition: transform var(--anim-ease) var(--anim-time);
      }
      > ul {
        transition: max-height var(--anim-ease) var(--anim-time),
          opacity var(--anim-ease) var(--anim-time);
        opacity: 1;
      }
      &.compressed {
        > ul {
          // !important overrides the inline max-height set by JS.
          max-height: 0 !important;
          visibility: hidden;
          opacity: 0;
        }
        > p > a::after {
          transform: rotate(180deg);
        }
      }
    }

    // ---- Indentation ladder ----
    // Consistent 12px step per nesting level so categories and their children
    // read as visually nested. Previously levels 1 and 2 were both at 16px,
    // which made category headers look coplanar with their parent top section.
    //   L1: top section link     -> 16px (via > ul > li > p > a above + 3px border)
    //   L2: category header      -> 28px
    //   L3: leaf / nested-cat    -> 40px
    //   L4: leaf in nested cat.  -> 52px
    li a { padding-left: 16px; }
    li li a { padding-left: 28px; }
    li li li a { padding-left: 40px; }
    li li li li a { padding-left: 52px; }
    li li li li li a { padding-left: 64px; }
  }
  .doc {
    grid-area: doc;
    background-color: var(--color-bg-white);
    margin: 20px;
    padding: 36px 48px;
    font-family: Roboto, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    color: var(--color-text);
    position: relative;
    border-radius: 8px;
    box-shadow:
      0 1px 3px rgba(0, 0, 0, 0.06),
      0 1px 2px rgba(0, 0, 0, 0.08);
    overflow: hidden;

    a {
      text-decoration: none;
      transition: color ease 0.1s;
      &:link {
        color: var(--color-link);
      }
      &:visited {
        color: var(--color-link-visited);
      }
      &:hover {
        color: var(--color-link-hover);
        text-decoration: underline;
      }
      &[href^="http"] {
        // External link.
        &:after {
          content: "open_in_new";
          font-family: "Material Icons Round";
          color: var(--color-text-muted);
          text-decoration: none;
          margin-left: 2px;
          margin-right: 4px;
          vertical-align: bottom;
        }
      }
    }

    h1,
    h2,
    h3 {
      margin: 10px 0;
      padding: 0;
      padding-top: 30px;
      color: var(--color-text);
    }
    h1 {
      font-size: 2.25rem;
      line-height: 2.25rem;
      margin: 0;
      padding: 0;
      margin-bottom: 1.5rem;
      font-family: "Source Sans Pro", sans-serif;
    }
    h2 {
      font-size: 1.5rem;
      border-bottom: 1px solid #e8eaed;
      padding-bottom: 6px;
    }
    h3 {
      font-size: 1.25rem;
    }
    * {
      max-width: 100%;
    }

    img[alt$="screenshot"] {
      box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
      border-radius: 6px;
    }

    code:not(.code-block) {
      background: #f1f5f9;
      border: 1px solid #e8eaed;
      border-radius: 6px;
      padding: 1px 4px;
    }
    .code-block {
      overflow-x: auto;
      white-space: pre;
      border-radius: 8px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
      border-top: 3px solid #8bc34a;
    }
    // Hide mermaid graphs until they are rendered, this is to avoid showing
    // the mermaid source while the renderer generates the SVG.
    .mermaid {
      transition: opacity var(--anim-ease) var(--anim-time);
      &:not(.rendered) {
        opacity: 0;
      }
    }
    .anchor {
      margin-left: -29px;
      padding-right: 5px;
      text-decoration: none;
      position: absolute;
      padding-top: var(--site-header-height);
      margin-top: calc(-1 * var(--site-header-height));
      outline: none;
      opacity: 0;
      transition: opacity var(--anim-ease) var(--anim-time);
      &::before {
        content: "insert_link";
        font-family: "Material Icons Round";
        color: #333;
        font-size: 24px;
      }
    }
    *:hover .anchor {
      opacity: 1;
    }
    code {
      font-family: "Roboto Mono", monospace;
      font-size: 14px;
    }
    table {
      width: 100%;
      font-size: 14px;
      border-spacing: 0;
      border-collapse: collapse;
      border-radius: 6px;
      overflow: hidden;
      th,
      td {
        padding: 10px 12px;
        border: 0 solid var(--color-border);
        border-top-width: 1px;
        border-bottom-width: 1px;
      }
      tr {
        height: 20px;
      }
      tr:target {
        background-color: #fef3cd;
      }
      thead {
        text-align: left;
        background-color: var(--color-bg);
        color: var(--color-text);
        font-weight: 600;
      }
      tbody tr:hover {
        background-color: #fafbfc;
      }
    }

    &[data-md-file^="/docs/reference/"] {
      h1,
      h2,
      h3 {
        code {
          margin-left: 20px;
          color: var(--color-text-secondary);
        }
      }
      table {
        width: 100%;
        font-size: 14px;
        border-spacing: 0;
        border-collapse: collapse;
        th,
        td {
          padding: 10px 12px;
          border: 0 solid var(--color-border);
          border-top-width: 1px;
          border-bottom-width: 1px;
        }
        tr {
          height: 20px;
        }
        thead {
          text-align: left;
          background-color: var(--color-bg);
          color: var(--color-text);
        }
        td {
          &:first-child {
            background: #fafbfc;
          }

          /* Not really 100% but makes sure that the description
                     * column takes most of the width */
          &:last-child {
            width: 80%;
          }
        }
      }
    }

    .callout {
      padding: 1rem 1rem 1rem 2.5rem;
      border: none;
      border-radius: 8px;
      margin: 1.25em auto;
      width: 92%;
      border-left: 4px solid transparent;
      box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.06),
        0 0 1px rgba(0, 0, 0, 0.08);
      line-height: 1.6;

      &:before {
        font-family: "Material Icons Round";
        position: absolute;
        font-size: 1.5rem;
        margin-left: -1.75rem;
        margin-top: -2px;
      }

      &.note {
        background-color: #eff6ff;
        border-color: #3b82f6;
        color: #1e40af;
        &:before {
          content: "bookmark";
        }
      }

      &.summary {
        background-color: #ecfeff;
        border-color: #06b6d4;
        color: #0e7490;
        &:before {
          content: "sms";
        }
      }

      &.tip {
        background-color: #f0fdf4;
        border-color: #22c55e;
        color: #166534;
        &:before {
          content: "star";
        }
      }

      &.todo {
        background-color: #f8fafc;
        border-color: #94a3b8;
        color: #475569;
        &:before {
          content: "error";
        }
      }

      &.warning {
        background-color: #fef2f2;
        border-color: #ef4444;
        color: #991b1b;
        &:before {
          content: "warning";
        }
      }
    }

    .tab-box {
      border: 1px solid var(--color-border);
      border-radius: 8px;
      padding: 0;
      overflow: hidden;
    }

    .tab-buttons {
      border-bottom: 1px solid var(--color-border);
      background-color: var(--color-bg);
    }

    .tab-button {
      cursor: pointer;
      border: none;
      background: transparent;
      font-family: Roboto, sans-serif;
      font-size: 1rem;
      padding: 8px;
      color: var(--color-text-secondary);
      transition: color ease 0.1s, border-color ease 0.1s;
      &:hover {
        color: var(--color-text);
        background-color: rgba(0, 0, 0, 0.03);
      }
      &.tab-button-selected {
        color: var(--color-text);
        border-bottom: 3px solid var(--color-accent);
      }
    }

    .tab-content {
      display: none;
      padding: 12px 16px;

      &.tab-content-selected {
        display: block;
      }
    }
  }
  .toc {
    grid-area: toc;
    padding: 24px 16px 24px 0;
    max-width: var(--toc-max-width);

    position: sticky;
    top: var(--site-header-height);
    height: calc(100vh - var(--site-header-height));
    overflow-y: auto;
    @include minimal-scrollbar;

    font-family: "Source Sans Pro", sans-serif;
    word-break: break-word;
    a {
      text-decoration: none;
      transition: color ease 0.1s;
    }
    a,
    a:visited {
      color: var(--color-text-secondary);
    }
    a:hover {
      color: var(--color-text);
    }
    a.highlighted {
      font-weight: 600;
      color: #b8860b;
    }
    font-size: 0.875rem;
    ul {
      list-style: none;
      margin: 0;
      padding: 0;
      li {
        margin: 4px 0;
        /* This make it so that a single word gets elided but if there
                 * are multiple words they span across lines.  */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: break-spaces;
        word-break: normal;
      }
    }
    > ul {
      border-left: 3px solid var(--color-accent);
      padding-left: 12px;
      position: static; // Otherwise gets v-centered in the middle.
      top: calc(var(--site-header-height) + 25px);
    }
  }

  @media #{$wide} {
    grid-template-columns: var(--nav-width) auto 0;
    .toc {
      display: none;
    }
  }
  @media #{$mobile} {
    display: block;
    .doc {
      margin: 0;
      padding: 20px;
      border-radius: 0;
    }
    .nav {
      // JS will persistently toggle to .after_first_click. This is to
      // avoid spurious transitions on page load.
      display: none;

      --nav-width-mobile: calc(min(90vw, 360px));
      width: var(--nav-width-mobile);
      position: fixed;
      z-index: 2;
      height: 100vh;
      overflow-y: auto;
      top: var(--site-header-height);
      transition:
        transform var(--anim-ease) var(--anim-time),
        box-shadow var(--anim-ease) var(--anim-time),
        visibility ease var(--anim-time);
      transform: translateX(calc(-1 * var(--nav-width-mobile)));
      visibility: hidden;
      > ul {
        position: static;
        top: 0;
      }
      &.after_first_click {
        display: block;
      }
      &.expanded {
        visibility: visible;
        transform: translateX(0);
        box-shadow: 0 1px 0 100vw rgba(0, 0, 0, 0.4);
      }
    }
  }
}
