/**
 * Module: Basic styling setup.
 */

@import './constants.css' layer(base);

@layer utilities {
  *,
  *::after,
  *::before {
    box-sizing: border-box;
  }
}

@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    border-color: var(--color-border);
    accent-color: var(--color-primary);
  }

  html {
    interpolate-size: allow-keywords;

    text-size-adjust: none;

    hanging-punctuation: first last;
    color-scheme: dark light;
  }

  body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  [data-color-scheme='dark'] {
    color-scheme: dark;
  }

  [data-color-scheme='light'] {
    color-scheme: light;
  }

  /* Default scroll behavior */
  @media (prefers-reduced-motion: no-preference) {
    :has(:target) {
      scroll-behavior: smooth;
      scroll-padding-top: var(--scroll-padding);
    }
  }

  :root {
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    font-family: var(--font-main);

    color: var(--color-foreground);
    border-color: var(--color-border);
    background-color: var(--color-background);
  }

  @media only screen and (width <= 639px) {
    :root {
      font-size: var(--font-size-sm);
    }
  }

  :focus,
  :focus-visible,
  :focus-within {
    outline: 2px solid transparent;
  }

  ::placeholder {
    color: var(--color-muted-foreground);
    user-select: none;
  }

  /* Wrapping headers */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    text-wrap: balance;
  }

  /* Limit text lines and setup wrapping */
  p,
  li {
    max-width: var(--text-max-width);
    text-wrap: pretty;
  }

  div:not(.dense) > p:not(:last-child) {
    margin-bottom: 0.5rem;
  }

  h1 {
    font-weight: 600;
    font-size: 1.125rem;
    line-height: 1.75rem;
    text-align: center;
  }

  h2 {
    font-weight: 600;
    text-align: center;

    &:not(:first-child) {
      :not([role='manuals']) & {
        margin-top: 0.5rem;
      }

      [role='manuals'] & {
        margin-top: 0.75rem;
        margin-bottom: 0.5rem;
      }
    }
  }

  b {
    font-weight: 600;
  }

  code {
    font-family: var(--font-math);
  }

  li {
    list-style-position: inside;
  }

  li::marker {
    content: '–\2009';
  }

  details {
    overflow: hidden;
  }

  details::details-content {
    block-size: 0;

    transition-property: block-size, content-visibility;
    transition-duration: var(--duration-dropdown);
    transition-timing-function: var(--ease-in-out);
    transition-behavior: allow-discrete;
  }

  details[open]::details-content {
    block-size: auto;
  }

  summary {
    cursor: pointer;
    list-style: none;
  }

  summary::before {
    font-family: var(--font-math);
    padding-right: 0.5rem;
    content: '+';
  }

  details[open] summary::before {
    font-family: var(--font-math);
    padding-right: 0.5rem;
    content: '-';
  }
}

@utility border {
  border-radius: 0.25rem;
}
