/* locations.css: the location picker (screen 2) and the workspaces grid. Built
   on field.css's tokens and components; see field.css for the rules every
   stylesheet here keeps.

   One markup for each location (.f-site): a compact row on phones, a card in
   an auto-fill grid from 700px, laid out by grid areas. */

.f-picker {
  grid-template-rows: auto 1fr;
  grid-template-areas: "head" "main";
  background: var(--bgColour-primary);
}

.f-picker__head {
  grid-area: head;
  padding: max(20px, env(safe-area-inset-top, 0px)) 20px 14px;
  background: var(--sfColour-primary);
  border-bottom: 1px solid var(--borderColour-primary);
  transition: padding-bottom 200ms ease;
}

/* The workspace button, and the avatar in the corner. */
.f-picker__bar { display: flex; align-items: center; gap: 8px; min-height: 36px; margin: -6px 0 12px; transition: margin 200ms ease; }
.f-picker__bar .f-avatar { margin: -7px -7px -7px auto; }
.f-picker[data-locdlg] .f-picker__bar .f-avatar { visibility: hidden; }

.f-picker__ws {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: calc(100% - 52px);
  height: 36px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--borderColour-primary);
  border-radius: 6px;
  color: inherit;
  font-size: 13px;
  text-decoration: none;
  transition: background 200ms ease;
}

@media (hover: hover) { .f-picker__ws:hover { background: var(--sfColour-hover); } }
.f-picker__ws:focus-visible { outline: 2px solid var(--field-coral); outline-offset: 2px; }
.f-picker__ws > .f-icon { flex: none; color: var(--textColour-secondary); }

.f-picker__wstag,
.f-wscard__tag {
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 600;
}

.f-picker__wstag { width: 24px; height: 24px; border-radius: 5px; background: var(--field-coral); color: #fff; font-size: 12px; }
.f-picker__wstag .f-entity-letter,
.f-wscard__tag .f-entity-letter { width: 100%; height: 100%; }
.f-picker__wstext { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-picker__wsname { font-weight: 600; }
.f-picker__wsorg { color: var(--textColour-secondary); }

.f-picker__titles { min-width: 0; padding-right: 44px; }

.f-picker__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
  transition: font-size 200ms ease, line-height 200ms ease;
}

.f-picker__blurb {
  margin: 3px 0 0;
  max-height: 20px;
  overflow: hidden;
  font-size: 13px;
  line-height: 18px;
  color: var(--textColour-secondary);
  text-wrap: pretty;
}

.f-picker__search { display: flex; align-items: center; gap: 8px; margin-top: 13px; max-height: 46px; }

/* Folded (js/locations.js, once the list scrolls): the title condenses, the
   workspace button stays; the access line, search and chips go. */
.f-picker__fold { transition: max-height 200ms ease, margin 200ms ease, padding 200ms ease, opacity 150ms ease; }
.f-picker__head.is-folded { padding-bottom: 10px; }
.f-picker__head.is-folded .f-picker__bar { margin-bottom: 6px; }
.f-picker__head.is-folded .f-picker__title { font-size: 17px; line-height: 22px; }
.f-picker__head.is-folded .f-picker__fold { max-height: 0; margin-top: 0; padding-block: 0; opacity: 0; overflow: hidden; visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .f-picker__head, .f-picker__bar, .f-picker__title, .f-picker__fold { transition: none; }
}

.f-picker__field {
  flex: 1;
  min-width: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 13px;
  border: 1px solid var(--borderColour-primary);
  border-radius: 8px;
  background: var(--sfColour-primary);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

/* No scan button (Capabilities.QRScan off): the field's own end padding. */
.f-picker__field:not(:has(.f-picker__scan)) { padding-right: 13px; }

.f-picker__field > .f-icon { flex: none; color: var(--textColour-tertiary); }
.f-picker__field:focus-within { border-color: var(--field-coral); box-shadow: 0 0 0 3px var(--field-coral-tint); }
.f-picker__field.has-q { border-color: var(--field-coral); }

.f-picker__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--textColour-primary);
  font: 500 16px var(--font-mono-accent); /* 16px stops iOS zooming the page on focus */
  letter-spacing: 0.02em;
}
@media (min-width: 700px) { .f-picker__input { font-size: 13px; } }

.f-picker__input::placeholder { color: var(--textColour-tertiary); font-family: var(--font-sans); font-size: 13px; font-weight: 400; letter-spacing: 0; }
.f-picker__input::-webkit-search-cancel-button { display: none; }

.f-picker__scan {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--textColour-secondary);
  cursor: pointer;
}

@media (hover: hover) { .f-picker__scan:hover { background: var(--sfColour-hover); } }

.f-picker__near {
  flex: none;
  height: 46px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--borderColour-primary);
  border-radius: 8px;
  background: var(--sfColour-primary);
  color: var(--textColour-primary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}

.f-picker__near[aria-pressed="true"] { background: #25292e; color: #fff; border-color: transparent; }
/* Blocked: the browser refused the position; a press explains how to allow it. */
.f-picker__near[data-denied]:not([aria-pressed="true"]) { opacity: 0.5; }
[data-theme="dark"] .f-picker__near[aria-pressed="true"] { background: #f0f6fc; color: #0d1117; }
/* Finding the person's position (Near me's first press). */
.f-picker__near[aria-busy="true"] { cursor: progress; }
.f-picker__near[aria-busy="true"] svg { animation: f-picker-locating 1.1s ease-in-out infinite; }
@keyframes f-picker-locating { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .f-picker__near[aria-busy="true"] svg { animation: none; } }

.f-picker__body {
  grid-area: main;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 24px;
}

.f-picker__label { display: block; padding: 0 4px 8px; }

.f-picker__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--sp));
}

.f-picker__li[hidden] { display: none; }

/* A location. Phone: tag | name, type · ID, status line | chevron. */
.f-site {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  grid-template-areas: "tag name end" "tag meta end" "tag status end";
  align-items: center;
  column-gap: calc(11px * var(--sp));
  height: 100%;
  padding: calc(13px * var(--sp));
  border-radius: 8px;
  border: 1px solid var(--borderColour-primary);
  background: var(--sfColour-primary);
  color: inherit;
  text-decoration: none;
  transition: background 200ms ease, border-color 200ms ease, transform 120ms ease;
}

/* "Change location" marks where the person came from (?current=); a first
   sign-in marks nothing. */
.f-site.is-current { border-color: var(--field-coral); }
@media (hover: hover) { .f-site.is-open:hover { background: var(--sfColour-hover); } }
.f-site.is-open:active { transform: scale(0.995); }
.f-site[aria-disabled="true"] { cursor: default; }

.f-site__tag {
  grid-area: tag;
  align-self: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--sfColour-hover);
  color: var(--textColour-secondary);
  font-size: 14px;
  font-weight: 600;
}

[data-theme="dark"] .f-site__tag { background: #2f3742; color: #b7bdc8; }
.f-site.is-current .f-site__tag { background: var(--field-coral); color: #fff; }

.f-site__name {
  grid-area: name;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One line on phones: type · ID (the project, when there is an ID, from
   700px). */
.f-site__meta { grid-area: meta; margin-top: 2px; font-size: 12px; line-height: 17px; color: var(--textColour-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-site__proj { display: none; }
.f-site__status { grid-area: status; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 6px; font-size: 11px; font-variant-numeric: tabular-nums; }
.f-site__whenkm { display: inline-flex; flex-wrap: wrap; gap: 2px 7px; }
.f-site__when { color: var(--textColour-secondary); }
.f-site__km { color: var(--textColour-tertiary); }
.f-site__end { grid-area: end; display: flex; align-items: center; color: var(--textColour-tertiary); }

.f-site__pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  background: var(--sfColour-hover);
  color: var(--textColour-secondary);
}

.f-site__pill span { width: 6px; height: 6px; border-radius: 50%; background: var(--field-muted-ink); }
.f-site__pill--live { background: #dafbe1; color: #116329; }
.f-site__pill--live span { background: #2da44e; }
.f-site__pill--soon { background: #ddf4ff; color: #0969da; }
.f-site__pill--soon span { background: #0969da; }
[data-theme="dark"] .f-site__pill--live { background: rgba(46, 160, 67, 0.18); color: #4ac26b; }
[data-theme="dark"] .f-site__pill--live span { background: #3fb950; }
[data-theme="dark"] .f-site__pill--soon { background: rgba(56, 139, 253, 0.16); color: #4493f8; }
[data-theme="dark"] .f-site__pill--soon span { background: #4493f8; }

.f-site__badge {
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--sfColour-hover);
  color: var(--textColour-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Tablet and up: a card grid; tag and end on top, the status row pinned to the
   bottom. */
@media (min-width: 700px) {
  .f-picker__head { padding-inline: var(--gx); }
  .f-picker__body { padding: 18px calc(var(--gx) - 4px) 32px; }

  .f-picker__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: calc(12px * var(--sp));
  }

  .f-site {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas: "tag . end" "name name name" "meta meta meta" ". . ." "status status status";
    align-items: start;
    padding: calc(16px * var(--sp));
  }

  .f-site__tag { width: 40px; height: 40px; border-radius: 8px; font-size: 16px; }
  .f-site__end { align-self: start; margin-top: 2px; }
  .f-site__name { margin-top: 14px; font-size: 16px; line-height: 22px; white-space: normal; text-wrap: pretty; }
  .f-site__meta { margin-top: 3px; font-size: 13px; line-height: 18px; white-space: normal; }
  .f-site__proj { display: inline; }
  .f-site__status { margin-top: 14px; gap: 8px; font-size: 12px; }
  .f-site__pill { height: 22px; padding: 0 9px; }
}

.f-picker__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 34px 20px;
  text-align: center;
}

.f-picker__empty[hidden] { display: none; }
.f-picker__empty .f-icon { color: var(--textColour-tertiary); stroke-width: 1.6; }
.f-picker__emptyt { font-size: 14px; font-weight: 500; }
.f-picker__emptys { max-width: 260px; font-size: 12px; line-height: 17px; color: var(--textColour-secondary); }

/* Selecting a card confirms the working Location for this sign-in. */
.f-picker__confirm { height: 100%; margin: 0; }
button.f-site { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.f-site__choice { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; }
button.f-site:focus-visible { outline: 2px solid var(--field-coral); outline-offset: 3px; }

/* Status chips remain in the header while the locations scroll. */
.f-picker__filters { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; max-height: 38px; margin: 12px -20px 0; padding: 3px 20px; scrollbar-width: none; }
.f-picker__filters::-webkit-scrollbar { display: none; }
.f-picker__chip { flex: none; display: inline-flex; align-items: center; gap: calc(6px * var(--sp)); height: 32px; padding: 0 calc(12px * var(--sp)); border: 1px solid var(--borderColour-primary); border-radius: var(--radius-pill); background: var(--sfColour-primary); color: var(--textColour-primary); font: inherit; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.f-picker__chip[hidden], .f-picker__clear[hidden] { display: none; }
.f-picker__chip[aria-pressed="true"] { background: #25292e; color: #fff; border-color: transparent; }
[data-theme="dark"] .f-picker__chip[aria-pressed="true"] { background: #f0f6fc; color: #0d1117; }
.f-picker__chip:focus-visible, .f-picker__clear:focus-visible { outline: 2px solid var(--field-coral); outline-offset: 2px; }
.f-picker__count { font-family: var(--font-mono-accent); font-variant-numeric: tabular-nums; opacity: .75; }
.f-picker__clear { margin-top: 4px; border: 0; background: transparent; color: var(--field-coral); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }

/* No locations in this workspace: the way to another. */
.f-picker__switch { width: auto; min-height: 44px; margin-top: 10px; padding: 0 16px; gap: 8px; text-decoration: none; }

@media (min-width: 700px) {
  .f-picker__filters { margin-inline: calc(var(--gx) * -1); padding-inline: var(--gx); }
}

/* ---------------------------------------------------------------- Near me's dialogs
   One at a time (js/locations.js): the explainer before the browser's prompt,
   blocked, approximate. */
.f-locdlg { position: fixed; inset: 0; z-index: var(--z-dialog); display: grid; place-items: center; padding: 24px; }
.f-locdlg[hidden] { display: none; }
.f-locdlg__scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); animation: f-fade var(--duration-normal) var(--ease-standard); }

.f-locdlg__card {
  position: relative;
  width: 100%;
  max-width: 360px;
  box-sizing: border-box;
  padding: 24px 20px 16px;
  border-radius: 12px;
  background: var(--sfColour-primary);
  color: var(--textColour-primary);
  box-shadow: var(--shadow-basic-06, 0 12px 32px rgba(0, 0, 0, 0.2));
  animation: f-sheet-up 200ms ease-out;
}

[data-theme="dark"] .f-locdlg__card { border: 1px solid var(--borderColour-primary); }

.f-locdlg__icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sfColour-hover);
  color: var(--textColour-secondary);
}

.f-locdlg__icon--brand { background: var(--field-coral-tint); color: var(--field-coral); }
.f-locdlg__icon--warn { background: var(--lm-yellow-0, #fff8c5); color: var(--lm-yellow-6, #9a6700); }
[data-theme="dark"] .f-locdlg__icon--warn { background: rgba(187, 128, 9, 0.18); color: var(--dm-yellow-6, #d29922); }

.f-locdlg__title { margin: 14px 0 0; font-family: var(--font-display); font-size: 18px; line-height: 24px; font-weight: 600; }
.f-locdlg__body { margin: 6px 0 0; font-size: 14px; line-height: 20px; color: var(--textColour-secondary); text-wrap: pretty; }
.f-locdlg__note { margin: 10px 0 0; font-size: 12px; line-height: 17px; color: var(--textColour-tertiary); }
.f-locdlg__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.f-locdlg__actions .f-btn { width: 100%; min-height: 44px; }

/* How to allow the position: in the browser, or installed to the home screen. */
.f-locdlg__body--installed { display: none; }
@media (display-mode: standalone) {
  .f-locdlg__body--browser { display: none; }
  .f-locdlg__body--installed { display: block; }
}

/* ---------------------------------------------------------------- workspaces grid
   "View all workspaces": a card per workspace, the current one marked. Its page
   background is the design's near-black in dark (--bgColour-primary is
   #0d1117 there). */
.f-wsgrid {
  grid-template-rows: auto 1fr;
  grid-template-areas: "head" "main";
  background: var(--bgColour-primary);
}

.f-wsgrid__head {
  grid-area: head;
  padding: max(8px, env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--sfColour-primary);
  border-bottom: 1px solid var(--borderColour-primary);
}

.f-wsgrid__bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.f-wsgrid__bar .f-avatar { margin: -7px -7px -7px auto; }

.f-wsgrid__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding-right: 8px;
  color: var(--textColour-brand, var(--field-coral));
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.f-wsgrid__back:focus-visible { outline: 2px solid var(--field-coral); outline-offset: 2px; border-radius: 4px; }
.f-wsgrid__titles { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.f-wsgrid__title { margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 28px; font-weight: 600; }
.f-wsgrid__count { font-family: var(--font-mono-accent); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--textColour-tertiary); }

.f-wsgrid__search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  margin-top: 12px;
  padding: 0 12px;
  border: 1px solid var(--borderColour-primary);
  border-radius: 6px;
  background: var(--sfColour-primary);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.f-wsgrid__search > .f-icon { flex: none; color: var(--textColour-secondary); }
.f-wsgrid__search:focus-within { border-color: var(--field-coral); box-shadow: 0 0 0 3px var(--field-coral-tint); }

.f-wsgrid__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--textColour-primary);
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming the page on focus */
}
@media (min-width: 700px) { .f-wsgrid__input { font-size: 14px; } }

.f-wsgrid__input::placeholder { color: var(--textColour-tertiary); }
.f-wsgrid__input::-webkit-search-cancel-button { display: none; }

.f-wsgrid__body { grid-area: main; min-height: 0; overflow-y: auto; padding: 16px 16px max(24px, var(--field-safe-bottom, 0px)); }

.f-wsgrid__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}

.f-wsgrid__li[hidden] { display: none; }
.f-wsgrid__empty { margin: 0; padding: 48px 16px; text-align: center; font-size: 14px; color: var(--textColour-secondary); }

.f-wscard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 132px;
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid var(--borderColour-primary);
  border-radius: 8px;
  background: var(--sfColour-primary);
  color: inherit;
  text-decoration: none;
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 120ms ease;
}

@media (hover: hover) { .f-wscard:hover { box-shadow: 0 6px 18px -10px rgba(16, 24, 40, 0.3); } }
.f-wscard:active { transform: scale(0.995); }
.f-wscard:focus-visible { outline: 2px solid var(--field-coral); outline-offset: 2px; }
.f-wscard.is-current { border-color: var(--field-coral); }

.f-wscard__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.f-wscard__tag { width: 36px; height: 36px; border-radius: 7px; background: #dde3ea; color: var(--textColour-secondary); font-size: 16px; }
[data-theme="dark"] .f-wscard__tag { background: #2a313c; }
.f-wscard.is-current .f-wscard__tag { background: var(--field-coral); color: #fff; }

.f-wscard__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--lm-brand-0, #fff1eb);
  color: var(--textColour-brand, var(--field-coral));
  font-size: 11px;
  font-weight: 600;
}

.f-wscard__badge .f-icon { stroke-width: 3; }
.f-wscard__text { display: flex; flex-direction: column; min-width: 0; }
.f-wscard__name { font-size: 15px; font-weight: 600; line-height: 20px; overflow-wrap: anywhere; }
.f-wscard__org { margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--textColour-secondary); text-wrap: pretty; }
.f-wscard__meta { margin-top: auto; font-size: 12px; color: var(--textColour-tertiary); }

@media (min-width: 700px) {
  .f-wsgrid__head { padding-inline: var(--gx); }
  .f-wsgrid__body { padding-inline: var(--gx); }
}
