/* ── Jar glyph: fill level = time until feeding due ───────────────────────── */
.jarglyph {
  --fill: 0.5;
  width: 64px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.jarglyph .lid {
  width: 46px;
  height: 9px;
  background: var(--rye-soft);
  border: 2px solid var(--rye);
  border-radius: 3px 3px 0 0;
}
.jarglyph .glass {
  position: relative;
  width: 58px;
  height: 74px;
  border: 2px solid var(--rye);
  border-top-width: 3px;
  border-radius: 4px 4px 10px 10px;
  background: linear-gradient(105deg, rgba(255,255,255,0.55) 8%, rgba(255,255,255,0) 30%), #efe9db;
  overflow: hidden;
}
.jarglyph .fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--fill) * 100%);
  min-height: 5px;
  background: linear-gradient(to bottom, #f0d79a, var(--levain));
  border-top: 2px solid #caa14a;
  transition: height 0.6s ease;
}
.jarglyph.is-cold .fill { background: linear-gradient(to bottom, #c3d0da, var(--fridge)); border-top-color: #64798a; }
.jarglyph.is-hungry .fill { background: linear-gradient(to bottom, #e0b7ad, var(--stamp-red)); border-top-color: var(--stamp-red); }
.jarglyph .band {
  position: absolute;
  left: -2px; right: -2px;
  top: 30%;
  height: 3px;
  background: var(--crust);
  opacity: 0.8;
}

/* Ambient culture bubbles — only on active jars */
.jarglyph .fill i {
  position: absolute;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 252, 240, 0.75);
  animation: bubble 10s linear infinite;
}
.jarglyph .fill i:nth-child(1) { left: 18%; animation-delay: 0s; }
.jarglyph .fill i:nth-child(2) { left: 52%; animation-delay: 3.5s; width: 4px; height: 4px; }
.jarglyph .fill i:nth-child(3) { left: 76%; animation-delay: 7s; }
.jarglyph.is-cold .fill i, .jarglyph.is-retired .fill i { animation: none; opacity: 0; }

@keyframes bubble {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 0.8; }
  85% { opacity: 0.7; }
  100% { transform: translateY(-52px); opacity: 0; }
}

/* ── Jiggle: jars shake on every (re)render, the Key stamp on tab change ──── */
.jarglyph { animation: jiggle 0.5s ease; }
#key-btn.jiggle { animation: jiggle 0.5s ease; }
@keyframes jiggle {
  0% { transform: rotate(0); }
  20% { transform: rotate(-2.5deg) translateX(-1px); }
  40% { transform: rotate(2deg) translateX(1px); }
  60% { transform: rotate(-1.3deg); }
  80% { transform: rotate(0.8deg); }
  100% { transform: rotate(0); }
}

/* ── Jar eyes: asleep by default, awake within a day of feeding due ───────── */
.jarglyph .eyes {
  --eye: 12px; --lid: 6px; --lidtop: 5px;
  position: absolute;
  top: 26%;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 9px;
  z-index: 2;
}
.jarglyph .eye {
  width: var(--eye); height: var(--eye);
  background: #fff;
  border: 2px solid var(--rye);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  animation: blink 4s infinite;
}
.jarglyph .pupil {
  position: absolute;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  background: var(--rye);
  border-radius: 50%;
}
.jarglyph .pupil { animation: look 5s ease-in-out infinite; }
.jarglyph.is-hungry .pupil { animation-duration: 2.5s; }
/* Asleep: closed lids that briefly peek open every few seconds */
.jarglyph .eyes.asleep .eye {
  height: var(--lid);
  margin-top: var(--lidtop);
  background: rgba(255, 255, 255, 0);
  border: 0 solid var(--rye);
  border-bottom-width: 2px;
  border-radius: 0 0 10px 10px;
  overflow: visible;
  animation: peek 9s infinite;
}
.jarglyph .eyes.asleep .pupil { opacity: 0; animation: peek-pupil 9s infinite, look 5s ease-in-out infinite; }
@keyframes peek {
  0%, 86%, 100% {
    height: var(--lid); margin-top: var(--lidtop);
    background: rgba(255, 255, 255, 0);
    border-width: 0 0 2px 0;
    border-radius: 0 0 10px 10px;
  }
  90%, 96% {
    height: var(--eye); margin-top: 0;
    background: rgba(255, 255, 255, 1);
    border-width: 2px;
    border-radius: 50%;
  }
}
@keyframes peek-pupil {
  0%, 88%, 98%, 100% { opacity: 0; }
  91%, 95% { opacity: 1; }
}
@keyframes look {
  0% { transform: translate(0, 0); }
  10%, 22% { transform: translate(-2.5px, 0.6px); }
  32%, 44% { transform: translate(2.5px, -0.6px); }
  52%, 60% { transform: translate(0.5px, 1.2px); }
  70%, 84% { transform: translate(-2px, -1px); }
  94%, 100% { transform: translate(0, 0); }
}
@keyframes blink {
  0%, 91%, 100% { transform: scaleY(1); }
  93%, 96% { transform: scaleY(0.12); }
}

/* Crying: 30+ min overdue, or 30+ min after a jar timer rang unfed */
.jarglyph .eyes.crying .pupil { top: 62%; }
.jarglyph .tear {
  position: absolute;
  top: 12px;
  width: 5px; height: 7px;
  background: #4a7fb5;
  border: 1px solid #35618c;
  border-radius: 50% 50% 60% 60% / 35% 35% 65% 65%;
  opacity: 0;
  animation: tear-fall 1.6s ease-in infinite;
}
.jarglyph .tear.t1 { left: calc(50% - 15px); }
.jarglyph .tear.t2 { left: calc(50% + 10px); animation-delay: 0.8s; }
@keyframes tear-fall {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { opacity: 0.9; }
  100% { transform: translateY(16px) scale(1); opacity: 0; }
}

/* Smile: 20 happy minutes after every feeding */
.jarglyph .smile {
  position: absolute;
  top: 15px;
  left: 50%;
  width: 16px; height: 8px;
  margin-left: -8px;
  border: 0 solid var(--rye);
  border-bottom-width: 2px;
  border-radius: 0 0 12px 12px;
}
.jarglyph.big .smile { top: 20px; width: 20px; height: 10px; margin-left: -10px; }

/* Pacifier for baby jars (younger than 7 days) */
.jarglyph .paci {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 13px; height: 8px;
  margin-left: -6.5px;
  background: var(--crust);
  border: 2px solid var(--rye);
  border-radius: 50% / 60%;
}
.jarglyph .paci::after {
  content: '';
  position: absolute;
  left: 50%; top: 4px;
  width: 8px; height: 8px;
  margin-left: -5px;
  border: 2px solid var(--rye);
  border-radius: 50%;
}

/* Bigger face on the detail-sheet jar */
.jarglyph.big .eyes { gap: 13px; top: 28%; --eye: 15px; --lid: 7px; --lidtop: 7px; }
.jarglyph.big .pupil { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; }
.jarglyph.big .paci { top: 22px; width: 16px; height: 10px; margin-left: -8px; }
.jarglyph.big .tear { top: 17px; }
.jarglyph.big .tear.t1 { left: calc(50% - 19px); }
.jarglyph.big .tear.t2 { left: calc(50% + 13px); }

/* Reduced motion: only the shakes stop — the tiny face/bubble animations
   stay, otherwise Android's "remove animations" freezes the jars entirely. */
@media (prefers-reduced-motion: reduce) {
  .jarglyph, #key-btn.jiggle { animation: none !important; }
}

/* ── Jar list cards ───────────────────────────────────────────────────────── */
.jar-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  font-family: var(--font-ui);
}
.jar-card .info { flex: 1; min-width: 0; }
.jar-card .tape { font-size: 18px; margin-bottom: 6px; }
.jar-card .facts {
  font-size: 13px;
  color: var(--rye-soft);
  line-height: 1.5;
}
.jar-card .due {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 3px;
}
.jar-card .due.over { color: var(--stamp-red); font-weight: 600; }
.jar-card .stamps { flex: none; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ── Jar detail sheet ─────────────────────────────────────────────────────── */
.jar-hero {
  display: flex;
  gap: 18px;
  align-items: center;
}
.jar-hero .jarglyph { width: 84px; }
.jar-hero .jarglyph .glass { width: 76px; height: 96px; }
.jar-hero .jarglyph .lid { width: 60px; }
.jar-facts { flex: 1; font-size: 14px; line-height: 1.7; }
.jar-facts .mono { font-size: 13px; }

.loglist { margin-top: 6px; }
.log-entry {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--kraft-deep);
  font-size: 14px;
}
.log-entry:last-child { border-bottom: none; }
.log-entry .when { font-family: var(--font-mono); font-size: 12px; color: var(--rye-soft); flex: none; width: 84px; }
.log-entry .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.log-entry .del { border: none; background: none; color: var(--rye-soft); font-size: 16px; padding: 0 4px; }

/* Star rating input + display */
.stars { display: inline-flex; gap: 4px; }
.stars button {
  border: none;
  background: none;
  font-size: 28px;
  line-height: 1;
  padding: 2px;
  color: var(--kraft-deep);
}
.stars button.on { color: var(--levain); text-shadow: 0 1px 0 #9a7420; }
.starline { color: var(--levain); text-shadow: 0 1px 0 #9a7420; letter-spacing: 2px; }
.starline .off { color: var(--kraft-deep); text-shadow: none; }

/* ── Jar form: grams calculator ───────────────────────────────────────────── */
.add-flour {
  flex: none;
  align-self: flex-end;
  width: 42px;
  height: 42px;
  border: 2px solid var(--kraft-deep);
  border-radius: 8px;
  background: var(--flour);
  color: var(--rye);
  font-size: 24px;
  line-height: 1;
  padding: 0;
}
.add-flour:active { transform: translate(1px, 1px); }
#jf-calc input[readonly] { background: #efe9db; font-family: var(--font-mono); }

/* ── Baker's percentage bars (jar detail, under the jar hero) ─────────────── */
.skillbars { display: flex; flex-direction: column; gap: 8px; }
.sb-head {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--rye-soft);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.sb-head .mono { font-size: 11px; text-transform: none; letter-spacing: 0; }
.skillbar { display: flex; align-items: center; gap: 8px; }
.skillbar .sb-label {
  flex: none;
  width: 106px;
  font-size: 12px;
  color: var(--rye);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.skillbar .sb-track {
  flex: 1;
  height: 14px;
  background: #efe9db;
  border: 2px solid var(--rye);
  border-radius: 7px;
  overflow: hidden;
}
.skillbar .sb-track i {
  display: block;
  height: 100%;
  background: linear-gradient(to right, #7cb356, #3e7d2f);
  border-radius: 0 5px 5px 0;
}
.skillbar .sb-val {
  flex: none;
  width: 46px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Best tab leaderboard ─────────────────────────────────────────────────── */
.best-card { display: flex; align-items: center; gap: 14px; }
.best-card .rank {
  font-family: var(--font-slab);
  font-size: 34px;
  width: 44px;
  flex: none;
  text-align: center;
  color: var(--crust);
}
.best-card.top .rank { color: var(--stamp-red); }
.best-card .info { flex: 1; min-width: 0; }
.best-card .tape { font-size: 17px; }
.best-card .facts { font-size: 13px; color: var(--rye-soft); margin-top: 5px; line-height: 1.5; }
