/* The one geography shell — one rail beside one map (D-TS-1, D-WS-2).
 *
 * The wizard, Today and the camp page wear this through `graze/_geography.html`. The map is the
 * constant: it is mounted for the whole page and changes shape only when the farmer enters draw
 * mode (D-TS-16). Everything without geography still renders the stacked `.app-main` layout.
 *
 * The rule that makes the shell work is that exactly ONE region scrolls: `.workspace__body`.
 * The strip above it and the action row below it are rows of a column that cannot scroll, so
 * they cannot be scrolled away and they never need an offset. That is what F14's
 * `position: sticky` was imitating, and why no `position` appears below (D-WS-3).
 */

/* The header is a static row above this, so the workspace is capped at what is left of the
   viewport — `100dvh` states the wish, `max-height: 100%` is the parent that already paid for
   the header. Without the cap the action row sits 72px below the fold. */
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, var(--m-workspace-rail)) 1fr;
  height: 100vh;
  height: 100dvh;
  max-height: 100%;
  overflow: hidden;
  background: var(--m-surface);
}

.app-main--workspace {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100dvh - var(--m-header-height));
  overflow: hidden;
}

/* --- The rail ---------------------------------------------------------- */

.workspace__rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--m-surface-container-lowest);
}

.workspace__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--m-space-lg) var(--m-space-md);
}

/* One action row per surface (D-TS-12): 68 px, an edge rather than a shadow, and exactly one
   primary inside it. The row is a row of the page, not chrome floating over the body. */
.workspace__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--m-space-sm);
  min-height: 68px;
  padding: var(--m-space-sm) var(--m-space-md);
  background: var(--m-surface-container-lowest);
  border-top: var(--m-edge);
  box-shadow: none;
}

.workspace__actions .btn { min-height: var(--m-tap-min); }

/* The one thing to press on this step. 52px because it is pressed with a thumb, outdoors,
   sometimes in gloves, and it is the only control that matters on the screen. */
.workspace__actions .btn--primary {
  flex: 1 1 auto;
  min-height: 52px;
  font-size: 1rem;
}

.workspace__actions .btn--ghost { flex: 0 0 auto; }

/* --- The map pane ------------------------------------------------------ */

.workspace__map {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--m-surface-container);
  transition: flex-basis 0.2s ease;
}

/* Draw mode (D-TS-16, C2). The one shape change the shell makes, and the farmer causes it: he
   enters it to draw and leaves it when the shape is saved, cancelled or done. Never on a step
   change, never because a field took focus — the tap that blurs the field would snap the map back
   and move the button under his thumb. */
.workspace[data-mode="draw"] .workspace__map { flex: 1 1 auto; }

.workspace[data-mode="draw"] .workspace__rail { display: none; }

@media (min-width: 1024px) {
  .workspace[data-mode="draw"] { grid-template-columns: 1fr; }
}

/* --- Phone: the map is pinned on top, 34dvH (D-TS-2) ------------------- */

@media (max-width: 1023px) {
  .workspace {
    display: flex;
    flex-direction: column;
  }

  .workspace__map {
    flex: 0 0 var(--m-workspace-map-phone);
    order: -1;
  }

  .workspace__rail {
    flex: 1 1 auto;
    min-height: 0;
  }

  .workspace__body {
    padding: var(--m-space-md) var(--m-space-md);
  }
}

/* --- The rail's content vocabulary ------------------------------------- */

.workspace__eyebrow {
  margin: 0 0 var(--m-space-xs);
  color: var(--m-on-surface-variant);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace__body h2 {
  margin: 0 0 var(--m-space-sm);
  font-size: 1.375rem;
  letter-spacing: -0.01em;
}

/* Two steps, numbered, because the second one ("tap the first corner again") is the one
   everybody misses and a closed shape is not optional. */
.guidance {
  display: grid;
  gap: var(--m-space-xs);
  margin: 0 0 var(--m-space-lg);
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.guidance li {
  display: flex;
  align-items: center;
  gap: var(--m-space-sm);
  font-size: 0.9375rem;
}

.guidance li > span {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--m-radius-full);
  background: var(--m-primary-fixed);
  color: var(--m-on-primary-fixed);
  font-size: 0.75rem;
  font-weight: 700;
}

/* The three numbers: derived every render, never stored (D-WS-6). */
.telemetry {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--m-space-xs);
  margin: 0 0 var(--m-space-md);
  padding: var(--m-space-sm);
  border-radius: var(--m-radius-lg);
  background: var(--m-surface-container-low);
}

.telemetry__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.telemetry__item span {
  color: var(--m-on-surface-variant);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* tabular-nums, not a mono family: the digits line up in columns without a second font file
   (D-WS-7). The `tnum` feature is in the vendored subset for exactly this. */
.telemetry__item strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telemetry__empty {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--m-on-surface-variant);
  font-size: 0.875rem;
}

/* --- The camp page's disclosures (D-WS-11) ----------------------------- */

/* `<details>` is the disclosure: closed on load, no script, and the summary is what a screen reader
   announces instead of a heading per panel. */
.camp-admin,
.camp-history {
  margin: var(--m-space-lg) 0 0;
  border-top: var(--m-edge);
  padding-top: var(--m-space-sm);
}

/* A block of the rail, separated from its neighbours by an edge and space — never by a card, which
   would be a sheet inside a sheet (D-TS-11). */
.camp-section {
  margin: var(--m-space-lg) 0 0;
  border-top: var(--m-edge);
  padding-top: var(--m-space-md);
}

.camp-section h3 {
  margin: 0 0 var(--m-space-sm);
  font-size: 1rem;
}

.camp-admin__body { padding-top: var(--m-space-sm); }

.camp-admin > summary,
.camp-history > summary {
  display: flex;
  align-items: center;
  min-height: var(--m-tap-min);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.camp-admin > summary::-webkit-details-marker,
.camp-history > summary::-webkit-details-marker { display: none; }

.camp-admin > summary::after,
.camp-history > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--m-on-surface-variant);
  font-size: 1.25rem;
  transition: transform 120ms ease;
}

.camp-admin[open] > summary::after,
.camp-history[open] > summary::after { transform: rotate(90deg); }

/* The camp's header block: name, number, area, category, then the state it is in. */
.camp-head { margin: 0 0 var(--m-space-lg); }
.camp-head h1 { margin-bottom: var(--m-space-xs); }
.camp-head .muted { margin-bottom: var(--m-space-sm); }

.camp-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--m-space-sm);
  margin: 0;
}

/* The move form is the page's primary card: it is why a farmer opens a camp at all. */

/* --- History rows (D-TS-11) -------------------------------------------- */

/* The history is a list inside a disclosure. Each row is separated by an edge, not by a card: a
   sheet in a rail on top of a sheet. */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline__item {
  padding: var(--m-space-sm) 0;
  border-bottom: var(--m-edge);
}

.timeline__item:last-child { border-bottom: 0; }

/* --- Today's rail (D-TS-4) --------------------------------------------- */

/* The farmer's question is "where does the herd go next", so the answer is the loudest thing on the
   page and it is followed by the rows that let him act on it. No primary: the rows are the choice. */
.now {
  margin: 0 0 var(--m-space-md);
  font-size: 1rem;
  color: var(--m-on-surface-variant);
}

.next {
  display: flex;
  flex-direction: column;
  gap: var(--m-space-xs);
  margin: 0 0 var(--m-space-lg);
  padding-bottom: var(--m-space-md);
  border-bottom: var(--m-edge);
}

.next strong,
.next__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--m-on-surface);
  text-decoration: none;
}

.next span {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--m-on-surface-variant);
}

.list-head {
  display: flex;
  justify-content: space-between;
  gap: var(--m-space-sm);
  margin: 0 0 var(--m-space-xs);
  font-size: 0.875rem;
  color: var(--m-on-surface-variant);
}

.camp-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* One line per camp: the state, the name, the rest. 56 px so four camps fit a 390 px screen without
   the rail scrolling — Today's measured height is 691 of 844 (D-TS-4). */
.camp-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: var(--m-space-sm);
  min-height: 56px;
  border-bottom: var(--m-edge);
  color: var(--m-on-surface);
  text-decoration: none;
}

.camp-row__dot {
  width: 12px;
  height: 12px;
  border-radius: var(--m-radius-full);
  background: var(--m-outline-variant);
}

.camp-row__name {
  font-size: 1rem;
  font-weight: 600;
}

.camp-row__state {
  display: inline-flex;
  align-items: center;
  gap: var(--m-space-xs);
  font-size: 0.9375rem;
  color: var(--m-on-surface-variant);
}

.camp-row__cta { color: var(--m-on-surface-variant); }

.camp-row--ready .camp-row__dot { background: var(--m-leaf-green); }
.camp-row--resting .camp-row__dot { background: var(--m-resting); }
.camp-row--herd .camp-row__dot { background: var(--m-secondary); }
.camp-row--never .camp-row__dot { background: var(--m-outline-variant); }

/* The mark that says the app has an opinion (D-TS-7). A tag, not a button, not a filled row: the
   farmer is being advised, not told. */
.tag {
  display: inline-block;
  padding: 0 var(--m-space-sm);
  border-radius: var(--m-radius-full);
  background: var(--m-primary-fixed);
  color: var(--m-on-primary-fixed);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 700;
}
