/*
 * The JOB screen (src/job.js): the job card, contract time, Crews & Subs,
 * and the contacts card with what to tell 911.
 *
 * Phone first, as styles.css: one hand, sun, a glove, 390 px wide. Every
 * control here is at least --tap (52 px) tall and every field 16 px or more,
 * so iOS never zooms. Colors are the tokens on :root; a crew's or sub's color
 * is its --trade-<name> token, stored by name, never by hex.
 */

#screen-job { gap: var(--g-3); }

/* ─── The job card ─────────────────────────────────────────────────────── */

#screen-job .jobcard {
  display: flex;
  flex-direction: column;
  gap: var(--g-1);
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
}
#screen-job .jobtitle { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
#screen-job .jobids { margin: 0; color: var(--dim); font-size: 14px; font-variant-numeric: tabular-nums; }
#screen-job .jobaddr { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
#screen-job .jobaddr.none { color: var(--dim); }
#screen-job .jobstate { margin: 6px 0 0; }
#screen-job .jobstate .status { margin-left: 0; padding: 5px 12px; font-size: 14px; }
#screen-job .jobcard .hint { margin: 6px 0 0; }

.status.job-ok { background: var(--tint-green-bg); color: var(--tint-green-ink); }
.status.job-suspended { background: var(--tint-red-bg); color: var(--tint-red-ink); }
.status.job-company,
.status.job-paused { background: var(--tint-warm-bg); color: var(--tint-warm-ink); }

/* ─── Sections: a body that is redrawn, a slot for the open form ───────── */

#screen-job .jobsec,
#screen-job .jobbody,
#screen-job .jobslot { display: flex; flex-direction: column; gap: var(--g-2); }
#screen-job .jobslot:empty { display: none; }
/* Clear of the sticky job bar and headbar when a form or a section is scrolled to. */
#screen-job .jobsec { scroll-margin-top: calc(var(--frame-pinned) + 20px); }
#screen-job .jobhead { display: flex; align-items: center; gap: var(--g-2); margin-top: 6px; }
#screen-job .jobhead .jsv-also { margin-left: auto; color: var(--dim); font-size: var(--fs-small); white-space: nowrap; }
#screen-job .jobh { margin: 0; font-size: 19px; font-weight: 700; }
#screen-job .jobsub { margin: 8px 0 0; color: var(--dim); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
#screen-job .pill { margin-left: auto; padding: 4px 12px; border-radius: var(--r-pill); background: var(--panel2); color: var(--ink); font-size: 14px; font-weight: 650; white-space: nowrap; }

/* ─── Contract time ────────────────────────────────────────────────────── */

#screen-job .ctpanel {
  display: flex;
  flex-direction: column;
  gap: var(--g-2);
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
}
#screen-job .ctline { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
#screen-job .ctleft { margin: 4px 0 0; font-size: 28px; line-height: 1.15; font-weight: 750; font-variant-numeric: tabular-nums; }
#screen-job .ctleft.over { color: var(--tint-red-ink); }
#screen-job .ctleft.none { font-size: 16px; font-weight: 400; color: var(--dim); }
/* Over: the days stay big and the dollars take a line of their own; the "·" between them is for the text alone. */
#screen-job .ctleft .ctsep { display: none; }
#screen-job .ctleft .ctmoney { display: block; margin-top: 4px; font-size: 19px; line-height: 1.3; font-weight: 700; }
#screen-job .ctsub { margin: 0 0 4px; color: var(--dim); font-size: 15px; }

#screen-job details.jobfold { margin-top: 6px; background: var(--bg); }
#screen-job details summary { min-height: var(--tap); }
#screen-job .logline { display: flex; flex-direction: column; gap: var(--g-1); padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; font-variant-numeric: tabular-nums; }
#screen-job .lognote { color: var(--dim); font-size: 14px; overflow-wrap: anywhere; }

#screen-job .jobbtns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--g-2); }
#screen-job .jobbtns .btn { width: 100%; line-height: 1.2; }
/* The contract card's one primary, and its ⋯ at the end of the row (R3-04). */
#screen-job .jobbtns.jobact { display: flex; align-items: center; gap: var(--g-2); }
#screen-job .jobbtns.jobact > .btn.primary { flex: 1; width: auto; }
#screen-job .btn.wide { width: 100%; }

/* ─── Crews & Subs ─────────────────────────────────────────────────────── */

#screen-job .item.trade .top { align-items: center; }
#screen-job .item.trade .tname { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
#screen-job .item .meta { margin: 4px 0 0; }
/* A panel's lines (SWMP, the survey): one under the other, no paragraph's margins between (found in use, item 49). */
#screen-job .panel > p.meta { margin: 0; }
#screen-job .item[role="button"] { cursor: pointer; }
#screen-job .item[role="button"]:active { filter: brightness(0.9); }
#screen-job .badge.sub { background: var(--tint-purple-bg); color: var(--tint-purple-ink); }
#screen-job .badge.crew { background: var(--tint-blue-bg); color: var(--tint-blue-ink); }

/* A trade's color: a dot on its row, a square in the picker. */
.swatch {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.3);
  background: var(--line);
}
.swatch[data-color=""] { background: none; border: 2px dashed var(--dim); }
.swatch[data-color="red"] { background: var(--trade-red); }
.swatch[data-color="orange"] { background: var(--trade-orange); }
.swatch[data-color="amber"] { background: var(--trade-amber); }
.swatch[data-color="yellow"] { background: var(--trade-yellow); }
.swatch[data-color="lime"] { background: var(--trade-lime); }
.swatch[data-color="green"] { background: var(--trade-green); }
.swatch[data-color="teal"] { background: var(--trade-teal); }
.swatch[data-color="sky"] { background: var(--trade-sky); }
.swatch[data-color="blue"] { background: var(--trade-blue); }
.swatch[data-color="violet"] { background: var(--trade-violet); }
.swatch[data-color="pink"] { background: var(--trade-pink); }
.swatch[data-color="brown"] { background: var(--trade-brown); }

#screen-job .swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--g-2); }
#screen-job button.swatch {
  position: relative;
  width: 100%;
  height: var(--tap);
  min-height: var(--tap);
  border-radius: var(--r-l);
  border: 3px solid transparent;
  padding: 0;
}
#screen-job button.swatch.on { border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--bg); }
#screen-job button.swatch.on::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}

/* ─── Contacts and 911 ─────────────────────────────────────────────────── */

/* The top of the list: a plain line, then the reference lines at the contact details' size. Nothing here is a link. */
#screen-job .ref911 { display: flex; flex-direction: column; gap: var(--g-1); margin: 0 0 10px; }
#screen-job .line911 { margin: 0; font-size: 16px; }
#screen-job .l911 { margin: 0; color: var(--dim); font-size: 14px; overflow-wrap: anywhere; }
#screen-job .gpsline { font-variant-numeric: tabular-nums; }

/* Who on the left, the numbers on the right: the row's middle is never a link. */
#screen-job .item.contact,
#screen-job .item.company-contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) fit-content(44%);
  gap: var(--g-2);
  align-items: start;
}
#screen-job .who { min-width: 0; }
#screen-job .who p { margin: 0; overflow-wrap: anywhere; }
#screen-job .who .role { color: var(--dim); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
#screen-job .who .name { margin-top: 2px; font-size: 17px; font-weight: 650; }
#screen-job .who .addr { margin-top: 4px; color: var(--dim); font-size: 14px; }
#screen-job .calls { display: flex; flex-direction: column; gap: var(--g-2); }
#screen-job .calls a {
  display: flex;
  align-items: center;
  justify-content: center;
  /* The contact rows stay 52 px whatever --tap becomes: a call made with a glove on. */
  min-height: 52px;
  padding: 8px 12px;
  border-radius: var(--r-l);
  border: 1px solid var(--edge);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
#screen-job .calls a.tel { flex-direction: column; gap: 1px; border-color: var(--ok); color: var(--tint-green-ink); }
#screen-job .calls .num { white-space: nowrap; }
#screen-job .calls .sub { font-size: 13px; font-weight: 600; opacity: 0.85; }
#screen-job .calls a:active { filter: brightness(0.88); }

/* ─── Forms, opened in place ───────────────────────────────────────────── */

#screen-job .jobform { border-color: var(--accent); scroll-margin-top: calc(var(--frame-pinned) + 20px); }
/* The Datum form (src/datumform.js): Add plans draws its fields in a fold that spaces them; here they are drawn open. */
#screen-job .ap-datum, #screen-job .ap-datum-change > .foldbody { display: flex; flex-direction: column; gap: var(--g-2); }

/* ─── Contract quantities: a line a pay item ───────────────────────────── */

/* The lines in one box, a hairline between them: the number, the name, the quantity at the right. */
#screen-job #jq-lines { display: flex; flex-direction: column; }
#screen-job .jqlist { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
#screen-job .jqlist > :not([hidden]) ~ * { border-top: 1px solid var(--line); }
#screen-job .jq-row { padding: 10px 12px; }
/* Every line keeps the ›'s column, so the quantities stand in one column whether a line has more under it or not. */
#screen-job .jqline { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content 12px; column-gap: 10px; align-items: baseline; }
#screen-job .jqnum { color: var(--accent); font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
#screen-job .jqsep { display: none; } /* " · " for the words the line reads as; the columns part them on screen */
#screen-job .jqname { min-width: 0; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
#screen-job .jqamt { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
/* A line with more under it (a note, a quantity directed beyond the contract) says so with a › that turns as it opens. */
#screen-job .jq-row.more { min-height: var(--tap-row); cursor: pointer; }
#screen-job .jq-row.more .jqline::after { content: "›"; align-self: start; color: var(--dim); font-size: 20px; line-height: 1; transform: rotate(90deg); }
#screen-job .jq-row.more.open .jqline::after { transform: rotate(-90deg); }
#screen-job .jq-row .jqmore { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
#screen-job .jq-row .jqmore[hidden] { display: none; }
#screen-job .jq-row .meta { margin: 0; color: var(--dim); font-size: 14px; overflow-wrap: anywhere; }
/* Past twelve: the find, then the book's sections, each a fold with its count; open, its lines in a box of their own. */
#screen-job .jqfind { display: flex; flex-direction: column; gap: var(--g-1); }
#screen-job .jqfind .hint { margin: 0; }
#screen-job details.jq-group { padding: 0; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
#screen-job details.jq-group:last-child { border-bottom: 1px solid var(--line); }
#screen-job details.jq-group > summary { margin: 0; padding: 0 2px; font-size: 16px; font-weight: 650; }
#screen-job details.jq-group > summary .jqgname { min-width: 0; overflow-wrap: anywhere; }
#screen-job details.jq-group > summary .val { flex: none; font-variant-numeric: tabular-nums; }
#screen-job details.jq-group > .jqlist { margin: 0 0 12px; background: var(--bg); }

/* The pay items read from the plans: the pages to read, then a line a pay item with its tick, what does not agree in the warm tone. */
#screen-job .jq-page { display: flex; flex-direction: column; align-items: flex-start; gap: var(--g-1); width: 100%; text-align: left; }
#screen-job .jqpage { align-items: center; justify-content: space-between; gap: var(--g-2); flex-wrap: wrap; }
#screen-job .jqpage p { margin: 0; }
#screen-job .jqpage a.btn { text-decoration: none; }
/* The page read, in a box that zooms (src/zoombox.js), to check the numbers against: as tall as the page's shape takes, a
   little more than half the screen at most. */
#screen-job .jq-zoom { max-height: 60vh; }
#screen-job .jobform .jqlist { background: var(--bg); }
/* A review line: the tick, the number and name, the ›; the quantity to take under them at the right (a phone has no room
   beside them); then what to look at, indented under the name. */
#screen-job .jq-line { display: flex; flex-direction: column; gap: 6px; padding: 8px 4px 10px 12px; }
#screen-job .jqhead { display: grid; grid-template-columns: 26px minmax(0, 1fr) var(--tap-row); grid-template-areas: "tick what more" ". amount amount"; column-gap: 10px; row-gap: 6px; align-items: center; }
#screen-job .jqtick { display: contents; } /* the tick and the words are the head's own cells; a tap on the words still ticks */
#screen-job .jqhead .jq-tick { grid-area: tick; align-self: start; width: 26px; height: 26px; min-height: 0; margin: 4px 0 0; accent-color: var(--accent); cursor: pointer; }
#screen-job .jqwhat { grid-area: what; align-self: start; min-width: 0; padding-top: 5px; line-height: 1.3; overflow-wrap: anywhere; cursor: pointer; }
#screen-job .jqwhat .jqnum { margin-right: 8px; }
#screen-job .jqwhat .jqname { font-weight: 600; }
#screen-job .jqhead .jqamount { grid-area: amount; justify-self: end; display: flex; align-items: center; gap: var(--g-2); margin-right: 8px; }
#screen-job .jqhead .jq-qty { width: 112px; min-height: var(--tap-row); padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; }
#screen-job .jqhead .unit { min-width: 40px; color: var(--dim); font-size: 14px; font-weight: 600; }
#screen-job .jqmorebtn { grid-area: more; align-self: start; display: flex; align-items: center; justify-content: center; width: var(--tap-row); height: var(--tap-row); padding: 0; border: 0; border-radius: var(--r-m); background: none; color: var(--dim); font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
#screen-job .jqmorebtn::before { content: "›"; transform: rotate(90deg); }
#screen-job .jq-line.open .jqmorebtn::before { transform: rotate(-90deg); }
#screen-job .jq-line.dim .jqhead :is(.jqname, .jqnum) { color: var(--dim); } /* the dim ink, not an opacity (design review, Later) */
#screen-job .jqnum.none { color: var(--dim); font-weight: 600; }
#screen-job .jq-line > :not(.jqhead, input) { margin: 0 8px 0 36px; }
#screen-job .jq-line p { margin-top: 0; margin-bottom: 0; }
#screen-job .jq-line .meta { color: var(--dim); font-size: 14px; overflow-wrap: anywhere; }
#screen-job .jq-line .jqmore { display: flex; flex-direction: column; gap: 4px; }
#screen-job .jq-line .jqmore[hidden] { display: none; }
#screen-job .jqflag { align-self: flex-start; margin: 0; padding: 2px 8px; border-radius: var(--r-m); background: var(--tint-warm-bg); color: var(--tint-warm-ink); font-size: 14px; }
/* A number the book gave by the name, or a person's pick: said in the info tone, never the warm one of a problem. */
#screen-job .jqmatch { align-self: flex-start; padding: 2px 8px; border-radius: var(--r-m); background: var(--tint-blue-bg); color: var(--tint-blue-ink); font-size: 14px; }
/* The items that fit and the book's search: a row each, the one the line is now ringed. */
#screen-job .jqpick { display: flex; flex-direction: column; gap: var(--g-2); padding-top: 4px; }
#screen-job .jqpick .lbl { margin: 0; }
#screen-job .jqchoices { display: flex; flex-direction: column; gap: var(--g-1); }
#screen-job .jqchoices .hint { margin: 0; }
#screen-job .jqchoice { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; column-gap: 10px; align-items: baseline; width: 100%; min-height: var(--tap-row); padding: 8px 10px; border: 1px solid var(--edge); border-radius: var(--r-m); background: var(--panel); color: var(--ink); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
#screen-job .jqchoice .jqname { font-size: 15px; }
#screen-job .jqchoice .unit { color: var(--dim); font-size: 13px; font-weight: 600; }
#screen-job .jqchoice.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
#screen-job .jqchoice:active { filter: brightness(0.9); }
#screen-job .jobform .head { font-size: 18px; }
#screen-job .fld { display: flex; flex-direction: column; gap: var(--g-1); }
#screen-job .fld .lbl { margin-top: 0; }
#screen-job .fld .hint { margin: 0; }
#screen-job .jobform > .lbl { margin: 8px 0 0; }
#screen-job .jobform > .lbl.jobpart { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 700; }
#screen-job .pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--g-2); }
/* The position the map's limits give (P19): shown, but greyed until someone types or keeps it. */
#screen-job .pair input.derived { color: var(--dim); }
#screen-job .pair.one { grid-template-columns: 1fr; }
#screen-job .pair.phone { grid-template-columns: minmax(0, 1fr) 100px; }
/* Full or Half on a weekend or a holiday: said in amber, before Save. */
#screen-job .jobform .warn { margin: 0; font-size: 15px; line-height: 1.35; }
/* "Lead man" under the crew's Foreman picker: a very small button, the picker's own afterthought. */
#screen-job .jobform .btn.leadman { align-self: flex-start; min-height: var(--tap-row); margin-top: -6px; padding: 4px 10px; border-radius: var(--r-m); font-size: 13px; }
#screen-job .jtoggle { display: flex; align-items: center; gap: var(--g-3); min-height: var(--tap); font-size: 17px; }
#screen-job .jtoggle input { width: 28px; height: 28px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
#screen-job .jobactions .btn { flex: 1 1 120px; }

