/* The palette is a school pencil case: yellow project paper, white A4,
   black texta, the teacher's red pen, a blue biro and a roll of tape. */
:root {
  --paper: #ffd534;
  --sheet: #ffffff;
  --texta: #1c1c1c;
  --red-pen: #cf2118;
  --biro: #1b3aa8;
  --tape: #a7c8ee;
  --pencil: #5a5341;

  --hand: "Shantell Sans", "Chalkboard SE", "Comic Sans MS", "Comic Neue", system-ui, sans-serif;
  --teacher: "Caveat", "Bradley Hand", "Segoe Print", cursive;

  --wobble: 14px 18px 12px 20px / 18px 12px 20px 14px;
  --gutter: 16px;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--texta);
  font-family: var(--hand);
  font-variation-settings: "BNCE" 0, "INFM" 0, "SPAC" 0;
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: clip;
}

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

h1,
h2,
h3,
p,
ul,
figure,
fieldset {
  margin: 0;
  padding: 0;
}

fieldset {
  border: 0;
  min-width: 0;
}

a {
  color: var(--biro);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--texta);
}

:focus-visible {
  outline: 3px solid var(--biro);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.scribble {
  font-variation-settings: "BNCE" 45, "INFM" 100, "SPAC" 0;
  font-weight: 800;
}

.redpen {
  font-family: var(--teacher);
  font-weight: 700;
  color: var(--red-pen);
  line-height: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Top of the page ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--texta);
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
}

.brand img {
  width: 54px;
  transform: rotate(-4deg);
}

.top-link {
  font-size: 0.95rem;
  color: var(--texta);
  white-space: nowrap;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  padding: 10px 10px 10px 16px;
  background: var(--sheet);
  border: 2px solid var(--texta);
  border-radius: var(--wobble);
}

.notice[hidden] {
  display: none;
}

.notice button {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--texta);
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.notice button:hover {
  background: var(--paper);
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  gap: 8px;
  padding-block: 20px 36px;
}

.hero h1 {
  font-size: clamp(2.3rem, 1.25rem + 5.1vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  max-width: 13ch;
  text-wrap: balance;
}

.hero .lede {
  margin-top: 16px;
  max-width: 34ch;
  font-size: 1.15rem;
}

.hero-art {
  position: relative;
  justify-self: end;
  width: min(74%, 300px);
  padding-top: 34px;
}

.hero-art img {
  transform: rotate(-5deg);
}

.hero-note {
  position: absolute;
  top: 0;
  left: -30%;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  font-size: 1.6rem;
  transform: rotate(-7deg);
  white-space: nowrap;
}

.hero-note svg {
  width: 46px;
  height: 40px;
  margin-top: 14px;
  flex: none;
}

/* ---------- The two caps ---------- */

.caps {
  display: grid;
  gap: 40px;
  padding-bottom: 56px;
}

.sheet {
  position: relative;
  background: var(--sheet);
  padding: 18px;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(94, 68, 0, 0.18), 0 10px 22px -12px rgba(94, 68, 0, 0.55);
}

.sheet::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 112px;
  height: 30px;
  margin-left: -56px;
  background: var(--tape);
  opacity: 0.9;
  transform: rotate(-3deg);
}

.sheet:nth-child(even)::before {
  transform: rotate(2.5deg);
  margin-left: -40px;
}

.photo {
  position: relative;
  aspect-ratio: 1;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo img.is-swapping {
  animation: settle 0.28s ease-out;
}

@keyframes settle {
  from {
    opacity: 0.35;
    transform: rotate(-1.5deg) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.grade {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  justify-items: center;
  gap: 2px;
  transform: rotate(8deg);
  font-size: 1.2rem;
  text-align: center;
}

.grade b {
  display: grid;
  place-items: center;
  min-width: 2.1em;
  height: 1.65em;
  padding-inline: 0.3em;
  font-size: 1.5em;
  border: 3px solid currentColor;
  border-radius: 58% 42% 55% 45% / 48% 56% 44% 52%;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.title-row h2 {
  font-size: 1.6rem;
  line-height: 1.1;
}

.price {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.blurb {
  margin-top: 6px;
  max-width: 38ch;
}

.colours {
  margin-top: 18px;
}

.colours legend {
  padding: 0;
  margin-bottom: 8px;
}

.colours legend b {
  font-weight: 700;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: -6px;
}

.swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
}

.swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch span {
  width: 32px;
  height: 32px;
  background: var(--chip, #ccc);
  border: 2px solid var(--texta);
  border-radius: 52% 48% 55% 45% / 47% 54% 46% 53%;
  transition: transform 0.12s ease-out;
}

.swatch:hover span {
  transform: scale(1.08);
}

.swatch input:checked + span {
  box-shadow: 0 0 0 3px var(--sheet), 0 0 0 6px var(--texta);
}

.swatch input:focus-visible + span {
  outline: 3px solid var(--biro);
  outline-offset: 7px;
}

.buy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
  margin-top: 20px;
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--texta);
  border-radius: var(--wobble);
}

.qty button {
  width: 44px;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--texta);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border-radius: 12px;
}

.qty button:hover:not(:disabled) {
  background: var(--paper);
}

.qty button:disabled {
  color: #b9b4a6;
  cursor: default;
}

.qty output {
  min-width: 1.6em;
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
}

.buy {
  flex: 1 1 170px;
  min-height: 52px;
  padding: 10px 18px;
  border: 2px solid var(--texta);
  border-radius: var(--wobble);
  background: var(--texta);
  color: #fff;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease-out, background-color 0.1s;
}

.buy:hover:not(:disabled) {
  background: var(--biro);
  border-color: var(--biro);
  transform: rotate(-1deg);
}

.buy:active:not(:disabled) {
  transform: scale(0.98);
}

.buy:disabled {
  cursor: progress;
  background: #55524a;
  border-color: #55524a;
}

.status {
  margin-top: 12px;
  padding: 10px 14px;
  border: 2px dashed var(--red-pen);
  border-radius: var(--wobble);
}

.status:empty {
  display: none;
}

.small {
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--pencil);
}

.caps-message {
  padding: 24px 0 56px;
  font-size: 1.15rem;
  max-width: 40ch;
}

/* ---------- Shipping, returns, the cap ---------- */

.info {
  padding-block: 8px 48px;
  scroll-margin-top: 12px;
}

.info > h2 {
  font-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.6rem);
  line-height: 1.1;
}

.info > .squiggle {
  display: block;
  width: 190px;
  height: 12px;
  margin-top: 4px;
}

.info > p {
  margin-top: 10px;
  max-width: 44ch;
}

.info-grid {
  display: grid;
  gap: 28px;
  margin-top: 28px;
}

.info-grid h3 {
  font-size: 1.3rem;
  line-height: 1.2;
}

.info-grid ul {
  margin-top: 8px;
  padding-left: 1.1em;
  max-width: 44ch;
}

.info-grid li {
  margin-top: 6px;
}

.info-grid li::marker {
  content: "– ";
}

/* ---------- Bottom of the page ---------- */

.foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-block: 20px 28px;
  border-top: 2px solid var(--texta);
  font-size: 0.95rem;
}

.foot img {
  width: 58px;
  flex: none;
  transform: rotate(5deg);
}

/* ---------- Thank you page and lost page ---------- */

.note-page {
  display: grid;
  justify-items: center;
  padding-block: 36px 56px;
}

.note-page .sheet {
  width: 100%;
  max-width: 560px;
  padding: 30px 22px 28px;
}

.note-page h1 {
  font-size: clamp(1.9rem, 1.4rem + 2.6vw, 2.7rem);
  line-height: 1.08;
}

.note-page h1 s {
  text-decoration-color: var(--red-pen);
  text-decoration-thickness: 3px;
}

.note-page p {
  margin-top: 14px;
  max-width: 42ch;
}

.note-page .grade {
  position: static;
  float: right;
  margin: -4px -6px 6px 12px;
  font-size: 1.3rem;
}

.note-end {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.note-art {
  width: 104px;
  flex: none;
  transform: rotate(4deg);
}

.back {
  display: inline-block;
  padding: 10px 18px;
  border: 2px solid var(--texta);
  border-radius: var(--wobble);
  background: var(--texta);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.back:hover {
  background: var(--biro);
  border-color: var(--biro);
  color: #fff;
}

/* ---------- Wider screens ---------- */

@media (min-width: 760px) {
  :root {
    --gutter: 32px;
  }

  body {
    font-size: 1.125rem;
  }

  .top {
    padding-block: 22px;
  }

  .brand {
    font-size: 1.45rem;
  }

  .brand img {
    width: 66px;
  }

  .top-link {
    font-size: 1rem;
  }

  .hero {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
    gap: 40px;
    padding-block: 36px 72px;
  }

  .hero h1 {
    font-size: clamp(3rem, 5.4vw, 4.1rem);
    max-width: none;
  }

  .hero .lede {
    font-size: 1.3rem;
  }

  .hero-art {
    width: 100%;
    max-width: 400px;
    padding-top: 60px;
  }

  .hero-note {
    left: -6%;
    font-size: 2.3rem;
  }

  .hero-note svg {
    width: 62px;
    height: 54px;
    margin-top: 20px;
  }

  .caps {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding-bottom: 88px;
  }

  .sheet {
    padding: 26px;
  }

  .grade {
    top: -8px;
    right: -6px;
    font-size: 1.65rem;
  }

  .info {
    padding-bottom: 72px;
  }

  .info-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
  }

  .note-page {
    padding-block: 64px 96px;
  }

  .note-page .sheet {
    padding: 44px 40px 40px;
  }

  .note-page .grade {
    margin: -8px -14px 8px 20px;
    font-size: 1.6rem;
  }

  .note-art {
    width: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
