/* Base styles and content styles */

/* PolySans font import - matching Amp's main site */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* If PolySans Var is not available, we'll use Inter as a close alternative */

/* Amp logo styling */
.amp-logo {
  height: 24px;
  width: 24px;
  margin-right: 12px;
  flex-shrink: 0;
}

.menu-title {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

:root {
  /* Browser default font-size is 16px, this way 1 rem = 10px */
  font-size: 62.5%;
  color-scheme: var(--color-scheme);
}

html {
  font-family: "PolySans Var", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background-color: var(--bg);
  text-size-adjust: none;
  -webkit-text-size-adjust: none;
}

body {
  margin: 0;
  font-size: 1.6rem;
  overflow-x: hidden;
}

code {
  font-family: var(--mono-font) !important;
  font-size: var(--code-font-size);
  direction: ltr !important;
}

/* make long words/inline code not x overflow */
main {
  overflow-wrap: break-word;
}

/* make wide tables scroll if they overflow */
.table-wrapper {
  overflow-x: auto;
}

/* Don't change font size in headers. */
h1 code,
h2 code,
h3 code,
h4 code,
h5 code,
h6 code {
  font-size: unset;
}

.left {
  float: left;
}
.right {
  float: right;
}
.boring {
  opacity: 0.6;
}
.hide-boring .boring {
  display: none;
}
.hidden {
  display: none !important;
}

h2,
h3 {
  margin-block-start: 2.5em;
}
h4,
h5 {
  margin-block-start: 2em;
}

.header + .header h3,
.header + .header h4,
.header + .header h5 {
  margin-block-start: 1em;
}

h1:target::before,
h2:target::before,
h3:target::before,
h4:target::before,
h5:target::before,
h6:target::before {
  display: inline-block;
  content: "»";
  margin-inline-start: -30px;
  width: 30px;
}

/* This is broken on Safari as of version 14, but is fixed
   in Safari Technology Preview 117 which I think will be Safari 14.2.
   https://bugs.webkit.org/show_bug.cgi?id=218076
*/
:target {
  /* Safari does not support logical properties */
  scroll-margin-top: calc(var(--menu-bar-height) + 0.5em);
}

.page {
  outline: 0;
  padding: 0 var(--page-padding);
  margin-block-start: calc(
    0px - var(--menu-bar-height)
  ); /* Compensate for the #menu-bar-hover-placeholder */
}
.page-wrapper {
  box-sizing: border-box;
  background-color: var(--bg);
}
.no-js .page-wrapper,
.js:not(.sidebar-resizing) .page-wrapper {
  transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}
[dir="rtl"] .js:not(.sidebar-resizing) .page-wrapper {
  transition: margin-right 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}

.content {
  overflow-y: auto;
  padding: 0 5px 50px 5px;
}
.content main {
  margin-inline-start: auto;
  margin-inline-end: auto;
  max-width: var(--content-max-width);
}
.content p {
  line-height: 1.45em;
}
.content ol {
  line-height: 1.45em;
}
.content ul {
  line-height: 1.45em;
}
.content a {
  text-decoration: none;
}
.content a:hover {
  text-decoration: underline;
}
.content img,
.content video {
  max-width: 100%;
}
.content .header:link,
.content .header:visited {
  color: var(--fg);
}
.content .header:link,
.content .header:visited:hover {
  text-decoration: none;
}

table {
  margin: 0 auto;
  border-collapse: collapse;
}
table td {
  padding: 3px 20px;
  border: 1px var(--table-border-color) solid;
}
table thead {
  background: var(--table-header-bg);
}
table thead td {
  font-weight: 700;
  border: none;
}
table thead th {
  padding: 3px 20px;
}
table thead tr {
  border: 1px var(--table-header-bg) solid;
}
/* Alternate background colors for rows */
table tbody tr:nth-child(2n) {
  background: var(--table-alternate-bg);
}

blockquote {
  margin: 20px 0;
  padding: 0 20px;
  color: var(--fg);
  background-color: var(--quote-bg);
  border-block-start: 0.1em solid var(--quote-border);
  border-block-end: 0.1em solid var(--quote-border);
}

.warning {
  margin: 20px;
  padding: 0 20px;
  border-inline-start: 2px solid var(--warning-border);
}

.warning:before {
  position: absolute;
  width: 3rem;
  height: 3rem;
  margin-inline-start: calc(-1.5rem - 21px);
  content: "ⓘ";
  text-align: center;
  background-color: var(--bg);
  color: var(--warning-border);
  font-weight: bold;
  font-size: 2rem;
}

blockquote .warning:before {
  background-color: var(--quote-bg);
}

kbd {
  background-color: var(--table-border-color);
  border-radius: 4px;
  border: solid 1px var(--theme-popup-border);
  box-shadow: inset 0 -1px 0 var(--theme-hover);
  display: inline-block;
  font-size: var(--code-font-size);
  font-family: var(--mono-font);
  line-height: 10px;
  padding: 4px 5px;
  vertical-align: middle;
}

sup {
  /* Set the line-height for superscript and footnote references so that there
       isn't an awkward space appearing above lines that contain the footnote.

       See https://github.com/rust-lang/mdBook/pull/2443#discussion_r1813773583
       for an explanation.
    */
  line-height: 0;
}

.footnote-definition {
  font-size: 0.9em;
}
/* The default spacing for a list is a little too large. */
.footnote-definition ul,
.footnote-definition ol {
  padding-left: 20px;
}
.footnote-definition > li {
  /* Required to position the ::before target */
  position: relative;
}
.footnote-definition > li:target {
  scroll-margin-top: 50vh;
}
.footnote-reference:target {
  scroll-margin-top: 50vh;
}
/* Draws a border around the footnote (including the marker) when it is selected.
   TODO: If there are multiple linkbacks, highlight which one you just came
   from so you know which one to click.
*/
.footnote-definition > li:target::before {
  border: 2px solid var(--footnote-highlight);
  border-radius: 6px;
  position: absolute;
  top: -8px;
  right: -8px;
  bottom: -8px;
  left: -32px;
  pointer-events: none;
  content: "";
}
/* Pulses the footnote reference so you can quickly see where you left off reading.
   This could use some improvement.
*/
@media not (prefers-reduced-motion) {
  .footnote-reference:target {
    animation: fn-highlight 0.8s;
    border-radius: 2px;
  }

  @keyframes fn-highlight {
    from {
      background-color: var(--footnote-highlight);
    }
  }
}

.tooltiptext {
  position: absolute;
  visibility: hidden;
  color: #fff;
  background-color: #333;
  transform: translateX(
    -50%
  ); /* Center by moving tooltip 50% of its width left */
  left: -8px; /* Half of the width of the icon */
  top: -35px;
  font-size: 0.8em;
  text-align: center;
  border-radius: 6px;
  padding: 5px 8px;
  margin: 5px;
  z-index: 1000;
}
.tooltipped .tooltiptext {
  visibility: visible;
}

.chapter li.part-title {
  color: var(--sidebar-fg);
  margin: 5px 0px;
  font-weight: bold;
}

.result-no-output {
  font-style: italic;
}

/* Amp Custom Styling */

/* Enhanced navigation - remove padding from chapter items */
.chapter li.chapter-item,
ol.chapter li.chapter-item,
.sidebar ol.chapter li.chapter-item,
.sidebar-iframe-inner ol.chapter li.chapter-item {
  padding: 0 !important;
  margin: 0 !important;
}

/* Enhanced navigation - full width sidebar links */
.chapter li.chapter-item a,
.sidebar ol.chapter li a,
.sidebar .chapter li a,
ol.chapter li a,
.sidebar-iframe-inner ol.chapter li a {
  padding: 0.8rem 1.5rem !important;
  border-radius: 6px !important;
  margin: 0 !important;
  transition: all 0.2s ease !important;
  display: block !important;
  text-decoration: none !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Enhanced navigation - hover states */
.chapter li.chapter-item a:hover,
.sidebar ol.chapter li a:hover,
.sidebar .chapter li a:hover,
ol.chapter li a:hover,
.sidebar-iframe-inner ol.chapter li a:hover {
  background-color: var(--theme-hover) !important;
  transform: translateX(2px) !important;
  width: 100% !important;
  box-sizing: border-box !important;
  display: block !important;
  margin: 0 !important;
  padding: 0.8rem 1.5rem !important;
  border-radius: 6px !important;
}
/* Enhanced navigation - active states */
.chapter li.chapter-item a.active,
ol.chapter li a.active,
.chapter li a.active,
.sidebar ol.chapter li a.active,
.sidebar-iframe-inner ol.chapter li a.active {
  background-color: var(--sidebar-active) !important;
  color: white !important;
  font-weight: 600 !important;
  width: 100% !important;
  display: block !important;
  margin: 0 !important;
  padding: 0.8rem 1.5rem !important;
  box-sizing: border-box !important;
  border-radius: 6px !important;
}

/* Enhanced typography */
.content h1 {
  font-size: 2.8rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-top: 0;
  margin-bottom: 2rem;
  color: var(--fg);
  border-bottom: 2px solid var(--sidebar-active);
  padding-bottom: 1rem;
}

.content h2 {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  color: var(--fg);
}

.content h3 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--sidebar-active);
}

/* Enhanced code blocks */
.content pre {
  border-radius: 8px;
  border: 1px solid var(--table-border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin: 1.5rem 0;
}

.content code:not(.hljs) {
  background-color: var(--quote-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--inline-code-color);
  font-weight: 600;
}

/* Enhanced tables */
.content table {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin: 2rem 0;
}

.content table th {
  background-color: var(--sidebar-active);
  color: white;
  font-weight: 600;
  text-align: left;
  padding: 1rem;
}

.content table td {
  padding: 0.8rem 1rem;
}

/* Enhanced blockquotes */
.content blockquote {
  border-left: 4px solid var(--sidebar-active);
  background-color: var(--quote-bg);
  border-radius: 0 6px 6px 0;
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  font-style: italic;
}

/* Callout boxes */
.content .warning,
.content .note,
.content .tip {
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
}

.content .warning {
  background-color: #fff5f5;
  border-left-color: #f56565;
}

.content .note {
  background-color: #f0f9ff;
  border-left-color: #3b82f6;
}

.content .tip {
  background-color: #f0fff4;
  border-left-color: #10b981;
}

/* Enhanced menu bar */
.menu-bar {
  background-color: var(--bg);
  border-bottom: 1px solid var(--sidebar-spacer);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-title {
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--fg);
}

/* Better spacing and readability */
.content {
  line-height: 1.7;
  max-width: 800px;
}

.content p {
  margin-bottom: 1.2rem;
}

.content ul,
.content ol {
  margin-bottom: 1.5rem;
}

.content li {
  margin-bottom: 0.5rem;
}

/* Enhanced links */
.content a {
  color: var(--links);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-bottom-color 0.2s ease;
}

.content a:hover {
  border-bottom-color: var(--links);
}

/* Print styles */
@media print {
  .content h1 {
    border-bottom: 2px solid #333;
    color: #333;
  }

  .content h3 {
    color: #333;
  }

  .content table th {
    background-color: #f0f0f0 !important;
    color: #333 !important;
  }
}
