/*
 * Copyright 2020 Adobe. All rights reserved.
 * This file is licensed to you 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 REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

:root {
  /* colors: an editor theme at night, warm text on blue-grey slate */
  --background-color: #1b1e26;
  --surface-color: #232733;
  --rule-color: #353b4a;
  --text-color: #e4e0d6;
  --muted-color: #a1a7b4;
  --link-color: #e8b860;
  --link-hover-color: #f4d494;
  --focus-color: #8fc9e8;

  /* legacy boilerplate names, mapped onto the theme */
  --light-color: var(--surface-color);
  --dark-color: var(--muted-color);

  /* syntax tokens, used to tell language types apart */
  --token-real: #a5cf8f;
  --token-invented: #e8b860;
  --token-visual: #bba6ea;
  --token-logic: #7fcbcf;
  --token-commands: #ec9f86;
  --token-other: #a1a7b4;

  /* fonts */
  --body-font-family: atkinson-hyperlegible-next, atkinson-fallback, sans-serif;
  --heading-font-family: martian-mono, martian-mono-fallback, monospace;

  /* body sizes */
  --body-font-size-m: 19px;
  --body-font-size-s: 17px;
  --body-font-size-xs: 15px;

  /* heading sizes: the mono face runs wide, so the scale stays compact */
  --heading-font-size-xxl: 30px;
  --heading-font-size-xl: 25px;
  --heading-font-size-l: 21px;
  --heading-font-size-m: 18px;
  --heading-font-size-s: 17px;
  --heading-font-size-xs: 16px;

  /* layout */
  --content-width: 1120px;
  --measure: 68ch;

  /* nav height */
  --nav-height: 64px;
}

/* fallback fonts */
@font-face {
  font-family: atkinson-fallback;
  size-adjust: 104%;
  src: local('Arial');
}

@font-face {
  font-family: martian-mono-fallback;
  size-adjust: 112%;
  src: local('Courier New');
}

@media (width >= 900px) {
  :root {
    /* body sizes */
    --body-font-size-m: 19px;
    --body-font-size-s: 17px;
    --body-font-size-xs: 15px;

    /* heading sizes */
    --heading-font-size-xxl: 40px;
    --heading-font-size-xl: 30px;
    --heading-font-size-l: 23px;
    --heading-font-size-m: 19px;
    --heading-font-size-s: 17px;
    --heading-font-size-xs: 16px;
  }
}

body {
  display: none;
  margin: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: var(--body-font-family);
  font-size: var(--body-font-size-m);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

::selection {
  background-color: #3d4a63;
  color: var(--text-color);
}

:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

body.appear {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* main takes the spare height so the footer sits at the bottom of short pages */
body.appear > main {
  flex: 1 0 auto;
}

header {
  height: var(--nav-height);
}

header .header,
footer .footer {
  visibility: hidden;
}

header .header[data-block-status="loaded"],
footer .footer[data-block-status="loaded"] {
  visibility: visible;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0.8em;
  margin-bottom: 0.25em;
  font-family: var(--heading-font-family);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-wrap: balance;
  scroll-margin: 40px;
}

h2,
h3 {
  margin-top: 1.6em;
}

/* the page title ends in a text cursor; it blinks a few times on load, then rests */
main h1::after {
  content: '';
  display: inline-block;
  width: 0.55em;
  height: 0.95em;
  margin-left: 0.2em;
  vertical-align: -0.1em;
  background-color: var(--link-color);
  animation: cursor-blink 1.1s step-end 4;
}

@keyframes cursor-blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  main h1::after {
    animation: none;
  }
}

h1 { font-size: var(--heading-font-size-xxl); }
h2 { font-size: var(--heading-font-size-xl); }
h3 { font-size: var(--heading-font-size-l); }
h4 { font-size: var(--heading-font-size-m); }
h5 { font-size: var(--heading-font-size-s); }
h6 { font-size: var(--heading-font-size-xs); }

p,
dl,
ol,
ul,
pre,
blockquote {
  margin-top: 0.8em;
  margin-bottom: 0.25em;
}

main p,
main li {
  max-width: var(--measure);
}

code,
pre {
  font-family: var(--heading-font-family);
  font-size: 0.85em;
}

pre {
  padding: 16px;
  border: 1px solid var(--rule-color);
  border-radius: 4px;
  background-color: var(--surface-color);
  overflow-x: auto;
  white-space: pre;
}

main > div {
  margin: 40px 16px;
}

input,
textarea,
select,
button {
  font: inherit;
}

/* links */
a:any-link {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link-color) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  overflow-wrap: break-word;
}

a:hover {
  color: var(--link-hover-color);
  text-decoration-color: currentcolor;
}

/* buttons */
p.button-wrapper {
  margin: 12px 0;
}

a.button:any-link,
button.button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  margin: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 0.5em 1.2em;
  font: inherit;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.button[aria-disabled="true"],
button.button:disabled {
  cursor: not-allowed;
  pointer-events: none;
}

a.button.primary,
button.button.primary {
  border-color: var(--text-color);
  background-color: var(--text-color);
  color: var(--background-color);
}

a.button.primary:hover,
a.button.primary:focus-visible,
button.button.primary:hover,
button.button.primary:focus-visible {
  border-color: var(--dark-color);
  background-color: var(--dark-color);
  color: var(--light-color);
}

a.button.primary[aria-disabled="true"],
a.button.primary[aria-disabled="true"]:hover,
a.button.primary[aria-disabled="true"]:focus-visible,
button.button.primary:disabled,
button.button.primary:disabled:hover,
button.button.primary:disabled:focus-visible {
  background-color: var(--light-color);
  border-color: var(--light-color);
  color: var(--dark-color);
}

a.button.secondary,
button.button.secondary {
  border-color: var(--text-color);
  background-color: transparent;
  color: var(--text-color);
}

a.button.secondary:hover,
a.button.secondary:focus-visible,
button.button.secondary:hover,
button.button.secondary:focus-visible {
  border-color: var(--dark-color);
  background-color: var(--light-color);
  color: var(--dark-color);
}

a.button.secondary[aria-disabled="true"],
a.button.secondary[aria-disabled="true"]:hover,
a.button.secondary[aria-disabled="true"]:focus-visible,
button.button.secondary:disabled,
button.button.secondary:disabled:hover,
button.button.secondary:disabled:focus-visible {
  background-color: var(--light-color);
  border-color: var(--light-color);
  color: var(--dark-color);
}

/* high-impact call-to-action */
a.button.accent,
button.button.accent {
  border-color: var(--link-color);
  background-color: var(--link-color);
  color: var(--background-color);
}

a.button.accent:hover,
a.button.accent:focus-visible,
button.button.accent:hover,
button.button.accent:focus-visible {
  border-color: var(--link-hover-color);
  background-color: var(--link-hover-color);
}

a.button.accent[aria-disabled="true"],
a.button.accent[aria-disabled="true"]:hover,
a.button.accent[aria-disabled="true"]:focus-visible,
button.button.accent:disabled,
button.button.accent:disabled:hover,
button.button.accent:disabled:focus-visible {
  background-color: var(--light-color);
  border-color: var(--light-color);
  color: var(--dark-color);
}

main img {
  max-width: 100%;
  width: auto;
  height: auto;
}

.icon {
  display: inline-block;
  height: 24px;
  width: 24px;
}

.icon img {
  height: 100%;
  width: 100%;
}

/* sections */
main > .section {
  margin: 40px 0;
}

main > .section > div {
  max-width: var(--content-width);
  margin: auto;
  padding: 0 24px;
}

main > .section:first-of-type {
  margin-top: 0;
}

@media (width >= 900px) {
  main > .section > div {
    padding: 0 32px;
  }
}

/* section metadata */
main .section.light,
main .section.highlight {
  background-color: var(--surface-color);
  margin: 0;
  padding: 40px 0;
}

/* link lists: items that lead with a bold link put it on its own line, description below */
main ul:has(> li > strong:first-child > a) {
  margin-top: 1.2em;
  padding-left: 0;
  list-style: none;
}

main ul:has(> li > strong:first-child > a) > li {
  padding-left: 16px;
  border-left: 1px solid var(--rule-color);
  color: var(--muted-color);
  line-height: 1.5;
}

main ul:has(> li > strong:first-child > a) > li + li {
  margin-top: 20px;
}

main ul:has(> li > strong:first-child > a) > li > strong:first-child {
  display: block;
  margin-bottom: 2px;
}
