@import 'code-examples.css';
@import 'code-highlighter.css';
@import 'copy-code.css';
@import 'outline.css';
@import 'search.css';
@import 'cera_typeface.css';

:root {
  --wa-brand-orange: #f36944;
  --wa-brand-grey: #30323b;
}

.wa-dark .only-light,
.only-dark:not(.wa-dark, .wa-dark *) {
  display: none;
}

wa-page {
  --wa-flow-spacing: var(--wa-space-xl);
}

/* Header */
wa-page::part(header) {
  background-color: var(--wa-color-surface-default);
  border-bottom: var(--wa-border-style) var(--wa-panel-border-width) var(--wa-color-surface-border);
}

wa-page::part(body) {
  padding-top: 0px;
}

wa-page::part(header-actions) {
  align-self: center;
}

wa-page > header {
  padding-inline: var(--wa-space-xl);

  a[href='/'] {
    color: var(--wa-color-text-normal);
    line-height: 1;
  }

  wa-button[data-toggle-nav] {
    --text-color: currentColor;
    font-size: 1rem;
    margin-inline-start: -0.875rem;
    margin-inline-end: 0;

    &::part(base) {
      padding: 0;
      padding-inline: 0.875rem;
    }
  }

  svg {
    width: auto;
    height: 1.75rem;
  }

  #docs-branding,
  #docs-toolbar {
    display: flex;
    align-items: center;
    gap: var(--wa-space-xs);
  }

  #version-number {
    color: var(--wa-color-text-quiet);
    font-size: var(--wa-font-size-xs);
    line-height: 1;
    margin-block-start: var(--wa-space-2xs);
  }
  #version-number + wa-badge {
    font-size: var(--wa-font-size-2xs);
    text-transform: uppercase;
  }
  wa-button#search-trigger {
    --background-color: var(--wa-form-control-background-color);
    --border-color: var(--wa-form-control-border-color);
  }
  #search-trigger kbd {
    font-size: var(--wa-font-size-2xs);
    line-height: var(--wa-form-control-value-line-height);
  }
}

#sidebar,
#outline {
  h2 {
    font-size: var(--wa-font-size-m);
    margin: 0;
  }

  h2:not(:first-child),
  wa-details:not(:first-child) {
    margin-block-start: var(--wa-space-xs);
  }

  wa-details {
    border: none;
    background: none;
    padding: 0;
  }

  ul {
    border-inline-start: var(--wa-border-width-s) solid var(--wa-color-surface-border);
    font-size: var(--wa-font-size-s);
    line-height: var(--wa-line-height-condensed);
    margin: 0;
    padding-inline-start: var(--wa-space-m);
  }

  ul ul {
    margin-block-start: var(--wa-space-m);
  }

  ul:empty {
    display: none;
  }

  li {
    list-style: none;

    + li {
      margin-block-start: var(--wa-space-m);
    }
  }

  li a {
    color: var(--wa-color-text-normal);
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }

  li wa-badge::part(base) {
    font-size: var(--wa-font-size-2xs);
    font-weight: var(--wa-font-weight-bold);
  }

  li wa-icon {
    color: var(--wa-color-text-quiet);
    vertical-align: middle;

    &[name='flask'] {
      margin-inline: 0.125em;
    }
  }
}

#outline-standard h2 {
  margin-block-end: var(--wa-space-m);
}

/* Pro badges */
wa-badge.pro {
  background-color: var(--wa-brand-orange);
  border-color: var(--wa-brand-orange);
}

#sidebar {
  h2 {
    color: var(--wa-color-text-quiet);

    a {
      display: flex;
      align-items: center;
      gap: 0.4em;
      color: var(--wa-color-text-normal);
      text-decoration: none;

      wa-icon {
        margin-block-end: -0.15em;
        font-size: var(--wa-font-size-s);
        font-weight: var(--wa-font-weight-action);
        color: var(--wa-color-gray-70);
      }

      &:hover {
        color: var(--wa-color-brand-on-normal);

        wa-icon {
          color: var(--wa-color-brand-on-quiet);
        }
      }
    }
  }

  wa-icon-button.delete {
    vertical-align: -0.2em;
    margin-inline-start: var(--wa-space-xs);

    &:not(li:hover > *, :focus) {
      opacity: 0;
    }
  }
}

wa-icon-button.delete {
  &:hover {
    color: var(--wa-color-danger-on-quiet);
  }

  &::part(base):hover {
    background: var(--wa-color-danger-fill-quiet);
  }

  &:not(:hover, :focus) {
    opacity: 0.5;
  }
}

#sidebar-close-button {
  display: none;
}

@media screen and (max-width: 768px) {
  #sidebar-close-button {
    display: inline-block;
    position: absolute;
    top: 1rem;
    right: 1rem;
  }
}

#sidebar nav {
  padding-bottom: 1rem;
}

wa-page::part(menu) {
  scrollbar-width: thin;
}

wa-page[view='mobile'] :is([slot='navigation-header'], [slot='navigation']) {
  padding: 0;

  & wa-details::part(icon) {
    padding-inline: var(--wa-space-xs); /* aligns details icons with drawer close icon */
  }
}

[slot='navigation-header'] wa-menu {
  font-family: var(--wa-font-family-body);
  font-size: var(--wa-font-size-m);
  font-weight: var(--wa-font-weight-normal);
}

/* Main content */
wa-page > main {
  max-width: 80ch;
  padding: var(--wa-space-xl);
  margin-inline: auto;
}

h1.title {
  wa-icon-button {
    font-size: var(--wa-font-size-l);
    color: var(--wa-color-text-quiet);

    &:not(:hover, :focus) {
      opacity: 0.5;
    }
  }

  wa-badge {
    vertical-align: middle;
    font-size: 1.5rem;
  }
}

.block-info {
  display: flex;
  gap: var(--wa-space-xs);
  flex-wrap: wrap;
  align-items: center;
  margin-block-end: var(--wa-flow-spacing);

  code {
    line-height: var(--wa-line-height-condensed);
  }
}

/* Current link */
#sidebar,
#outline {
  .current {
    font-weight: var(--wa-font-weight-bold);
    text-decoration-style: solid;
  }
}

/* Anchor headings */
.anchor-heading a {
  visibility: hidden;
  text-decoration: none;
}

@media (hover: hover) {
  .anchor-heading:hover a {
    visibility: visible;
    padding: 0 0.125em;
  }
}

/* Callouts */
.callout {
  display: flex;
  gap: 1rem;
  border: var(--wa-border-style) var(--wa-border-width-s);
  border-radius: var(--wa-border-radius-l);
  padding: 1rem;
  margin-block-end: var(--wa-flow-spacing);

  :first-child {
    margin-block-start: 0;
  }

  :last-child {
    margin-block-end: 0;
  }
}

.callout-icon {
  flex: 0 0 auto;
  font-size: 1.5rem;
}

.callout-content {
  flex: 1 1 auto;
}

.callout-info {
  background-color: var(--wa-color-brand-fill-quiet);
  border-color: var(--wa-color-brand-border-quiet);

  .callout-icon {
    color: var(--wa-color-brand-on-normal);
  }

  code {
    background-color: var(--wa-color-brand-fill-normal);
  }
}

.callout-warning {
  background-color: var(--wa-color-warning-fill-quiet);
  border-color: var(--wa-color-warning-border-quiet);

  .callout-icon {
    color: var(--wa-color-warning-on-normal);
  }

  code {
    background-color: var(--wa-color-warning-fill-normal);
  }
}

/* Index Pages */
wa-page > main:has(> .index-grid) {
  max-width: 120ch;
  margin-inline: auto;
}

.index-summary {
  max-inline-size: 80ch;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(22ch, 100%), 1fr));
  gap: var(--wa-space-2xl);
  margin-block-end: var(--wa-space-3xl);

  a {
    border-radius: var(--wa-border-radius-l);
    text-decoration: none;
  }

  wa-card {
    box-shadow: none;
    --spacing: var(--wa-space-m);
    inline-size: 100%;

    &:hover {
      --border-color: var(--wa-color-brand-border-loud);
      border-color: var(--border-color);
      box-shadow: 0 0 0 var(--wa-border-width-s) var(--border-color);

      .page-name {
        color: var(--wa-color-brand-on-quiet);
      }
    }

    [slot='header'] {
      display: flex;
    }

    &::part(header) {
      background-color: var(--header-background, var(--wa-color-neutral-fill-quiet));
      border-bottom: none;
      display: flex;
      align-items: center;
      justify-content: center;
      min-block-size: calc(6rem + var(--spacing));
    }
  }

  .page-name {
    font-size: var(--wa-font-size-s);
    font-weight: var(--wa-font-weight-action);
  }
}

.index-category {
  grid-column: 1 / -1;
  margin-block-end: 0;
  margin-block-start: var(--wa-space-2xl);
}

/* Swatches */
.swatch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border-color: var(--wa-color-neutral-border-normal);
  border-style: var(--wa-border-style);
  border-width: var(--wa-border-width-s);
  border-radius: var(--wa-border-radius-m);
  box-sizing: border-box;
  min-height: 2.5em;
  padding: var(--wa-space-xs);
  font-weight: var(--wa-font-weight-semibold);
  line-height: var(--wa-line-height-condensed);

  &.color {
    border-color: transparent;
    transition: background var(--wa-transition-slow);
    background: linear-gradient(var(--color-2, transparent) 0% 100%) no-repeat border-box var(--color,);
    background-position: var(--color-2-position, bottom);
    background-size: var(--color-2-width, 100%) var(--color-2-height, 50%);

    &.contrast-fail {
      outline: 1px dashed var(--wa-color-red);
      outline-offset: calc(-1 * var(--wa-space-2xs));
    }
  }

  > wa-copy-button {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    --background-color-hover: transparent;
    font-family: var(--wa-font-family-code);

    &::part(button) {
      display: block;
      height: 100%;
      width: 100%;
    }

    &::part(button):hover {
      cursor: copy;
    }

    &::part(copy-icon),
    &::part(success-icon),
    &::part(error-icon) {
      opacity: 0 !important;
    }
  }
}

table.colors {
  thead {
    th {
      text-align: center;
      padding-block: 0;
    }
  }

  tbody {
    tr {
      border: none;
      &:hover {
        background: transparent;
      }
    }

    th {
      width: 0;
      vertical-align: middle;
      text-align: right;
    }

    td {
      padding-inline: var(--wa-space-3xs);
      padding-block: var(--wa-space-s);
    }
  }

  .core-column {
    padding-inline-end: var(--wa-space-xl);
  }
}

.value-up,
.value-down {
  position: relative;

  &::after {
    content: ' ' var(--icon);
    position: absolute;
    margin-inline-start: 3em;
    scale: 1 0.6;
    color: color-mix(in oklch, oklch(from var(--icon-color) none c h) 0%, oklch(from currentColor l none none));
    font-size: 90%;
  }
}

.value-down {
  --icon: '▼';
  --icon-color: var(--wa-color-danger-fill-quiet);

  &::after {
    margin-block-end: -0.2em;
  }
}

.value-up {
  --icon: '▲';
  --icon-color: var(--wa-color-success-fill-quiet);
}

.icon-modifier {
  position: relative;
  display: inline-flex;

  .modifier {
    position: absolute;
    bottom: -0.1em;
    right: -0.3em;
    font-size: 60%;

    &::part(svg) {
      stroke: var(--background-color, var(--wa-color-surface-default));
      stroke-width: 100px;
      paint-order: stroke;
      overflow: visible;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
  }
}

/* Layout Examples */
.layout-example-boundary {
  border: var(--wa-border-width-s) dashed var(--wa-color-neutral-border-normal);
  border-radius: var(--wa-border-radius-l);
  padding: var(--wa-space-s);
}

.layout-example-block {
  background-color: var(--wa-color-indigo-60);
  border-radius: var(--wa-border-radius-m);
  min-block-size: 4rem;
  min-inline-size: 4rem;
}

.layout-example-mixed-sizing .layout-example-block:nth-child(3n) {
  min-inline-size: 6rem;
}
.layout-example-mixed-sizing .layout-example-block:nth-child(3n + 2) {
  min-inline-size: 8rem;
}

/* Utilities */
.two-columns {
  columns: 2;
  gap: 1rem;
}

.component-table td > * + * {
  margin-block-start: var(--wa-space-s);
}

.table-scroll {
  overflow-x: auto;
  margin-block-end: var(--wa-flow-spacing);
}

/** mobile */
@media screen and (max-width: 768px) {
  wa-page .only-desktop {
    display: none;
  }
}

/** desktop */
@media screen and not (max-width: 768px) {
  /* Navigation sidebar */
  wa-page::part(navigation) {
    border-right: var(--wa-border-style) var(--wa-panel-border-width) var(--wa-color-surface-border);
  }

  wa-page > #sidebar {
    overflow: auto;
    max-height: 100%;
    min-width: 300px;
    padding: var(--wa-space-xl);
    max-width: 300px;
  }

  wa-page > main {
    padding: var(--wa-space-3xl);
  }
}

.page-wide {
  wa-page > main {
    max-width: 140ch;

    .max-line-length {
      max-width: 80ch;
    }
  }
}

.layout-theme {
  iframe {
    width: 100%;
    min-height: 16lh;
    height: 65vh;
    max-height: 21lh;
  }
}
