/* «Шило и клейстер» — переплётная мастерская */

:root {
  color-scheme: light;

  --paper: #f3ede1;
  --paper-deep: #e9e0cd;
  --ink: #2b2520;
  --ink-soft: #5d5248;
  --leather: #7b2f2a;
  --cloth: #344a3f;
  --cloth-deep: #26372e;
  --gilt: #b38f4c;
  --thread: #d8c7a0;
  --rule: #cdbf9f;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;

  --step--1: 0.875rem;
  --step-0: clamp(1.03rem, 0.98rem + 0.25vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.15rem + 0.5vw, 1.45rem);
  --step-2: clamp(1.55rem, 1.35rem + 1vw, 2rem);
  --step-4: clamp(2.35rem, 1.6rem + 3.8vw, 4.25rem);

  --gutter: clamp(1rem, 4vw, 2.5rem);
  --measure: 36rem;
  --page: 58rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 15% 0%, rgba(255, 252, 244, 0.9), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(201, 184, 150, 0.25), transparent 60%);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums;
}

/* Headband: a striped silk band across the top, as on a book's spine */
body::before,
.site-foot::after {
  content: "";
  display: block;
  height: 7px;
  background: repeating-linear-gradient(
    135deg,
    var(--leather) 0 5px,
    var(--thread) 5px 10px
  );
}

::selection {
  background: var(--thread);
  color: var(--ink);
}

a {
  color: var(--leather);
  text-decoration-line: underline;
  text-decoration-color: var(--thread);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 160ms ease;
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--leather);
  outline-offset: 3px;
  border-radius: 2px;
}

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

/* Layout */

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main {
  flex: 1 0 auto;
  padding-bottom: 3rem;
}

/* Masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem 1.5rem;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--step-1);
  letter-spacing: 0.01em;
}

.brand i {
  color: var(--leather);
}

.masthead nav {
  display: flex;
  gap: 1.25rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
}

.masthead nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}

.masthead nav a:hover,
.masthead nav a[aria-current="page"] {
  color: var(--leather);
  border-bottom-color: var(--leather);
}

/* Cover: the hero is dressed as a cloth-bound book with a gilt frame */

.cover {
  position: relative;
  color: var(--paper);
  background-color: var(--cloth);
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 3px);
  border-left: 14px solid var(--cloth-deep);
  border-radius: 2px 8px 8px 2px;
  padding: clamp(2.5rem, 7vw, 4.75rem) clamp(1.75rem, 6vw, 4rem);
}

.cover::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--gilt);
  outline: 1px solid var(--gilt);
  outline-offset: -5px;
  opacity: 0.75;
  pointer-events: none;
}

.cover h1 {
  margin: 0.35rem 0 0.75rem;
  font-size: var(--step-4);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: #f7f0de;
}

.cover h1 i {
  color: var(--gilt);
}

.cover .lede {
  margin: 0;
  max-width: 30rem;
  font-size: var(--step-1);
  line-height: 1.45;
  font-style: italic;
  color: #e6dcc6;
}

.kicker {
  margin: 0;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
  color: var(--leather);
}

.cover .kicker {
  color: var(--gilt);
}

/* Title block for inner pages */

.title-page {
  padding-block: clamp(1.5rem, 5vw, 3rem) 0.5rem;
  text-align: center;
}

.title-page h1 {
  margin: 0.4rem 0 0.5rem;
  font-size: var(--step-4);
  font-weight: 400;
  line-height: 1.08;
}

.title-page .lede {
  margin: 0 auto;
  max-width: 30rem;
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--step-1);
  line-height: 1.45;
}

/* Ornament between chapters */

.orn {
  display: block;
  width: 9rem;
  height: auto;
  margin: 2.75rem auto 2.25rem;
  color: var(--gilt);
}

/* Chapters */

.chapter {
  max-width: var(--measure);
  margin-inline: auto;
}

.chapter h2 {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 1rem;
  font-size: var(--step-2);
  font-weight: 400;
  line-height: 1.2;
}

.chapter h2 .num {
  flex: none;
  min-width: 1.6em;
  font-variant-caps: all-small-caps;
  font-size: 0.8em;
  letter-spacing: 0.06em;
  color: var(--leather);
}

.chapter p {
  margin: 0 0 1rem;
  hyphens: auto;
}

/* Sewing stitch under headings */

.stitch {
  height: 2px;
  margin: 0 0 1.5rem;
  border: 0;
  background: repeating-linear-gradient(
    90deg,
    var(--leather) 0 9px,
    transparent 9px 15px
  );
  opacity: 0.55;
}

/* Lists */

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.items li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.items li:first-child {
  padding-top: 0;
}

.items b,
.steps b {
  font-weight: 600;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0 0 1rem 2.6rem;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--leather);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--leather);
}

.works {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

/* Each work is a small library card */
.works li {
  padding: 1rem 1.1rem 1.1rem;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-top: 3px double var(--leather);
  border-radius: 2px;
}

.works h3 {
  margin: 0 0 0.35rem;
  font-size: var(--step-1);
  font-weight: 400;
  line-height: 1.25;
}

.works .meta {
  display: block;
  margin-bottom: 0.4rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-size: 1rem;
}

.works p {
  margin: 0;
  font-size: 0.98rem;
}

/* About: drop cap on the opening paragraph */

.opening::first-letter {
  float: left;
  margin: 0.08em 0.12em 0 0;
  font-size: 3.4em;
  line-height: 0.82;
  color: var(--leather);
}

.fairs {
  margin: 0;
}

.fairs div {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.25rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.fairs dt {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--leather);
}

.fairs dd {
  margin: 0;
}

.note {
  margin-top: 1.25rem;
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--gilt);
  background: rgba(233, 224, 205, 0.6);
  font-style: italic;
  color: var(--ink-soft);
}

/* 404 */

.lost {
  max-width: 32rem;
  margin-inline: auto;
  padding-block: clamp(2rem, 8vw, 5rem) 1rem;
  text-align: center;
}

.lost h1 {
  margin: 0.4rem 0 0.75rem;
  font-size: var(--step-2);
  font-weight: 400;
}

.lost .leaf {
  display: block;
  width: 5.5rem;
  height: auto;
  margin: 0 auto 1.25rem;
  color: var(--leather);
}

.lost p {
  margin: 0 0 1rem;
}

/* Footer */

.site-foot {
  flex: none;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: var(--step--1);
}

.site-foot .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.25rem 1.5rem;
}

.site-foot p {
  margin: 0;
}

@media (max-width: 30rem) {
  .cover {
    border-left-width: 10px;
  }

  .fairs div {
    grid-template-columns: 1fr;
  }

  .steps li {
    padding-left: 2.35rem;
  }
}
