/* the Tracker app: running activities, event type tiles, day log, undo toast, type dialogs */

#app-tracker {
  position: relative;
  display: grid;
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.tr-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.tr-title { flex: 1; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.tr-bar button { height: 24px; border-color: var(--border); }

.tr-body { overflow: auto; padding: 20px 24px 60px; background: var(--bg); }
.tr-body > section { max-width: 1000px; margin: 0 auto 24px; }

/* running activities */
.tr-spans { display: flex; flex-direction: column; gap: 8px; }

.tr-span {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--accent);
}

.tr-emoji { font-size: 22px; line-height: 1; text-align: center; font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", var(--ui); }
.tr-sname { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tr-sname small { margin-left: 8px; color: var(--muted); font-weight: 400; }
.tr-dur { font-family: var(--mono); font-size: 18px; }
.tr-span button { height: 28px; padding: 0 14px; border-color: var(--accent); }
.tr-track { position: relative; grid-column: 1 / -1; height: 8px; background: var(--panel); }
.tr-fill { height: 100%; background: var(--accent); }
.tr-scale { position: absolute; right: 0; top: 10px; color: var(--muted); font-size: 11px; }
.tr-span { padding-bottom: 22px; }

/* type tiles */
.tr-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }

.tr-tile, .tr-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: auto;
  min-height: 112px;
  padding: 10px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
}

.tr-tile:hover { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.tr-tile .tr-emoji, .tr-preview .tr-emoji { font-size: 34px; }
.tr-tile-name { max-width: 100%; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.tr-tile-meta { color: var(--muted); font-size: 11px; }
.tr-tile.running { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); opacity: 0.6; cursor: default; }
.tr-tile.hit { background: var(--accent); border-color: var(--accent); }
.tr-tile.hit * { color: var(--accent-fg); }
.tr-tile.add { border-style: dashed; border-color: var(--border-strong); color: var(--muted); }
.tr-tile.add .tr-emoji { font-size: 30px; font-family: var(--ui); }

/* log */
.tr-log-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.tr-log-head button { height: 26px; border-color: var(--border); }
.tr-day { min-width: 200px; text-align: center; font-weight: 600; }

.tr-rows { border: 1px solid var(--border); background: var(--surface); }

.tr-row {
  display: grid;
  grid-template-columns: 100px 100px 44px minmax(120px, 1fr) minmax(160px, 2fr) 48px;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 6px 0 14px;
  font-size: 24px;
  border-bottom: 1px solid var(--border);
}

.tr-row:last-child { border-bottom: 0; }
.tr-row:hover { background: var(--hover); }
.tr-time { justify-self: start; height: 40px; padding: 0 6px; font-size: 24px; border-color: transparent; font-family: var(--mono); }
.tr-time:hover { border-color: var(--border-strong); }
.tr-start, .tr-end { position: relative; }
/* the time editor is wider than its column: it floats over the row */
.tr-row input[type="datetime-local"] {
  position: absolute; z-index: 2; top: 50%; left: 0; height: 44px; transform: translateY(-50%);
  background: var(--surface); font-family: var(--mono); font-size: 22px;
}
.tr-running { padding: 0 7px; color: var(--accent); font-size: 18px; }
.tr-len { position: relative; display: flex; align-items: center; height: 40px; }
.tr-len i { position: absolute; inset: 0 auto 0 0; min-width: 2px; background: var(--accent); opacity: 0.25; }
.tr-len.running i { opacity: 0.45; }
.tr-len span { position: relative; padding: 0 10px; font-size: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-row .tr-emoji { font-size: 32px; }
.tr-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-what.gone { color: var(--muted); font-style: italic; }
.tr-row .fdel { height: 44px; padding: 0; font-size: 24px; }
.tr-row .fdel:hover { background: var(--danger); color: #fff; }

/* undo toast */
.tr-toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 90%;
  padding: 6px 6px 6px 14px;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.tr-toast button { height: 26px; border-color: currentColor; }
.tr-toast.err { background: var(--danger); color: #fff; }

/* dialogs */
.tr-new-dlg { width: min(600px, 94vw); }
.tr-new-body { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 14px 16px; padding: 14px 12px; }
.tr-preview { min-height: 116px; }
.tr-preview .tr-emoji.none { color: var(--muted); font-family: var(--ui); }
.tr-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; align-items: center; }
.tr-fields > label, .tr-fields > span { color: var(--muted); }
.tr-fields input:not([type]) { height: 30px; padding: 0 8px; }
.tr-icon-line { display: flex; align-items: center; gap: 10px; }
.tr-icon-line .muted { font-size: 12px; }
.tr-icon-line .err { color: var(--danger); }
.tr-icon-in { width: 56px; font-size: 18px; text-align: center; font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", var(--ui); }
.tr-kinds { display: flex; flex-direction: column; gap: 4px; }
.tr-kinds .check { color: var(--fg); font-size: 13px; white-space: normal; }
.tr-pick { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.tr-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, 57px); gap: 3px; }
/* the emoji font for every button: symbols like ☀ ☕ 🍽 would otherwise come from a text font in another size */
.tr-pick-grid button {
  width: 57px; height: 57px; padding: 0; border: 1px solid transparent;
  font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", var(--ui); font-size: 33px; line-height: 1;
}
.tr-pick-grid button.on { border-color: var(--accent); background: var(--hover); }
.tr-all-btn { align-self: flex-start; height: 26px; border-color: var(--border); }
.tr-all { max-height: min(390px, 40vh); overflow: auto; padding-right: 4px; border-top: 1px solid var(--border); }
.tr-all-head { position: sticky; top: 0; z-index: 1; padding: 6px 0 4px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; }

.tr-type-row {
  display: grid;
  grid-template-columns: 16px 56px minmax(120px, 1fr) auto 72px;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.tr-type-row input[type="text"] { min-width: 0; height: 26px; padding: 0 6px; }
.tr-type-row .tr-icon-in { width: 56px; font-size: 16px; }
.tr-type-row button { height: 26px; border-color: var(--border); }
.tr-type-row.archived input { color: var(--muted); text-decoration: line-through; }
.tr-type-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tr-type-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.tr-types-hint { margin: 10px 0 0; }
.dlg-foot .tr-clear { color: var(--danger); }
.dlg-foot .tr-clear:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* narrow screens (phones): the log row in two lines, times, icon, name and × on top, the duration bar below */
@media (max-width: 600px) {
  .tr-body { padding: 12px 10px 60px; }
  .tr-day { min-width: 0; flex: 1; }
  .tr-row {
    grid-template-columns: auto 62px 28px minmax(0, 1fr) 36px;
    grid-template-areas: "start end icon what del" "bar bar bar bar bar";
    gap: 0 6px;
    height: auto;
    min-height: 48px;
    padding: 4px 2px 4px 6px;
    font-size: 17px;
  }
  .tr-start { grid-area: start; }
  .tr-end { grid-area: end; }
  .tr-row .tr-emoji { grid-area: icon; font-size: 24px; }
  .tr-what { grid-area: what; }
  .tr-len { grid-area: bar; height: 26px; margin-bottom: 2px; }
  .tr-len:empty { display: none; }
  .tr-len span { font-size: 15px; }
  .tr-row .fdel { grid-area: del; height: 40px; font-size: 20px; }
  .tr-time { height: 40px; padding: 0 4px; font-size: 17px; }
  .tr-running { padding: 0 4px; font-size: 14px; }
  .tr-row input[type="datetime-local"] { font-size: 16px; height: 40px; }
}
