/* ─────────────────────────────────────────────────────────────────────────────
   pH Lens  |  aSpace free tool
   Chrome (header/nav/footer/hero) comes from assets/css/site-chrome.css —
   this file only styles the tool itself. Functional colours keep the
   nutrient-status palette; brand tokens come from site.css.
───────────────────────────────────────────────────────────────────────────── */

/* ── Reset & Tokens ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --green:   #22c55e;
  --brown:   var(--color-primary, #002fa7);
  --sky:     #87CEEB;
  --gold:    #DAA520;
  --muted:   var(--color-muted, #425078);

  --bg:      var(--color-surface, #f7f5ef);
  --surface: var(--color-surface-elevated, #ffffff);
  --border:  var(--color-border, #d2d1d6);

  --text-dark:   var(--color-ink, #152047);
  --text-body:   var(--color-ink-muted, #425078);
  --text-light:  var(--muted);

  --status-high:   var(--green);
  --status-medium: var(--gold);
  --status-low:    var(--color-problem, #fd3b31);
  --status-toxic:  var(--color-error, #c02e27);

  --radius:  10px;
  --shadow:  0 2px 12px rgba(21,32,71,.06);
  --font:    var(--font-body, "Archivo", system-ui, sans-serif);
  --font-mono: var(--font-ui-label, "Space Mono", ui-monospace, monospace);
}

.page-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ── pH Panel ────────────────────────────────────────────────────────────── */
.ph-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px 24px;
  margin-bottom: 16px;
}

.ph-display {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap; gap: 10px;
}
.ph-value-wrap { display: flex; align-items: baseline; gap: 10px; }
.ph-label {
  font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.ph-value {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -.03em;
  line-height: 1;
  min-width: 80px;
  transition: color .25s;
}

.ph-zone-badge {
  font-size: .8rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--sky);
  color: #1a4a5a;
  border: 1px solid rgba(135,206,235,.4);
  transition: background .3s, color .3s;
  white-space: nowrap;
}
.ph-zone-badge.zone-opt    { background: var(--green); color: #fff; }
.ph-zone-badge.zone-acidic { background: #ffe0b2; color: #7a3800; }
.ph-zone-badge.zone-alkaline { background: var(--sky); color: #1a4a5a; }
.ph-zone-badge.zone-extreme  { background: #fce4ec; color: #8b0000; }

/* Slider track */
.ph-slider-wrap { position: relative; }

.ph-track-bg {
  position: absolute; top: 15px; left: 0; right: 0;
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right,
    #e05555 0%,        /* pH 4 */
    #e07a30 12.5%,     /* pH 4.75 */
    #DAA520 25%,       /* pH 5.5 */
    var(--green) 37%,  /* pH 6.2 */
    var(--green) 55%,  /* pH 7.3 */
    var(--sky)   72%,  /* pH 8.3 */
    #9b59b6    100%    /* pH 10 */
  );
  pointer-events: none;
  z-index: 0;
}
.ph-opt-marker {
  position: absolute;
  left: 36.67%;  /* (6.2-4)/(10-4) */
  width: 30.16%; /* (7.3-6.2)/(10-4) * 100 */
  top: -3px; height: 12px;
  background: rgba(32, 215, 96, .25);
  border: 1.5px solid var(--green);
  border-radius: 3px;
  pointer-events: none;
}

.ph-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  background: transparent;
  cursor: pointer;
  outline: none;
  position: relative; z-index: 1;
  margin-bottom: 4px;
}
.ph-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--green);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  cursor: grab;
  transition: border-color .2s, transform .15s;
  margin-top: -11px;
}
.ph-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.12); }
.ph-slider::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--green);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  cursor: grab;
}
.ph-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; }
.ph-slider::-moz-range-track { height: 6px; border-radius: 3px; background: transparent; }

.ph-tick-labels {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--muted);
  padding: 0 1px;
  margin-top: 2px;
}
.ph-zone-labels {
  display: flex;
  justify-content: space-around;
  font-size: .65rem;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

/* ── Diagnosis Bar ───────────────────────────────────────────────────────── */
.diagnosis-bar {
  background: #f0fdf5;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin-bottom: 24px;
  font-size: .875rem;
  color: var(--text-dark);
  min-height: 46px;
  display: flex; align-items: center; gap: 10px;
  transition: background .3s;
}
.diagnosis-bar.diag-warn  { background: #fff9e6; border-color: var(--gold); }
.diagnosis-bar.diag-alert { background: #fff0f0; border-color: #e05555; }
.diag-loading { color: var(--muted); font-style: italic; }

.diag-icon { font-size: 1.1rem; flex-shrink: 0; }
.diag-text { flex: 1; }
.diag-counts {
  display: flex; gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.diag-pill {
  font-size: .72rem; font-weight: 700;
  padding: 3px 9px; border-radius: 12px;
  white-space: nowrap;
}
.diag-pill-high   { background: #d4f5e2; color: #145c32; }
.diag-pill-medium { background: #fef3c7; color: #7a5200; }
.diag-pill-low    { background: #fde8e8; color: #7a1111; }
.diag-pill-toxic  { background: #c0392b; color: #fff; }

/* ── Main Grid ───────────────────────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 840px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ── Nutrients Panel ─────────────────────────────────────────────────────── */
.panel-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
}
.panel-hint {
  font-size: .78rem; color: var(--muted);
  margin-bottom: 14px;
}
.nutrient-group-label {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--brown);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

/* Nutrient row */
.nutrient-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .18s, transform .15s;
  margin-bottom: 4px;
  border: 1px solid transparent;
  position: relative;
}
.nutrient-row:hover {
  background: #f4fdf8;
  border-color: var(--border);
  transform: translateX(2px);
}
.nutrient-row:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.nut-symbol {
  font-size: .95rem; font-weight: 700;
  width: 36px; text-align: center;
  color: var(--brown);
  flex-shrink: 0;
  background: #fdf6ea;
  border-radius: 6px;
  padding: 4px 0;
  letter-spacing: -.01em;
}
.nut-label {
  font-size: .85rem; font-weight: 500;
  color: var(--text-dark);
  width: 110px; flex-shrink: 0;
}
.nut-bar-wrap {
  flex: 1; height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.nut-bar {
  height: 100%; border-radius: 6px;
  transition: width .45s cubic-bezier(.22,.61,.36,1), background .3s;
  will-change: width;
}
.nut-bar.high   { background: var(--green); }
.nut-bar.medium { background: var(--gold); }
.nut-bar.low    { background: #e05555; }
.nut-bar.toxic  { background: var(--status-toxic); }

.nut-pct {
  font-size: .78rem; font-weight: 600;
  width: 38px; text-align: right;
  flex-shrink: 0;
  color: var(--text-body);
}
.nut-status {
  font-size: .68rem; font-weight: 700;
  width: 62px; text-align: center;
  padding: 3px 6px; border-radius: 10px;
  flex-shrink: 0;
  text-transform: capitalize;
}
.nut-status.high   { background: #d4f5e2; color: #145c32; }
.nut-status.medium { background: #fef3c7; color: #7a5200; }
.nut-status.low    { background: #fde8e8; color: #7a1111; }
.nut-status.toxic  { background: var(--status-toxic); color: #fff; }

.nut-info-icon {
  font-size: .9rem; color: var(--sky);
  flex-shrink: 0; opacity: .7;
  transition: opacity .2s;
}
.nutrient-row:hover .nut-info-icon { opacity: 1; }

/* ── Side Panel ──────────────────────────────────────────────────────────── */
.side-panel { display: flex; flex-direction: column; gap: 16px; }

.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .85rem; font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 12px;
  letter-spacing: -.01em;
}
.card-loading { color: var(--muted); font-size: .8rem; font-style: italic; }

/* Legend */
.legend-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-body); }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.dot-high   { background: var(--green); }
.dot-medium { background: var(--gold); }
.dot-low    { background: #e05555; }
.dot-toxic  { background: var(--status-toxic); }
.legend-note {
  font-size: .72rem; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 10px;
  line-height: 1.5;
}

/* Fix card */
.fix-action-badge {
  display: inline-block;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 10px;
  margin-bottom: 10px;
}
.fix-action-badge.none  { background: #d4f5e2; color: #145c32; }
.fix-action-badge.raise { background: #fef3c7; color: #7a5200; }
.fix-action-badge.lower { background: #e8f4fd; color: #1a4a5a; }
.fix-title {
  font-size: .88rem; font-weight: 600;
  color: var(--text-dark); margin-bottom: 8px;
}
.fix-detail {
  font-size: .78rem; color: var(--text-body);
  line-height: 1.65;
}
.fix-gap {
  font-size: .78rem; font-weight: 600;
  color: var(--brown);
  margin-bottom: 6px;
}

/* Optimum bar */
.opt-desc { font-size: .8rem; color: var(--text-body); margin-bottom: 12px; line-height: 1.55; }
.opt-bar-track {
  position: relative;
  height: 12px; border-radius: 6px;
  background: linear-gradient(to right, #e05555 0%, var(--gold) 30%, var(--green) 50%, var(--sky) 75%, #9b59b6 100%);
  margin-bottom: 4px;
}
.opt-bar-marker {
  position: absolute;
  left: 36.67%; width: 30.16%;
  top: -2px; height: 16px;
  border: 2.5px solid var(--text-dark);
  border-radius: 4px;
  pointer-events: none;
}
.opt-bar-labels {
  display: flex; justify-content: space-between;
  font-size: .65rem; color: var(--muted);
}

/* ── Crops Section ───────────────────────────────────────────────────────── */
.crops-section {
  margin-top: 40px;
}
.section-title {
  font-size: 1.25rem; font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
}
.section-sub {
  font-size: .875rem; color: var(--muted);
  margin-bottom: 20px;
}
.crops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.crop-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  text-align: center;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.crop-card.in-range {
  border-color: var(--green);
  background: #f0fdf5;
}
.crop-card.out-range {
  border-color: #f5c6c6;
  opacity: .85;
}
.crop-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.crop-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.crop-name {
  font-size: .8rem; font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 4px;
}
.crop-ph-range {
  font-size: .7rem; color: var(--muted);
  margin-bottom: 8px;
}
.crop-status-pill {
  display: inline-block;
  font-size: .68rem; font-weight: 700;
  padding: 3px 8px; border-radius: 10px;
}
.crop-status-pill.ok  { background: #d4f5e2; color: #145c32; }
.crop-status-pill.no  { background: #fde8e8; color: #7a1111; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.modal-overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-box {
  background: var(--bg);
  border-radius: 14px;
  width: 100%; max-width: 500px;
  max-height: 80vh; overflow-y: auto;
  padding: 28px 28px 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  position: relative;
  animation: slideUp .2s ease;
}
.modal-close {
  position: absolute; top: 16px; right: 18px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dark); font-size: 1rem;
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .18s;
}
.modal-close:hover { background: #fee; }

.modal-symbol-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
}
.modal-symbol-big {
  font-size: 1.6rem; font-weight: 800;
  background: #fdf6ea;
  color: var(--brown);
  width: 56px; height: 56px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-nut-name { font-size: 1.2rem; font-weight: 700; color: var(--text-dark); }
.modal-nut-group { font-size: .75rem; color: var(--muted); text-transform: capitalize; margin-top: 2px; }
.modal-score-wrap { margin-left: auto; text-align: right; }
.modal-score-val {
  font-size: 2rem; font-weight: 700;
  line-height: 1;
}
.modal-score-val.high   { color: var(--green); }
.modal-score-val.medium { color: var(--gold); }
.modal-score-val.low    { color: #e05555; }
.modal-score-val.toxic  { color: var(--status-toxic); }
.modal-score-label { font-size: .72rem; color: var(--muted); }

.modal-bar-wrap {
  width: 100%; height: 10px;
  background: var(--border); border-radius: 5px;
  overflow: hidden; margin-bottom: 20px;
}
.modal-bar {
  height: 100%; border-radius: 5px;
  transition: width .5s cubic-bezier(.22,.61,.36,1);
}
.modal-bar.high   { background: var(--green); }
.modal-bar.medium { background: var(--gold); }
.modal-bar.low    { background: #e05555; }
.modal-bar.toxic  { background: var(--status-toxic); }

.modal-section-title {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--brown);
  margin-bottom: 6px;
}
.modal-why-text, .modal-fix-text {
  font-size: .86rem; color: var(--text-body);
  line-height: 1.7;
  margin-bottom: 18px;
}
.modal-loading { color: var(--muted); font-style: italic; font-size: .9rem; }

/* ── CTA section ─────────────────────────────────────────────────────────── */
.cta-section { margin-top: 56px; }
.cta-box {
  background: var(--gradient-hero, linear-gradient(160deg, #002fa7 0%, #0435b0 45%, #0b3ebd 100%));
  border-radius: 16px;
  padding: 40px 36px;
  text-align: center;
}
.cta-title {
  font-size: 1.3rem; font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.35;
}
.cta-sub {
  font-size: .9rem; color: rgba(255,255,255,.75);
  margin-bottom: 24px;
  max-width: 480px; margin-left: auto; margin-right: auto;
}
.btn-cta {
  display: inline-block;
  background: var(--color-accent, #b2f704);
  color: var(--color-ink, #152047);
  font-family: var(--font-mono);
  font-size: .95rem; font-weight: 400;
  padding: 13px 32px; border-radius: 30px;
  text-decoration: none;
  transition: opacity .2s, transform .15s;
  letter-spacing: .01em;
}
.btn-cta:hover { opacity: .88; transform: translateY(-2px); text-decoration: none; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.skeleton-rows::after {
  content: '';
  display: block;
  height: 160px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0%   { background-position: 100% 50% }
  100% { background-position: 0%   50% }
}

@media (max-width: 600px) {
  .ph-panel { padding: 20px 16px 16px; }
  .page-wrap { padding: 0 14px 48px; }
  .nut-label { width: 80px; font-size: .78rem; }
  .nut-pct, .nut-status { display: none; }
  .modal-box { padding: 22px 18px 20px; }
  .cta-box { padding: 28px 20px; }
  .ph-zone-labels { display: none; }
}
