@import 'mixins';

* {
  box-sizing: border-box;
}

html {
  --bg-light-theme: #fafafa; // should match the backgound color of the light themed screenshots
  --bg-dark: #263238; // should match the backgound color of the dark themed screenshots
  --bg-light-theme-darker: #ececec;
  --bg-main: hsl(199, 15%, 13%);
  --bg-darker: hsl(199, 15%, 12%);
  --bg-light: hsl(200, 23%, 28%);
  --body: rgb(120, 155, 171);
  --body-dark: hsl(199, 23%, 52%);
  --highlight: #ff4592;
  --bg-highlight: #db045d;
  --header-shadow: 0 2px 24px rgba(0, 0, 0, 0.225), 0 1px 2px rgba(0,0,0,.125);
  --header-height: 108px;
}

::selection {
  background-color: var(--highlight);
  color: white;
}

body {
  --bg: var(--bg-main);
  --text: var(--body);
  font: {
    family: 'Ringside Regular SSm A', 'Ringside Regular SSm B', system-ui,
      sans-serif;
    size: 15px;
  }
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  @include medium {
    &::-webkit-scrollbar {
      width: 10px;
      background: var(--bg-main);
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      background-color: var(--bg-dark);
    }
  }
}

body.no-transition * {
  transition: none !important;
  transition-delay: 0s !important;
  --transition-duration: 0s !important;
}

ul {
  margin: 0;
  padding: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
blockquote {
  line-height: 1;
  margin: 0;
  font: inherit;
}

blockquote {
  font-style: italic;
  position: relative;
  display: flex;
  align-items: baseline;
  padding-left: 1em;

  &::before {
    content: '‟';
    position: absolute;
    width: 2em;
    height: 2em;
    top: -0.2em;
    left: -0.075em;
    font-size: 8em;
    opacity: 0.1;
    pointer-events: none;
  }
}

a {
  &,
  &:visited {
    color: var(--highlight);
  }
}

img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: -webkit-optimize-contrast;
}

label {
  user-select: none;
}

.comma-list-item {
  font-style: inherit;

  &:not(:last-child) {
    &:after {
      content: ', ';
    }
  }

  &:nth-last-child(2) {
    &:after {
      content: ' ';
    }
  }

  &:last-child:not(:first-of-type) {
    &:before {
      content: 'and ';
    }
  }

  &:last-child:first-child {
    &:before {
      content: '';
    }
  }
}

.site-wrapper {
  display: flex;
  flex-direction: column-reverse;
  padding-top: var(--header-height);

  @include medium {
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
    padding-top: 0;
  }
}

.sidebar {
  background-color: var(--bg-darker, var(--bg-dark));
  --text: var(--body-dark);

  @include medium {
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 256px 0 0;
    position: sticky;
    top: 0;

    &::-webkit-scrollbar {
      width: 10px;
      background: var(--bg-main);
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      background-color: var(--bg-dark);
    }
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 24px;
  background-color: inherit;
  font: {
    size: 19px;
    weight: 700;
  }
  color: white;
  height: var(--header-height);
  position: fixed;
  width: 100vw;
  top: 0;
  z-index: 9;
  box-shadow: var(--header-shadow);
  transition: box-shadow 0.3s ease-out;

  @include medium {
    position: sticky;
    width: 100%;

    &:not(.stuck) {
      box-shadow: none;
    }

    &.stuck {
      padding-top: 26px;
    }
  }

  svg {
    width: 64px;
    height: 64px;
    margin-right: 0.75em;
    margin: -4px 0.75em 0 -4px;
  }
}

.fonts-nav {
  padding: 12px 0;

  @include medium {
    padding: 0;
  }
}

.contribute {
  margin: 18px 24px 12px;
  padding: 24px 0 12px;
  border-top: solid 1px var(--bg-light);
  font-size: 0.8em;

  a {
    display: block;
    margin-top: 0.33em;
  }
}

a.fonts-nav-link {
  display: block;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 1;
  padding: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.3s ease-out;
  margin: 0 12px;
  border-radius: 6px;

  @include medium {
    padding: 9px 12px;

    &:after {
      content: '';
      background: {
        image: url("data:image/svg+xml,%3Csvg width='15' height='15' viewBox='0 0 15 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.65685 12.7929L10.7377 7.13605L7.65685 1.47919' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
        size: 100%;
      }
      margin-right: -6px;
      width: 15px;
      height: 15px;
      display: block;
      opacity: 0;
      transform: translateX(-50%) scale(0.75);
    }
  }

  @include only-small {
    margin: 0 3px;
    padding: 12px 9px;
  }

  &:hover {
    color: white;
  }

  &.active {
    background-color: var(--bg-highlight);
    color: white;
    font-weight: 700;

    &:after {
      opacity: 1;
      transform: none;
      transition: all 0.45s ease-out 0.075s;
    }
  }
}

.fonts-nav-item {
  animation: enter-fonts-nav-item 0.6s ease-in-out
    calc((var(--i) - (1 / (var(--i) * var(--i)))) * 0.05s + 0.3s) 1 backwards;
  @keyframes enter-fonts-nav-item {
    from {
      opacity: 0;
      transform: translateX(-24px);
    }
  }
}

main {
  @include medium {
    flex: 1;
  }

  @include large {
    display: flex;
    margin-top: 72px;
    align-self: flex-start;
  }
}

.screenshot-stage {
  --transition-duration: 0.2333s;
  --transition-timing: ease-out;
  --transition: all var(--transition-duration) var(--transition-timing);
  position: relative;
  max-width: 100vw;
  flex: 1;
  margin: 24px;
  border-radius: 9px;
  overflow: hidden;
  user-select: none;

  @include large {
    margin: 12px;
    max-width: 100vh;
  }

  @include only-small {
    margin: 6px;
  }

  &:after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: var(--bg-dark);
    transition: background-color var(--transition-duration)
      cubic-bezier(0, 0.91, 0.11, 1);
    z-index: -1;
  }

  [value='light']:checked ~ & {
    &:after {
      background-color: var(--bg-light-theme);
      // transition-timing-function: cubic-bezier(0,.91,.11,1)
    }

    .controls {
      background-color: var(--bg-light-theme-darker);

      label {
        --inactive-text: var(--bg-dark);
      }
    }
  }

  @include large {
    flex: 1600px 0 1;
    margin: 0;
    margin-left: 72px;
    border-radius: 18px;
    align-self: flex-start;
  }
}

.screenshot-wrapper {
  flex: 1;
  padding-bottom: 75%;
  max-width: 100%;
  position: relative;

  .screenshot {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transition: var(--transition);
  }
}

$themes: light, dark;
$languages: html, css, js, charmap;

.screenshot-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px 0;
  z-index: 3;
  position: relative;

  @include medium {
    padding: 24px 24px 0;
  }

  @include only-small {
    padding: 3px 3px 0;
  }

  .controls {
    display: flex;
    background-color: var(--bg-light);
    padding: 3px;
    border-radius: 9px;
    transition: var(--transition);
    position: relative;
    font: {
      size: 12px;
      weight: 500;
    }
    --active: var(--bg-highlight);

    label {
      --inactive-text: white;
      display: block;
      line-height: 1;
      padding: 0.5em 1em;
      color: white;
      cursor: pointer;
      border-radius: 6px;
      background-color: var(--active);
      position: relative;
      z-index: 1;
    }
  }

  .controls.with-widths {
    &:after {
      content: '';
      position: absolute;
      margin: 3px 0;
      top: 0;
      bottom: 0;
      background-color: var(--active);
      border-radius: 6px;
      z-index: 0;
      transition: all 0.15s ease-out;

      @each $language in $languages {
        [value='#{$language}']:checked ~ .screenshot-stage & {
          left: var(--left-#{$language});
          width: var(--width-#{$language});
        }
      }
    }

    label {
      --active: transparent;
    }
  }

  .theme-controls {
    border-radius: 16px;
    width: 32px;
    height: 32px;
    margin-right: -2px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;

    label {
      position: absolute;
      border-radius: inherit;
      padding: 16px;
      font-size: 20px;
      background: {
        color: var(--bg-light);
        size: 1em;
        position: center;
        repeat: no-repeat;
      }
      color: white;
      transition: var(--transition);

      &[data-theme='dark'] {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round' class='css-i6dzq1'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'%3E%3C/path%3E%3C/svg%3E");
      }

      &[data-theme='light'] {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' stroke='%232D2D2D' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round' class='css-i6dzq1'%3E%3Ccircle cx='12' cy='12' r='5'%3E%3C/circle%3E%3Cline x1='12' y1='1' x2='12' y2='3'%3E%3C/line%3E%3Cline x1='12' y1='21' x2='12' y2='23'%3E%3C/line%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'%3E%3C/line%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'%3E%3C/line%3E%3Cline x1='1' y1='12' x2='3' y2='12'%3E%3C/line%3E%3Cline x1='21' y1='12' x2='23' y2='12'%3E%3C/line%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'%3E%3C/line%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'%3E%3C/line%3E%3C/svg%3E");
        background-color: var(--bg-light-theme-darker);
      }
    }
  }
}

@each $theme in $themes {
  [value='#{$theme}']:not(:checked) ~ .screenshot-stage {
    .screenshot-controls [data-theme='#{$theme}'] {
      opacity: 0;
      transition: opacity 0.3s ease-out;
      z-index: 2;
    }

    .screenshot-wrapper [data-theme='#{$theme}'] {
      opacity: 0;
      pointer-events: none;
      transition: none; //var(--transition);
    }
  }
}

@each $language in $languages {
  [value='#{$language}']:not(:checked) ~ .screenshot-stage {
    .screenshot-controls [data-language='#{$language}'] {
      background-color: transparent;
      color: var(--inactive-text, white);
    }

    .screenshot-wrapper [data-language='#{$language}'] {
      opacity: 0;
      pointer-events: none;
      // transition: none;
    }
  }
}

.details {
  margin: 24px;
  word-break: break-word;

  @include large {
    flex: 314px 0 0;
    margin-right: 60px;
    margin: 22px 24px 24px 60px;
  }

  @include only-small {
    margin: 12px;
  }

  h2 {
    font: {
      size: 32px;
      weight: 200;
    }
    color: white;
  }

  a {
    display: block;
  }

  .designers {
    font-weight: 500;
  }

  .enter {
    @include medium {
      animation: enter-details 0.3s ease-in-out calc(var(--i) * 0.05s) 1
        backwards;
      @keyframes enter-details {
        from {
          opacity: 0;
          transform: translateY(3px);
        }
      }
    }
  }
}

ul.features {
  margin-top: 48px;

  li {
    display: flex;
    justify-content: space-between;

    &:not(:last-of-type) {
      padding-bottom: 1em;
      margin-bottom: 1em;
      border-bottom: solid 1px var(--bg-light);
    }
  }

  span {
    &::first-letter {
      text-transform: uppercase;
    }
  }
}

.icon {
  display: block;
  background: {
    size: contain;
    position: center;
  }

  &.v {
    width: 18px;
    height: 13px;
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='13' viewBox='0 0 18 13' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17 1L6 12L1 7' stroke='%23789bab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }

  &.x {
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13 1L1 13' stroke='%23789bab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M1 1L13 13' stroke='%23789bab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

button:focus:not(:focus-visible) { 
  outline: none 
}

.modal {
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--body);

  &:before {
    content: '';
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: var(--bg-light);
    opacity: .85;
    transition: opacity 0.3s ease-out;
  }

  .content {
    position: relative;
    background-color: var(--bg);
    padding: 36px;
    margin: 24px;
    border-radius: 24px;
    box-shadow: var(--header-shadow);
    transition: all 0.3s ease-out 0.15s;
  }

  header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .close {
    --webkit-appearance: none;
    background-color: transparent;
    border: none;
    color: var(--body-dark);
    transition: color .15s ease-out;
    cursor: pointer;

    &:hover {
      color: var(--body);
    }
  }

  li {
    list-style: none;
  }

  h2 {
    font-size: 21px;
    font-weight: 500;
    color: white;
  }
  
  h3 {
    margin-top: 12px;
    margin-bottom: 6px;
    color: white;
    font-weight: 500;
  }

  .shortcuts-categories {
    @include medium {
      display: flex;
      flex-wrap: wrap;
      
      > li {
        flex: 50% 0 0;
      }
    }
  }

  .shortcut {
    display: flex;
    align-items: baseline;
    font-size: 12px;
  }

  .keyboard-key {
    display: inline-block;
    color: white;
    background-color: var(--bg-dark);
    padding: .15em .25em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 15px;
    font-weight: bold;
    margin: 3px 6px 3px 0;
  }

  &.hidden {
    // opacity: 0;
    // pointer-events: none;
    // transition: none;
    clip: rect(0 0 0 0); 
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap; 
    width: 1px;
    
    &:before {
      opacity: 0;
      transition: none;
    }
    
    .content {
      opacity: 0;
      transition: none;
      transform: scale(.97);
    }
  }
}

.modal-toggle {
  --webkit-appearance: none;
  background-color: transparent;
  color: inherit;
  border: none;
  font-size: 18px;
  position: fixed;
  bottom: 0;
  left: calc(256px - 2em - 12px);
  padding: 6px;
  transition: opacity .15s ease-out;
  cursor: pointer;
  display: none;

  @include medium {
    display: block;
  }

  &:not(:hover) {
    opacity: .25;
  }

  svg {
    width: 1em;
  }

  path {
    fill: var(--body-dark);
  }
}