* { box-sizing: border-box; }

html {
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.4;
  margin: 0;
  padding: 0;
}

body {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
  display: grid;
  gap: 2rem;
  grid-template-areas:
    "header"
    "main"
    "footer";
}

body.page-index {
  grid-template-areas:
    "header header"
    "aside main"
    "footer footer";
  grid-template-columns: 250px auto;
  grid-template-rows: auto 1fr auto;
}

h1,h2,h3,h4,h5,h6,p {
  margin-top: 0;
  margin-bottom: 0.75em;
}

a {
  color: #552e08;
  text-underline-offset: 2px;
}

a:hover,
a:active {
  color: #dd6b00;
}

header {
  grid-area: header;
  padding: 11px 1rem 11px 0;
  text-align: center;
  background: linear-gradient(-90deg, #f0790922, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;

  h1 {
    font-size: 1.6rem;
    line-height: 1.2;
    font-family: monospace;
    text-transform: uppercase;
    margin: 0;
    text-align: left;

    a {
      color: #371e06;
    }

    a:not(:hover):not(:focus) {
      text-decoration: none;
    }

    span.top {
      font-size: 0.65em;
      opacity: 0.8;
    }

    span.mobile {
      display: none;
    }
  }
}

nav {
  ul {
    list-style: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  a {
    margin: 0 -1.6em;
    color: #552e08;
    text-decoration-color: #f07909;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    transform: rotate(-33deg) skew(-22deg) translate(-30%, 71%) scale(1.3);
    transform-origin: 0 0;
    display: inline-block;
    transition: .2s all;
    white-space: nowrap;
    width: 104px;
  }

  a:hover,
  a:active {
    color: #f07909;
    text-decoration-thickness: 4px;
  }
}

aside {
  grid-area: aside;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
}

footer {
  grid-area: footer;
}

main {
  grid-area: main;
}

form label,
form .label {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin: 0.5rem 0 1rem;
}

.estimated-sag {
  color: #f07909;
  font-weight: 700;
  align-items: center;

  span {
    font-size: 1.2rem;
    font-family: monospace;
  }
}

fieldset {
  width: 100%;
  margin: 0 0 1.5rem;
  padding: 0;
  border: none;
}

fieldset > div:first-child {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

fieldset > div:first-child hr {
  all: unset;
  border-top: 1px solid #d0d0d0;
  margin: 0;
  flex-grow: 1;
}

legend {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0;
  margin: 0;
}

input,
select {
  appearance: none;
  font-size: 1rem;
  background-color: white;
  border: 1px solid #d5d5d5;
  border-top-color: rgb(213, 213, 213);
  border-bottom-color: rgb(213, 213, 213);
  border-top-color: #00000017;
  border-bottom-color: #00000036;
  border-radius: 0.35em;
  font-size: 1rem;
  padding: 0.25em 0.65em;
  line-height: 1;
  box-shadow: 0 0.05em 0.15em #0000001a, 0 0.15em 0.9em #00000005;
}

input { max-width: 6em; }
select { line-height: 1.15; }

.search {
  position: relative;
  flex-grow: 1;
  max-width: 300px;
}

#search-results {
  position: absolute;
  z-index: 1;
  background: white;
  width: 100%;
  top: 2.3rem;
  border-radius: 0.6rem;
  box-shadow: 0 0.05em 0.15em #0000001a, 0 0.15em 0.9em #00000005;
  padding: 0.4rem 0;
}

#search-results > div {
  padding: 0.3rem 0.5rem;
}

#search-results > div[data-bike]:hover,
#search-results > div[data-bike]:focus {
  background: #efefef;
  cursor: pointer;
}

#search-results > div[data-bike] p {
  font-weight: 700;
  margin: 0;
}

#search-results > div[data-bike] small span {
  display: inline-block;
}


#search-results > div[data-bike] .meta {
  margin-right: 1em;
}

#search-results > div[data-bike] .metakey {
  text-transform: capitalize;
  margin-right: 0.3em;
  opacity: 0.7;
}

#search-results > div.empty,
#search-results > div.prompt {
  text-align: center;
}

#search-results > div.prompt {
  font-style: italic;
  opacity: 0.5;
}

#search-results > div.empty a {
  display: block;
  font-size: 0.8em;
}

#search-results > div.info {
  text-align: center;
  opacity: 0.5;
  font-size: 0.8em;
  margin-top: 0.7em;
}


input[type="search"] {
  max-width: none;
  width: 100%;
  padding: 0.25em 0.75em;
  border-radius: 20px;
}

input[type="search"]:not(:focus) {
  background: #efefef;
  box-shadow: none;
  border-color: #efefef;
}

button {
  appearance: none;
  font-size: 1.5rem;
  font-weight: 700;
  font-style: italic;
  font-family: monospace;
  display: block;
  padding: 0.5em 1em;
  border: none;
  border-radius: 0.5em;
  color: #f07909;
  background: white;
  box-shadow: 0 2px 0 5px #f07909;
  position: relative;
  top: 0;
  transition: 0.15s all;
  cursor: pointer;
  margin-top: 1.5rem;
}

button:active {
  top: 2px;
  box-shadow: 0 0px 0 5px #f07909;
}

.curve-container {
  padding-bottom: 30px;
  position: relative;
  margin: 1rem 0;
}

.curve-container > span {
  position: absolute;
  pointer-events: none;
}

.curve-container { padding-left: 40px; }

.curve-container > span:not(.x-axis) {
  text-align: right;
  display: inline-block;
  width: 30px;
}

#upper-leverage,
#base-leverage,
#lower-leverage {
  line-height: 1;
  font-family: monospace;
  font-size: 0.9em;
  transform: translateY(-50%);
  left: 0;
}

#upper-leverage { top: 0; }
#base-leverage { top: calc(50% - 15px); }
#lower-leverage { bottom: 15px; }

.x-axis {
  transform: translateX(-50%);
  bottom: 0;
  left: calc(50% + 20px);
  font-size: 0.7em;
  opacity: 0.5;
  text-transform: uppercase;
  font-weight: bold;
}

.curve-heading {
  margin-top: 1em;
  margin-bottom: 1.5em;
  display: flex;
  justify-content: space-between;
}

.curve-heading h2 {
  font-size: 1rem;
  font-weight: 400;
  margin: 0;
}

#curve {
  border: 1px solid #eaeaea;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 1px 1px 2px 1px white,
              inset -1px -1px 2px 1px #0000000f;
  cursor: row-resize;
}

.disclaimer {
  margin-top: 2rem;
  text-align: justify;
  display: block;
  color: #777;
  line-height: 1.5;
}

.bike-toc {
  column-count: 2;

  div {
    break-inside: avoid-column;
    margin-bottom: 1rem;
  }

  ul {
    padding: 0;
    list-style: none;
    margin: 0;
  }

  span {
    opacity: 0.6;
  }

  h2 {
    text-transform: uppercase;
    font-size: 1.2rem;
  }
}

@media (max-width: 800px) {
  body {
    gap: 1rem 0;
  }

  body.page-index {
    grid-template-areas:
      "header"
      "aside"
      "main"
      "footer";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;

    main {
      padding-top: 2rem;
    }
  }

  header {
    padding: 11px 1rem;
    margin: 0 -1rem;
    width: calc(100% + 2rem);

    h1 {
      font-size: 1.4rem;
    }
  }

  nav {
    a {
      margin: 0 -1.9em;
      transform: rotate(-33deg) skew(-22deg) translate(-24%, 78%) scale(1.15);
    }
  }

  aside {
    margin-top: 0;
  }
}

@media (max-width: 550px) {
  header h1 span:not(.mobile) {
    display: none;
  }

  header h1 span.mobile {
    display: unset;
  }

  .bike-toc {
    column-count: 1;
  }
}
