:root {
  --bg: #faf5f4;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --accent: #ddb8ad;
  --accent-bar: var(--accent);
  --rule: #ddd8d0;
  --measure: 30rem;
  --top-bar-height: 2.75rem;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --link-shadow: inset 0 -0.08em 0 currentColor;
  --link-shadow-hover: inset 0 -0.42em 0 var(--accent-bar);
}

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

html {
  font-size: clamp(18px, 3.5vw, 24px);
}

body {
  margin: 0;
  padding-top: var(--top-bar-height);
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-serif);
  line-height: 1.55;

  &.body--home {
    padding-top: 0;

    .site-main {
      width: 100%;
      max-width: none;
    }

    .doc:not(.doc--intro) {
      width: 90vw;
      max-width: var(--measure);
      margin-left: auto;
      margin-right: auto;
    }
  }
}

a {
  color: inherit;
  text-decoration: none;
  box-shadow: var(--link-shadow);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;

  &:hover {
    box-shadow: var(--link-shadow-hover);
  }

  &:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 30;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  color: var(--text);
  box-shadow: none;

  &:focus {
    left: 1rem;
    top: 1rem;
  }
}

.site-main,
.site-footer {
  width: 90vw;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0;
}

.site-main {
  padding-bottom: 3rem;
}

.doc {
  h2,
  h3 {
    margin: 0 0 1rem;
    font-weight: 600;
    line-height: 1.2;
  }

  h1 {
    margin: 3rem 0 1.75rem;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
  }

  h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1.05rem;
    margin-top: 1.75rem;
  }

  p {
    margin: 0 0 1rem;
    font-size: 1rem;
  }

  hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 3rem 0;
  }

  &.doc--me {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 1px solid var(--rule);
  }

  &.doc--intro {
    box-sizing: border-box;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    overflow-y: hidden;
    padding-top: 0;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;

    .intro-wrap {
      width: 90vw;
      max-width: var(--measure);
      margin: 0 auto;
    }

    .intro-body {
      position: relative;
      z-index: 1;
    }

    /* 100svh up from 2rem below intro copy — IO target (svh = small/stable on mobile) */
    .intro-nav-sentinel {
      position: absolute;
      left: 0;
      right: 0;
      bottom: -2rem;
      height: 100vh;
      height: 100svh;
      pointer-events: none;
    }

    .intro-scroll-hint {
      position: absolute;
      left: 50%;
      top: calc(100% + 2rem);
      transform: translateX(-50%);
      width: 3rem;
      height: auto;
      color: var(--accent);
      box-shadow: none;
      pointer-events: none;
    }
  }

  /* CV — h2 section / h4 employer / h5 role */
  &.doc--cv {
    h1 {
      margin: 2rem 0 0;
      font-size: 1.5rem;
      font-weight: 900;
      line-height: 1.3;
    }

    h2 {
      margin: 1.25rem 0 0.6rem;
      font-size: 1.25rem;
      font-weight: 600;
      line-height: 1.3;

      + h4 {
        margin-top: 1.1rem;
      }

      strong {
        font-weight: inherit;
      }
    }

    h4 {
      margin: 1.5rem 0 0.2rem;
      font-size: 0.75rem;
      font-weight: 600;
      line-height: 1.25;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--muted);

      + h5 {
        margin-top: 0.35rem;
      }

      strong {
        font-weight: inherit;
      }
    }

    h5 {
      margin: 0.35rem 0 0.15rem;
      font-size: 0.9rem;
      font-weight: 400;
      color: var(--muted);
      line-height: 1.4;

      strong {
        font-weight: inherit;
      }
    }

    p {
      margin: 0 0 0.65rem;
      font-size: 0.75rem;
    }

    ul {
      margin: 0 0 1rem;
      padding-left: 1.2rem;
      font-size: 0.75rem;
    }

    li {
      margin-bottom: 0.4rem;

      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}

.endmark-container {
  white-space: nowrap;

  .endmark {
    display: inline-block;
    width: 0.45em;
    height: 0.45em;
    margin-left: 0.12em;
    vertical-align: baseline;
    background: var(--text);
  }
}

.site-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--top-bar-height);
  background: var(--accent);
  transform: translateY(0);
  opacity: 1;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;

  &.site-top--hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;

    &.site-top--hidden {
      transform: translateY(-100%);
    }
  }
}

.site-top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 90vw;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0;
  font-size: 0.85rem;

  a {
    box-shadow: none;
    color: var(--text);

    &:not(.page-back):hover {
      box-shadow: var(--link-shadow);
    }
  }
}

.site-top-nav-end {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
}

.site-brand {
  flex-shrink: 0;
  font-weight: 600;
}

.site-nav-current {
  box-shadow: none;
  color: var(--muted);
}

.page-back {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex-shrink: 0;

  svg {
    width: 1.1rem;
    height: 1.1rem;
    box-shadow: none;
  }

  &:hover {
    svg {
      box-shadow: none;
    }

    span {
      box-shadow: var(--link-shadow);
      box-decoration-break: clone;
      -webkit-box-decoration-break: clone;
    }
  }
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.625rem 0;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.8rem;

  & .site-footer-copy {
    margin: 0;
  }

  & .site-footer-about {
    flex-shrink: 0;
    box-shadow: var(--link-shadow);

    &:hover {
      box-shadow: var(--link-shadow-hover);
    }
  }
}
