/* Terrathink — Tools (calculators). Loaded after styles.css and notes.css.
   Inputs sit on the deeper tan, results on navy, so the answer is the strongest thing on the page. */

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tool { display: grid; gap: clamp(20px, 2.4vw, 32px); margin: 0 var(--gutter); }
.tool > * { min-width: 0; }

.tool-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--ink-line);
  border-radius: 22px;
  background: var(--paper-deep);
}
.tool-inputs { display: grid; align-content: start; gap: 22px; padding: clamp(22px, 3vw, 40px); }
.panel-title { font-family: var(--display); font-size: clamp(1.5rem, 2vw, 1.875rem); line-height: 1.1; }

.field label { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: 0.9375rem; font-weight: 500; }
.field .opt { font-size: 0.8125rem; font-weight: 400; color: var(--ink-soft); }
.field[hidden] { display: none; }
.input-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.input-row input { flex: 1 1 140px; }
.tool input[type="number"], .tool select {
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-field);
  background: var(--paper);
  color: var(--ink);
  font: 500 1.25rem/1 var(--text);
  font-variant-numeric: tabular-nums;
}
.tool input[type="number"]:hover, .tool select:hover { border-color: rgba(30, 61, 81, 0.45); }
.tool input[type="number"]:focus-visible, .tool select:focus-visible { outline: 2px solid var(--leaf); outline-offset: 1px; border-color: var(--ink); }
.tool select {
  width: 100%;
  padding-right: 44px;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1.5 7 7.5l6-6' fill='none' stroke='%231E3D51' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}
.input-row select { flex: 1 1 180px; width: auto; }
.unit { min-width: 2ch; font-size: 1rem; color: var(--ink-soft); }
.hint { margin-top: 8px; font-size: 0.875rem; line-height: 1.5; color: var(--ink-soft); }
.range { width: 100%; margin: 14px 0 0; accent-color: var(--ink); }

.seg { display: inline-flex; flex: none; padding: 4px; border: 1px solid var(--ink-line); border-radius: var(--radius-pill); background: var(--paper); }
.seg button {
  height: 42px; padding: 0 14px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--ink-soft); font: 500 0.9375rem/1 var(--text); cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.tool-result { display: grid; align-content: start; gap: 14px; padding: clamp(22px, 3vw, 40px); background: var(--night); color: var(--paper); }
.result-label { font-size: 0.9375rem; color: var(--cream-soft); }
.result-value {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px;
  font-family: var(--display); font-size: clamp(3.5rem, 7vw, 5.5rem); line-height: 0.95;
  font-variant-numeric: tabular-nums;
}
.result-unit { font-family: var(--text); font-size: 1.125rem; color: var(--cream-soft); }
.result-band {
  align-self: start; padding: 10px 14px; border-left: 3px solid var(--cream-line); border-radius: 4px 12px 12px 4px;
  background: rgba(255, 237, 213, 0.08); font-size: 0.9688rem; line-height: 1.45;
}
.result-band[data-band="low"] { border-left-color: #9EC0D2; }
.result-band[data-band="mid"] { border-left-color: #8FCF9E; }
.result-band[data-band="high"] { border-left-color: #F2B27A; }
.result-note { font-size: 0.9688rem; line-height: 1.5; color: var(--cream-soft); }
.result-detail { margin: 4px 0 0; border-top: 1px solid rgba(255, 237, 213, 0.18); }
.result-detail div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid rgba(255, 237, 213, 0.18); font-size: 0.9688rem; }
.result-detail dt { color: var(--cream-soft); }
.result-detail dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.tool-panel-plan .result-value { font-size: clamp(2.75rem, 5vw, 4rem); }
@media (min-width: 961px) {
  .tool-panel-plan .tool-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
  .tool-panel-plan .panel-title { grid-column: 1 / -1; }
}

/* VPD chart: the reading's nearest cell is outlined. */
.vpd-chart { margin: 0; }
.vpd-chart figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; margin-bottom: 12px; }
.vpd-chart-title { font-family: var(--display); font-size: 1.375rem; line-height: 1.2; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.875rem; color: var(--ink-soft); }
.key { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.key + .key, .legend .key:not(:first-child) { margin-left: 8px; }
.b-low { background: #DCE7EC; }
.b-mid { background: #D5EAD7; }
.b-high { background: #F6D9BD; }
.key-here { box-shadow: inset 0 0 0 2px var(--ink); }
.vpd-chart .table-wrap { margin-top: 0; background: var(--paper); }
.vpd-chart table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.vpd-chart th, .vpd-chart td { padding: 10px 12px; text-align: center; white-space: nowrap; }
.vpd-chart thead th { background: var(--paper-deep); font-weight: 500; }
.vpd-chart tbody th { background: var(--paper-deep); font-weight: 500; text-align: left; }
.vpd-chart tbody th span { margin-left: 6px; font-weight: 400; color: var(--ink-soft); }
.vpd-chart tbody tr + tr > * { border-top: 1px solid rgba(30, 61, 81, 0.08); }
.vpd-chart td.is-here { outline: 2px solid var(--ink); outline-offset: -2px; font-weight: 500; }

/* Tool cards: the hub, and "More tools" under each calculator. */
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2vw, 24px); margin: 0; padding: 0 var(--gutter); list-style: none; }
.tool-grid-hub { padding-bottom: clamp(56px, 6vw, 96px); }
.more .tool-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.tool-card {
  position: relative; display: grid; align-content: start; gap: 12px;
  padding: clamp(22px, 2.4vw, 32px); border: 1px solid var(--ink-line); border-radius: 18px;
  background: var(--paper-deep); transition: border-color .2s ease;
}
.more .tool-card { background: var(--paper); }
.tool-card:hover { border-color: var(--ink); }
.tool-card:has(a:focus-visible) { outline: 2px solid var(--leaf); outline-offset: 4px; }
.tool-glyph { margin-bottom: 6px; font-family: var(--display); font-size: clamp(2.5rem, 4vw, 3.5rem); line-height: 1; }
.tool-card h2, .tool-card h3 { font-size: clamp(1.5rem, 2vw, 1.875rem); line-height: 1.1; }
.tool-card h2 a, .tool-card h3 a { text-decoration: none; }
.tool-card h2 a::after, .tool-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 18px; }
.tool-card h2 a:focus-visible, .tool-card h3 a:focus-visible { outline: none; }
.tool-card .dek { line-height: 1.55; color: var(--ink-soft); }
.tool-go { margin-top: 4px; font-size: 0.9375rem; font-weight: 500; }
.tool-go::after { content: " \2192"; }
.tool-card-class { background: var(--night); border-color: var(--night); color: var(--paper); }
.tool-card-class:hover { border-color: var(--night); background: var(--night-deep); }
.tool-card-class .dek { color: var(--cream-soft); }
.more-tools-head { margin-top: clamp(48px, 5vw, 72px); }

/* Fertilizer calculator: mode switch, N-P-K row. */
.field-label { display: block; margin-bottom: 8px; font-size: 0.9375rem; font-weight: 500; }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1 1 0; height: auto; min-height: 42px; padding: 8px 12px; line-height: 1.2; }
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.fert-npk legend { margin-bottom: 8px; padding: 0; font-size: 0.9375rem; font-weight: 500; }
.npk-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.npk-row label { display: grid; gap: 6px; font-size: 0.875rem; color: var(--ink-soft); }
.npk-row input { width: 100%; }
.result-detail div[hidden] { display: none; }

@media (max-width: 960px) {
  .tool-panel { grid-template-columns: minmax(0, 1fr); }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .tool-panel { border-radius: 18px; }
  .vpd-chart th, .vpd-chart td { padding: 9px 8px; font-size: 0.875rem; }
  .vpd-chart tbody th span { display: block; margin-left: 0; }
}