/* Staff site, 5 of 13: the job page (cards, field activity, job cost, timeline, photos) and the job report. */

/* Job page: the status step in Details, and who is on site */
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0 0 .75rem; }
.status-line form { margin: 0; }
.on-site { margin-bottom: 1rem; }
.on-site h3 { margin: 0 0 .4rem; font-size: 1rem; }
.on-site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.on-site-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem; }

/* Job page: the website's clock, supplies and capture forms */
.field-clock { margin-bottom: 1rem; }
.field-clock form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0; }
.field-clock form > p, .field-clock form > label { flex-basis: 100%; }
.btn-punch { min-width: 10rem; min-height: 56px; font-size: 1.1rem; }
.offline-note[hidden] { display: none; }
.supply-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.supply-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .75rem; }
.supply-state { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.inline-form { display: inline; margin: 0; }
.choice { flex-direction: row; align-items: center; gap: .4rem; min-height: 44px; margin: 0; padding: 0 .8rem; color: var(--text);
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; }
.choice input { width: auto; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--info-wash); }
/* The same choices one under another, for options a sentence long (Company's clock-in rule): each wraps in its box. */
.choice-stack { border: 0; padding: 0; margin: 0 0 .75rem; min-width: 0; display: grid; gap: .4rem; }
.choice-stack legend { padding: 0; margin-bottom: .25rem; font-size: .9rem; color: var(--muted); }
.choice-stack .choice { border-radius: var(--radius); padding: .5rem .8rem; gap: .6rem; }
.choice-stack .choice input { flex: none; }

/* Field activity */
/* Tiles keep a tile's width however few there are, rather than stretching across the page. */
.grid-3.totals-row { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); margin-bottom: 1rem; }
.stat {
    display: flex; flex-direction: column; gap: .15rem;
    border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; background: var(--well);
}
.stat-label { color: var(--muted); font-size: var(--fs-small); }
.stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
a.stat-link { color: inherit; text-decoration: none; }
a.stat-link:hover { border-color: var(--primary); }
/* Job cost: the shared "$X of $Y · N %" line and its colour badge (JobCostLine). */
.cost-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; font-variant-numeric: tabular-nums; }
.cost-headline { font-size: 1.25rem; font-weight: 700; margin: 0 0 .25rem; }
.cost-breakdown { margin-bottom: 1rem; }
/* A card's form folded under a text-button summary: Materials' "Add an item", Job cost's "Change budget". */
.fold { margin-top: 1rem; border-top: 1px solid var(--line-soft); padding-top: .5rem; }
.fold summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: .35rem 0; }
.fold[open] summary { margin-bottom: .5rem; }

/* Job page cards (JobCard): a <details> folded to its title and hint on a phone, open with a plain heading wider.
   Named twice so the phone block's summary rule (a list-item with a triangle) does not outrank it. */
.card.job-card > summary { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .75rem; cursor: pointer; list-style: none; }
.job-card > summary::-webkit-details-marker { display: none; }
.job-card > summary h2 { margin: 0; }
.job-card-hint { color: var(--muted); font-size: var(--fs-small); }
/* The fold's chevron at the row's end, turned over when open. */
.job-card > summary::after {
    content: ""; margin-left: auto; width: 12px; height: 8px; flex: none;
    background: var(--select-chevron) no-repeat center / 12px; transition: transform .15s;
}
.job-card[open] > summary { margin-bottom: .5rem; }
.job-card[open] > summary::after { transform: rotate(180deg); }
.job-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.job-card-actions:not(:has(*)) { display: none; }
.job-card-actions > form { margin: 0; }
/* Wide: always open (the content box shown whatever the summary says), the title a heading, the buttons beside it.
   Only where ::details-content is known: an older browser (Safari before 18.4, Firefox before 143) would drop that
   rule but keep the summary's pointer-events, leaving a closed card nothing opens; there the phone's tap-to-open stays.
   The title floats left and the buttons float right: beside it while both fit, under it (still right) when a narrow
   card (two side by side) has too little room. The card's content clears both. */
@media (min-width: 801px) {
    @supports selector(::details-content) {
        .job-card { display: flow-root; }
        .job-card::details-content { display: block; content-visibility: visible; }
        .job-card > summary { float: left; max-width: 100%; margin: 0 1rem .5rem 0; cursor: default; pointer-events: none; min-height: 2.25rem; }
        .job-card > summary::after { display: none; }
        .job-card-actions { float: right; max-width: 100%; justify-content: flex-end; margin: 0 0 .5rem; }
        .job-card-actions .btn { white-space: nowrap; }
        .job-card > :not(summary, .job-card-actions) { clear: both; }
    }
}
.project-card-cost { margin-top: .35rem; }

/* The job feed (Timeline): a vertical line with a dot per entry, coloured by kind. The dot sits on
   the centre of the entry's first line; the line runs through the dots' centres (6 px in). */
.timeline { list-style: none; margin: 1rem 0 0; padding: 0 0 0 1.75rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 2px; background: var(--line); }
.timeline-item { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; padding: 0 0 1.1rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: ""; position: absolute; left: -1.75rem; top: calc(.725em - 6px); width: 12px; height: 12px;
    border-radius: 50%; background: var(--brand-blue); box-shadow: 0 0 0 3px var(--surface);
}
.timeline-item.kind-expense::before { background: var(--brand-green); }
.timeline-item.kind-photo::before { background: var(--brand-blue-light); }
.timeline-item.kind-note::before { background: var(--ink-3); }
.timeline-what { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.timeline-when { font-size: var(--fs-small); color: var(--muted); }
/* A photo link keeps a tap-sized box before its lazy image loads (or if the browser cannot show
   it, say a HEIC receipt), instead of shrinking to a 2 px line. */
.thumb {
    max-width: 200px; max-height: 200px; min-width: 48px; min-height: 48px;
    border-radius: 6px; border: 1px solid var(--border); display: block; background: var(--well);
}

/* A receipt in a table row: enough to recognise, full size one tap away. */
.thumb-small { width: 48px; height: 48px; object-fit: cover; }

.photo-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem;
}
.photo-grid .thumb { width: 100%; max-width: none; height: 160px; object-fit: cover; }
.photo-grid-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem; margin-top: .35rem; font-size: var(--fs-small); }
.photo-note { margin: .35rem 0 0; font-size: var(--fs-small); overflow-wrap: anywhere; }
.photo-day { display: flex; align-items: baseline; gap: .5rem; margin: 1rem 0 .5rem; font-size: 1rem; }
.photo-day .muted { font-size: var(--fs-small); font-weight: 400; }
.photo-open { margin-bottom: 1rem; }
.photo-open img { display: block; max-width: 100%; max-height: 70vh; border-radius: 6px; border: 1px solid var(--border); }

/* A file input dressed as a button (FieldCapture's camera and library): the input covers the button, unseen. */
.btn-file { position: relative; overflow: hidden; }
.btn-file input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
/* A batch of job photos waiting for Save (photo-pick.js): a row of thumbnails that wraps on a phone. */
.photo-batch { flex-basis: 100%; }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.photo-thumbs img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.btn-camera { display: inline-flex; align-items: center; gap: .5rem; padding: .75rem 1.25rem; font-weight: 600; }

.auth-alt { margin: 1rem 0 0; text-align: center; font-size: .9rem; }

/* ---- Job report (JobReportView: the office page and the client's link) ---- */
.job-report-head { border-top: 4px solid var(--brand-blue); padding-top: .75rem; margin-bottom: 1rem; }
.job-report-head p { margin: 0; }
.job-report-company { font-weight: 700; color: var(--brand-blue); }
.job-report-title { margin: .25rem 0; color: var(--brand-green-deep); }
.job-report-section { border-top: 1px solid var(--line-soft); padding-top: .25rem; margin-top: 1rem; }
.job-report-section h3 { margin-top: .75rem; }
.job-report-visits, .job-report-notes { list-style: none; margin: 0; padding: 0; }
.job-report-visits li {
    display: grid; grid-template-columns: 11rem 1fr 4rem 1fr; gap: .25rem 1rem;
    padding: .5rem 0; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums;
}
.job-report-notes li { padding: .5rem 0; border-bottom: 1px solid var(--line-soft); }
.job-report-notes li p { margin: .25rem 0 0; }
.job-report-day { margin: .75rem 0 .5rem; font-size: 1rem; }
.job-report-photos { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.job-report-photos li { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; background: var(--surface); }
/* A ticked photo is outlined in the brand blue, so the picks read at a glance. */
.job-report-photos li:has(input[type=checkbox]:checked) { border-color: var(--brand-blue); box-shadow: 0 0 0 2px var(--brand-blue); }
.job-report-photos figure { margin: 0; }
.job-report-photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.job-report-photos figcaption { display: flex; flex-direction: column; gap: .1rem; margin-top: .35rem; font-size: var(--fs-small); overflow-wrap: anywhere; }
/* The whole row is the tick target, at least 44 px tall. */
.job-report-pick { flex-direction: row; align-items: center; gap: .5rem; min-height: 44px; margin: .25rem 0 0; color: var(--text); cursor: pointer; }
.job-report-pick input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
