/* Time clock (modules/time.js), Your day (lib/day-timeline.js), Automatic day (lib/auto-day-ui.js)
   and location (lib/location-ui.js). The components (status card, inset lists, sheets, action bar)
   come from css/app.css; this file holds what is specific to time. Tokens only. */

/* ---------- the clock: one live status card ---------- */
.clk-clock .status-meta { white-space: normal; }
.clk-readout { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--s2); margin-top: var(--s4); }
.clk-readout-time { font-family: var(--font-display); font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.clk-readout-label { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--text-muted); }
.status-card.tone-live .clk-readout-label { color: var(--status-muted); }
.clk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s3); }
.clk-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 2px 10px; border-radius: var(--r-pill); background: var(--fill); color: var(--text-muted); font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; }
/* Shared change wanted: a --status-fill token (the translucent fill app.css uses on the live card). */
.status-card.tone-live .clk-chip { background: rgba(255, 255, 255, .14); color: var(--status-text); }
.status-card.tone-live .clk-chip svg { color: var(--accent-fill); }
.status-card.tone-live .badge.neutral { background: rgba(255, 255, 255, .14); color: var(--status-text); }
.clk-shift .ios-row-value { max-width: 55%; }

/* Who's on the clock, flags to review: rows with marks under the name. */
.clk-sub { display: flex; flex-direction: column; gap: 4px; }
.clk-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.clk-who-on .ios-row-value { color: var(--text); font-weight: 600; }
.clk-who-on .avatar, .time-crew .avatar { width: 30px; height: 30px; font-size: 11px; flex: none; }
.clk-review .ios-row-body > .btn, .clk-who-on .ios-row-body > .btn { flex: none; }

/* ---------- timesheets ---------- */
.clk-weekbar { display: flex; align-items: center; gap: var(--s1); margin: 0 0 var(--s5); }
.clk-weekseg { flex: 1; min-width: 0; }
.clk-weekseg .segment-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* A native picker inside a row (iOS shows its wheel). */
.clk-select-row { cursor: pointer; }
.clk-select-row .clk-select {
  -webkit-appearance: none; appearance: none; flex: 0 1 auto; min-width: 0; max-width: 62%; min-height: 44px; margin: -11px 0; padding: 0;
  border: 0; background: transparent; color: var(--text-muted); font-size: var(--fs-body); text-align: right; text-align-last: right; text-overflow: ellipsis; cursor: pointer;
}
.clk-select-row .clk-select:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 2px; border-radius: 6px; }
.clk-select-row .ios-row-chev { opacity: .8; }

.clk-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); margin: 0 0 var(--s5); }
.clk-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: var(--s3) var(--s4); border-radius: var(--r-group); background: var(--surface); }
.clk-stat-label { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; color: var(--text-muted); }
.clk-stat-value { font-family: var(--font-display); font-size: var(--fs-title2); line-height: var(--lh-title2); font-weight: 700; font-variant-numeric: tabular-nums; }
.clk-stat-hint { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clk-stat.travel .clk-stat-value { color: var(--info); }
.clk-stat.accent .clk-stat-value { color: var(--accent); }
@media (max-width: 600px) { .clk-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* The week at a glance: work (green) and travel (blue) per day. */
.clk-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s2); align-items: end; margin: 0 0 var(--s5); padding: var(--s4) var(--s3) var(--s3); border-radius: var(--r-group); background: var(--surface); }
.clk-bar-day { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.clk-bar { display: flex; flex-direction: column-reverse; width: 100%; max-width: 30px; height: 88px; border-radius: 6px; background: var(--fill); overflow: hidden; }
.clk-bar i { display: block; width: 100%; flex: none; }
.clk-bar .tw { background: var(--tile-green); }
.clk-bar .tt { background: var(--tile-blue); }
.clk-bar-val { min-height: 16px; font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--text-muted); white-space: nowrap; }
.clk-bar-label { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; color: var(--text-muted); }
.clk-bar-day.today .clk-bar-label { color: var(--accent); }
.clk-bar-day.today .clk-bar { box-shadow: 0 0 0 2px var(--accent-fill); }
.clk-bar-day.over .clk-bar-val { color: var(--danger); font-weight: 700; }
.clk-bar-flag { font-size: var(--fs-caption); line-height: var(--lh-caption); }

/* Entries, one inset group per day. */
.clk-day .ios-group-header { align-items: center; }
.clk-day-total { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; color: var(--text-muted); }
.clk-day.is-today .ios-group-header h2 { color: var(--accent); }
.clk-entry { display: flex; align-items: center; gap: var(--s3); min-height: var(--row); padding-left: var(--s4); background: var(--surface); }
.clk-entry + .clk-entry .clk-entry-main { border-top: .5px solid var(--separator); }
.clk-entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-self: stretch; justify-content: center; margin: 0; padding: 10px var(--s4) 10px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; }
button.clk-entry-main { cursor: pointer; }
.clk-entry.is-link:active { background: var(--fill-strong); }
@media (hover: hover) { .clk-entry.is-link:hover, .clk-entry.is-link:hover .clk-entry-main { background: var(--surface-2); } }
button.clk-entry-main:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: -3px; border-radius: var(--r-sm); }
.clk-entry-top { display: flex; align-items: baseline; gap: var(--s2); }
.clk-entry-title { flex: 1; min-width: 0; font-size: var(--fs-body); line-height: var(--lh-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clk-entry-hours { flex: none; font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 600; }
.clk-entry-sub { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--text-muted); overflow-wrap: anywhere; }
.clk-entry-job { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clk-entry .clk-tags { margin-top: 4px; }
.clk-entry > .btn { flex: none; margin-right: var(--s4); }
/* The approval check: a round tick like iOS Reminders, with a 44pt target. */
.clk-tick { position: relative; flex: none; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--border-input); background: none; color: transparent; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.clk-tick::before { content: ""; position: absolute; inset: -10px; }
.clk-tick.on { background: var(--tile-green); border-color: var(--tile-green); color: var(--on-tile); }
.clk-tick:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 3px; }

.time-locked { display: inline-flex; gap: 4px; align-items: center; color: var(--text-muted); font-size: var(--fs-xs); }
.time-correction { color: var(--info); }
.time-late { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-radius: var(--r-group); background: var(--surface-2); font-size: var(--fs-sm); }
.time-late label { display: flex; gap: var(--s2); align-items: center; min-height: 44px; }
.time-travel { color: var(--info); }
.time-warn { color: var(--danger); font-weight: 600; }
.time-warnings { margin: 0; padding-left: var(--s5); }

/* ---------- Your day (lib/day-timeline.js): a vertical timeline, on the clock and on Today ---------- */
.day-timeline .ios-group-header.day-top { align-items: center; }
.day-nav { display: flex; align-items: center; gap: 2px; }
.day-date { min-width: 4.5em; text-align: center; font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: 600; white-space: nowrap; }
.day-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: .5px solid var(--separator); }
.day-stat { display: flex; flex-direction: column; min-width: 0; }
.day-stat-label { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; color: var(--text-muted); }
.day-stat-value { font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 700; white-space: nowrap; }
.day-stat.work .day-stat-value { color: var(--success); }
.day-stat.travel .day-stat-value { color: var(--info); }
.day-list { list-style: none; margin: 0; padding: var(--s2) 0 0; }
.day-row { position: relative; }
/* The line through the nodes: solid between parts, dashed across a gap off the clock. */
.day-row::before, .day-end::before { content: ""; position: absolute; left: calc(var(--s4) + 15px); top: 0; bottom: 0; width: 2px; background: var(--separator); }
.day-row:first-child::before { top: 50%; }
.day-row.gap::before { width: 0; background: none; border-left: 2px dashed var(--separator); }
.day-end::before { bottom: 50%; }
.day-part { position: relative; display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; margin: 0; padding: var(--s2) var(--s4); border: 0; background: none; color: inherit; font: inherit; text-align: left; }
button.day-part { cursor: pointer; -webkit-user-select: none; user-select: none; }
button.day-part:active { background: var(--fill-strong); }
@media (hover: hover) { button.day-part:hover { background: var(--surface-2); } }
button.day-part:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: -3px; border-radius: var(--r-group); }
.day-node { position: relative; z-index: 1; flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--tile-gray); color: var(--on-tile); box-shadow: 0 0 0 3px var(--surface); }
.day-node.tone-blue { background: var(--tile-blue); }
.day-node.tone-green { background: var(--tile-green); }
.day-node.tone-purple { background: var(--tile-purple); }
.day-row.open .day-node { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--success-soft); }
.day-row.gap .day-part { min-height: 48px; }
.day-row.gap .day-node { width: 24px; height: 24px; margin: 0 4px; background: var(--surface); border: 2px solid var(--separator); color: var(--text-muted); }
.day-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.day-title { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-sub { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-job { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-empty { margin: 0; padding: var(--s4); color: var(--text-muted); font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.day-row.gap .day-title { font-weight: 400; color: var(--text-muted); }
.day-row.gap .day-sub { font-size: var(--fs-footnote); line-height: var(--lh-footnote); }
.day-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.day-km { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--info-soft); color: var(--info); font-size: var(--fs-xs); font-weight: 700; }
.day-value { flex: none; font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-now { color: var(--success); font-weight: 700; }
.day-chev { flex: none; display: grid; color: var(--text-muted); opacity: .55; margin-right: -6px; }
.day-row.check .day-title { color: var(--warning); }
.day-end { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 40px; padding: 0 var(--s4) var(--s1); font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-muted); }
.day-end-dot { position: relative; z-index: 1; flex: none; width: 12px; height: 12px; margin: 0 10px; border-radius: 50%; background: var(--text-muted); box-shadow: 0 0 0 3px var(--surface); }
.day-card .empty { background: none; }
.day-warn { display: flex; align-items: flex-start; gap: var(--s2); margin: 0; padding: var(--s3) var(--s4); border-radius: var(--r-group); background: var(--warning-soft); color: var(--warning); font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: 600; }
.day-warn svg { flex: none; margin-top: 2px; }
.day-sheet .ios-group, .clk-pick .ios-group { margin-bottom: var(--s4); }
.day-sheet .ios-list, .clk-pick .ios-list { background: var(--surface-2); }
.day-sheet .ios-row, .clk-pick .ios-row { background: var(--surface-2); }
.clk-pick .ios-group:last-child, .day-sheet .ios-group:last-child { margin-bottom: 0; }

/* ---------- Automatic day (lib/auto-day-ui.js): an iOS settings flow ---------- */
.auto-day .status-card { margin-bottom: var(--s5); }
.auto-status:empty { display: none; }
.auto-status { margin-top: var(--s2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-muted); }
.auto-off .ios-row-text { align-items: center; }
.auto-off .ios-row-title { color: var(--danger); }
.auto-summary .ios-row-title { font-weight: 600; }
/* An iOS switch. Shared change wanted: ui.switch. */
.clk-switch { position: relative; flex: none; width: 51px; height: 31px; padding: 0; border: 0; border-radius: var(--r-pill); background: var(--fill-strong); cursor: pointer; transition: background var(--t-base); }
.clk-switch::before { content: ""; position: absolute; inset: -7px -2px; }
.clk-switch.on { background: var(--tile-green); }
.clk-switch-thumb { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: var(--control-thumb); box-shadow: var(--shadow-card); transition: transform var(--t-base) var(--ease-ios); }
.clk-switch.on .clk-switch-thumb { transform: translateX(20px); }
.clk-switch:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .clk-switch, .clk-switch-thumb { transition: none; } }

/* Supplier stops (office, Time clock settings). */
.supplier-stops .ios-group-header { align-items: center; }
.supplier-stops .ios-group-header .btn { flex: none; }

/* ---------- location (lib/location-ui.js) ---------- */
.loc-small { font-size: var(--fs-xs); line-height: var(--lh-xs); }
.loc-hint { display: flex; align-items: center; gap: var(--s1); color: var(--success); }
.loc-cell { gap: var(--s2); flex-wrap: nowrap; }
.loc-line { margin-top: var(--s1); gap: var(--s2); }

/* The notice and consent sheet: the whole policy stays on screen. */
.loc-consent-hero { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-group); background: var(--info-soft); }
.loc-consent-hero p { margin: 0; font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.loc-policy p { margin: 0 0 var(--s3); font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.loc-facts-head { margin: var(--s4) var(--s4) 6px; font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.loc-facts { list-style: none; margin: 0; padding: 0; border-radius: var(--r-group); background: var(--surface-2); }
.loc-facts li { padding: var(--s3) var(--s4); border-bottom: .5px solid var(--separator); font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.loc-facts li:last-child { border-bottom: 0; }

/* My location */
.loc-records { margin-bottom: var(--s3); }
.loc-records-note { margin: 0 var(--s1); }
.loc-map { margin: 0 0 var(--s5); }
.loc-day .loc-time { flex: none; min-width: 64px; font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--text-muted); }
.loc-map-note { margin: 0 0 var(--s3); }
.loc-details summary { cursor: pointer; font-weight: 600; }
.loc-details[open] summary { margin-bottom: var(--s2); }
.loc-dayhead { margin: var(--s3) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }

/* Owner settings: grouped like iOS Settings, Save in the action bar. */
.loc-settings-body { padding: var(--s4); }
.loc-policy-text { font: inherit; min-height: 220px; }

/* Suggestion bar (shift tracker): above the tab bar and the home indicator. */
.loc-suggest {
  position: fixed; left: calc(var(--rail) + var(--s4)); right: var(--s4); bottom: calc(var(--s4) + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4);
  background: var(--surface); color: var(--text); border: 2px solid var(--info); border-radius: var(--r-md); box-shadow: var(--shadow-float);
  max-width: 720px; margin: 0 auto;
}
.loc-suggest > .grow { flex: 1 1 220px; min-width: 0; }
.loc-suggest-actions { gap: var(--s2); margin-left: auto; flex-wrap: nowrap; }
@media (max-width: 1023px) {
  .loc-suggest { left: var(--s3); right: var(--s3); bottom: calc(var(--tabbar) + var(--s3) + env(safe-area-inset-bottom, 0px)); }
  body:has(.main .action-bar) .loc-suggest { bottom: calc(var(--tabbar) + 84px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 720px) { .loc-suggest-actions { width: 100%; justify-content: flex-end; } }

/* Job site card (jobs.js) */
.loc-site { display: flex; flex-direction: column; gap: var(--s3); }
.loc-site-actions { gap: var(--s2); flex-wrap: wrap; }
.loc-radius-field { gap: var(--s1); }
.loc-radius { width: 90px; }

/* Small map */
.mm { position: relative; overflow: hidden; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); touch-action: none; user-select: none; }
.mm-pick { cursor: crosshair; }
.mm-tiles, .mm-pins { position: absolute; inset: 0; }
.mm-tile { position: absolute; max-width: none; pointer-events: none; }
.mm-missing { visibility: hidden; }
.mm-overlay { position: absolute; inset: 0; pointer-events: none; }
.mm-radius { fill: var(--info); fill-opacity: .14; stroke: var(--info); stroke-width: 2; }
.mm-pin { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--accent-fill); border: 2px solid var(--text); box-shadow: var(--shadow-card); }
.mm-crew { background: var(--success); border-color: var(--surface); width: 24px; height: 24px; margin: -12px 0 0 -12px; }
.mm-point { background: var(--info); border-color: var(--surface); width: 20px; height: 20px; margin: -10px 0 0 -10px; }
.mm-pin-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--surface); }
.mm-zooms { position: absolute; top: var(--s2); right: var(--s2); display: flex; flex-direction: column; gap: var(--s1); }
.mm-zoom { width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.mm-attr { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: 10px; line-height: 14px; color: var(--text-muted); background: var(--surface); opacity: .85; }

/* ---------- dashboard tile: hours by person, work and travel ---------- */
.time-tile { display: flex; flex-direction: column; gap: var(--s3); color: inherit; text-decoration: none; }
.time-legend { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-xs); color: var(--text-muted); }
.time-legend i, .time-bar i { display: inline-block; height: 10px; border-radius: 3px; }
.time-legend i { width: 10px; }
.tw { background: var(--success); }
.tt { background: var(--info); }
.time-bars { display: flex; flex-direction: column; gap: var(--s2); }
.time-bar-row { display: grid; grid-template-columns: minmax(64px, 110px) 1fr auto; align-items: center; gap: var(--s3); }
.time-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-bar { display: flex; gap: 2px; height: 10px; min-width: 40px; }
.time-bar-val { font-size: var(--fs-sm); white-space: nowrap; }
.time-ot { color: var(--accent); }
