@font-face {
  src: local('Concourse'), local('Concourse Index'), local('Concourse-Index'), url('/fonts/concourse-index-regular.woff2') format('woff2');
  font-family: 'Concourse';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  src: local('iA Writer Duo'), local('iAWriterDuoS-Regular'), url('/fonts/ia-writer-duo-s-regular.woff2') format('woff2');
  font-family: 'iA Writer Duo';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  src: local('iA Writer Duo Bold'), local('iAWriterDuoS-Bold'), url('/fonts/ia-writer-duo-s-bold.woff2');
  font-family: 'iA Writer Duo';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  src: local('Cormorant Garamond'), url('/fonts/cormorant-garamond-cyrillic-variable-italic.woff2') format('woff2');
  font-family: 'Cormorant Garamond';
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;

  /* cyrillic */
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  src: local('Cormorant Garamond'), url('/fonts/cormorant-garamond-latin-variable-italic.woff2') format('woff2');
  font-family: 'Cormorant Garamond';
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
  
  /* latin */
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  src: local('Cormorant Garamond'), url('/fonts/cormorant-garamond-cyrillic-variable-normal.woff2') format('woff2');
  font-family: 'Cormorant Garamond';
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  
  /* cyrillic */
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  src: local('Cormorant Garamond'), url('/fonts/cormorant-garamond-latin-variable-normal.woff2') format('woff2');
  font-family: 'Cormorant Garamond';
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  
  /* latin */
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  src: local('Source Serif 4'), url('/fonts/source-serif-4-cyrillic-italic.woff2') format('woff2');
  font-family: 'Source Serif 4';
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;

  /* cyrillic */
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  src: local('Source Serif 4'), url('/fonts/source-serif-4-latin-italic.woff2') format('woff2');
  font-family: 'Source Serif 4';
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
  
  /* latin */
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  src: local('Source Serif 4'), url('/fonts/source-serif-4-cyrillic-normal.woff2') format('woff2');
  font-family: 'Source Serif 4';
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;

  /* cyrillic */
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  src: local('Source Serif 4'), url('/fonts/source-serif-4-latin-normal.woff2') format('woff2');
  font-family: 'Source Serif 4';
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  
  /* latin */
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font-primary: 'Source Serif 4', 'Noto Serif', Merriweather, Georgia, Times, 'Times New Roman', serif;
  --font-accent: 'Cormorant Garamond', 'Libre Baskerville', Garamond, Georgia, Times, 'Times New Roman', serif;
  --font-index: Concourse, Tahoma, Arial, sans-serif;
  --font-code: 'iA Writer Duo', 'Fira Code', 'Fira Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;

  --color-background: #F3EDE2;

  --color-primary: #2F2A26;

  --color-accent-lighter: #C9B48A;
  --color-accent: #C2A060;
  --color-accent-darker: #A88A5A;
  --color-accent-darkest: #7A5C2E;
}

html, body {
  margin: 0;
  font-family: var(--font-primary);
  background: var(--color-background);
  color: var(--color-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--color-accent-lighter);
  color: #fff;
}

body {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

main {
  max-width: 640px;
  margin: 96px auto 120px;
}

header {
  margin-bottom: 96px;

  p {
    margin: 0;
    padding: 24px 0 28px;
    text-transform: uppercase;
    text-align: center;
    font-family: var(--font-accent);
    font-size: 48px;
    font-weight: 500;
    line-height: 1;
    border-bottom: 1px solid var(--color-accent);
  }

  a {
    text-decoration: none;
    color: inherit;

    &:hover {
      color: var(--color-accent-darkest);
    }
  }
}

nav {
  text-transform: uppercase;
  font-family: var(--font-accent);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.08em;

  ul {
    list-style: none;
    display: flex;
    gap: 32px;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 16px 0;
  }

  li {
    position: relative;

    + li::before {
      content: '';
      position: absolute;
      top: 50%;
      left: -16px;
      width: 3px;
      height: 3px;
      transform: translate(-50%, -50%);
      background: var(--color-accent-darker);
      border-radius: 50%;
    }
  }

  a {
    text-decoration: none;
    color: inherit;

    &:hover, &.active {
      color: var(--color-accent-darkest);
    }
  }
}

article {
  font-size: 19px;
  line-height: 1.75;

  h1 {
    margin: 0 auto 12px;
    font-family: var(--font-accent);
    font-weight: 600;
    font-size: 44px;
    line-height: 1;
    text-align: center;

    &::after {
      content: '';
      display: block;
      width: 120px;
      height: 1px;
      margin: 16px auto 0;
      background: var(--color-accent-lighter);
    }
  }

  time {
    display: block;
    margin-bottom: 36px;
    padding: 0 0 12px;
    text-align: center;
    font-size: 14px;
    color: var(--color-accent-darker);
    letter-spacing: 0.05em;

    + p {
      &:first-letter {
        float: left;
        padding: 3px 8px 0 0;
        font-size: 80px;
        font-weight: 500;
        line-height: 1;
        color: var(--color-accent-darker);
      }
    }
  }

  a {
    text-underline-offset: 4px;
    text-decoration-color: var(--color-accent-lighter);
    color: inherit;

    &:hover {
      text-decoration-color: var(--color-accent);
      color: var(--color-accent-darkest);
    }

    &[href^="#footnote-"]:not([href$="-source"]) {
      margin-left: 0.15em;
      font-family: var(--font-index);
      text-decoration: none;
      color: var(--color-accent-darker);

      &:hover {
        font-feature-settings: 'ss02';
      }
    }

    &[href^="#footnote-"][href$="-source"]:after {
      /* TODO: тут можно картинку перерисовать, чтобы не нужны были эти странные махинации */
      content: '';
      display: inline-block;
      width: 0.6em;
      height: calc(0.6em / 9 * 8);
      margin-left: 0.20em;
      transform: rotate(-90deg);
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='8' fill='none'%3E%3Cpath fill='%237A5C2E' d='m5 0 3.536 3.536-.708.707L4.293.707z'/%3E%3Cpath fill='%237A5C2E' d='m4.293 6.37 3.536-3.536.707.707L5 7.077z'/%3E%3Cpath fill='%237A5C2E' d='M0 3.04h8v1H0z'/%3E%3C/svg%3E");
      background-size: cover;
    }
  }

  ol, ul {
    padding-left: 28px;
  }

  li {
    margin-bottom: 16px;

    &::marker {
      font-weight: 500;
      color: var(--color-accent-darker);
    }
  }

  p {
    margin: 0 0 24px;
  }

  em, blockquote {
    font-style: italic;
    color: var(--color-accent-darkest);
  }

  blockquote {
    margin: 0 0 0 36px;

    p {
      margin-bottom: 8px;
    }
  }
}

footer {
  padding: 24px 0 48px;
  border-top: 1px solid var(--color-accent);

  p {
    margin: 0;
    padding: 32px 0;
    text-transform: uppercase;
    text-align: center;
    font-family: var(--font-accent);
    font-size: 24px;
    line-height: 1;
    font-weight: 500;
  }

  a {
    text-decoration: none;
    letter-spacing: 0.08em;
    color: inherit;

    &:hover {
      color: var(--color-accent-darker);
    }
  }
}

aside {
  ol {
    list-style: none;
    padding-left: 36px;
    counter-reset: footnotes;
    font-size: 18px;
    line-height: 1.6;

    li {
      &::before {
        counter-increment: footnotes;
        content: counter(footnotes);
        position: absolute;
        margin-left: -36px;
        margin-top: -.15em;
        font-family: var(--font-index);
        font-size: 1.2em;
        font-weight: 400;
      }

      &:target::before {
        font-feature-settings: 'ss02';
      }
    }
  }
}

aside {
  margin: 72px 0 96px;

  h2 {
    margin: 0 0 32px;
    text-transform: uppercase;
    text-align: center;
    font-family: var(--font-accent);
    font-size: 22px;
    line-height: 1;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: double;
    text-decoration-color: var(--color-accent-lighter);
    text-decoration-inset: 64px;
    text-decoration-thickness: 1px;
    text-underline-offset: 8px;
  }
}

ul.nav {
  list-style: none;
  padding-left: 0;

  &::before {
    content: '';
    display: block;
    width: 120px;
    height: 1px;
    background: var(--color-accent-lighter);
    margin: 32px auto 32px;
  }

  li {
    margin-bottom: 0;
  }

  p {
    margin-bottom: 16px;
  }
}

hr {
  position: relative;
  display: block;
  width: 120px;
  height: 64px;
  margin: 36px auto 36px;
  border: none;

  &::before {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: 2px;
    background: var(--color-accent-lighter);
  }
}

a:hover hr {
  &::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 32px;
    /* TODO: оптимизировать картинку и заинлайнить */
    background: var(--color-background) url('./anchor.svg') center no-repeat;
    background-size: contain;
  }
}

code {
  font-family: var(--font-code);
  font-variant: none;
  font-size: 0.9em;
  color: var(--color-accent-darkest);
}

pre {
  box-sizing: border-box;
  overflow: auto;
  max-width: 100%;
  margin: 0 0 24px;
  line-height: 1.4;
}

:not(pre) > code {
  display: inline-block;
}