/* Header, footer, buttons, cards, badges, the terminal block and page sections. */
@layer components {
  .skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 20;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    background: var(--card);
    color: var(--foreground);

    &:focus {
      top: 0.75rem;
    }
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
    background: color-mix(in oklch, var(--background), transparent 15%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    .container {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 0.25rem 0.5rem;
      min-height: var(--header-height);
      padding-block: 0.5rem;
    }
    @media (width < 26rem) {
      .logo img {
        height: 1.25rem;
      }
    }
  }

  .logo {
    flex: none;

    img {
      height: 1.5rem;
      width: auto;
    }
  }

  .site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;

    a {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.375rem 0.75rem;
      border-radius: 999px;
      color: var(--muted-foreground);
      font-size: 0.875rem;
      font-weight: 500;
      text-decoration: none;

      &:hover,
      &[aria-current="page"] {
        color: var(--foreground);
        background: var(--muted);
      }
    }

    svg {
      flex: none;
      width: 1.125rem;
      height: 1.125rem;
    }

    /* On a narrow screen the row holds the logo, two links and the toggle; GitHub stays in the footer. */
    @media (width < 26rem) {
      gap: 0;

      a {
        padding-inline: 0.375rem;
      }

      a[href^="https://github.com"] {
        display: none;
      }
    }
  }

  .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;

    &:hover {
      color: var(--foreground);
      background: var(--muted);
    }

    svg {
      width: 1.125rem;
      height: 1.125rem;
    }
  }

  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.5rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;

    svg {
      width: 1.125rem;
      height: 1.125rem;
    }
  }

  .button-primary {
    background: var(--primary);
    color: var(--primary-foreground);

    &:hover {
      background: var(--highlight);
      box-shadow: 0 0 20px color-mix(in oklch, var(--primary), transparent 70%);
    }
  }

  .button-outline {
    border-color: var(--input);
    background: var(--card);
    color: var(--foreground);

    &:hover {
      border-color: color-mix(in oklch, var(--primary), transparent 40%);
      background: var(--muted);
    }
  }

  .button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--card-foreground);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;

    &:hover {
      border-color: color-mix(in oklch, var(--primary), transparent 60%);
      box-shadow:
        0 4px 12px color-mix(in oklch, var(--primary), transparent 90%),
        0 0 0 1px color-mix(in oklch, var(--primary), transparent 80%);
    }

    p {
      color: var(--muted-foreground);
    }
  }

  .card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
  }

  .card-link {
    margin-top: auto;
    padding-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 1.5rem;
    padding: 0;
    list-style: none;
  }

  .shadow-elevated {
    box-shadow:
      0 10px 15px -3px color-mix(in oklch, var(--foreground), transparent 90%),
      0 4px 6px -4px color-mix(in oklch, var(--foreground), transparent 90%),
      0 0 0 1px var(--border);
  }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.125rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: 999px;
    background: var(--card);
    color: var(--foreground);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
    white-space: nowrap;

    &::before {
      content: "";
      width: 0.5rem;
      height: 0.5rem;
      border-radius: 50%;
      background: var(--muted-foreground);
    }
  }

  .badge-available::before { background: var(--success); }
  .badge-preview::before { background: var(--secondary); }
  .badge-in-development::before { background: var(--warning); }

  .terminal {
    position: relative;
    border: 1px solid var(--input);
    border-radius: 1rem;
    background: var(--card);

    pre {
      padding: 1rem 3.5rem 1rem 1.25rem;
      overflow-x: auto;
      line-height: 1.5rem;
    }

    .icon-button {
      position: absolute;
      top: 0.5rem;
      right: 0.5rem;
    }

    [data-copied] {
      color: var(--link);
    }
  }

  .hero {
    padding-block: 5rem 4rem;
    background:
      radial-gradient(60rem 24rem at 50% -8rem, color-mix(in oklch, var(--primary), transparent 82%), transparent 70%);

    h1 {
      max-width: 20ch;
      font-size: clamp(2.5rem, 7vw, 4rem);
      line-height: 1.1;
      letter-spacing: -0.035em;

      &.font-serif {
        font-weight: 400;
        line-height: 1.2;
        letter-spacing: -0.02em;
      }
    }

    .text-lead {
      max-width: 40rem;
    }

    .stack > * + * {
      margin-top: 1.5rem;
    }
  }

  .section-head {
    max-width: 40rem;
    margin-bottom: 2rem;
  }

  .section-muted {
    border-block: 1px solid var(--border);
    background: var(--muted);
  }

  .link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    padding: 0;
    list-style: none;
  }

  /* Text that is waiting for approved wording. */
  .placeholder {
    outline: 1px dashed var(--input);
    outline-offset: 0.25rem;
    border-radius: 0.25rem;
  }

  .notice {
    padding-block: 0.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: center;
  }

  .site-footer {
    border-top: 1px solid var(--border);
    padding-block: 2.5rem;
    font-size: 0.875rem;

    .container {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 1.5rem;
    }

    a {
      color: var(--muted-foreground);
      text-decoration: none;

      &:hover {
        color: var(--foreground);
        text-decoration: underline;
      }
    }
  }

  .not-found {
    padding-block: 6rem;
    text-align: center;

    .stack {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    .code {
      font-family: var(--font-mono);
      font-size: 0.875rem;
      color: var(--muted-foreground);
    }
  }

  .swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 0.75rem;
    padding: 0;
    list-style: none;

    li {
      padding: 2.5rem 0.75rem 0.5rem;
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      font-family: var(--font-mono);
      font-size: 0.75rem;
    }
  }

  .swatch-background { background: var(--background); }
  .swatch-card { background: var(--card); }
  .swatch-muted { background: var(--muted); }
  .swatch-primary { background: var(--primary); color: var(--primary-foreground); }
  .swatch-secondary { background: var(--secondary); color: var(--secondary-foreground); }
  .swatch-highlight { background: var(--highlight); color: var(--primary-foreground); }
  .swatch-success { background: var(--success); color: var(--primary-foreground); }
  .swatch-warning { background: var(--warning); color: var(--primary-foreground); }
}
