/* Steps 1 and 2, the kitchen screens: the question, the search and the steps on the kitchen wall, then the shelves
   of photos on the left and the open fridge (or pantry) photo on the right, where what I have takes its place.
   Built on the tokens of application.css. Both photos are 3:4, so one zone system (fridge_items_helper.rb) fits both;
   swapping a photo is one image file. */

:root {
  --oak-hi: #d9a86c;
  --oak-lo: #a8733f;
  --larder-hi: #fbf1dd;
  --larder: #f2e1c1;
  --larder-lo: #e7cfa4;
  --larder-ink-dim: #5b4630;
}

.kitchen-page { display: grid; gap: 1.25rem; max-width: 92rem; margin: 0 auto; padding: 1.25rem 1rem 0; }

/* The header (US1-AC7): the question, the search that answers it, then the steps, stacked on a phone. From a laptop up
   they sit on the screen's own two halves: the search over the shelves, since both pick ingredients, and the steps over
   the photo, as wide as it, since they name the storage it shows. The suggestions and the status line open under the
   search, over the page, so typing, a status or the next tap never moves what is under the pointer. */
.kitchen-intro { display: grid; gap: 0.85rem; }
.kitchen-intro h1 { font: clamp(2.4rem, 8vw, 4.4rem)/0.9 var(--display); text-transform: uppercase; letter-spacing: 0.01em;
  color: var(--cream); }
.finder-wrap { position: relative; z-index: 6; display: grid; gap: 0.6rem; max-width: 46rem; } /* over the kitchen */
.kitchen-intro .suggestions { position: absolute; z-index: 1; top: calc(3.5rem + 0.5rem); left: 0; right: 0; padding: 0.6rem;
  border-radius: var(--radius); background: var(--panel); box-shadow: 0 22px 44px -14px rgb(0 0 0 / 0.8); }
.finder-wrap:not(:focus-within, :hover) .suggestions { display: none; } /* put away while I am elsewhere, back on return */
.kitchen-intro .suggestions .key-button { background: var(--cream); color: var(--charcoal); }
.kitchen-notice { display: flex; align-items: baseline; gap: 0.6rem; max-width: 46rem; padding: 0.7rem 0.95rem;
  border-radius: var(--key-radius); background: var(--panel); color: var(--cream); }
.kitchen-notice::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--saffron);
  translate: 0 -0.1rem; } /* a saffron point, instead of a coloured side bar (the craft floor bans those) */
.kitchen-notice:empty { display: none; }
@media (min-width: 64rem) {
  /* the columns and the gap of the halves below (.kitchen-screen), so each control lines up with what it drives */
  .kitchen-intro { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "question question" "search steps";
    align-items: end; gap: 1rem 1.25rem; }
  .kitchen-intro h1 { grid-area: question; }
  .finder-wrap { grid-area: search; max-width: none; }
  .kitchen-intro .kitchen-steps { grid-area: steps; justify-self: center; width: min(100%, calc((100svh - 12rem) * 0.75));
    --between: 1.7rem; --arrow: 1rem; }
  /* the status floats over the top of the shelves until the next change: it never pushes them down, and never blocks them */
  .kitchen-notice { position: absolute; top: calc(3.5rem + 0.6rem); left: 0; max-width: 100%; pointer-events: none;
    box-shadow: 0 14px 30px -10px rgb(0 0 0 / 0.65); }
}

/* The steps: three keys joined by arrows, the path from the fridge to the recipes, on all three screens. The current
   key is outlined, a filled one lit with what it holds, and an arrow lights once the step before it is filled. */
.kitchen-steps { --arrow: 1.15rem; --between: 2.1rem; list-style: none; margin: 0; padding: 0; display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--between); max-width: 46rem; }
.kitchen-steps li { position: relative; }
.kitchen-steps li:not(:last-child)::after { content: ""; position: absolute; top: 50%; translate: 0 -50%;
  right: calc((var(--between) + var(--arrow)) / -2); width: var(--arrow); height: var(--arrow); background: var(--silk-dim);
  -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='M4 12h15M13 6l6 6-6 6'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='M4 12h15M13 6l6 6-6 6'/></svg>") center / contain no-repeat;
  transition: background 200ms var(--ease); }
.kitchen-steps li.done::after { background: var(--saffron); }
.kitchen-steps a, .kitchen-steps li > span { display: grid; align-content: center; gap: 0.1rem; height: 100%; min-height: 3.5rem;
  padding: 0.45rem 0.75rem; border-radius: var(--key-radius); background: var(--panel); color: var(--silk); text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--rule); transition: box-shadow 160ms var(--ease), background 160ms var(--ease); }
.kitchen-steps a:hover, .kitchen-steps [aria-current="step"] { box-shadow: inset 0 0 0 2px var(--saffron); }
.kitchen-steps [aria-current="step"] { background: #332c28; }
.kitchen-steps b { display: flex; align-items: center; gap: 0.45rem; color: var(--cream); font-weight: 800; line-height: 1.15; }
.kitchen-steps b span { flex: none; display: grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%;
  color: var(--saffron); font-size: 0.8rem; font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 2px var(--saffron); }
.kitchen-steps small { color: var(--silk-dim); font-size: 0.8rem; line-height: 1.3; }
.kitchen-steps .done small { color: var(--saffron); font-weight: 700; }
.kitchen-steps .done b span, .kitchen-steps .ready b span { background: var(--saffron); color: var(--charcoal);
  box-shadow: 0 0 12px rgb(246 201 14 / 0.6); }
.kitchen-steps li:not(.ready) > span b { color: var(--silk-dim); } /* Recipes, not open yet */
.kitchen-steps li:not(.ready) > span b span { color: var(--silk-dim); box-shadow: inset 0 0 0 2px var(--rule); }
@media (max-width: 30rem) {
  .kitchen-steps { --arrow: 0.8rem; --between: 1.15rem; }
  .kitchen-steps a, .kitchen-steps li > span { padding: 0.5rem 0.55rem; }
  .kitchen-steps b { gap: 0.35rem; font-size: 0.95rem; }
  .kitchen-steps b span { width: 1.35rem; height: 1.35rem; font-size: 0.78rem; }
  .kitchen-steps small { font-size: 0.78rem; }
}

/* The screen: the photo first on a phone, the shelves on the left from a laptop up */
.kitchen-screen { display: grid; gap: 1.25rem; grid-template-areas: "photo" "shelves" "end"; }
@media (min-width: 64rem) {
  /* two equal halves (the owner's choice). The photo is as tall as the window allows and centred in its half, so the
     whole fridge stays in view while I drag from any shelf, and the bar at the bottom never covers its drawers */
  .kitchen-screen { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "shelves photo" "end end";
    align-items: start; }
  .kitchen-screen .storage-photo, .kitchen-screen .storage-head { width: min(100%, calc((100svh - 12rem) * 0.75)); }
  .kitchen-screen .storage { position: sticky; top: 1rem; }
}
.kitchen-screen .storage { grid-area: photo; display: grid; gap: 0.6rem; justify-items: center; }
.shelves-panel { grid-area: shelves; min-width: 0; display: grid; gap: 0.35rem; align-content: start; padding: 1.1rem 1rem 0.6rem;
  border-radius: 24px; color: var(--ink); transition: box-shadow 160ms var(--ease); }
.kitchen-fridge .shelves-panel { background: linear-gradient(180deg, var(--ice-hi) 0%, var(--ice) 55%, var(--ice-lo) 100%); }
.kitchen-pantry .shelves-panel { background: linear-gradient(180deg, var(--larder-hi) 0%, var(--larder) 55%, var(--larder-lo) 100%); }
.shelves-panel.drop-ready { box-shadow: 0 0 0 3px var(--saffron), 0 0 28px rgb(246 201 14 / 0.4); }
.shelves-panel .shelf h3 { font: 700 0.78rem/1 var(--text); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim);
  padding-left: 0.25rem; }
.kitchen-pantry .shelf h3 { color: var(--larder-ink-dim); }
.kitchen-pantry .shelf::after { background: linear-gradient(180deg, var(--oak-hi) 0 2px, var(--oak-lo) 2px 100%);
  box-shadow: 0 10px 14px -8px rgb(70 40 10 / 0.55); }
.tile { touch-action: manipulation; }
.tile.lifted { opacity: 0.55; transform: scale(0.94); }
/* On its way: it leaves its place at once, so the next one is under the pointer at the next click (US2-AC10) */
.tile.leaving, .stored.leaving { display: none; }
/* A full storage (US2-AC7), before any tap: its shelves' photos dim, a line over them says why, and its count turns LED
   red. A tap still answers why, and taking one out lights them again (every answer morphs the head) */
.shelves-full { display: none; }
.kitchen-screen:has(.storage-head[data-full="true"]) .shelves-full { display: flex; align-items: baseline; gap: 0.55rem;
  margin-bottom: 0.35rem; padding: 0.6rem 0.85rem; border-radius: var(--key-radius); background: var(--charcoal);
  color: var(--cream); font-weight: 700; }
.shelves-full::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--led);
  translate: 0 -0.1rem; }
.kitchen-screen:has(.storage-head[data-full="true"]) .tile { opacity: 0.45; filter: grayscale(0.7); cursor: not-allowed; }
.kitchen-screen:has(.storage-head[data-full="true"]) .tile:hover :is(img, .drawing) { transform: none; }
.storage-head[data-full="true"] .storage-count { color: var(--led); text-shadow: 0 0 8px rgb(255 74 61 / 0.6); }
/* A mouse's arrows at the ends of a row that holds more than it shows (US2-AC12): enamel keys at the photos' middle,
   over the row's faded edges, rising like every key and dimmed at the row's end. A touch screen swipes, and has none */
.shelf-arrow { display: none; }
@media (hover: hover) and (pointer: fine) {
  .shelf-scrolls .shelf-arrow { position: absolute; top: 4rem; z-index: 2; translate: 0 -50%; display: grid; place-items: center;
    width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: 50%; background: var(--enamel); color: var(--ink);
    box-shadow: 0 3px 8px rgb(0 0 0 / 0.25); cursor: pointer;
    transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), opacity 160ms var(--ease); }
  .shelf-arrow-back { left: -0.85rem; }
  .shelf-arrow-next { right: -0.85rem; }
  .shelf-arrow .icon { width: 1.2rem; height: 1.2rem; }
  .shelf-arrow-next .icon { scale: -1 1; }
  .shelf-arrow:enabled:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgb(0 0 0 / 0.3); }
  .shelf-arrow:enabled:active { transform: translateY(1px); box-shadow: none; }
  .shelf-arrow:disabled { opacity: 0.35; box-shadow: none; cursor: default; pointer-events: none; } /* the photo under it takes the click */
}

/* The photo, and what I have in it: each zone is placed in percent of the photo, items sized to its width */
.storage-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; width: 100%; }
.storage-head h2 { font: clamp(2rem, 5vw, 2.6rem)/0.95 var(--display); text-transform: uppercase; color: var(--cream); }
.storage-head form { margin-left: auto; }
.clear-storage { min-height: 2.25rem; padding: 0 0.85rem; border: 0; border-radius: 999px; background: none; color: var(--silk);
  font: 700 0.85rem/1 var(--text); box-shadow: inset 0 0 0 1px var(--rule); cursor: pointer;
  transition: box-shadow 160ms var(--ease), color 160ms var(--ease); }
.clear-storage:hover { color: var(--cream); box-shadow: inset 0 0 0 2px var(--paprika); }
.storage-count { padding: 0.3rem 0.55rem; border-radius: 6px; background: #0e1a22; color: #7fe3ff;
  font: 700 0.85rem/1 var(--text); letter-spacing: 0.08em; font-variant-numeric: tabular-nums; text-shadow: 0 0 8px rgb(127 227 255 / 0.6); }
.storage-pantry .storage-count { background: #2a1a0c; color: #ffcf7a; text-shadow: 0 0 8px rgb(255 207 122 / 0.6); }
.storage-photo { position: relative; width: 100%; aspect-ratio: 3 / 4; container-type: inline-size;
  border-radius: 18px; overflow: hidden; background: var(--ice); box-shadow: 0 28px 60px rgb(0 0 0 / 0.5);
  transition: box-shadow 160ms var(--ease), filter 160ms var(--ease); }
.storage.drop-ready .storage-photo { box-shadow: 0 0 0 4px var(--saffron), 0 0 44px rgb(246 201 14 / 0.6); filter: brightness(1.06); }
.storage-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.storage-empty { position: absolute; left: 26%; right: 26%; top: 27%; padding: 0.7rem 0.8rem; border-radius: 12px; text-align: center;
  background: rgb(255 255 255 / 0.88); color: var(--ink); font-weight: 700; font-size: clamp(0.85rem, 3.4cqw, 1.05rem); }
.zone { position: absolute; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; align-content: flex-end;
  gap: 0.6cqw; border-radius: 1.6cqw; transition: background 150ms var(--ease), box-shadow 150ms var(--ease); }
.zone.zone-target { background: rgb(246 201 14 / 0.28); box-shadow: inset 0 0 0 0.45cqw var(--saffron); }
.stored { width: 7.4cqw; display: grid; justify-items: center; gap: 0.3cqw; padding: 0; border: 0; background: none; color: var(--ink);
  cursor: pointer; touch-action: manipulation; animation: settle 200ms var(--ease) both; }
.stored img, .stored .drawing { width: 6.2cqw; height: 6.2cqw; filter: drop-shadow(0 0.8cqw 0.7cqw rgb(20 50 80 / 0.45));
  transition: transform 160ms var(--ease); }
.stored img { object-fit: contain; }
/* A shelf's drawing, where TheMealDB has no photo (IMG-AC5): a cream plate with the shelf's line icon */
.drawing { padding: 18%; border-radius: 50%; background: var(--cream); color: var(--ink-dim); box-shadow: inset 0 0 0 2px rgb(29 26 24 / 0.12); }
.tile .drawing { width: 4.6rem; height: 4.6rem; filter: drop-shadow(0 9px 8px rgb(20 50 80 / 0.25)); transition: transform 200ms var(--ease); }
.tile:hover .drawing, .stored:hover .drawing { transform: translateY(-4px) scale(1.04); }
@media (max-width: 30rem) { .tile .drawing { width: 4rem; height: 4rem; } }
.stored::after { content: attr(data-name); max-width: 100%; padding: 0.2cqw 0.6cqw; border-radius: 0.8cqw;
  background: rgb(255 255 255 / 0.9); font: 700 1.45cqw/1.15 var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stored:hover img { transform: translateY(-0.5cqw) scale(1.05); }
@container (max-width: 30rem) { .stored::after { display: none; } }
/* Its full name, at once, on hover, focus or a press (US2-AC11): the labels are short, and hidden in a narrow photo. The
   photo clips, so the tooltip stays inside it: it opens inward at the left and right edges, below the item on the top
   shelves, and a long name wraps (44cqw is less than the room around any middle zone) */
.stored { position: relative; }
.stored:is(:hover, :focus-visible, :active) { z-index: 1; }
.tooltip { position: absolute; left: 50%; bottom: calc(100% + 0.35rem); translate: -50% 0; width: max-content;
  max-width: min(12rem, 44cqw); padding: 0.35rem 0.55rem; border-radius: 6px; background: var(--charcoal); color: var(--cream);
  font: 700 0.78rem/1.2 var(--text); text-align: center; text-wrap: balance; box-shadow: 0 6px 14px rgb(0 0 0 / 0.35);
  visibility: hidden; opacity: 0; pointer-events: none; transition: opacity 120ms var(--ease), visibility 120ms; }
.stored:is(:hover, :focus-visible, :active) .tooltip { visibility: visible; opacity: 1; }
.stored.lifted .tooltip { visibility: hidden; } /* not in the picture of a dragged item */
[data-zone-name*="-left"] .tooltip { left: 0; translate: none; }
[data-zone-name*="-right"] .tooltip { left: auto; right: 0; translate: none; }
[data-zone-name$="-1"] .tooltip { top: calc(100% + 0.35rem); bottom: auto; }
@keyframes settle { from { opacity: 0; transform: scale(0.6); } }

/* The end of the screen: what is assumed, and the next step, in reach while scrolling */
.kitchen-end { grid-area: end; position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: flex-end; gap: 0.5rem 1rem; margin: 0 -1rem; padding: 1.4rem 1rem calc(0.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgb(29 26 24 / 0), var(--charcoal) 42%); }
.shelves-panel .staples-hint { padding: 0.2rem 0.25rem 0.4rem; }
.kitchen-pantry .staples-hint { color: var(--larder-ink-dim); }
.next-step, .find-recipes { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 3.5rem;
  padding: 0 1.7rem; border-radius: 999px; background: var(--saffron); color: var(--charcoal); font: 800 1.15rem/1 var(--text);
  text-decoration: none; box-shadow: 0 12px 28px rgb(0 0 0 / 0.45); transition: transform 160ms var(--ease); }
.next-step:hover, a.find-recipes[href]:hover { transform: translateY(-2px); }
.find-recipes.secondary { background: var(--panel); color: var(--cream); box-shadow: inset 0 0 0 2px var(--saffron); }
.find-recipes[aria-disabled="true"] { background: var(--panel); color: var(--silk-dim); box-shadow: inset 0 0 0 2px var(--rule);
  cursor: not-allowed; }
.find-hint { color: var(--silk-dim); font-size: 0.9rem; }
@media (max-width: 30rem) {
  .kitchen-end { flex-wrap: nowrap; gap: 0.5rem; }
  .next-step, .find-recipes { flex: 1 1 0; min-width: 0; padding: 0 0.8rem; font-size: 1rem; }
  .find-hint { display: none; }
}
