/* Biolink — Nutrition "The Daily Table" v2 (docs/nutrition-redesign.md)
   Image-centric catalog: transparent dish cutouts floating over paper, monochrome ink
   system, hairline borders, one shadow story, Fraunces display. No gradient washes.
   Class prefix: nx- */

@font-face {
  font-family: "Fraunces";
  src: url("/app/fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  --nx-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --nx-ink: #1D1F24;
  --nx-ink-2: #5C616B;
  --nx-ink-3: #979CA6;
  --nx-hair: rgba(29,31,36,0.08);
  --nx-hair-2: rgba(29,31,36,0.16);
  --nx-card: #FFFFFF;
  --nx-shadow-card: 0 1px 2px rgba(28,27,24,0.04), 0 10px 28px rgba(28,27,24,0.05);
  --nx-shadow-card-hover: 0 2px 3px rgba(28,27,24,0.05), 0 16px 40px rgba(28,27,24,0.09);
  --nx-shadow-dish: drop-shadow(0 16px 16px rgba(30,28,22,0.15)) drop-shadow(0 4px 5px rgba(30,28,22,0.08));
  --nx-ease-spring: cubic-bezier(.34,1.3,.42,1);
}

.nx-screen { position: relative; }

/* ---- masthead ---- */
.nx-masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  margin: 4px 0 18px; flex-wrap: wrap; }
.nx-masthead .nx-kicker { font-size: 11px; font-weight: 700; letter-spacing: 2.4px;
  text-transform: uppercase; color: var(--nx-ink-3); margin-bottom: 6px; }
.nx-masthead .nx-title { font-family: var(--nx-serif); font-weight: 560;
  font-size: clamp(28px, 4vw, 38px); line-height: 1.02; letter-spacing: -0.4px;
  font-variation-settings: "opsz" 72; color: var(--nx-ink); }
.nx-masthead .nx-sub { color: var(--nx-ink-3); font-size: 12.5px; margin-top: 6px; font-weight: 550; }

/* segmented Table/Stack — hairline pill, ink active */
.nx-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  background: var(--nx-card); border: 1px solid var(--nx-hair-2); }
.nx-seg button { border: none; background: none; padding: 7px 16px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: var(--nx-ink-2); transition: color .15s, background .15s; }
.nx-seg button.active { background: var(--nx-ink); color: #fff; }

/* ---- day strip ---- */
.nx-daystrip { position: relative; display: flex; gap: 4px; overflow-x: auto; padding: 2px 2px 10px;
  scrollbar-width: none; -ms-overflow-style: none; cursor: grab; user-select: none;
  -webkit-user-select: none; touch-action: pan-x; }
.nx-daystrip::-webkit-scrollbar { display: none; }
.nx-daystrip.dragging { cursor: grabbing; scroll-behavior: auto; }
.nx-day { flex: none; width: 52px; padding: 6px 0 7px; border-radius: 14px; text-align: center;
  border: none; background: none; color: var(--nx-ink-2); transition: background .15s; }
.nx-day .dow { font-size: 9px; font-weight: 800; letter-spacing: 1.3px; text-transform: uppercase;
  color: var(--nx-ink-3); }
.nx-day .num { width: 30px; height: 30px; margin: 3px auto 0; display: grid; place-items: center;
  font-family: var(--nx-serif); font-size: 16.5px; font-weight: 550; border-radius: 50%;
  font-variation-settings: "opsz" 40; color: var(--nx-ink);
  transition: background .18s, color .18s; }
.nx-day .kdot { width: 4px; height: 4px; border-radius: 50%; margin: 4px auto 0;
  background: transparent; }
.nx-day.haslog .kdot { background: var(--nx-ink-3); }
.nx-day:hover .num { background: rgba(29,31,36,0.06); }
.nx-day.active .num { background: var(--nx-ink); color: #fff; }
.nx-day.future { opacity: .32; pointer-events: none; }

/* ---- energy (compact single row) ---- */
.nx-energy { display: flex; align-items: center; gap: 36px; flex-wrap: wrap;
  background: var(--nx-card); border: 1px solid var(--nx-hair); border-radius: 18px;
  box-shadow: var(--nx-shadow-card); padding: 18px 24px 17px; margin: 6px 0 0; }
.nx-energy .e-main { min-width: 200px; }
.nx-energy .nx-kcal-label { font-size: 10px; font-weight: 800; letter-spacing: 1.8px;
  text-transform: uppercase; color: var(--nx-ink-3); }
.nx-energy .nx-kcal-num { font-family: var(--nx-serif); font-weight: 480; font-size: 34px;
  line-height: 1.05; letter-spacing: -0.5px; font-variation-settings: "opsz" 60;
  font-variant-numeric: tabular-nums; color: var(--nx-ink); margin-top: 2px; }
.nx-energy .nx-kcal-num small { font-family: var(--font); font-size: 12px; font-weight: 650;
  color: var(--nx-ink-3); letter-spacing: 0; margin-left: 5px; }
.nx-energy .e-bar { position: relative; width: 100%; max-width: 210px; height: 3px;
  border-radius: 999px; background: rgba(29,31,36,0.08); margin-top: 10px; }
.nx-energy .e-bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px;
  background: var(--nx-ink); }
.nx-energy .e-bar .fill.over { background: var(--warning); }
.nx-energy .e-sub { font-size: 11.5px; color: var(--nx-ink-3); margin-top: 9px; font-weight: 550; }
.nx-energy .e-sub b { color: var(--nx-ink-2); font-weight: 700; }
.nx-energy .e-sub button { border: none; background: none; padding: 0; font-size: 11.5px;
  font-weight: 700; color: var(--nx-ink-2); text-decoration: underline;
  text-decoration-color: var(--nx-hair-2); text-underline-offset: 3px; }
.nx-energy .e-sub button:hover { color: var(--nx-ink); }
.nx-energy .e-macros { display: flex; gap: 26px; flex-wrap: wrap; margin-left: auto; }
.nx-energy .m { min-width: 62px; }
.nx-energy .m .m-l { font-size: 9.5px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--nx-ink-3); }
.nx-energy .m .m-v { font-family: var(--mono); font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--nx-ink); margin-top: 3px; }
.nx-energy .m .m-v small { font-size: 10px; color: var(--nx-ink-3); font-weight: 600; }
.nx-energy .m .m-bar { position: relative; width: 100%; height: 3px; border-radius: 999px;
  background: rgba(29,31,36,0.08); margin-top: 7px; }
.nx-energy .m .m-bar .fill { position: absolute; inset: 0 auto 0 0; width: 0;
  border-radius: 999px; background: var(--nx-ink-2); }

/* ---- meal card grid (image-centric) ---- */
.nx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 64px 18px; margin-top: 74px; align-items: start; }
.nx-card { position: relative; background: var(--nx-card); border: 1px solid var(--nx-hair);
  border-radius: 20px; padding: 128px 20px 12px; box-shadow: var(--nx-shadow-card);
  text-align: center; transition: box-shadow .25s ease, transform .25s ease; }
.nx-card:hover { box-shadow: var(--nx-shadow-card-hover); transform: translateY(-2px); }

/* floating dish cutout — breaks out of the card top */
.nx-dish { position: absolute; top: -52px; left: 50%; width: 168px; height: 168px;
  transform: translateX(-50%); pointer-events: none; }
.nx-dish img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; filter: var(--nx-shadow-dish);
  transition: transform .45s var(--nx-ease-spring); }
.nx-dish img.fx-revealed { opacity: 1; }
.nx-dish img.fx-reveal-css { transition: opacity .6s ease, transform .45s var(--nx-ease-spring); }
.nx-dish img.fx-reveal-css.fx-revealed { opacity: 1; }
.nx-card:hover .nx-dish img { transform: translateY(-5px) scale(1.025); }
.fx-reveal-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2;
  pointer-events: none; filter: var(--nx-shadow-dish); }

/* placeholder while the portrait is being generated — quiet ceramic plate */
.nx-plating { position: absolute; inset: 0; display: grid; place-items: center; }
.nx-plating .plate { width: 108px; height: 108px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #FFFFFF, #F1EFE9 68%, #E7E4DC);
  box-shadow: 0 14px 22px rgba(30,28,22,0.12), inset 0 1px 0 #fff;
  animation: nx-breathe 2.8s ease-in-out infinite; }
@keyframes nx-breathe { 50% { transform: scale(1.04); } }
.nx-plating .cap { position: absolute; bottom: 2px; font-size: 9px; font-weight: 800;
  letter-spacing: 1.8px; text-transform: uppercase; color: var(--nx-ink-3); }
/* fallback (blocked/failed/disabled): plate with a serif monogram */
.nx-plating.fallback .plate { animation: none; display: grid; place-items: center;
  font-family: var(--nx-serif); font-size: 34px; font-weight: 500; color: var(--nx-ink-3); }

/* card text */
.nx-card .c-eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 2px;
  text-transform: uppercase; color: var(--nx-ink-3); }
.nx-card .c-title { font-family: var(--nx-serif); font-weight: 545; font-size: 18.5px;
  line-height: 1.18; letter-spacing: -0.1px; font-variation-settings: "opsz" 34;
  color: var(--nx-ink); margin: 7px auto 0; max-width: 30ch; text-wrap: balance; }
.nx-card .c-stats { font-family: var(--mono); font-size: 11.5px; font-weight: 650;
  font-variant-numeric: tabular-nums; color: var(--nx-ink-2); margin-top: 9px;
  letter-spacing: 0.2px; }
.nx-card .c-stats .sep { color: var(--nx-ink-3); opacity: .6; padding: 0 3px; }

/* items disclosure */
.nx-card .c-toggle { margin: 12px auto 0; display: inline-flex; align-items: center; gap: 5px;
  border: none; background: none; padding: 6px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; color: var(--nx-ink-2); transition: background .15s; }
.nx-card .c-toggle:hover { background: rgba(29,31,36,0.05); color: var(--nx-ink); }
.nx-card .c-toggle .chev { display: inline-block; transition: transform .25s var(--nx-ease-spring); }
.nx-card.open .c-toggle .chev { transform: rotate(180deg); }
.nx-card .c-toggle .ico { width: 13px; height: 13px; }

.nx-items { overflow: hidden; height: 0; text-align: left; }
.nx-items-inner { border-top: 1px solid var(--nx-hair); margin-top: 6px; padding-top: 2px; }
.nx-item { border-bottom: 1px solid var(--nx-hair); }
.nx-item:last-child { border-bottom: none; }
.nx-item .row-main { display: flex; align-items: baseline; gap: 10px; padding: 9.5px 2px;
  cursor: pointer; border-radius: 8px; transition: background .13s; }
.nx-item .row-main:hover { background: rgba(29,31,36,0.03); }
.nx-item .it-name { font-weight: 650; font-size: 12.5px; color: var(--nx-ink); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-item .it-sub { font-size: 10.5px; color: var(--nx-ink-3); flex: none; }
.nx-item .it-kcal { margin-left: auto; font-family: var(--mono); font-size: 11.5px;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--nx-ink-2); flex: none; }
.nx-item .it-kcal small { font-size: 9px; color: var(--nx-ink-3); }

/* inline editor */
.nx-edit { overflow: hidden; height: 0; }
.nx-edit-inner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 2px 2px 12px; }
.nx-stepper { display: inline-flex; align-items: center; border: 1px solid var(--nx-hair-2);
  border-radius: 10px; overflow: hidden; background: var(--nx-card); }
.nx-stepper button { width: 30px; height: 30px; border: none; background: none; color: var(--nx-ink);
  font-size: 15px; font-weight: 700; display: grid; place-items: center; }
.nx-stepper button:hover { background: rgba(29,31,36,0.05); }
.nx-stepper input { width: 52px; height: 30px; border: none; text-align: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700; background: none; color: var(--nx-ink); }
.nx-stepper input:focus { outline: none; }
.nx-stepper .unit { padding-right: 8px; font-size: 10px; color: var(--nx-ink-3); font-weight: 700; }
.nx-edit select { width: auto; padding: 6px 26px 6px 10px; font-size: 12px; border-radius: 10px;
  border-color: var(--nx-hair-2); }
.nx-edit .apply { margin-left: auto; }
.nx-ghostbtn { border: 1px solid var(--nx-hair-2); background: var(--nx-card); color: var(--nx-ink-2);
  border-radius: 10px; padding: 6px 11px; font-size: 11.5px; font-weight: 700; transition: .15s; }
.nx-ghostbtn:hover { color: var(--nx-ink); border-color: var(--nx-ink-3); }
.nx-ghostbtn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---- empty day ---- */
.nx-empty { text-align: center; padding: 84px 20px 60px; }
.nx-empty .plate { width: 118px; height: 118px; margin: 0 auto 22px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #FFFFFF, #F1EFE9 66%, #E7E4DC);
  box-shadow: 0 20px 34px rgba(30,28,22,0.12), inset 0 1px 0 #fff; }
.nx-empty h3 { font-family: var(--nx-serif); font-weight: 545; font-size: 24px; margin: 0 0 7px;
  font-variation-settings: "opsz" 50; color: var(--nx-ink); }
.nx-empty p { color: var(--nx-ink-2); font-size: 13px; margin: 0 0 20px; }

/* ---- ink buttons ---- */
.nx-primary { display: inline-flex; justify-content: center; align-items: center; gap: 7px;
  padding: 12px 22px; border: none; border-radius: 999px; font-size: 13.5px; font-weight: 750;
  color: #fff; background: var(--nx-ink); box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  transition: background .15s, transform .1s; }
.nx-primary:hover { background: #2B2E35; }
.nx-primary:disabled { opacity: .5; }
.nx-primary.block { display: flex; width: 100%; margin-top: 16px; padding: 13px; }
.nx-primary .ico { width: 15px; height: 15px; }

/* floating add button */
.nx-fab { position: fixed; right: 30px; bottom: 30px; z-index: 60; width: 56px; height: 56px;
  border-radius: 50%; border: none; display: grid; place-items: center; color: #fff;
  background: var(--nx-ink);
  box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 12px 28px rgba(28,27,24,0.24);
  transition: box-shadow .2s, background .15s; }
.nx-fab:hover { background: #2B2E35; box-shadow: 0 3px 6px rgba(0,0,0,0.18), 0 16px 36px rgba(28,27,24,0.30); }
.nx-fab .ico { width: 24px; height: 24px; }

/* ---- add sheet ---- */
.nx-sheet-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(24,25,29,0.34);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 720px) { .nx-sheet-overlay { align-items: center; padding: 24px; } }
.nx-sheet { width: 100%; max-width: 600px; max-height: 86vh; overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 8px 22px 24px; background: #FEFDFB;
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 -18px 60px rgba(20,21,24,0.30); touch-action: pan-y; }
@media (min-width: 720px) { .nx-sheet { border-radius: 26px; box-shadow: 0 36px 90px rgba(20,21,24,0.35); } }
.nx-sheet .grab { width: 38px; height: 4px; border-radius: 999px; background: rgba(29,31,36,0.14);
  margin: 6px auto 14px; }
.nx-sheet h3 { font-family: var(--nx-serif); font-weight: 550; font-size: 22px; margin: 2px 2px 3px;
  font-variation-settings: "opsz" 50; color: var(--nx-ink); }
.nx-sheet .sub { color: var(--nx-ink-3); font-size: 12px; margin: 0 2px 15px; }
.nx-searchbox { position: relative; }
.nx-searchbox input { width: 100%; padding: 14px 44px 14px 17px; font-size: 14.5px;
  border-radius: 15px; border: 1px solid var(--nx-hair-2); background: var(--nx-card);
  transition: border-color .15s, box-shadow .15s; font-family: inherit; color: var(--nx-ink); }
.nx-searchbox input:focus { outline: none; border-color: var(--nx-ink-3);
  box-shadow: 0 0 0 4px rgba(29,31,36,0.06); }
.nx-searchbox .sicon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--nx-ink-3); display: grid; place-items: center; }
.nx-meal-pick { display: flex; gap: 6px; margin: 13px 0 4px; flex-wrap: wrap; }
.nx-meal-pick .mp { padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--nx-hair-2); background: var(--nx-card); color: var(--nx-ink-2); transition: .15s; }
.nx-meal-pick .mp.active { background: var(--nx-ink); color: #fff; border-color: var(--nx-ink); }
.nx-results { margin-top: 10px; }
.nx-result { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 14px;
  cursor: pointer; transition: background .13s; }
.nx-result:hover { background: rgba(29,31,36,0.035); }
.nx-result .r-name { font-weight: 650; font-size: 13px; color: var(--nx-ink); }
.nx-result .r-sub { font-size: 11px; color: var(--nx-ink-3); }
.nx-result .r-add { width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: rgba(29,31,36,0.06); color: var(--nx-ink);
  border: none; transition: .15s; }
.nx-result:hover .r-add { background: var(--nx-ink); color: #fff; }
/* favorite star — pins a food to the top of the add sheet (filled ink when on) */
.nx-result .r-fav { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; border: none; background: none; color: var(--nx-ink-3);
  transition: color .15s, background .15s; }
.nx-result .r-fav:hover { background: rgba(29,31,36,0.06); color: var(--nx-ink); }
.nx-result .r-fav:focus-visible { outline: 2px solid var(--nx-ink); outline-offset: 2px; }
.nx-result .r-fav .ico { width: 15px; height: 15px; }
.nx-result .r-fav.on { color: var(--nx-ink); }
.nx-result .r-fav.on .ico path { fill: currentColor; }
.nx-result .r-fav + .r-add { margin-left: 4px; }
.nx-favlabel { font-size: 10px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--nx-ink-3); margin: 12px 2px 2px; }
.nx-thumb { width: 38px; height: 38px; border-radius: 12px; flex: none; overflow: hidden;
  position: relative; background: #F3F1EC; box-shadow: inset 0 0 0 1px var(--nx-hair);
  display: grid; place-items: center; }
.nx-thumb .lt { font-family: var(--nx-serif); font-size: 15px; color: var(--nx-ink-3); }
.nx-ai-cta { display: flex; align-items: center; gap: 11px; width: 100%; margin-top: 11px;
  padding: 12px 15px; border-radius: 15px; border: 1px dashed var(--nx-hair-2);
  background: none; color: var(--nx-ink); font-weight: 700; font-size: 13px; transition: .15s;
  text-align: left; }
.nx-ai-cta:hover { border-style: solid; border-color: var(--nx-ink-3); background: rgba(29,31,36,0.025); }
.nx-ai-cta .ico { width: 17px; height: 17px; flex: none; color: var(--nx-ink-2); }
.nx-ai-cta .hint { display: block; font-size: 10.5px; color: var(--nx-ink-3); font-weight: 600; margin-top: 1px; }
.nx-chiprow { display: flex; gap: 8px; margin-top: 11px; }

/* AI thinking shimmer text */
.nx-thinking { display: inline-block; font-weight: 700; font-size: 12.5px;
  background: linear-gradient(90deg, var(--nx-ink-3) 25%, var(--nx-ink) 50%, var(--nx-ink-3) 75%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: nx-shimmer-text 1.4s linear infinite; }
@keyframes nx-shimmer-text { to { background-position: -200% 0; } }

/* review cards */
.nx-review { margin-top: 12px; }
.nx-review .rv-note { font-size: 11.5px; color: var(--nx-ink-2); line-height: 1.5; margin: 4px 2px 8px; }
.nx-review .nx-result { cursor: default; }
.nx-review .rm { width: 28px; height: 28px; border-radius: 9px; border: none; margin-left: 4px;
  flex: none; display: grid; place-items: center; background: none; color: var(--nx-ink-3); }
.nx-review .rm:hover { color: var(--danger); background: var(--danger-soft); }
.nx-grams-inline { width: 68px; padding: 6px 8px; border: 1px solid var(--nx-hair-2);
  border-radius: 9px; font-family: var(--mono); font-size: 12px; font-weight: 700;
  text-align: center; background: var(--nx-card); color: var(--nx-ink); }
.nx-grams-inline:focus { outline: none; border-color: var(--nx-ink-3); }

/* consent card */
.nx-consent { display: flex; gap: 15px; align-items: center; border-radius: 16px; padding: 15px 18px;
  margin: 14px 0 0; background: var(--nx-card); border: 1px solid var(--nx-hair);
  box-shadow: var(--nx-shadow-card); text-align: left; }
.nx-consent .ic { width: 40px; height: 40px; border-radius: 13px; flex: none; display: grid;
  place-items: center; background: rgba(29,31,36,0.06); color: var(--nx-ink); }
.nx-consent .t { font-weight: 750; font-size: 13px; color: var(--nx-ink); }
.nx-consent .s { font-size: 11.5px; color: var(--nx-ink-2); margin-top: 2px; line-height: 1.5; }
.nx-consent .go { margin-left: auto; flex: none; }

/* supplements (Stack) */
.nx-stack-day { font-family: var(--nx-serif); font-size: 18px; font-weight: 550; margin: 6px 2px 12px;
  color: var(--nx-ink); }

/* day-swipe container */
.nx-dayview { position: relative; touch-action: pan-y; }

/* ---- responsive ---- */
@media (max-width: 880px) {
  .nx-energy { gap: 18px; padding: 16px 18px; }
  /* 2x2 macro grid — no orphaned fourth macro on narrow screens */
  .nx-energy .e-macros { margin-left: 0; width: 100%; display: grid;
    grid-template-columns: repeat(2, 1fr); gap: 14px 22px; }
  .nx-fab { right: 18px; bottom: 18px; }
}
@media (max-width: 560px) {
  .nx-grid { grid-template-columns: 1fr; gap: 58px 0; margin-top: 66px; }
  .nx-masthead .nx-title { font-size: 29px; }
  .nx-dish { width: 150px; height: 150px; top: -46px; }
  .nx-card { padding-top: 112px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nx-plating .plate, .nx-thinking { animation: none !important; }
  .nx-card, .nx-dish img, .nx-card .c-toggle .chev { transition: none !important; }
}
