@layer reset, layout, components, page;

@font-face {
  font-family: "Grandstander";
  src: url("../fonts/Grandstander-VariableFont_wght.ttf")
    format("truetype-variations");
  font-display: swap;
  font-weight: 100 900;
}

@font-face {
  font-family: "Grandstander-fallback";
  size-adjust: 112.22%;
  src: local("Arial");
}

@font-face {
  font-family: "berlin_type";
  src: url("../fonts/berlintypeoffice-bold-webfont.woff2") format("woff2");
  font-display: swap;
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: "berlin_type";
  src: url("../fonts/berlintypeoffice-regular-webfont.woff2") format("woff2");
  font-display: swap;
  font-weight: normal;
  font-style: normal;
}

:root {
  --lightness: 50%;
  --chroma: 0.1652;
  --hue: 164.1;

  --primary-color: oklch(var(--lightness) var(--chroma) var(--hue));
  --primary-color-dark: color-mix(in oklch, var(--primary-color) 90%, black);

  --warning-color: oklch(90% var(--chroma) 50);
  --warning-color-dark: color-mix(in oklch, var(--warning-color) 90%, black);

  --error-color: oklch(0.53 0.2415 28.59);
  --error-color-dark: color-mix(in oklch, var(--error-color) 90%, black);

  --shadow: 3.4px 3.4px 2.7px rgba(0, 0, 0, 0.022),
    8.7px 8.7px 6.9px rgba(0, 0, 0, 0.031),
    17.7px 17.7px 14.2px rgba(0, 0, 0, 0.039),
    36.5px 36.5px 29.2px rgba(0, 0, 0, 0.048),
    100px 100px 80px rgba(0, 0, 0, 0.07);

  --brand-font: "Grandstander", "Grandstander-fallback";
}

@layer components {
  header {
    --hero-height: clamp(15rem, 50svw, 25rem);

    isolation: isolate;
    position: sticky;
    z-index: 10;
    inset-block-start: calc(-1 * var(--hero-height) - 3rem);

    .logo {
      display: flex;
      align-items: end;
      z-index: 1;
      background-color: white;
      padding-block: 0.5rem;
      padding-inline: 0.5rem;
      border-radius: 0.25em;
      margin-inline: auto;
      width: fit-content;
      line-height: 1.1;
      letter-spacing: -0.02em;
      color: inherit;
      text-decoration: initial;

      svg {
        height: 6rem;
      }

      span {
        font-weight: normal;
        font-size: 0.7em;
      }
    }

    .hero {
      width: min(100%, 1024px);
      margin-inline: auto;
      margin-block-start: -2rem;
    }

    .hero-image {
      background-color: #ccc;
      height: var(--hero-height);
      border-radius: max(0px, min(0.25rem, calc((100vw - 100%) * 9999)));
      overflow: clip;

      img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }

    .cta {
      margin-block: auto 4rem;
      margin-inline-start: auto;
      background: var(--primary-color);
      padding: 0.5rem 2rem;
      border-start-start-radius: 0.5rem;
      border-end-start-radius: 0.5rem;
      text-decoration: none;
      font-weight: 700;
      font-family: var(--brand-font);
      font-size: 1.5rem;
      color: white;
      border: 3px solid var(--primary-color-dark);
      border-inline-end: none;

      &:hover {
        background-color: var(--primary-color-dark);
        border-color: var(--primary-color);
      }

      &:focus-visible {
        outline-style: solid;
        outline-offset: 6px;
        outline-width: 2px;
        outline-color: var(--primary-color-dark);
      }
    }

    nav {
      display: flex;
      margin-block-start: auto;
      translate: 0 50%;

      ul {
        background-color: white;
        margin-inline: auto;
        padding: 0;
        border: 2px solid white;
        border-radius: 9999px;
        display: flex;
        list-style-type: none;
        box-shadow: var(--shadow);
        overflow: clip;

        li {
          white-space: nowrap;
        }

        a {
          --min-padding: 0.25rem;

          display: block;
          padding-block: 0.5rem;
          padding-inline: clamp(0.25rem, 2lvw, 1rem);
          text-decoration: none;

          li:first-of-type & {
            padding-inline-start: 1rem;
          }

          li:last-of-type & {
            padding-inline-end: 1rem;
          }
        }
      }
    }
  }

  footer {
    display: flex;
    gap: 2em;
    align-items: end;
    font-size: 0.8rem;
    margin-block-start: 4rem;
    padding-block: 1rem;

    nav {
      margin-inline-start: auto;

      ul {
        display: flex;
        list-style-type: none;
        padding: 0;
        gap: 1rem;
      }
    }
  }

  .person-intro {
    margin-block-start: 2rem;

    h1 {
      margin-block: 0;
    }

    figure {
      display: flex;
      align-items: start;
      gap: clamp(1rem, 10%, 4rem);
    }

    img {
      width: clamp(4rem, 25%, 10rem);
      aspect-ratio: 1/1;
      background-color: #eee;
      box-shadow: var(--shadow);
      outline: 4px solid white;

      rotate: var(--rotate);
    }

    figcaption {
      flex: 1;
    }
  }

  table {
    width: 100%;
    border-collapse: collapse;
    line-height: 1.5;

    tr {
      &:nth-child(even) {
        background-color: #ededed;
      }

      td,
      th {
        padding-block: 0.25rem;
        padding-inline: 0.5rem;
        text-align: left;
      }

      td {
        &:first-of-type {
          white-space: nowrap;
        }
      }
    }
  }
}

@layer layout {
  html {
    height: 100%;
  }

  body {
    min-height: 100%;
    display: flex;
    flex-direction: column;

    main {
      flex: 1;
    }
  }

  .container {
    --container-width: min(100%, calc(42rem + 2 * var(--space-inline)));
    --space-inline: 1rem;
    width: var(--container-width);
    padding-inline: var(--space-inline);
    margin-inline: auto;

    .container-wide {
      --width: calc(min(100dvw, 1024px) - 2 * var(--space-inline));
      margin-inline: calc((var(--container-width) - var(--width)) / 2);
    }
  }

  .stack {
    display: grid;

    > * {
      grid-area: 1 / 1;
    }
  }

  main {
    section {
      p + p {
        margin-block-start: 2rem;
      }
    }

    :where(h1, h2, h3, h4, h5, h6) {
      margin-block-start: 3rem;
      margin-block-end: 0.5rem;
    }
  }

  .split-columns {
    display: flex;
    flex-wrap: wrap;
    column-gap: 2rem;

    > * {
      flex: 1 0 30ch;
    }
  }
}

@layer reset {
  /*
    1. Use a more-intuitive box-sizing model.
  */
  *,
  *::before,
  *::after {
    position: relative;
    box-sizing: border-box;
  }

  /*
    2. Remove default margin
  */
  * {
    margin: 0;
  }

  /*
    Typographic tweaks!
    3. Add accessible line-height
    4. Improve text rendering
  */
  body {
    font-family: "berlin_type", "Helvetica Neue", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  address {
    font-style: normal;
  }

  /*
    5. Improve media defaults
  */
  img,
  picture,
  video,
  canvas,
  svg {
    display: block;
    max-width: 100%;
  }

  /*
    6. Remove built-in form typography styles
  */
  input,
  button,
  textarea,
  select {
    font: inherit;
    accent-color: var(--primary-color-dark);

    &:focus-visible {
      outline-color: var(--primary-color-dark);
    }
  }

  /*
    7. Avoid text overflows
  */
  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    overflow-wrap: break-word;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--brand-font);
    font-optical-sizing: auto;
    font-weight: 700;
    font-style: normal;
    text-wrap: pretty;
  }

  a {
    color: var(--primary-color);

    &[data-active] {
      color: color-mix(in oklab, currentcolor 50%, black);
    }
  }
}
