/* Meal Orbit: meals are discrete observations around a calm target zone. */
.profile-meal-magnet {
  --viz-center: #15956f;
  --viz-center-soft: color-mix(in srgb, var(--viz-center) 14%, transparent);
  --viz-fit: #3972b8;
  --viz-next: #b86f22;
  --viz-empty: var(--muted);
  --viz-glow: color-mix(in srgb, var(--viz-center) 30%, transparent);
  --viz-center-text: #0b7257;
  --viz-fit-text: #285b96;
  --viz-next-text: #8a4d12;
  display: grid;
  gap: 9px;
}

.profile-meal-magnet__summary {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.4;
}

.profile-meal-magnet--empty .profile-meal-magnet__summary {
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--viz-center) 6%, var(--card) 94%);
  color: var(--muted);
  font-weight: 600;
}

.profile-meal-magnet__chart {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 400 / 270;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
}

.profile-meal-magnet__field {
  stroke: color-mix(in srgb, var(--viz-center) 20%, var(--line) 80%);
  stroke-width: 1;
}

.profile-meal-magnet__atmosphere {
  opacity: 0.64;
}

.profile-meal-magnet__center-band {
  stroke: color-mix(in srgb, var(--viz-center) 30%, transparent);
  stroke-width: 1;
}

.profile-meal-magnet__center-shine {
  mix-blend-mode: screen;
  opacity: 0.72;
}

.profile-meal-magnet__axis {
  stroke: color-mix(in srgb, var(--text) 32%, transparent);
  stroke-dasharray: 4 5;
  stroke-width: 1.5;
}

.profile-meal-magnet__day-tick {
  stroke: color-mix(in srgb, var(--line) 68%, transparent);
  stroke-dasharray: 2 6;
  stroke-width: 1;
}

.profile-meal-magnet__tether {
  stroke: color-mix(in srgb, var(--viz-fit) 34%, transparent);
  stroke-width: 1.4;
  stroke-dasharray: 2 4;
}

.profile-meal-magnet__tether--strong { stroke: color-mix(in srgb, var(--viz-center) 38%, transparent); }
.profile-meal-magnet__tether--next { stroke: color-mix(in srgb, var(--viz-next) 42%, transparent); }

.profile-meal-magnet__date,
.profile-meal-magnet__center-label,
.profile-meal-magnet__band-label,
.profile-meal-magnet__overflow {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.profile-meal-magnet__center-label {
  fill: var(--viz-center-text);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.profile-meal-magnet__band-label {
  fill: var(--viz-next-text);
  font-size: 10px;
}

.profile-meal-magnet__point {
  --orbit-ring-color: var(--viz-fit);
  cursor: pointer;
  outline: none;
}

.profile-meal-magnet__point-hit {
  fill: transparent;
}

.profile-meal-magnet__point-core {
  stroke: var(--card);
  stroke-width: 3;
}

.profile-meal-magnet__point-ring {
  fill: none;
  stroke: var(--orbit-ring-color);
  stroke-dasharray: 5 4;
  stroke-width: 2;
}

.profile-meal-magnet__point--strong .profile-meal-magnet__point-ring {
  stroke-dasharray: none;
}

.profile-meal-magnet__point--next .profile-meal-magnet__point-ring {
  stroke-dasharray: 2 5;
}

.profile-meal-magnet__point--strong { --orbit-ring-color: var(--viz-center); }
.profile-meal-magnet__point--next { --orbit-ring-color: var(--viz-next); }

.profile-meal-magnet__point-aura {
  opacity: 0.7;
  transform-origin: center;
}

.profile-meal-magnet__point-specular {
  fill: rgba(255, 255, 255, 0.92);
  opacity: 0.84;
}

.profile-meal-magnet__selection-marker {
  fill: var(--viz-center);
  opacity: 0;
  transform-origin: center;
}

.profile-meal-magnet__point--next .profile-meal-magnet__selection-marker {
  fill: var(--viz-next);
}

.profile-meal-magnet__point.is-selected .profile-meal-magnet__point-ring {
  stroke-width: 3;
}

.profile-meal-magnet__point.is-selected .profile-meal-magnet__point-aura {
  opacity: 1;
}

.profile-meal-magnet__point.is-selected .profile-meal-magnet__selection-marker {
  opacity: 1;
}

.profile-meal-magnet__point:focus-visible .profile-meal-magnet__point-hit {
  fill: color-mix(in srgb, var(--viz-center) 16%, transparent);
  stroke: var(--viz-center);
  stroke-width: 2;
}

.profile-meal-magnet__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.7rem;
}

.profile-meal-magnet__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-meal-magnet__legend-marker {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--viz-fit);
  border-radius: 50%;
}

.profile-meal-magnet__legend-item--strong .profile-meal-magnet__legend-marker {
  border-color: var(--viz-center);
  background: var(--viz-center);
}

.profile-meal-magnet__legend-item--next .profile-meal-magnet__legend-marker {
  border-color: var(--viz-next);
  border-style: dashed;
}

.profile-meal-magnet__detail {
  display: grid;
  gap: 7px;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--viz-center) 30%, var(--line) 70%);
  border-radius: 14px;
  background: color-mix(in srgb, var(--viz-center) 7%, var(--card) 93%);
}

.profile-meal-magnet__detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.profile-meal-magnet__detail-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-meal-magnet__detail-state {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--viz-fit) 45%, transparent);
  border-radius: 999px;
  color: var(--viz-fit-text);
  font-size: 0.66rem;
  font-weight: 750;
  white-space: nowrap;
}

.profile-meal-magnet__detail-state--strong {
  border-color: color-mix(in srgb, var(--viz-center) 45%, transparent);
  color: var(--viz-center-text);
}

.profile-meal-magnet__detail-state--next {
  border-color: color-mix(in srgb, var(--viz-next) 45%, transparent);
  color: var(--viz-next-text);
}

.profile-meal-magnet__detail-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.profile-meal-magnet__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.profile-meal-magnet__metric {
  padding: 5px 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.profile-meal-magnet__metric--kcal {
  background: color-mix(in srgb, var(--viz-center) 12%, transparent);
  color: var(--text);
  font-weight: 750;
}

.profile-meal-magnet__metric--protein { border-left: 3px solid #2563eb; }
.profile-meal-magnet__metric--carbs { border-left: 3px solid #b7791f; }
.profile-meal-magnet__metric--fat { border-left: 3px solid #7c3aed; }

.profile-meal-magnet__why {
  justify-self: start;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--viz-center) 38%, var(--line));
  border-radius: 999px;
  background: transparent;
  color: var(--viz-center-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 750;
}

.profile-meal-magnet__why:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--viz-center) 45%, transparent);
  outline-offset: 2px;
}

.profile-meal-magnet__explanation {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.profile-meal-magnet__text-alternative {
  margin: 0;
  padding: 0;
}

.profile-meal-magnet .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html.sl-theme-dark .profile-meal-magnet__detail {
  background: color-mix(in srgb, var(--viz-center) 14%, var(--card) 86%);
}

html.sl-theme-dark .profile-meal-magnet {
  --viz-center-text: #5eead4;
  --viz-fit-text: #93c5fd;
  --viz-next-text: #fbbf6a;
}

html.sl-theme-dark .profile-meal-magnet__atmosphere { opacity: 0.36; }
html.sl-theme-dark .profile-meal-magnet__center-shine { opacity: 0.36; }

@media (max-width: 420px) {
  .profile-meal-magnet__chart {
    margin-inline: -6px;
    width: calc(100% + 12px);
  }

  .profile-meal-magnet__metric {
    flex: 1 1 calc(50% - 5px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .profile-meal-magnet__point-core,
  .profile-meal-magnet__point-ring,
  .profile-meal-magnet__point-aura,
  .profile-meal-magnet__selection-marker {
    transition: filter 160ms ease, opacity 160ms ease, stroke-width 160ms ease;
  }

  .profile-meal-magnet__point {
    animation: profile-meal-magnet-appear 180ms ease-out both;
    animation-delay: var(--orbit-delay, 0ms);
  }
}

@keyframes profile-meal-magnet-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Keep visualization details on the readable content layer. */
.profile-meal-magnet--empty .profile-meal-magnet__summary,
.profile-meal-magnet__detail,
.profile-meal-magnet__recommendation {
  background: color-mix(in srgb, var(--surface-content-strong) 92%, var(--viz-center) 8%);
  border-color: color-mix(in srgb, var(--viz-center) 28%, var(--glass-border-outer) 72%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

@media (forced-colors: active) {
  .profile-meal-magnet--empty .profile-meal-magnet__summary,
  .profile-meal-magnet__detail,
  .profile-meal-magnet__recommendation {
    background: Canvas;
    border: 1px solid CanvasText;
    box-shadow: none;
  }
}
