/* NearbyCheck result-layout contract.
   Loads after the presentation layer and owns structural stacking / visibility behavior.

   Result-state rule:
   - app bar stays sticky at the top;
   - Current check remains in normal document flow;
   - List / Map is the only result-local sticky rail;
   - decision-surface visibility always outranks presentation styling;
   - Field Guide numbers alternatives without rewriting their internal content flow.

   This continues to fence the historical 54/58/106/116px offset stack. */

:root{
  --nc-appbar-h:64px;
  --nc-result-nav-top:var(--nc-appbar-h);
}

/* Field Guide owns the public canvas width. The historical 1180px shell came
   from the pre-Field-Guide UI and was still compressing the desktop decision
   column to ~410px. Give the new composition its intended 1320px canvas. */
body.field-guide-app>.shell{
  width:min(1320px,calc(100% - 56px))!important;
  max-width:none!important;
  padding:0!important;
}

.topbar{
  height:var(--nc-appbar-h)!important;
  min-height:var(--nc-appbar-h)!important;
}

/* Landing is one composed decision entry, not a landing page followed by an
   empty results application. The workspace appears only when a real result state exists. */
body.field-guide-app:not(.has-live-results) .results-section{
  display:none!important;
}

/* On desktop the map is a first-class visual column. It should span the full
   composition height rather than ending halfway down beside a taller control deck. */
@media(min-width:761px){
  body.field-guide-app:not(.has-live-results) .field-map-visual{
    align-self:stretch!important;
    height:auto!important;
    min-height:650px!important;
  }
}

/* Current check is a query summary, not a second app bar. */
body.has-live-results .decision-check-summary{
  position:static!important;
  top:auto!important;
  z-index:auto!important;
  min-height:0!important;
  box-shadow:none!important;
}

/* Field Guide result mode is compact by default, but Change must genuinely
   reopen the query editor. decision-brief.js owns the editing state; this final
   layout layer makes that state visible without restoring the landing hero. */
body.field-guide-app.has-live-results.decision-controls-editing .field-control-deck{
  padding:0!important;
  border:1px solid rgba(19,42,34,.72)!important;
  border-radius:12px!important;
  background:rgba(251,250,244,.96)!important;
  box-shadow:0 18px 44px rgba(19,42,34,.075)!important;
}
body.field-guide-app.has-live-results.decision-controls-editing .field-step{
  display:grid!important;
}
body.field-guide-app.has-live-results.decision-controls-editing .field-fine-tune{
  display:block!important;
  border-top:1px solid var(--fg-rule)!important;
}
body.field-guide-app.has-live-results.decision-controls-editing .field-fine-tune>summary{
  display:flex!important;
}
body.field-guide-app.has-live-results.decision-controls-editing .field-fine-tune-body{
  padding:4px 19px 16px!important;
}
body.field-guide-app.has-live-results.decision-controls-editing .field-submit-row{
  display:grid!important;
}
body.field-guide-app.has-live-results.decision-controls-editing .decision-check-summary{
  margin-bottom:12px!important;
}

/* Best Match evidence belongs to the dark answer surface itself. Do not render
   an old pale card inside the new Field Guide answer. */
body.field-guide-app .po6-has-results .decision-banner .decision-brief{
  display:grid!important;
  gap:0!important;
  margin:14px 0 10px!important;
  padding:0!important;
  border:0!important;
  border-top:1px solid rgba(255,255,255,.18)!important;
  border-bottom:1px solid rgba(255,255,255,.18)!important;
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
}
body.field-guide-app .po6-has-results .decision-banner .decision-brief-label{
  padding:9px 0 7px!important;
  color:#d8bd7c!important;
  font-size:8px!important;
  font-weight:850!important;
  letter-spacing:.13em!important;
  text-transform:uppercase!important;
}
body.field-guide-app .po6-has-results .decision-banner .decision-brief-row{
  display:grid!important;
  grid-template-columns:88px minmax(0,1fr)!important;
  gap:12px!important;
  padding:9px 0!important;
  border:0!important;
  border-top:1px solid rgba(255,255,255,.11)!important;
  background:transparent!important;
}
body.field-guide-app .po6-has-results .decision-banner .decision-brief-row span{
  color:#8fa297!important;
  font-size:9px!important;
  font-weight:760!important;
  line-height:1.4!important;
}
body.field-guide-app .po6-has-results .decision-banner .decision-brief-row strong{
  color:#f2f6f3!important;
  font-size:11px!important;
  font-weight:680!important;
  line-height:1.45!important;
}
body.field-guide-app .po6-has-results .decision-banner .decision-brief-row.decision-brief-risk strong{
  color:#e9cd8d!important;
}

/* Decision-surface visibility is semantic, not decorative. A later presentation
   layer must never resurrect the hidden Best Match duplicate or collapsed rows. */
body.decision-surface-active .place-card.decision-primary-duplicate,
body.decision-surface-active .place-card.po-duplicate,
body.decision-surface-active .place-card.decision-overflow-card:not(.decision-overflow-open){
  display:none!important;
}

/* Field Guide alternative geometry. Keep each card's existing internal flow and
   use the ordinal/action rail as decoration around it instead of grid-placing
   every historical child node. */
body.field-guide-app.decision-surface-active .po6-has-results .place-card:not(.decision-primary-duplicate):not(.po-duplicate){
  display:block!important;
  position:relative!important;
  min-height:112px!important;
  padding:18px 150px 18px 70px!important;
}
body.field-guide-app.decision-surface-active .po6-has-results .place-card:not(.decision-primary-duplicate):not(.po-duplicate)::before{
  content:"0" counter(alt)!important;
  display:block!important;
  position:absolute!important;
  left:0!important;
  top:18px!important;
  width:48px!important;
  color:var(--fg-moss)!important;
  font-family:var(--fg-display)!important;
  font-size:30px!important;
  font-weight:560!important;
  line-height:1!important;
  letter-spacing:-.04em!important;
  opacity:1!important;
}
body.field-guide-app.decision-surface-active .po6-has-results .place-card .card-actions{
  position:absolute!important;
  right:0!important;
  top:50%!important;
  width:120px!important;
  margin:0!important;
  transform:translateY(-50%)!important;
  display:grid!important;
  grid-template-columns:1fr!important;
  gap:6px!important;
}
body.field-guide-app.decision-surface-active .po6-has-results .place-card .card-actions>*{
  width:120px!important;
}

/* Reassert semantic hiding at the highest presentation specificity. */
body.field-guide-app.decision-surface-active .po6-has-results .place-card.decision-primary-duplicate,
body.field-guide-app.decision-surface-active .po6-has-results .place-card.po-duplicate,
body.field-guide-app.decision-surface-active .po6-has-results .place-card.decision-overflow-card:not(.decision-overflow-open){
  display:none!important;
}

/* Try Nearby is an evidence register, not a second stack of lifestyle cards. */
body.field-guide-app .try-nearby-section .try-nearby-card{
  margin:0!important;
  border:0!important;
  border-bottom:1px solid var(--fg-rule)!important;
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
}
body.field-guide-app .try-nearby-section .try-nearby-card:first-of-type{
  border-top:1px solid var(--fg-rule)!important;
}

/* The one useful local sticky control while comparing results. */
.po6-has-results .result-view-tabs{
  top:var(--nc-result-nav-top)!important;
}

body.has-live-results .results-section{
  scroll-margin-top:calc(var(--nc-appbar-h) + 8px)!important;
}

@media(max-width:760px){
  body.field-guide-app>.shell{
    width:calc(100% - 28px)!important;
    max-width:none!important;
    padding:0!important;
  }

  /* Mobile should show the Field Guide identity immediately after the promise,
     before asking the user to work through the complete control deck. */
  body.field-guide-app:not(.has-live-results) .field-hero-copy{order:1!important}
  body.field-guide-app:not(.has-live-results) .field-map-visual{order:2!important}
  body.field-guide-app:not(.has-live-results) .field-control-deck{order:3!important}

  body.field-guide-app.has-live-results.decision-controls-editing .field-fine-tune-body{
    padding:4px 13px 14px!important;
  }

  /* Keep the primary action on the same content spine as steps 01/02. The
     numbered rail remains visually separate instead of being crossed by a
     full-width button. */
  body.field-guide-app .field-submit-row{
    padding:13px 13px 13px 56px!important;
  }
  body.field-guide-app .field-submit-row .primary-button{
    width:100%!important;
    margin:0!important;
  }

  .po6-has-results .result-view-tabs{
    top:var(--nc-result-nav-top)!important;
    /* On short mobile documents the browser can hit max scroll a few pixels before
       the sticky threshold. Pull the local rail into that residual space so the
       visible rail still meets the 64px app bar instead of leaving a 3px seam. */
    margin-top:-4px!important;
  }

  body.field-guide-app .po6-has-results .decision-banner .decision-brief{
    margin:12px 0 8px!important;
  }
  body.field-guide-app .po6-has-results .decision-banner .decision-brief-row{
    grid-template-columns:74px minmax(0,1fr)!important;
    gap:8px!important;
    padding:8px 0!important;
  }
  body.field-guide-app .po6-has-results .decision-banner .decision-brief-row strong{
    font-size:10px!important;
  }

  body.field-guide-app.decision-surface-active .po6-has-results .place-card:not(.decision-primary-duplicate):not(.po-duplicate){
    min-height:0!important;
    padding:15px 0 15px 46px!important;
  }
  body.field-guide-app.decision-surface-active .po6-has-results .place-card:not(.decision-primary-duplicate):not(.po-duplicate)::before{
    content:"0" counter(alt)!important;
    display:block!important;
    left:0!important;
    top:16px!important;
    width:34px!important;
    color:var(--fg-moss)!important;
    font-size:23px!important;
    opacity:1!important;
  }
  body.field-guide-app.decision-surface-active .po6-has-results .place-card .card-actions{
    position:static!important;
    width:100%!important;
    margin-top:10px!important;
    transform:none!important;
    display:grid!important;
    grid-template-columns:1fr 1fr!important;
    gap:7px!important;
  }
  body.field-guide-app.decision-surface-active .po6-has-results .place-card .card-actions>*{
    width:100%!important;
    min-height:44px!important;
  }

  body.field-guide-app.decision-surface-active .po6-has-results .place-card.decision-primary-duplicate,
  body.field-guide-app.decision-surface-active .po6-has-results .place-card.po-duplicate,
  body.field-guide-app.decision-surface-active .po6-has-results .place-card.decision-overflow-card:not(.decision-overflow-open){
    display:none!important;
  }

  body.field-guide-app .try-nearby-section .try-nearby-card{
    padding-left:0!important;
    padding-right:0!important;
  }
}
