/* Dates view ("On the Clock"): countdown cards, pin form, six-week calendar, agenda, popover. */

#pm-dates-main { position: relative; } /* the popover is placed inside the view */

/* ---- countdown cards ---- */
.pmv-dt-next { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 28px 0 24px; }
.pmv-dt-cd { position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 16px 16px 14px 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md, 14px); background: var(--glass); box-shadow: inset 4px 0 0 var(--pc, var(--accent)); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background .15s; }
@media (hover: hover) { .pmv-dt-cd:hover { background: rgba(255, 255, 255, .07); } }
.pmv-dt-cd:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pmv-dt-n { font-family: var(--display); font-size: 64px; line-height: .9; font-weight: 400; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.pmv-dt-u, .pmv-dt-k { color: var(--muted); font-size: 12px; line-height: 18px; }
.pmv-dt-u { margin-top: 4px; font-size: var(--fs-cap, 11px); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; line-height: 16px; }
.pmv-dt-k { font-size: var(--fs-meta, 13px); }
.pmv-dt-l { margin-top: 8px; font-size: var(--fs-body, 14px); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmv-dt-cd.late { --pc: var(--danger); border-color: rgba(240, 138, 138, .55); background: rgba(240, 138, 138, .07); }
.pmv-dt-cd.late .pmv-dt-n, .pmv-dt-cd.late .pmv-dt-u { color: var(--danger); }
.pmv-dt-cd.soon .pmv-dt-n { color: var(--amber); }
.pmv-dt-empty { grid-column: 1 / -1; padding: 6px 0; color: var(--faint, rgba(255, 255, 255, .28)); font-size: var(--fs-body, 14px); }

/* ---- pin form + calendar nav ---- */
.pmv-dt-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 12px; }
.pmv-dt-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; flex: 1 1 420px; min-width: 0; }
.pmv-dt-form .field { min-width: 0; gap: 6px; }
.pmv-dt-form .field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pmv-dt-f-label { flex: 1 1 220px; }
.pmv-dt-f-date { flex: 0 1 170px; }
.pmv-dt-form input { height: var(--field-h, 44px); font-size: var(--fs-body, 14px); }
.pmv-dt-form .btn { flex: none; }
.pmv-dt-nav { display: flex; align-items: center; gap: 8px; }
.pmv-dt-title { min-width: 130px; margin: 0 4px; color: var(--text); font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; text-align: center; white-space: nowrap; }

/* ---- calendar ---- */
.pmv-dt-calbox { max-width: 100%; overflow-x: auto; border-radius: var(--r-lg, 20px); }
.pmv-dt-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; min-width: 320px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg, 20px); background: var(--line); }
.pmv-dt-h { padding: 8px 13px; background: var(--glass-strong); color: var(--muted); font-size: var(--fs-cap, 11px); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.pmv-dt-day { display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 92px; padding: 6px 6px 8px; background: var(--surface); transition: background .15s; }
.pmv-dt-day.wk { background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.pmv-dt-day.past .pmv-dt-dn { opacity: .5; }
.pmv-dt-day.past .pmv-dt-chip:not(.late) { opacity: .6; }
.pmv-dt-day.over { background: rgba(52, 211, 153, .12); }
.pmv-dt-dn { align-self: flex-start; padding: 1px 7px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }
button.pmv-dt-dn { cursor: pointer; }
@media (hover: hover) { button.pmv-dt-dn:hover { color: var(--text); background: rgba(255, 255, 255, .06); } }
.pmv-dt-day:has(button.pmv-dt-dn) { cursor: pointer; }
.pmv-dt-day.today .pmv-dt-dn { box-shadow: 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 600; }
.pmv-dt-dn:focus-visible, .pmv-dt-chip:focus-visible, .pmv-dt-ag:focus-visible, .pmv-dt-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.pmv-dt-chip { display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 4px 7px 4px 10px; border: 0; border-radius: var(--r-chip, 8px); background: color-mix(in srgb, var(--pc) 18%, var(--surface)); box-shadow: inset 3px 0 0 var(--pc); color: var(--text); font: inherit; font-size: 12px; font-weight: 600; line-height: 16px; text-align: left; cursor: pointer; }
.pmv-dt-chip[draggable="true"] { cursor: grab; }
.pmv-dt-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmv-dt-chip.ws { padding-left: 7px; background: var(--pc); color: #0b1324; box-shadow: none; }
.pmv-dt-chip.ws::before { content: "◆"; flex: none; font-size: 9px; }
.pmv-dt-chip.late { box-shadow: inset 3px 0 0 var(--pc), inset 0 0 0 1.5px var(--danger); }
.pmv-dt-chip.ws.late { box-shadow: inset 0 0 0 1.5px var(--danger); }
.pmv-dt-chip.draft { opacity: .75; }
.pmv-dt-chip.ws.draft { background: transparent; color: var(--text); outline: 1.5px dashed var(--pc); outline-offset: -1.5px; }
.pmv-dt-chip.dragging { opacity: .4; }

/* ---- agenda: the phone's list (hidden on wide screens, the calendar shows it all) ---- */
.pmv-dt-agenda { display: none; }
.pmv-dt-ag { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px 10px 16px; border: 1px solid var(--line); border-radius: var(--r-md, 14px); box-shadow: inset 4px 0 0 var(--pc); background: var(--glass); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pmv-dt-ag-d { flex: none; min-width: 52px; color: var(--muted); font-size: var(--fs-meta, 13px); font-variant-numeric: tabular-nums; }
.pmv-dt-ag-t { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmv-dt-ag-c { flex: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.pmv-dt-ag.soon .pmv-dt-ag-c { color: var(--amber); }
.pmv-dt-ag.late .pmv-dt-ag-c { color: var(--danger); }

/* ---- popover ---- */
.pmv-dt-pop { position: absolute; z-index: 8; display: flex; flex-direction: column; gap: 12px; width: min(360px, calc(100% - 16px)); padding: 18px 18px 16px; border: 1px solid var(--line); border-radius: var(--r-lg, 20px); background: var(--glass-strong); box-shadow: inset 0 3px 0 var(--pc, var(--accent)), var(--elevation), 0 24px 60px -20px rgba(0, 0, 0, .7); }
.pmv-dt-pop:focus { outline: none; }
.pmv-dt-pop h4 { margin: 0; padding-right: 28px; font-size: var(--fs-lead, 20px); line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }
.pmv-dt-pop-k { color: var(--muted); font-size: 12px; font-weight: 600; }
.pmv-dt-pop-k.soon { color: var(--amber); }
.pmv-dt-pop-k.late { color: var(--danger); }
.pmv-dt-pop .field { gap: 6px; }
.pmv-dt-pop .field label { color: var(--muted); font-size: var(--label-fs, 13px); font-weight: 500; line-height: 18px; }
.pmv-dt-pop input { height: var(--field-h, 44px); font-size: var(--fs-body, 14px); }
.pmv-dt-pop-date { color: var(--text); font-size: 14px; }
.pmv-dt-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pmv-dt-acts .btn { height: var(--btn-h-sm, 36px); }
.pmv-dt-x { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r); background: none; color: var(--muted); font: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
@media (hover: hover) { .pmv-dt-x:hover { color: var(--text); background: rgba(255, 255, 255, .06); } }

@media (max-width: 980px) {
  .pmv-dt-next { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .pmv-dt-next { gap: 8px; }
  .pmv-dt-cd { padding: 12px 12px 12px 16px; }
  .pmv-dt-n { font-size: 52px; }
  .pmv-dt-l { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 18px; }
  .pmv-dt-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; flex-basis: 100%; }
  .pmv-dt-f-label { grid-column: 1 / -1; }
  .pmv-dt-nav { width: 100%; }
  .pmv-dt-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pmv-dt-nav .btn { padding: 0 14px; }

  /* compact calendar: small cells, chips as coloured dots */
  .pmv-dt-calbox, .pmv-dt-cal { border-radius: var(--r-md, 14px); }
  .pmv-dt-h { padding: 6px 2px; font-size: var(--fs-cap, 11px); letter-spacing: .08em; text-align: center; }
  .pmv-dt-day { min-height: 56px; gap: 3px; padding: 4px 3px; }
  .pmv-dt-dn { align-self: center; padding: 0 3px; font-size: 11px; white-space: nowrap; }
  .pmv-dt-chip { height: 7px; padding: 0; border: 0; border-radius: 4px; background: var(--pc); box-shadow: none; }
  .pmv-dt-chip.late { box-shadow: 0 0 0 1px var(--danger); }
  .pmv-dt-chip span, .pmv-dt-chip.ws::before { display: none; }
  .pmv-dt-chip.draft { background: transparent; outline: 1px dashed var(--pc); outline-offset: -1px; }

  .pmv-dt-agenda { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }

  /* popover becomes a sheet above the dock */
  .pmv-dt-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); width: auto; }
}
