/* Soil report pieces — shared by soil-doctor.html and report.html */

.report { display: grid; gap: var(--s-6); }

.report-head {
  display: grid;
  gap: var(--s-5);
  padding: var(--s-5);
  border-radius: var(--r-xl);
  align-items: center;
  overflow: hidden;
}
@media (min-width: 860px) { .report-head { grid-template-columns: 1fr auto; padding: var(--s-6) var(--s-7); } }
.report-head::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 90% at 100% 0%, rgb(var(--teal-rgb) / 0.12), transparent 70%);
  pointer-events: none;
}
.report-head-copy { display: grid; gap: var(--s-4); justify-items: start; position: relative; }
.report-head h2 { font-size: var(--fs-3xl); line-height: 1; }
.report-head h2 em { color: var(--text-2); }

.report-meta { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.report-meta li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.report-meta .icon { color: var(--teal); }

.report-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.report-actions .btn { --btn-h: 42px; }

.report-section { display: grid; gap: var(--s-4); }
.report-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); }
.report-section-head h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-2xl); letter-spacing: -0.01em; }

.legend { list-style: none; display: flex; gap: 14px; font-size: var(--fs-xs); color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; }
.legend .deficient::before { background: var(--deficient); }
.legend .excess::before { background: var(--excess); }
.legend .sufficient::before { background: var(--sufficient); }

/* Health ring */
.health {
  position: relative;
  display: grid;
  grid-template-columns: 150px auto;
  align-items: center;
  gap: var(--s-5);
}
.health-ring-wrap { width: 150px; height: 150px; grid-row: 1; grid-column: 1; }
.health-ring { width: 100%; height: 100%; }
.health-ring .arc { animation: ring-draw 1.2s var(--ease) both; }
.health-center {
  grid-row: 1; grid-column: 1;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  line-height: 1.1;
}
.health-center strong { font-size: 1.9rem; font-weight: 600; }
.health-center span { font-size: var(--fs-xs); color: var(--muted); }
.health-counts { list-style: none; display: grid; gap: 8px; }
.health-counts li { display: flex; align-items: baseline; gap: 10px; font-size: var(--fs-sm); color: var(--text-2); }
.health-counts strong { font-size: 1.35rem; min-width: 1.6ch; }
.health-counts .deficient strong { color: var(--deficient); }
.health-counts .excess strong { color: var(--excess); }
.health-counts .sufficient strong { color: var(--sufficient); }
@media (max-width: 420px) { .health { grid-template-columns: 120px auto; } .health-ring-wrap { width: 120px; height: 120px; } }

/* Nutrient cards */
.nutrient-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.nutrient-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  animation: fade-up 480ms var(--ease) both;
}
.nutrient-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.nutrient-card.is-deficient::before { background: var(--deficient); }
.nutrient-card.is-excess::before { background: var(--excess); }
.nutrient-card.is-sufficient::before { background: var(--sufficient); }
.nc-head { display: flex; align-items: flex-start; gap: 12px; }
.nc-sym {
  width: 38px; height: 38px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.nc-name { flex: 1; min-width: 0; display: grid; gap: 2px; }
.nc-name h4 { font-size: var(--fs-md); }
.nc-name span { font-size: var(--fs-xs); color: var(--muted); }
.nc-gap { font-size: var(--fs-sm); color: var(--text-2); }
.is-deficient .nc-gap { color: var(--gap-deficient); }
.is-excess .nc-gap { color: var(--gap-excess); }

.gauge {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 3px;
  height: 8px;
}
.gauge .zone { border-radius: 4px; }
.gauge .low { background: rgb(242 179 61 / 0.22); }
.gauge .ok { background: rgb(74 185 77 / 0.28); }
.gauge .high { background: rgb(240 98 90 / 0.22); }
.gauge .marker {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-strong), 0 0 14px rgb(255 255 255 / 0.25);
  animation: marker-in 900ms var(--ease) both;
}
.gauge .at-deficient { left: 14%; background: var(--deficient); }
.gauge .at-sufficient { left: 50%; background: var(--sufficient); }
.gauge .at-excess { left: 86%; background: var(--excess); }
.gauge-labels { display: grid; grid-template-columns: 1fr 1.2fr 1fr; font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: -6px; }
.gauge-labels span:nth-child(2) { text-align: center; }
.gauge-labels span:nth-child(3) { text-align: right; }

/* Crop tiers */
.tiers { display: grid; gap: 12px; }
@media (min-width: 860px) { .tiers { grid-template-columns: repeat(3, 1fr); } }
.tier {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-1);
}
.tier header { display: flex; gap: 12px; align-items: flex-start; }
.tier header .icon { width: 22px; height: 22px; margin-top: 2px; }
.tier header h4 { font-size: var(--fs-md); }
.tier header span { font-size: var(--fs-xs); color: var(--muted); }
.tier-best { border-color: rgb(var(--green-rgb) / 0.4); background: linear-gradient(180deg, rgb(var(--green-rgb) / 0.08), var(--surface-1)); }
.tier-best header .icon { color: var(--green); }
.tier-moderate header .icon { color: var(--teal); }
.tier-low header .icon { color: var(--muted); }
.tier ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.tier li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.tier li { padding-left: 6px; }
.tier-ic { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: rgb(255 255 255 / 0.04); }
.tier-ic svg { width: 22px; height: 22px; }
.tier li.is-chosen { border-color: var(--teal); box-shadow: 0 0 0 3px rgb(var(--teal-rgb) / 0.15); }
.tier .your { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--on-brand); background: var(--grad); padding: 2px 7px; border-radius: var(--r-pill); }

.section-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 6px; }
.crop-needs { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (min-width: 1100px) { .crop-needs { grid-template-columns: repeat(4, 1fr); } }
.nc-note { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--muted); margin-top: -4px; }

/* Crop needs (fertilizer step) */
.needs { list-style: none; display: grid; gap: 10px; }
@media (min-width: 720px) { .needs { grid-template-columns: repeat(3, 1fr); } }
.needs li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid rgb(242 179 61 / 0.3);
}
.needs-name { font-weight: 600; flex: 1; }
.needs-val { color: var(--gap-deficient); font-size: var(--fs-sm); text-align: right; }

/* Fertilizer options */
.plan-options { display: grid; gap: var(--s-4); }
.plan-options-head { display: grid; gap: 10px; }
.plan-options-head p { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.fert-list { list-style: none; display: grid; gap: 10px; }
.fert {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  animation: fade-up 420ms var(--ease) both;
}
@media (min-width: 640px) { .fert { grid-template-columns: auto 1fr auto; } }
.fert-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad);
  color: var(--on-brand);
}
.fert-icon .icon { width: 24px; height: 24px; stroke-width: 2; }
.fert-name { display: grid; gap: 3px; min-width: 0; }
.fert-name strong { font-size: var(--fs-md); }
.fert-name .mono { font-size: var(--fs-sm); color: var(--text-2); }
.fert-total {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
@media (min-width: 640px) { .fert-total { grid-column: auto; display: grid; justify-items: end; gap: 2px; padding: 8px 14px; } }
.fert-total span { font-size: var(--fs-xs); color: var(--muted); }
.fert-total strong { font-size: 1.25rem; font-weight: 600; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.no-fert { display: grid; justify-items: center; gap: 12px; text-align: center; padding: var(--s-6) var(--s-4); }
.no-fert p { color: var(--text-2); max-width: 44ch; }

.plan-badge {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 22px 28px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--green);
}
.plan-badge strong { font-size: 2rem; color: var(--text); }
.plan-badge span { font-size: var(--fs-xs); color: var(--muted); }

/* Shared report page */
.shared-wrap { padding-top: var(--s-6); }
.next-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: var(--s-5); }
.shared-loading { display: grid; justify-items: center; gap: var(--s-4); padding: var(--s-9) 0; color: var(--text-2); }
.shared-empty { max-width: 560px; margin: var(--s-7) auto; }
.shared-empty h2 { font-size: var(--fs-2xl); color: var(--text); }
.shared-empty p { max-width: 42ch; }

@keyframes ring-draw { from { stroke-dasharray: 0 400; } }
@keyframes marker-in { from { left: 50%; opacity: 0; } }

/* Shared report page: the download button stays inside the head card, under the details (not first on phones) */
@media (max-width: 640px) { body[data-page='soil'] .report-head .report-actions { order: 0; width: auto; } }
