/* The recipe grid with the dish that flies into the recipe: Tilth, an invented recipe app, in a warm white window on
   a paper page with soft light and grain. The plates are canvases where script.js draws the photos; their size is measured in
   pixels by the script (on resize too), the rest is measured on width AND height so it fits a short phone box. */
:root {
  --page: #efe9df;          /* the page around the app */
  --page-light: #fbf7f0;    /* the light on the page */
  --app: #fffdf9;           /* the app window */
  --card: #ffffff;          /* the cards */
  --line: rgba(64, 44, 24, 0.1); /* the hairlines */
  --ink: #241a12;           /* the words */
  --muted: #8b7d6e;         /* the small words */
  --accent: #b9532f;        /* the one accent, a terracotta */
  --shadow: 52, 34, 18;     /* the colour of the shadows, as r, g, b */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- the page: a warm paper with a soft window light from the top left and a fine grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: min(4vw, 4vh, 28px) 12px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 18% 0%, var(--page-light) 0%, rgba(251, 247, 240, 0) 62%),
    radial-gradient(80% 70% at 100% 100%, rgba(185, 83, 47, 0.07) 0%, rgba(185, 83, 47, 0) 70%),
    var(--page);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.36 0 0 0 0 0.27 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- the app window */
.app {
  position: relative;
  z-index: 1;
  width: min(100%, 860px);
  height: min(92vh, 480px);
  border-radius: min(22px, 3.4vh);
  background: var(--app);
  box-shadow:
    0 0 0 1px rgba(var(--shadow), 0.07),
    0 1px 1px rgba(var(--shadow), 0.04),
    0 4px 10px -2px rgba(var(--shadow), 0.06),
    0 18px 40px -12px rgba(var(--shadow), 0.16),
    0 50px 90px -30px rgba(var(--shadow), 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  opacity: 0;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.view--grid {
  position: relative;
  height: 100%;
}

.view--detail {
  visibility: hidden;
}

/* ---- the bar at the top of both views */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: min(52px, 11vh);
  padding: 0 min(20px, 4vw);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  font-variation-settings: 'opsz' 40, 'SOFT' 60;
  letter-spacing: -0.01em;
}

.brand--small {
  margin: 0 auto;
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}

.brand__mark {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bar__tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 3px;
  border-radius: 99px;
  background: #f5f0e8;
  box-shadow: inset 0 0 0 1px var(--line);
}

.bar__tab {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 520;
  color: var(--muted);
  white-space: nowrap;
}

.bar__tab.is-on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(var(--shadow), 0.12), 0 0 0 1px rgba(var(--shadow), 0.05);
}

.bar__icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- the grid */
.grid__head {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: min(18px, 3vh) min(20px, 4vw) min(12px, 2vh);
}

.grid__title {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(17px, min(3vw, 5vh), 26px);
  font-weight: 560;
  font-variation-settings: 'opsz' 72, 'SOFT' 40;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.grid__count {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: min(14px, 2.4vh);
  padding: 0 min(20px, 4vw) min(20px, 3.4vh);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: min(10px, 1.8vh);
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 0 0 1px rgba(var(--shadow), 0.07),
    0 1px 2px rgba(var(--shadow), 0.05),
    0 4px 8px -4px rgba(var(--shadow), 0.06);
  transition: box-shadow 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* the lifted card: four layers of shadow, from the contact line to the long soft one */
.card.is-lifted {
  box-shadow:
    0 0 0 1px rgba(var(--shadow), 0.06),
    0 2px 3px rgba(var(--shadow), 0.05),
    0 8px 14px -6px rgba(var(--shadow), 0.1),
    0 22px 34px -14px rgba(var(--shadow), 0.18),
    0 40px 60px -28px rgba(var(--shadow), 0.2);
}

.card:focus-visible,
.back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card__plate {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background:
    radial-gradient(90% 80% at 30% 20%, #fbf8f2 0%, #f2ece2 100%);
  box-shadow: inset 0 0 0 1px rgba(var(--shadow), 0.04);
}

.card__save {
  position: absolute;
  top: min(16px, 2.8vh);
  right: min(16px, 2.8vh);
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.card__name {
  margin: min(10px, 1.6vh) 2px 3px;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(12.5px, min(1.7vw, 3.2vh), 15.5px);
  font-weight: 540;
  font-variation-settings: 'opsz' 24, 'SOFT' 30;
  line-height: 1.18;
  letter-spacing: -0.005em;
}

.card__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 2px;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.card__meta svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* ---- a plate: its shadow and the dish photo; the script sets the pixel size */
.plate {
  position: relative;
  display: block;
}

.plate__shadow {
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--shadow), 0.42) 55%, rgba(var(--shadow), 0) 100%);
  transform: translate(3%, 6%) scale(1.02);
  filter: blur(3px);
}

.plate__dish {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- the recipe */
.detail {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: 'hero info' 'hero cols';
  column-gap: min(30px, 3.4vw);
  padding: min(22px, 3.6vh) min(26px, 4vw);
}

.detail__hero {
  grid-area: hero;
  display: grid;
  place-items: center;
  min-height: 0;
}

.detail__info {
  grid-area: info;
  min-width: 0;
}

.detail__cols {
  grid-area: cols;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: min(22px, 2.6vw);
  margin-top: min(18px, 3vh);
}

.detail__kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.detail__title {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(18px, min(3vw, 5.6vh), 30px);
  font-weight: 560;
  font-variation-settings: 'opsz' 96, 'SOFT' 50;
  letter-spacing: -0.02em;
  line-height: 1.06;
}

.times {
  display: flex;
  gap: 6px;
  margin: min(14px, 2.2vh) 0 0;
}

.time {
  min-width: 0;
  padding: 6px 10px 7px;
  border-radius: 10px;
  background: #faf6ef;
  box-shadow: inset 0 0 0 1px var(--line);
}

.time dt {
  font-size: 9.5px;
  font-weight: 560;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.time dd {
  margin: 1px 0 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.time dd small {
  font-size: 10.5px;
  font-weight: 480;
  color: var(--muted);
}

.block {
  min-width: 0;
}

.block__label {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.ingredients,
.steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredient {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: min(6px, 1vh) 0;
  font-size: 12px;
  line-height: 1.25;
}

.ingredient span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the hairline under each ingredient draws itself from the left */
.ingredient__rule {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--line);
  transform-origin: 0 50%;
}

.steps {
  position: relative;
  padding-left: 14px;
}

/* the thread that joins the steps grows downward */
.steps__thread {
  position: absolute;
  left: 3px;
  top: 6px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(var(--accent), rgba(185, 83, 47, 0.12));
  transform-origin: 50% 0;
}

.step {
  position: relative;
  padding: 0 0 min(10px, 1.6vh);
  font-size: 11.5px;
  line-height: 1.35;
  color: #5a4a3c;
}

.step__knot {
  position: absolute;
  left: -14px;
  top: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--app);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.step b {
  display: block;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  font-variation-settings: 'opsz' 24;
  color: var(--ink);
}

/* ---- the back button */
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 0 -6px;
  padding: 5px 10px 5px 6px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 540;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s;
}

.back.is-hot {
  background: #f5f0e8;
}

.back svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- the flying dish, above everything */
.flyer {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  visibility: hidden;
  pointer-events: none;
}

/* ---- the drawn pointer of the walk on its own */
.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -5px;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(36, 26, 18, 0.28));
}

.cursor path {
  fill: var(--ink);
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

/* ---- on wide boxes with room the dish area is square, so the plates are big */
@media (min-width: 641px) and (min-height: 600px) {
  .app {
    height: auto;
    min-height: min(92vh, 470px);
  }

  .view--grid {
    position: relative;
    height: auto;
    min-height: inherit;
  }

  .grid {
    align-content: center;
  }

  .card__plate {
    flex: none;
    aspect-ratio: 1 / 1;
  }
}

/* ---- phone and short boxes: two by two, and the recipe stacked */
@media (max-width: 640px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .bar__tabs .bar__tab:last-child {
    display: none;
  }

  .grid__count {
    display: none;
  }

  .card {
    border-radius: 13px;
  }

  .card__plate {
    border-radius: 9px;
  }

  .detail {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'hero info' 'cols cols';
    column-gap: 12px;
    padding: min(14px, 2.6vh) 14px 10px;
  }

  .detail__hero {
    width: min(30vw, 26vh);
  }

  .detail__cols {
    gap: 12px;
    margin-top: min(12px, 2.2vh);
  }

  .detail__kicker {
    margin-bottom: 4px;
    font-size: 9.5px;
  }

  .times {
    gap: 4px;
    margin-top: 8px;
  }

  .time {
    padding: 4px 7px 5px;
    border-radius: 8px;
  }

  .time dt {
    font-size: 8.5px;
  }

  .time dd {
    font-size: 11.5px;
  }

  .time dd small {
    font-size: 9.5px;
  }

  .ingredient {
    padding: min(4px, 0.8vh) 0;
    font-size: 10.5px;
  }

  .step {
    padding-bottom: min(7px, 1.2vh);
    font-size: 10px;
    line-height: 1.3;
  }

  .step b {
    font-size: 11.5px;
  }

  .block__label {
    font-size: 9px;
    margin-bottom: 3px;
  }
}

@media (max-width: 380px) {
  .bar__tabs {
    display: none;
  }

  .grid__head {
    padding-top: min(14px, 2.6vh);
  }
}
