/* ==========================================================================
   Crow-Flies Distance Calculator (AU) - Tool-Specific Styles
   Layout conventions match the AU postcode trio (postcode-radius.css).
   ========================================================================== */

/* Layout: same !important override, same documented reason, as
   ca-route-optimizer.css - global.css's .tool-container grid loads after
   this file and wins on equal specificity without it. Real measurement,
   2026-09-11: the sidebar's own content (measure-distance, results,
   travel-time compare, about, data & attribution, related tools) renders
   1651px tall against #map's fixed 600px - since a CSS grid row with no
   explicit height stretches to match its tallest cell, .map-container
   was stretching to 1651px too, leaving ~1050px of dead white space
   below the map, beside the sidebar's later sections - exactly the
   "map column ends, empty area beside the remaining sidebar" bug Dan
   found on ca-route-optimizer. Same fix: cap the row height and let the
   sidebar scroll independently instead.*/
.tool-container {
  display: flex !important;
  height: 700px !important;
  max-height: 700px !important;
  overflow: hidden !important;
  background-color: var(--bg);
}

.tool-sidebar {
  width: 400px;
  overflow-y: auto;
  flex-shrink: 0;
}

.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 500px;
  max-height: 700px;
}

.map-container .map,
.map-container #map {
  width: 100%;
  height: 100% !important;
  min-height: 500px;
}

@media (max-width: 900px) {
  .tool-container {
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
  }
  .tool-sidebar {
    width: 100%;
    max-height: 400px;
  }
  .map-container .map,
  .map-container #map {
    height: 400px !important;
  }
}

.sidebar-content label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-content label:first-of-type {
  margin-top: 0;
}

.tool-section h3 {
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-section {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--card) 100%);
  margin: -20px -20px 0 -20px;
  padding: 20px;
  border-radius: 12px 12px 0 0;
}

.point-field {
  position: relative;
  margin-bottom: 4px;
}

.point-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.point-field-row input[type='text'] {
  flex: 1;
}

.btn-icon {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 15px;
  line-height: 1;
}

.suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.suggestions.show {
  display: block;
}

.suggestions .item {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}

.suggestions .item:last-child {
  border-bottom: none;
}

.suggestions .item:hover {
  background: var(--hover-bg);
}

.item-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 6px;
}

/* Per-field resolution feedback - a genuine refusal (not found, ambiguous,
   fetch failed) by default; .field-note softens it for the "matched the
   postcode but not the specific address" fallback case, which isn't a
   failure - the calculation still runs. */
.field-error {
  display: none;
  font-size: 0.78rem;
  color: var(--danger, #dc2626);
  margin-top: 4px;
  line-height: 1.4;
}

.field-error.field-note {
  color: var(--text-muted);
}

.swap-row {
  display: flex;
  justify-content: center;
  margin: 4px 0;
}

.btn-swap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 16px;
}

.unit-toggle {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.unit-toggle .btn {
  flex: 1;
}

.click-hint {
  display: none;
  font-size: 0.82rem;
  color: var(--primary);
  background: var(--glass);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 10px;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.button-row .btn {
  flex: 1;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.result-box {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
}

.result-points {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.result-points .pt-label {
  font-weight: 600;
  color: var(--text);
}

.result-distance {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.result-distance .unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.result-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Exact vs. range honesty note - see distance-between-au.js's
   buildPrecisionNote(). Three states, three treatments: exact is quiet
   confirmation, a known range is a neutral caveat, an unknown range
   (couldn't load the spread data) reads closer to a warning since it's
   the one state where the figure above carries uncertainty this tool
   can't currently bound. */
.precision-note {
  font-size: 0.8rem;
  line-height: 1.5;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--text-muted);
}

.precision-note.precision-exact {
  color: var(--success, #16a34a);
}

.precision-note.precision-unknown {
  color: var(--warning, #d97706);
}

.result-bearing {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.result-bearing strong {
  color: var(--text);
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.compare-item {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  text-align: center;
}

.compare-item .icon {
  font-size: 1.1rem;
  display: block;
  margin-bottom: 4px;
}

.compare-item .val {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  display: block;
}

.compare-item .lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.compare-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.5;
}

.tool-info {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
}

.tool-item {
  font-size: 13px;
  color: var(--text);
  padding: 6px 0;
}

.tool-distinction {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-distinction a {
  color: var(--primary);
}

/* Map point icons (A / B pins) + click-armed cursor */
.distance-point-icon .point-pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.distance-point-icon .point-pin > * {
  transform: rotate(45deg);
}

.point-from .point-pin {
  background: var(--primary);
}

.point-to .point-pin {
  background: var(--success, #16a34a);
}

#map.click-armed {
  cursor: crosshair;
}

@media (max-width: 900px) {
  .result-distance {
    font-size: 1.8rem;
  }
}

@media (max-width: 600px) {
  .input-section {
    margin: -16px -16px 0 -16px;
    padding: 16px;
  }

  .compare-grid {
    gap: 6px;
  }
}
