/* Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
   for details. All rights reserved. Use of this source code is governed by a
   BSD-style license that can be found in the LICENSE file. */

/******************************************************
  site base
******************************************************/

@use 'variables';

body {
  background-color: var(--pub-neutral-bgColor);
  color: var(--pub-neutral-textColor);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  overflow-wrap: anywhere;

  font-family: var(--pub-font-family-body);
  // we don't use font ligatures, and Google Sans fonts would otherwise change text in surprising ways
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
}

p {
  font-size: 16px;
}

p.warning {
  border-left: 0.25em solid var(--pub-color-dangerRed);
  padding-left: 10px;
}

body,
.markdown-body {
  font-weight: 400;
  font-size: 16px;

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--pub-font-family-body);
    font-weight: 400;
  }

  h1 { font-size: 36px; } // note: github uses 2em, ~32px
  h2 { font-size: 24px; } // note: github uses 1.5em, ~24px
  h3 { font-size: 21px; } // note: github uses 1.25em, ~20px
  h4 { font-size: 18px; } // note: github uses 1em, ~16px
  h5 { font-size: 17px; } // note: github uses 0.875em, ~14px
  h6 { font-size: 16px; } // note: github uses 0.85em, ~13.6px
}

img {
  max-width: 100%;
}

summary {
  cursor: pointer;
  background: transparent;
  transition: background-color 0.3s;

  &:hover {
    background: color-mix(in srgb, var(--pub-link-text-color), var(--pub-neutral-bgColor) 80%);
  }

  &:focus {
    outline: 0;
  }
}

button {
  cursor: pointer;
  border: none;

  &.pub-button-danger {
    --mdc-theme-primary: var(--pub-button-danger-background);
  }

  &.pub-button-cancel {
    --mdc-theme-primary: #f0f0f0;
    --mdc-theme-on-primary: #000000;
  }
}

// The class annotates an image icon with either black or white pixels on
// a transparent base layer.
// The default display with the muted opacity will move the icon's color
// towards the gray spectrum, and on hovering it will show high contrast.
//
// Note: The `filter: brightness()` used below with the `a` element does
//       not work with monochrome images, as the linear transformation
//       will keep the pixels with rgb(0,0,0) the same.
.pub-monochrome-icon {
  opacity: var(--pub-monochrome-opacity-initial);
  transition: opacity 0.3s;

  .pub-monochrome-icon-hoverable:hover &,
  &:focus,
  a:hover & {
    opacity: var(--pub-monochrome-opacity-hover);
  }
}

a {
  color: var(--pub-link-text-color);

  // TODO: fix style to not use bgColor as text and text color as background
  &.link-button {
    background: var(--pub-link-text-color);
    color: var(--pub-neutral-bgColor);
    display: inline-block;
    padding: 4px 12px;
  }

  @include variables.brightness-on-hover;
}

main {
  min-height: calc(100vh - 130px); // top nav (50) + footer (80)
  margin-bottom: 32px;
}

/* Useful for synchronizing the alignment of different page blocks. */
.container,
.-wide-header-detail-page .detail-container {
  max-width: variables.$site-max-width;
  /* The top and bottom margins are left on default to allow `main` to set it. */
  margin-left: auto;
  margin-right: auto;
  padding: 0 20px;
}

.standalone-side-image-block {
  display: none;
  float: right;
  max-width: 400px;
}

.standalone-content {
  max-width: 700px;
  margin: 0px auto;
}

@media (min-width: 1000px) {
  .standalone-side-image-block {
    display: block;
  }
  .standalone-wrapper.-has-side-image {
    .standalone-content {
      margin: 0px;
    }
  }
}

strong {
  font-weight: 500;
}

.markdown-body code,
code {
  background: var(--pub-inset-bgColor);
  border: none;
  border-radius: 4px;
  font-family: var(--pub-font-family-code);
  padding: 2px 4px;
}

.light-theme .hljs,
.dark-theme .hljs,
.markdown-body pre,
pre {
  background: var(--pub-inset-bgColor);
  color: var(--pub-code-text-color);
}

pre {
  line-height: 1.2;
  padding: 30px;
  overflow-x: auto;

  > code {
    padding: 0px !important;
    border-radius: 0;
    display: inline-block;
  }
}

.-pub-pre-copy-container {
  position: relative;

  &:hover {
    .-pub-pre-copy-button {
      opacity: 0.35;
    }
  }

  .-pub-pre-copy-button {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: url("../img/content-copy-icon.svg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 16px 16px;

    cursor: pointer;

    opacity: 0.15;
    transition: opacity 0.5s;

    &:focus,
    &:hover {
      opacity: 1;
    }
  }

  .-pub-pre-copy-feedback {
    display: none;

    position: absolute;
    top: 32px;
    right: 4px;

    font-size: 11px;
    padding: 8px;
    background: var(--pub-copy_feedback-background-color);
    box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, 0.05);

    white-space: nowrap;
    transition: opacity variables.$copy-feedback-transition-opacity-delay;

    &.visible {
      display: block;
    }

    &.fadeout {
      opacity: 0;
    }
  }
}

.markdown-body {
  p {
    margin-top: 8px; /* overrides github-markdown.css */
    margin-bottom: 12px; /* overrides github-markdown.css */
  }

  table {

    td, th {
      padding: 12px 12px 12px 0; /* overrides github-markdown.css */
      border: none; /* overrides github-markdown.css */
    }

    tr {
      border-top: none; /* overrides github-markdown.css */

      &:nth-child(2n) {
        background-color: var(--pub-overlay-gray-08); /* overrides github-markdown.css */
      }
    }

    th {
      font-family: var(--pub-font-family-body);
      font-size: 16px;
      font-weight: 400; /* overrides github-markdown.css */
      border-bottom: 1px solid var(--pub-overlay-gray-80);
      text-align: left;
    }

    td {
      border-bottom: 1px solid var(--pub-overlay-gray-30);
    }

    img {
      background-color: inherit; /* overrides github-markdown.css */
    }
  }
}

._banner-bg {
  background: var(--pub-searchbar-background-color);
  background-size: cover;
  color: var(--pub-searchbar-text-color);
  padding: 10px 0px;

  a {
    color: var(--pub-link-text-color);
  }

  // Display background image only on the landing page.
  body.page-landing & {
    background-image: url("../img/hero-bg-static.svg");
  }
}

/*
 * Hide only visually, but have it available for screen readers:
 * http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 */
._visuallyhidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;

  &:active,
  &:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
  }
}

.-pub-publisher-shield {
  vertical-align: middle;
  margin: -1px 3px 0 0;
  width: 14px;
  height: 14px;
}

.-pub-publisher {
  display: inline-block;
}

.-pub-like-button {
  --mdc-theme-primary: #f8f8f8;
  --mdc-theme-on-primary: var(--pub-neutral-textColor);
}

.-pub-like-button-img {
  opacity: 0.7;
}

/******************************************************
  spinner
******************************************************/

.spinner-frame {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;

  background: var(--pub-spinner_frame-background-color);

  display: flex;
  align-items: center;
  justify-content: center;

  .spinner {
    border: 8px solid #f3f3f3;
    border-top-color: var(--pub-link-text-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 3s linear infinite;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hash-link {
  color: var(--pub-hash_link-text-color);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease-in-out 0.1s;

  .hash-header:hover & {
    visibility: visible;
    opacity: 1;
  }
}

.foldable {
  .foldable-button {
    cursor: pointer;
  }

  .foldable-content {
    display: none;
  }

  &.-active {
    .foldable-content {
      display: block;
    }
  }
}

.announcement-banner {
  padding: 10px 0;

  background: var(--pub-selected-bgColor);
  font-size: 16px;

  text-align: center;

  .dismisser {
    position: absolute;
    display: inline-block;
    right: 0px;
    padding: 5px 15px;
    margin-top: -5px;
    cursor: pointer;
    user-select: none;
  }

  &.dismissed {
    display: none;
  }

  z-index: 1000;
}

a.-x-ago {
  color: var(--pub-neutral-textColor);
  text-decoration: underline dotted #ccc;
}

.inline-icon-img {
  display: inline-block;
  position: relative;
  top: 3px;
  opacity: 0.75;
  margin-right: 3px;
}

.-pub-session-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--pub-selected-bgColor);
  color: var(--pub-neutral-textColor);
  padding: 12px 24px;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, 0.05);
  z-index: 101; // TODO: depend on variables with the site header

  button {
    background-color: transparent;
    color: var(--pub-neutral-textColor);
    margin-left: 8px;
    padding: 8px;
  }
}

.pub-toc {
  border-left: 4px solid var(--pub-inset-bgColor);
  padding: 4px 12px;
  color: var(--pub-neutral-textColor);

  a {
    color: var(--pub-neutral-textColor);
  }

  .pub-toc-node-0 {
    margin-top: 4px;
  }
  .pub-toc-node-1 {
    margin-left: 12px;
  }
  .pub-toc-node-2 {
    margin-left: 24px;
  }
  .pub-toc-node-3 {
    margin-left: 36px;
  }
}

.-pub-ongoing-screenshot {
  // Disables flashing caret (cursor) in input fields by making it invisible.
  caret-color: transparent;

  // Instantaneous transitions - no ambiguous delay in the end state.
  * {
    transition-duration: 0s !important;
  }
}
