/* Holiday baked mac and cheese. The page is the dish: a broiled crust on top, cheese sauce underneath. */

@font-face {
  font-family: "Caprasimo";
  src: url("fonts/caprasimo-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-next-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --crust: #3a1d0c;      /* the broiled top: head and footer */
  --cheddar: #f4b23e;    /* title, the one bright note */
  --sauce: #fff1cc;      /* cheese sauce: the page */
  --paper: #ffffff;      /* the ingredients card */
  --roux: #2b170a;       /* ink */
  --roux-2: #6b4a33;     /* quieter ink */
  --chive: #2f6b2c;      /* done, running, focus */
  --rule: #ecd39a;
  --on-crust: #d4c2a2;   /* sauce at 78% on crust */
  --display: "Caprasimo", "Cooper Black", Georgia, serif;
  --text: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(20px, 4vw, 56px);
  --page: 1320px;        /* head, body and footer share one left edge */
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sauce);
  color: var(--roux);
  font: 400 1.125rem/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
/* Short blocks (two to four lines) balance, so no last line is left short */
.dek, .credit, .preheat, .kit, .note, .aside, .tip p, .list small, .layers figcaption, .foot p { text-wrap: balance; }
@media (min-width: 420px) { .steps p { text-wrap: balance; } }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
.nb { white-space: nowrap; }
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
:focus-visible { outline: 3px solid var(--chive); outline-offset: 3px; border-radius: 6px; }
.head :focus-visible, .foot :focus-visible { outline-color: var(--cheddar); }

/* ---------- Head: the crust ---------- */

.head {
  position: relative;
  overflow: hidden;
  background: var(--crust);
  color: var(--sauce);
}
.head__photo { display: block; }
.head__photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: 50% 40%;
}
.title {
  font: 400 clamp(2.2rem, 11.2vw, 3.4rem)/.98 var(--display);
  color: var(--cheddar);
  letter-spacing: -.005em;
  font-kerning: normal;
}
.dek {
  margin-top: 18px;
  max-width: 30em;
  font-size: clamp(1.1rem, 1rem + .35vw, 1.3rem);
  line-height: 1.45;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 30px;
  margin: 26px 0 0;
}
.facts dt { font-size: .85rem; color: var(--on-crust); }
.facts dd { margin: 2px 0 0; font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.actions:not(:has(.btn:not([hidden]))) { display: none; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 20px;
  border: 1.5px solid rgba(255, 241, 204, .55);
  border-radius: 999px;
  background: transparent;
  color: var(--sauce);
  font: 700 1rem/1 var(--text);
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn:hover { background: rgba(255, 241, 204, .1); border-color: var(--sauce); }
.btn[aria-pressed="true"] { background: var(--cheddar); border-color: var(--cheddar); color: var(--roux); }
#wake::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}
#wake[aria-pressed="true"]::before { background: currentColor; }
.credit { margin-top: 22px; font-size: .95rem; color: var(--on-crust); }
.credit a { color: var(--sauce); }

@media (max-width: 959.98px) {
  .head__inner { display: flex; flex-direction: column; }
  .head__photo {
    order: -1;
    -webkit-mask-image: linear-gradient(#000 56%, transparent);
    mask-image: linear-gradient(#000 56%, transparent);
  }
  .head__photo img { max-height: 60vh; }
  .head__text { position: relative; margin-top: -12px; padding: 0 var(--gutter) 40px; }
}

@media (min-width: 960px) {
  .head__inner {
    display: flex;
    align-items: center;
    max-width: var(--page);
    min-height: clamp(540px, 76vh, 700px);
    margin: 0 auto;
    padding: 56px var(--gutter);
  }
  .head__text { position: relative; z-index: 1; width: min(660px, 52%); }
  .title { font-size: clamp(2.75rem, 1rem + 4.4vw, 4.9rem); }
  .head__photo {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(58%, 1200px);
    -webkit-mask-image: linear-gradient(to right, transparent, rgba(0,0,0,.04) 14%, rgba(0,0,0,.22) 24%, rgba(0,0,0,.58) 34%, #000 46%);
    mask-image: linear-gradient(to right, transparent, rgba(0,0,0,.04) 14%, rgba(0,0,0,.22) 24%, rgba(0,0,0,.58) 34%, #000 46%);
  }
  .head__photo img { width: 100%; height: 100%; aspect-ratio: auto; object-position: 55% 45%; }
}

/* ---------- Body: the sauce ---------- */

.recipe {
  display: grid;
  gap: clamp(36px, 5vw, 72px);
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(32px, 6vw, 80px) var(--gutter) clamp(56px, 8vw, 112px);
}
@media (min-width: 960px) {
  .recipe { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  /* The card stays put beside the steps. When it is taller than the window it scrolls on its own,
     and a shadow at its top or bottom edge says there is more. */
  .ingredients .card {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #dcb868 transparent;
    background:
      linear-gradient(#fff 40%, rgba(255, 255, 255, 0)) top / 100% 56px no-repeat local,
      linear-gradient(rgba(255, 255, 255, 0), #fff 60%) bottom / 100% 56px no-repeat local,
      radial-gradient(farthest-side at 50% 0, rgba(58, 29, 12, .3), rgba(58, 29, 12, 0)) top / 100% 18px no-repeat scroll,
      radial-gradient(farthest-side at 50% 100%, rgba(58, 29, 12, .3), rgba(58, 29, 12, 0)) bottom / 100% 18px no-repeat scroll,
      #fff;
  }
  .card .card__more { display: block; position: sticky; bottom: 0; height: 0; margin: 0 -26px; }
  .card__more span {
    position: absolute;
    inset: auto 0 -24px 0;
    padding: 40px 0 14px;
    background: linear-gradient(rgba(255, 255, 255, 0), #fff 62%);
    color: var(--chive);
    font: 700 .9rem/1 var(--text);
    text-align: center;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
  }
  .card[data-more] .card__more span { opacity: 1; }
  .list label { min-height: 0; padding: 7px 0; }
  .card h3 { margin-top: 20px; }
  .method { padding-top: 27px; }
  .skip { display: none; }
}

/* Ingredients card */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 26px 26px 24px;
}
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card__more { display: none; }
.card h2, .method h2, .tips h2 {
  font: 400 clamp(1.9rem, 1.5rem + 1.2vw, 2.4rem)/1.05 var(--display);
  color: var(--crust);
}
.textbtn {
  min-height: 44px;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--chive);
  font: 700 .95rem/1 var(--text);
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}
.hint { margin-top: 6px; font-size: .95rem; color: var(--roux-2); }
.skip { color: var(--chive); font-weight: 700; margin-left: 4px; }
.card h3 {
  margin: 24px 0 2px;
  font: 700 1rem/1.3 var(--text);
  color: var(--roux-2);
}
.note { margin: 4px 0 6px; font-size: .95rem; line-height: 1.45; color: var(--roux-2); }
.list { list-style: none; }
.list li + li { border-top: 1px solid #f4e7c6; }
.list label {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 44px;
  padding: 9px 0;
  cursor: pointer;
  line-height: 1.4;
}
.list input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 24px; height: 24px;
  margin: 0;
  border: 2px solid #9c7a55;
  border-radius: 7px;
  background: #fff center / 16px 16px no-repeat;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.list input:checked {
  border-color: var(--chive);
  background-color: var(--chive);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.list b { font-weight: 750; }
.list small { display: block; margin-top: 1px; font-size: .88rem; color: var(--roux-2); }
.list input:checked + span { color: var(--roux-2); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: rgba(107, 74, 51, .55); }
/* Method */
.preheat { margin-top: 10px; color: var(--roux-2); }
.kit { margin-top: 6px; max-width: 38em; font-size: 1rem; line-height: 1.5; color: var(--roux-2); }
.kit b { color: var(--roux); }
.steps { list-style: none; margin-top: 26px; counter-reset: step; }
.steps > li {
  position: relative;
  counter-increment: step;
  padding: 26px 0 28px 4.25rem;
  border-top: 1px solid var(--rule);
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 22px;
  width: 3rem;
  font: 400 2.75rem/1 var(--display);
  color: var(--crust);
  text-align: left;
}
.steps h3 { font: 750 1.25rem/1.3 var(--text); margin: 6px 0 8px; }
.steps p { max-width: 38em; }
.steps p + p { margin-top: 10px; }
.aside { font-size: 1rem; color: var(--roux-2); }

/* Timers */
.timers { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.timer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 18px 8px 12px;
  border: 1.5px solid #9c7a55;
  border-radius: 999px;
  background: #fff;
  color: var(--roux);
  font: 700 1rem/1 var(--text);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.timer svg {
  width: 20px; height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.timer:hover { border-color: var(--roux); }
.timer[data-state="running"] { background: var(--chive); border-color: var(--chive); color: #fff; }
.timer[data-state="done"] { background: var(--cheddar); border-color: var(--roux); color: var(--roux); animation: ring 1.1s ease-in-out infinite; }
@keyframes ring {
  0%, 60%, 100% { transform: none; }
  10% { transform: rotate(-4deg); }
  20% { transform: rotate(4deg); }
  30% { transform: rotate(-3deg); }
  40% { transform: rotate(3deg); }
}

/* The dish, built in layers */
.layers { margin: 20px 0 0; }
.dish { position: relative; max-width: 440px; margin: 0 22px; }
.dish::before, .dish::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 22px; height: 14px;
  background: var(--crust);
}
.dish::before { left: -21px; border-radius: 9px 0 0 9px; }
.dish::after { right: -21px; border-radius: 0 9px 9px 0; }
.bands {
  display: flex;
  flex-direction: column-reverse;
  list-style: none;
  overflow: hidden;
  border: 7px solid var(--crust);
  border-top: 0;
  border-radius: 0 0 28px 28px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.band {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: .98rem;
  line-height: 1.25;
}
.band__n { flex: none; width: 1.3em; font: 400 1.25rem/1 var(--display); text-align: center; }
.band--pasta {
  min-height: 64px;
  color: var(--roux);
  background: #f5c252 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='44'%3E%3Cg fill='none' stroke='%23dc9a2e' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M4 12c2-4 4-4 6 0s4 4 6 0 4-4 6 0'/%3E%3Cpath d='M34 32c2-4 4-4 6 0s4 4 6 0 4-4 6 0'/%3E%3Cpath d='M44 6c3 1 3 3 0 4s-3 3 0 4 3 3 0 4'/%3E%3Cpath d='M14 28c3 1 3 3 0 4s-3 3 0 4'/%3E%3C/g%3E%3C/svg%3E");
}
.band--cheese {
  min-height: 42px;
  color: var(--roux);
  background: #fff0bf url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='22'%3E%3Cg stroke-linecap='round' stroke-width='2.2'%3E%3Cpath d='M3 6l9 3' stroke='%23f0b93f'/%3E%3Cpath d='M18 15l10-2' stroke='%23ffffff'/%3E%3Cpath d='M30 5l7 4' stroke='%23f0b93f'/%3E%3Cpath d='M8 18l6-3' stroke='%23ffffff'/%3E%3Cpath d='M22 4l5 1' stroke='%23e3a535'/%3E%3C/g%3E%3C/svg%3E");
}
.band--crust {
  min-height: 50px;
  color: #fff4da;
  text-shadow: 0 1px 0 rgba(43, 23, 10, .45);
  background: #8e4a15 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='28'%3E%3Cg fill='%236a360f'%3E%3Cellipse cx='7' cy='8' rx='4' ry='2.4'/%3E%3Cellipse cx='30' cy='18' rx='5' ry='2.6'/%3E%3Cellipse cx='42' cy='6' rx='2.6' ry='1.8'/%3E%3Cellipse cx='16' cy='22' rx='2.4' ry='1.6'/%3E%3C/g%3E%3Cg fill='%23a35c1d'%3E%3Cellipse cx='22' cy='7' rx='3' ry='1.8'/%3E%3Cellipse cx='39' cy='23' rx='3.2' ry='2'/%3E%3C/g%3E%3C/svg%3E");
}
.layers figcaption { margin: 10px 22px 0; font-size: .95rem; color: var(--roux-2); }

/* Small phones: a narrower number column and dish, so the layers keep room for their words */
@media (max-width: 599.98px) {
  .steps > li { padding-left: 3.1rem; }
  .steps > li::before { font-size: 2.3rem; width: 2.4rem; }
  .dish { margin: 0 15px; }
  .dish::before, .dish::after { width: 16px; }
  .dish::before { left: -15px; }
  .dish::after { right: -15px; }
  .band { gap: 10px; padding: 8px 12px; }
  .layers figcaption { margin: 10px 15px 0; }
}

/* Good to know */
.tips { margin-top: clamp(40px, 6vw, 72px); container-type: inline-size; }
.tips__grid { display: grid; gap: 26px 36px; margin-top: 22px; }
@container (min-width: 600px) { .tips__grid { grid-template-columns: 1fr 1fr; } }
.tip { padding-top: 14px; border-top: 3px solid var(--cheddar); }
.tip h3 { font: 750 1.1rem/1.3 var(--text); margin-bottom: 6px; }
.tip p { font-size: 1.02rem; }

/* ---------- Footer ---------- */

.foot { background: var(--crust); color: var(--on-crust); padding: 36px var(--gutter) 44px; font-size: .95rem; }
.foot__inner { display: grid; gap: 8px; max-width: calc(var(--page) - 2 * var(--gutter)); margin: 0 auto; }
.foot a { color: var(--sauce); }

/* ---------- Motion and print ---------- */

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

@media print {
  @page { margin: 13mm 14mm; }
  html { font-size: 9.5pt; }
  body { background: #fff; color: #000; font-size: 1.1rem; line-height: 1.42; }
  .head { background: none; color: #000; overflow: visible; }
  .head__photo, .actions, .timers, .textbtn, .hint, .credit { display: none !important; }
  .head__inner { display: block; min-height: 0; max-width: none; padding: 0; }
  .head__text { width: auto; margin: 0; padding: 0; }
  .title { font-size: 26pt; color: #000; }
  .dek { max-width: none; font-size: 11.5pt; }
  .facts { gap: 4px 22px; margin-top: 10px; }
  .facts dt { color: #444; }
  .recipe { grid-template-columns: 33% 1fr; gap: 9mm; max-width: none; padding: 7mm 0 0; }
  .ingredients .card { position: static; max-height: none; overflow: visible; padding: 0; border: 0; background: none; }
  .card h2, .method h2, .tips h2 { font-size: 17pt; color: #000; }
  .card h3 { margin-top: 12px; color: #000; break-after: avoid; }
  .card h3 + .note, .card h3 + .list, .note + .list { break-before: avoid; }
  .list { break-inside: avoid; }
  .band--crust { text-shadow: none; }
  .list label { min-height: 0; padding: 3px 0; gap: 8px; }
  .list input { width: 12px; height: 12px; margin-top: 3px; border: 1px solid #555; border-radius: 3px; }
  .list li + li { border: 0; }
  .note, .kit, .aside, .list small, .preheat, .layers figcaption { color: #333; }
  .steps { margin-top: 10px; }
  .steps > li { padding: 8px 0 8px 2.6rem; break-inside: avoid; border-color: #ccc; }
  .steps > li::before { top: 6px; font-size: 18pt; color: #000; }
  .steps h3 { margin: 0 0 2px; font-size: 11.5pt; }
  .layers, .tip { break-inside: avoid; }
  .layers { margin-top: 8px; }
  .dish { max-width: 300px; }
  .band { font-size: .95rem; padding: 4px 12px; }
  .band--pasta { min-height: 38px; }
  .band--cheese { min-height: 26px; }
  .band--crust { min-height: 32px; }
  .tips { margin-top: 6mm; }
  .tips__grid { grid-template-columns: 1fr 1fr; gap: 4mm 6mm; margin-top: 3mm; }
  .tip { padding-top: 6px; border-top-width: 2px; border-top-color: #999; }
  .foot { background: none; color: #333; padding: 6mm 0 0; }
  .foot a { color: #000; }
  a { text-decoration: none; }
}
