/* Hand me downs · recipe book
   Colours: deep olive for Lunch, Pinterest Palette 2026 (Cool Blue, Orange Topaze, Cassis), and pink & burgundy.
   Each category's colour is the base: the desk around the book takes the bold colour,
   the pages a pastel of the same hue, and all text a dark shade of that hue.
   Set through [data-category] on the body (desk), on each page and on each chip.
   Every text/background pair below is checked for at least 4.5:1 contrast. */

:root {
  /* home and cook pages: warm brown desk, white pages, dark brown text */
  --base: #6B4330;           /* bold colour: desk, chips, avatars, ticks */
  --on-base: #FFF8F0;        /* text on --base */
  --paper: #FFFDF9;          /* page background */
  --ink: #3B2418;            /* main text on --paper */
  --ink-2: #4E3326;          /* body copy */
  --muted: #7A5A48;          /* small labels and meta */
  --rule: #EFE6DC;
  --rule-strong: #DCCAB7;

  --desk: #6B4330;
  --ring: #FFF8F0;
  --chip-edge: rgba(255, 248, 240, 0.35);

  --sans: 'Bricolage Grotesque', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  --page-pad: clamp(22px, 4vw, 56px);
  --chapters-height: 76px;
  color-scheme: light;
}

/* Lunch: butter yellow with dark brown-olive text */
[data-category="lunch"] {
  --base: #F4DC85; --on-base: #4A3A08;
  --paper: #FDF8E4; --ink: #3A2E05; --ink-2: #4A3B0A; --muted: #6B5815;
  --rule: #F1E6B8; --rule-strong: #E3D08A;
}
/* Voorgerechten: Cool Blue */
[data-category="starter"] {
  --base: #D7EFFF; --on-base: #1F3A52;
  --paper: #F1F9FF; --ink: #1A3247; --ink-2: #26425B; --muted: #46637A;
  --rule: #CFE4F4; --rule-strong: #A9CBE4;
}
/* Hoofdgerechten: deep olive (#3F4900) with pale olive-yellow text */
[data-category="main"] {
  --base: #3F4900; --on-base: #E6EDA0;
  --paper: #F3F5DF; --ink: #2A3000; --ink-2: #3A4207; --muted: #5A6320;
  --rule: #E2E6C2; --rule-strong: #C8CE95;
}
/* Desserts: Cassis */
[data-category="dessert"] {
  --base: #351E28; --on-base: #EBC3D7;
  --paper: #F1E8ED; --ink: #351E28; --ink-2: #4A2C3A; --muted: #6B4656;
  --rule: #EAD3DE; --rule-strong: #D7B3C4;
}
/* Borrel: pink base with burgundy text */
[data-category="drinks"] {
  --base: #F48FB8; --on-base: #5C0B2B;
  --paper: #FFEDF4; --ink: #4D0A25; --ink-2: #631332; --muted: #8A2346;
  --rule: #F8D0E0; --rule-strong: #EFA9C6;
}

body[data-category] { --desk: var(--base); --ring: var(--on-base); --chip-edge: rgba(0, 0, 0, 0.12); }
body[data-category="dessert"] { --chip-edge: rgba(235, 195, 215, 0.4); }
body[data-category="main"] { --chip-edge: rgba(230, 237, 160, 0.4); }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* fade the desk colour only after the first render, so a page never loads mid-fade */
body.is-ready, body.is-ready .chapters { transition: background-color 0.3s; }

a { color: var(--ink); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: 4px; }
.page :focus-visible { outline-color: var(--ink); }

/* ---------- Chapter carousel ---------- */

.chapters {
  max-width: calc(1280px + 2 * (52px + clamp(8px, 2vw, 28px)));
  margin: 0 auto;
  padding: clamp(14px, 2vw, 24px) clamp(16px, 3vw, 40px) 0;
}

.chapter-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 6px 4px;
}
.chapter-track::-webkit-scrollbar { display: none; }
/* centred while it fits, still scrollable from the first chip when it doesn't */
.chapter-track > :first-child { margin-left: auto; }
.chapter-track > :last-child { margin-right: auto; }

.chip {
  flex: none;
  scroll-snap-align: center;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1.5px solid var(--chip-edge);
  border-radius: 999px;
  background: var(--base);
  color: var(--on-base);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chip:hover { transform: translateY(-1px); }
.chip[aria-current="true"] { box-shadow: 0 0 0 3px var(--desk), 0 0 0 5px var(--ring); }

/* ---------- Desk and book ---------- */

.desk {
  min-height: calc(100dvh - var(--chapters-height));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 2vw, 28px);
  padding: clamp(14px, 2vw, 24px) clamp(16px, 3vw, 40px) clamp(16px, 3vw, 40px);
}

.book {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  perspective: 2600px;
  border-radius: 10px;
  box-shadow: 0 20px 44px rgba(53, 30, 40, 0.22);
}

.page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* a fixed book size on desktop: pages scroll inside when their content is longer */
  height: clamp(540px, calc(100dvh - var(--chapters-height) - 64px), 920px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
  padding: var(--page-pad);
  background-color: var(--paper);
}

.page.left {
  border-radius: 10px 2px 2px 10px;
  background-image: linear-gradient(to left, rgba(53, 30, 40, 0.1), rgba(53, 30, 40, 0) 48px);
}

.page.right {
  border-radius: 2px 10px 10px 2px;
  background-image: linear-gradient(to right, rgba(53, 30, 40, 0.1), rgba(53, 30, 40, 0) 48px);
}

/* ---------- Arrows ---------- */

.arrow {
  /* pinned to the middle of the screen, so the arrows stay at the same height on every page */
  align-self: start;
  position: sticky;
  top: calc(50vh - 26px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(53, 30, 40, 0.15);
  transition: transform 0.15s, opacity 0.15s;
}
.arrow:hover:not(:disabled) { transform: scale(1.06); }
.arrow:disabled { opacity: 0.35; cursor: default; }
.arrow svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- The turning leaf ---------- */

.leaf {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  pointer-events: none;
}
.leaf.forward { left: 50%; transform-origin: left center; }
.leaf.backward { left: 0; transform-origin: right center; }
.leaf > .page {
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.leaf > .back-face { transform: rotateY(180deg); }
.leaf > .page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(53, 30, 40, 0);
  animation: shade var(--turn-duration, 700ms) ease-in-out forwards;
  pointer-events: none;
}
@keyframes shade {
  50% { background: rgba(53, 30, 40, 0.12); }
  100% { background: rgba(53, 30, 40, 0); }
}

/* ---------- Page typography ---------- */

.label, .meta, .section-label, .tag {
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tag {
  align-self: flex-start;
  width: fit-content;
  margin: 0 0 18px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--base);
  color: var(--on-base);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--on-base) 25%, transparent);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
a.tag:hover { box-shadow: inset 0 0 0 1.5px var(--on-base); }

.title {
  margin: 0;
  font-size: clamp(36px, 4.4vw, 60px);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}

.label { font-size: 12px; color: var(--muted); }

.byline {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 16px 0 0;
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
}
a.byline:hover span { text-decoration: underline; text-underline-offset: 3px; }
.avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--rule);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.avatar.medium, .avatar.large { background: var(--base); color: var(--on-base); }
.avatar.medium { width: 48px; height: 48px; font-size: 20px; }
.avatar.pair { font-size: 0.72em; letter-spacing: -0.04em; }
.avatar.medium.pair { font-size: 15px; }
.avatar.large.pair { font-size: 64px; }
.avatar.large { width: min(60cqi, 280px); height: min(60cqi, 280px); font-size: 96px; }

.intro { margin-top: 20px; color: var(--ink-2); }
.intro p, .prose p { margin: 0 0 0.8em; }
.intro p:last-child, .prose p:last-child { margin-bottom: 0; }

.heading-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
  margin-top: 30px;
  margin-bottom: 8px;
}

.section-label {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.right > .section-label:not(:first-child) { margin-top: 34px; }
.right > .section-label { margin-bottom: 12px; }

/* servings stepper */
.servings {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 2px;
  font-family: var(--mono);
  font-size: 13px;
}
.servings button {
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 18px; line-height: 1;
}
.servings button:hover:not(:disabled) { background: var(--base); color: var(--on-base); }
.servings button:disabled { opacity: 0.3; cursor: default; }
.servings output { min-width: 5.5em; text-align: center; }

/* ingredients */
.group { margin: 16px 0 4px; font-size: 15px; font-weight: 600; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li + li { border-top: 1px dashed var(--rule-strong); }
.ingredient {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  line-height: 1.35;
}
.check {
  flex: none;
  width: 20px; height: 20px;
  margin-top: 1px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.check svg { width: 12px; height: 12px; fill: none; stroke: var(--on-base); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.ingredient .qty { font-weight: 600; }
.ingredient[aria-pressed="true"] .check { background: var(--base); }
.ingredient[aria-pressed="true"] .check svg { opacity: 1; }
.ingredient[aria-pressed="true"] .item-text { text-decoration: line-through; color: var(--muted); }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.step {
  display: grid;
  grid-template-columns: 1.4em 1fr;
  gap: 12px;
  width: 100%;
  padding: 10px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  line-height: 1.5;
}
.step .num {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--muted);
}
.step[aria-pressed="true"] { color: var(--muted); }
.step[aria-pressed="true"] > span:last-child { text-decoration: line-through; }
.step[aria-pressed="true"] .num { color: var(--rule-strong); }

.prose { color: var(--ink-2); }
.prose ul, .prose ol { margin: 0 0 0.8em; padding-left: 1.2em; }
.prose h4 { margin: 1em 0 0.3em; font-size: 16px; }
.prose blockquote { margin: 0 0 0.8em; padding-left: 14px; border-left: 3px solid var(--base); font-style: italic; }

.dish-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 28px;
}
.dish-photo.on-left { display: none; }

.letter {
  position: relative;
  margin: 44px 6px 8px 0;
  padding: 18px 22px 20px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--base) 9%, var(--paper));
  box-shadow: 0 1px 2px rgba(53, 30, 40, 0.06), 0 8px 18px rgba(53, 30, 40, 0.08);
  transform: rotate(-1.2deg);
  font-family: var(--hand);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-2);
}
.letter-text p { margin: 0 0 0.45em; }
.letter-text p:last-child { margin-bottom: 0; }
.letter-photo {
  float: right;
  width: 36%;
  max-width: 150px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  margin: -38px -16px 10px 14px;
  padding: 5px 5px 16px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(53, 30, 40, 0.18);
  transform: rotate(4deg);
}

.note {
  align-self: flex-end;
  max-width: 22ch;
  margin: 34px 4px 0 0;
  font-family: var(--hand);
  font-size: 27px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--ink);
  transform: rotate(-3deg);
  text-align: right;
}

/* ---------- Home: title page and the cooks ---------- */

.page.title-page { container-type: inline-size; justify-content: flex-end; }
.title-photo {
  position: relative;
  flex: 1 1 0;              /* fills the page above the title */
  min-height: 220px;
  margin-bottom: clamp(20px, 3vw, 32px);
}
.title-photo img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
  object-position: 50% 40%;
}

/* "Random": a round sticker on the corner of the photo, in a random category colour; opens a random main */
.random-pick {
  position: absolute;
  right: -14px;
  bottom: -22px;
  width: 96px;
  height: 96px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-content: center;
  background: var(--base);
  color: var(--on-base);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(53, 30, 40, 0.28);
  transform: rotate(-10deg);
  cursor: pointer;
  transition: transform 0.2s;
}
.random-pick:hover { transform: rotate(6deg) scale(1.06); }
.random-pick:active { transform: rotate(16deg) scale(0.96); }
.book-title {
  margin: 0;
  font-size: clamp(52px, 19cqi, 140px);
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--base);
}
.book-text {
  margin: 22px 0 0;
  max-width: 30ch;
  font-size: clamp(18px, 1.7vw, 21px);
  line-height: 1.45;
  color: var(--ink-2);
}

.cooks { list-style: none; margin: 4px 0 0; padding: 0; }
.cooks li + li { border-top: 1px dashed var(--rule-strong); }
.cooks a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 10px 0;
  color: var(--ink);
  text-decoration: none;
}
.cook-name { font-size: 22px; font-weight: 700; line-height: 1.2; }
.cook-name small { display: block; margin-top: 2px; font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cooks a:hover .cook-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* ---------- A cook's page ---------- */

.page.cook-page { container-type: inline-size; justify-content: flex-end; gap: 24px; }

/* ---------- Table of contents (chapter pages) ---------- */

.toc { list-style: none; margin: 0; padding: 0; }
.toc li + li { border-top: 1px dashed var(--rule-strong); }
.toc a {
  display: block;
  min-height: 44px;
  padding: 10px 0;
  text-decoration: none;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
}
.toc a small { display: block; margin-top: 3px; font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.toc a.numbered { display: grid; grid-template-columns: 1.4em 1fr; gap: 12px; }
.toc a .num { font-weight: 800; color: var(--muted); }
.toc a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.empty { margin: 18px 0 0; color: var(--muted); }
.empty code { font-family: var(--mono); font-size: 0.9em; background: var(--rule); padding: 1px 5px; border-radius: 4px; }

/* ---------- Chapter page (a category without recipes) ---------- */

.page.chapter-page {
  container-type: inline-size;
  background-color: var(--base);
  color: var(--on-base);
  justify-content: flex-end;
}
.chapter-page .chapter-title {
  margin: 0;
  font-size: clamp(36px, 14cqi, 104px); /* long names like "Voorgerechten" still fit */
  overflow-wrap: anywhere;
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: -0.05em;
}
.chapter-contents .label { margin: 0 0 10px; font-weight: 500; }
.chapter-contents .empty { margin-top: 6px; font-size: 19px; }

/* ---------- Portrait tablet and phone: one page at a time ---------- */

@media (max-width: 899px) {
  body { padding-bottom: calc(var(--chapters-height) + env(safe-area-inset-bottom, 0px)); }

  .desk {
    display: block;
    min-height: 0;
    padding: 16px;
  }
  .arrow { display: none; }

  .book {
    grid-template-columns: 1fr;
    max-width: 720px;
    perspective: none;
  }

  .page { height: auto; min-height: 0; overflow: visible; }
  .page.left {
    border-radius: 10px 10px 0 0;
    background-image: none;
    padding-bottom: 8px;
  }
  .page.right {
    border-radius: 0 0 10px 10px;
    background-image: none;
    padding-top: 8px;
  }
  .page.right::before {
    content: "";
    display: block;
    margin: 0 0 26px;
    border-top: 1px solid var(--rule-strong);
  }
  .page.chapter-page { min-height: 46vh; padding-bottom: var(--page-pad); }
  .page.cook-page { padding-bottom: var(--page-pad); }
  .title-photo { flex: none; height: clamp(220px, 60vw, 380px); }
  .random-pick { right: -6px; width: 84px; height: 84px; font-size: 13px; }
  .dish-photo.on-left { display: block; }
  .dish-photo.on-right { display: none; }
  .page.chapter-contents { padding-top: var(--page-pad); }
  .page.chapter-contents::before { display: none; }

  /* the chapter carousel becomes a bar at the bottom of the screen */
  .chapters {
    position: fixed;
    z-index: 10;
    left: 0; right: 0; bottom: 0;
    max-width: none;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--desk);
    box-shadow: 0 -6px 18px rgba(53, 30, 40, 0.16);
  }
  .chapter-track { padding: 6px 16px; scroll-padding-inline: 16px; }
}

@media (max-width: 420px) {
  .page { padding-left: 20px; padding-right: 20px; }
  .step { gap: 10px; }
}

/* ---------- Easter egg: all steps done ---------- */

.cheer {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(var(--chapters-height) + 32px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  pointer-events: none;
  animation: cheer-out 0.4s ease-in 2.4s forwards;
}
.cheer-text {
  position: relative;
  display: block;
  padding: 8px 22px 10px;
  border-radius: 999px;
  background: var(--base);
  color: var(--on-base);
  font-family: var(--hand);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(53, 30, 40, 0.25);
  animation: cheer-pop 0.5s cubic-bezier(.3, 1.6, .5, 1) both;
}
.cheer-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  opacity: 0;
  animation: cheer-burst 0.9s ease-out 0.15s both;
}
@keyframes cheer-pop {
  0% { transform: scale(0.3) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(-4deg); opacity: 1; }
}
@keyframes cheer-burst {
  0% { transform: rotate(var(--angle)) translateX(0) scale(1); opacity: 1; }
  100% { transform: rotate(var(--angle)) translateX(var(--distance)) scale(0.4); opacity: 0; }
}
@keyframes cheer-out { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print: only the open recipe ---------- */

@media print {
  body { background: #fff; padding: 0; font-size: 11pt; }
  .arrow, .chapters, .servings button { display: none !important; }
  .desk { display: block; padding: 0; min-height: 0; }
  .book { box-shadow: none; grid-template-columns: 1fr 1fr; gap: 10mm; max-width: none; }
  .page { min-height: 0; padding: 0; background: none !important; }
  .ingredient, .step { min-height: 0; padding: 4px 0; }
}
