/* The fridge (and rack) drawing: rungs, spaces, bottle tops, their motion. Shared by the cellar
   app (my-cellar.html) and the home page's demo fridge (landing.html), so both draw the same fridge.
   Load after tokens.css and components.css, before the page's own stylesheet. */
/* ---------- Fridge ---------- */
.fridge-col {
  display: grid; justify-items: center; gap: 6px; touch-action: pan-y pinch-zoom;
  will-change: transform, opacity; transition: transform .22s ease, opacity .22s ease;
}
.fridge-col.dragging .fridge,
.fridge-col.dragging .feet { will-change: transform; }
@keyframes in-from-right { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes in-from-left { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.fridge-col.in-right { animation: in-from-right .22s ease-out; }
.fridge-col.in-left { animation: in-from-left .22s ease-out; }

.fridge {
  width: 100%;
  max-width: var(--fridge-max);
  background: linear-gradient(180deg, var(--cab-edge), var(--cab) 6%, var(--cab) 94%, var(--cab-edge));
  border-radius: var(--r-md) 10px 6px 6px;
  padding: 14px 30px 18px 14px;
  position: relative;
  box-shadow: var(--shadow);
}
/* Scaled to fit between the top app bar and the switcher dots (the fridge keeps its proportions;
   never narrower than 300 px, where the page scrolls instead). */
:root { --fridge-max: clamp(300px, calc((100dvh - 210px) * 0.56), 440px); }
@media (min-width: 840px) { :root { --fridge-max: clamp(300px, calc((100dvh - 150px) * 0.56), 440px); } }
.fridge::after { /* door handle */
  content: "";
  position: absolute;
  right: 11px;
  top: 30%;
  width: 7px;
  height: 22%;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, #11161a, #3a4247, #11161a);
}
.glass {
  background:
    linear-gradient(115deg, rgba(255,255,255,.07) 0 18%, transparent 18% 60%, rgba(255,255,255,.035) 60% 70%, transparent 70%),
    var(--interior);
  border: 2px solid #050809;
  border-radius: var(--r-xs);
  padding: 0 10px 12px;
  display: grid;
  gap: 0;
}
.led { height: 16px; margin: 0 22% 10px; border-radius: 0 0 8px 8px; background: #182026; position: relative; }
.led::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%; bottom: 3px;
  height: 3px;
  border-radius: 2px;
  background: var(--led);
  box-shadow: 0 0 14px 4px rgba(127, 196, 255, .45);
}
.rung { position: relative; padding: 6px 0 12px; }
.rung::after { /* wire rack, front edge */
  content: "";
  position: absolute;
  left: -4px; right: -4px; bottom: 4px;
  height: 5px;
  border-top: 2px solid var(--wire);
  border-bottom: 1px solid rgba(169, 180, 186, .45);
  border-radius: 2px;
}
.rung-label { position: absolute; left: -2px; top: 2px; font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: #6c7a82; }
/* --cols is set per row by the script from the fridge layout. */
.slots { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 4px; justify-items: center; }
.slots.mag { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.base { margin-top: 8px; padding-top: 14px; border-top: 3px solid #1f272c; background: linear-gradient(180deg, #0f1519, var(--interior)); }
.base .rung::after { height: 7px; }

.slot {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  width: 100%;
  max-width: 62px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 50%;
  position: relative;
  color: inherit;
  font: inherit;
}
.slots.mag .slot { max-width: 92px; }
.slot:focus-visible { outline: 2px solid var(--led); outline-offset: 3px; }
/* A chosen empty space (selection.js): an LED-blue ring and a check, over the fridge's own drawing. */
.slot.selected .empty, .slot.selected:hover .empty { border: 2px solid var(--led); background: rgba(127, 196, 255, .16); color: transparent; }
.slot.selected::after {
  content: ""; position: absolute; right: 2%; top: 2%; width: 34%; max-width: 18px; aspect-ratio: 1; border-radius: 50%;
  background: var(--led) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4 8-9' fill='none' stroke='%2320272b' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 70% no-repeat;
  pointer-events: none;
}
.slot .empty {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px dashed #3b474e;
  display: grid;
  place-items: center;
  color: #56646c;
  font-size: 18px;
  line-height: 1;
  transition: border-color .15s, color .15s, background .15s;
}
.slot:hover .empty { border-color: var(--led); color: var(--led); background: rgba(127,196,255,.06); }

/* --wine, --vint-ink and --status are set per bottle by the script. */
.bottle {
  width: 86%;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.28), transparent 42%), var(--wine, #5a1426);
  box-shadow: 0 0 0 3px var(--status, var(--st-none)), inset 0 0 0 4px rgba(0,0,0,.35);
  transition: transform .15s;
}
.bottle::before { /* punt */
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,0,0,.35), rgba(0,0,0,.08) 70%);
}
.slot:hover .bottle { transform: scale(1.06); }
.bottle .vint { position: relative; font-family: var(--mono); font-size: 11px; color: var(--vint-ink, #f4e9ec); font-variant-numeric: tabular-nums; }
.slots.mag .bottle .vint { font-size: 13px; }

.feet { display: flex; justify-content: space-between; width: 100%; max-width: var(--fridge-max); padding: 0 18px; margin-top: -10px; }
.feet span { width: 22px; height: 8px; background: #151a1d; border-radius: 0 0 4px 4px; }

/* Hold-and-drag to move a bottle */
.slot.drag-src .bottle { opacity: .25; }
.slot.drop-ok::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 2px dashed var(--led); opacity: .55; pointer-events: none; }
.slot.drop-hover::after { opacity: 1; background: rgba(127, 196, 255, .18); }
.drag-ghost { position: fixed; left: 0; top: 0; width: 56px; height: 56px; pointer-events: none; z-index: 30; display: grid; place-items: center; filter: drop-shadow(0 10px 14px rgba(0,0,0,.55)); }
.drag-ghost .bottle { width: 100%; transform: scale(1.12); }

/* ---------- Bottle motion ----------
   .added   : the bottle drops into its slot and its status ring pulses once
              (new bottle saved, or a drink undone).
   .leaving : the bottle lifts up and out (Drink it); render.js removes it after. */
@keyframes bottle-drop-in {
  0%   { transform: translateY(-34px) scale(1.04); opacity: 0; }
  55%  { transform: translateY(3px); opacity: 1; }
  75%  { transform: translateY(-1.5px); }
  100% { transform: none; }
}
@keyframes bottle-lift-out {
  0%   { transform: none; opacity: 1; }
  30%  { transform: translateY(2px); }
  100% { transform: translateY(-38px) scale(1.06); opacity: 0; }
}
@keyframes bottle-ring-glow {
  0%   { box-shadow: 0 0 0 3px var(--status), 0 0 0 0 var(--status), inset 0 0 0 4px rgba(0,0,0,.35); }
  100% { box-shadow: 0 0 0 3px var(--status), 0 0 0 10px transparent, inset 0 0 0 4px rgba(0,0,0,.35); }
}
.slot .bottle.added { animation: bottle-drop-in .6s cubic-bezier(.2, .7, .3, 1) both, bottle-ring-glow 1.1s .5s ease-out; }
.slot .bottle.leaving { animation: bottle-lift-out .5s ease-in forwards; pointer-events: none; }
/* Being looked up: the status ring breathes slowly. Something new about the bottle: a small dot. */
@keyframes bottle-looking { 0%, 100% { box-shadow: 0 0 0 3px var(--status, var(--st-none)), inset 0 0 0 4px rgba(0,0,0,.35); }
                            50% { box-shadow: 0 0 0 3px transparent, inset 0 0 0 4px rgba(0,0,0,.35); } }
.slot .bottle.looking { animation: bottle-looking 2.4s ease-in-out infinite; }
.slot .bottle.news::after { content: ""; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%;
                            background: var(--accent); box-shadow: 0 0 0 2px var(--fridge-bg, #1b2125); }
@media (prefers-reduced-motion: reduce) { .slot .bottle.added, .slot .bottle.leaving, .slot .bottle.looking { animation: none; } }
