/* ==========================================================================
   Human-Machine Learning / Corinne Schillizzi
   One stylesheet for every page. Sections:
     1. Fonts          4. Header & navigation   7. Blog
     2. Tokens         5. Footer                8. Shop
     3. Base & layout  6. Home & author pages   9. Forms
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */

@font-face {
  font-family: "Source Serif Pro";
  font-style: normal;
  font-weight: 200 900;
  font-display: fallback;
  src: url("../fonts/SourceSerif4Variable-Roman.ttf.woff2") format("woff2");
}

@font-face {
  font-family: "Source Serif Pro";
  font-style: italic;
  font-weight: 200 900;
  font-display: fallback;
  src: url("../fonts/SourceSerif4Variable-Italic.ttf.woff2") format("woff2");
}

/* 2. Tokens --------------------------------------------------------------- */

:root {
  --color-text: #000;
  --color-background: #fff;
  --color-accent: #ffe770;
  --color-separator: #808080;
  --color-error: #d63637;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --font-serif: "Source Serif Pro", serif;

  --text-small: 1rem;
  --text-base: 1.125rem;
  --text-heading: clamp(2.75rem, 6vw, 3.25rem);
  --line-height: 1.6;

  --width-content: 650px;
  --width-wide: 1000px;

  --space-flow: 1.5rem;                         /* between stacked blocks */
  --space-gutter: max(1.25rem, 5vw);            /* page side padding */
  --space-large: clamp(4rem, 10vw, 8rem);
  --space-section: calc(3em + 2 * var(--space-flow)); /* around separators */
}

/* 3. Base & layout -------------------------------------------------------- */

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

body {
  margin: 0;
  padding: 0 var(--space-gutter);
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2 {
  font-family: var(--font-serif);
  font-size: var(--text-heading);
  font-weight: 300;
  line-height: 1.2;
}

p,
ul,
ol,
h1,
h2,
figure,
blockquote,
fieldset {
  margin: 0;
}

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

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25ch;
}

a:hover,
a:focus {
  text-decoration-style: dashed;
}

a:active {
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: var(--width-content);
  margin-inline: auto;
}

.container--wide {
  max-width: var(--width-wide);
}

/* stacks its children with a regular gap */
.flow > * + * {
  margin-block-start: var(--space-flow);
}

.site-main {
  display: flow-root; /* keeps the last block's bottom margin inside */
  margin-block-start: var(--space-flow);
}

.page-title {
  line-height: 1.15;
}

.separator {
  width: 100px;
  margin-block: var(--space-section);
  margin-inline: auto;
  border: 0;
  border-bottom: 2px solid;
  color: var(--color-separator);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

.skip-link:focus {
  top: 5px;
  left: 5px;
  z-index: 100001;
  width: auto;
  height: auto;
  padding: 15px 23px 14px;
  clip: auto;
  background: #f1f1f1;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: normal;
  text-decoration: none;
}

/* 4. Header & navigation -------------------------------------------------- */

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-flow);
  padding: 2em 0 3em;
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-flow);
}

.brand__logo {
  display: inline-block;
  line-height: 0;
}

.brand__title {
  font-family: inherit;
  font-size: var(--text-small);
  font-style: italic;
  font-weight: 400;
  line-height: var(--line-height);
}

.brand__title a {
  text-decoration: none;
}

.brand__title a:hover {
  text-decoration: underline;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-flow);
  padding: 0;
  list-style: none;
}

.site-nav__list a {
  text-decoration: none;
}

.site-nav__list a:hover {
  text-decoration: underline;
}

.site-nav__open,
.site-nav__close {
  display: flex;
  cursor: pointer;
}

.site-nav__close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1; /* above the menu list, which overlaps it */
}

/* small screens: the menu opens as a full-screen overlay,
   toggled by the hidden checkbox (no JavaScript) */
@media (max-width: 599px) {
  .site-nav__panel {
    display: none;
  }

  .site-nav__toggle:checked ~ .site-nav__panel {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: block;
    overflow: auto;
    padding: var(--space-gutter) var(--space-gutter) var(--space-large);
    background: var(--color-background);
    animation: menu-fade-in 0.1s ease-out forwards;
  }

  .site-nav__toggle:checked ~ .site-nav__panel .site-nav__list {
    position: relative;
    flex-direction: column;
    align-items: flex-end;
    padding-top: calc(2rem + 24px);
  }

  .site-nav__toggle:checked ~ .site-nav__panel .site-nav__close {
    top: var(--space-gutter);
    right: var(--space-gutter);
  }

  html:has(.site-nav__toggle:checked) {
    overflow: hidden;
  }
}

@media (min-width: 600px) {
  .site-nav__open,
  .site-nav__close {
    display: none;
  }
}

@keyframes menu-fade-in {
  from {
    opacity: 0;
    transform: translateY(0.5em);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 5. Footer --------------------------------------------------------------- */

.site-footer {
  margin-block-start: var(--space-flow);
  padding-top: var(--space-large);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-flow);
  padding: 4rem 0;
}

.site-footer__title {
  font-style: italic;
}

/* keeps the logo and title apart from the social links on wide screens */
.site-footer__spacer {
  flex-basis: 497px;
  height: 100px;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1em;
  padding: 0;
  font-size: 24px;
  list-style: none;
}

.social-links a {
  display: flex;
  align-items: center;
  line-height: 0;
}

.social-links svg {
  fill: currentColor;
}

/* 6. Home & author pages -------------------------------------------------- */

.book-cover {
  display: block;
  width: 100%;
  object-fit: contain;
}

.buy {
  margin-block: var(--space-section);
}

.buy__title {
  text-align: center;
}

.buy__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-flow);
  margin-block-start: var(--space-flow);
  /* the original layout offsets the buttons by one gap */
  padding: 0 0 0 var(--space-flow);
  list-style: none;
}

.button {
  display: inline-block;
  padding: calc(0.667em + 2px) calc(1.333em + 2px);
  background: var(--color-accent);
  color: var(--color-text);
  text-align: center;
  text-decoration: none;
}

.button:hover {
  opacity: 0.9;
}

.profile {
  display: grid;
  grid-template-columns: 41% auto;
  align-items: start;
}

.profile__photo {
  display: block;
  width: 100%;
}

.profile__roles {
  padding: 0 8%;
}

.profile__roles p {
  margin-block: 1em;
}

.list-title {
  font: inherit;
  font-weight: 700;
}

@media (max-width: 600px) {
  .profile {
    grid-template-columns: 100%;
  }
}

/* 7. Blog ----------------------------------------------------------------- */

.post-list {
  display: grid;
  gap: 1em;
  margin-block-start: calc(50px + 2 * var(--space-flow));
  padding: 0 1em 1em 0;
  list-style: none;
}

@media (min-width: 600px) {
  .post-list {
    grid-template-columns: 1fr 1fr;
  }
}

.post-list__item a {
  display: block;
}

.post-list__date {
  display: block;
  font-size: 0.8125em;
}

.newsletter {
  margin-block-start: calc(80px + 2 * var(--space-flow));
}

.newsletter__title {
  font-size: 2rem;
  font-weight: 400;
  line-height: var(--line-height);
}

/* 8. Shop ----------------------------------------------------------------- */

.breadcrumb {
  font-size: var(--text-small);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-flow);
  /* where the (empty) product grid used to start */
  margin-block-start: calc(3 * var(--space-flow));
}

/* 9. Forms ---------------------------------------------------------------- */

.form {
  --field-height: 43px;
  --field-font-size: 16px;
  --field-radius: 3px;
  --field-border: rgba(0, 0, 0, 0.25);
  --label-spacing: 15px;
  --checkbox-size: 16px;
  --button-height: 41px;
  --button-font-size: 17px;
  --button-padding: 15px;
  --button-spacing: 10px;
  --button-background: #066aab;
  --button-color: #fff;
  --button-radius: 3px;

  margin-block-end: var(--space-flow);
}

.form--sample {
  --field-height: 50px;
  --field-font-size: 18px;
  --field-radius: 0;
  --label-spacing: 20px;
  --checkbox-size: 18px;
  --button-height: 48px;
  --button-font-size: 20px;
  --button-padding: 20px;
  --button-spacing: 15px;
  --button-background: var(--color-accent);
  --button-color: var(--color-text);
  --button-radius: 0;
}

.form fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.form__field {
  padding: 15px 0;
}

.form__label {
  display: block;
  margin: 0 0 var(--label-spacing);
  padding: 0;
  color: rgba(0, 0, 0, 0.85);
  font-size: 16px;
  font-weight: 700;
  line-height: 19px;
}

.form__required {
  color: var(--color-error);
  font-weight: 400;
}

.form__input {
  display: block;
  width: 100%;
  max-width: 60%;
  height: var(--field-height);
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background-color: #fff;
  background-clip: padding-box;
  color: rgba(0, 0, 0, 0.7);
  font: inherit;
  font-size: var(--field-font-size);
  line-height: 100%;
}

.form__select {
  appearance: none;
  padding-right: 24px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--field-border) 50%),
    linear-gradient(135deg, var(--field-border) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  line-height: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.form__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  max-width: 60%;
}

.form__row > * {
  width: 50%;
  padding-right: 10px;
}

.form__row > * + * {
  padding: 0 0 0 10px;
}

.form__row .form__input {
  max-width: 100%;
}

.form__sublabel {
  display: block;
  margin-top: 5px;
  color: rgba(0, 0, 0, 0.55);
  font-size: 14px;
  line-height: 17px;
}

.form__choice {
  display: flex;
  align-items: flex-start;
}

.form__choice label {
  padding-left: 12px;
  color: rgba(0, 0, 0, 0.85);
  font-size: 16px;
  line-height: 1.3;
}

/* custom checkbox: a bordered box, with a tick when checked */
.form__choice input {
  position: relative;
  flex: none;
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  /* centres the box on the first line of the 16px/1.3 label */
  margin: calc((16px * 1.3 - var(--checkbox-size)) / 1.5) 0 0 2px;
  appearance: none;
}

.form__choice input::before,
.form__choice input::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  box-sizing: content-box;
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  cursor: pointer;
}

.form__choice input::before {
  border: 1px solid var(--field-border);
  border-radius: 3px;
  background: #fff padding-box;
}

.form__choice input:checked::before,
.form__choice input:focus::before {
  border-color: var(--button-background);
  box-shadow: 0 0 0 1px var(--button-background), 0 1px 2px rgba(0, 0, 0, 0.15);
}

.form__choice input:checked::after {
  top: -2px;
  left: -3px;
  height: calc(var(--checkbox-size) * 0.6);
  border-bottom: 4px solid var(--button-background);
  border-left: 4px solid var(--button-background);
  transform: translate(0, 1px) scale(0.5) rotate(-45deg);
}

.form__submit {
  display: inline-block;
  height: var(--button-height);
  margin-top: var(--button-spacing);
  padding: 0 var(--button-padding);
  border: 0;
  border-radius: var(--button-radius);
  background: var(--button-background);
  color: var(--button-color);
  font: inherit;
  font-size: var(--button-font-size);
  font-weight: 500;
  line-height: 100%;
  cursor: pointer;
}

.form__submit:hover {
  box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
  .form__field {
    padding-inline: 1px;
  }

  .form__input,
  .form__row {
    max-width: 100%;
  }
}
