/* Squares: the strip-of-squares mark (squares.js). Shape plus colour carries the state; every colour is a theme token
   from theme-tokens.css. Square corners throughout. */
.sq-rows { display: grid; grid-template-columns: max-content 1fr; gap: var(--sq-row-gap, 6px) 12px; align-items: center; }
.sq-row { display: contents; }
.sq-name { font-size: 13px; color: var(--th-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.sq-strip { display: flex; flex-wrap: wrap; gap: var(--sq-gap, 3px); align-items: center; min-height: var(--sq-size, 14px); }

.sq {
  --sq-ink: var(--th-text-2);
  position: relative; display: inline-block; flex: none; box-sizing: border-box;
  width: var(--sq-size, 14px); height: var(--sq-size, 14px); padding: 0; margin: 0;
  border: 1.5px solid var(--sq-ink); border-radius: 0; background: transparent;
  font: inherit; color: inherit; text-decoration: none; cursor: default;
  forced-color-adjust: none;
}
button.sq, a.sq { cursor: pointer; }
button.sq:hover, a.sq:hover { box-shadow: 0 0 0 1px var(--th-text); }
.sq:focus { outline: none; }
.sq:focus-visible { outline: 2px solid var(--th-focus); outline-offset: 2px; z-index: 2; }

/* done: filled */
.sq-done { --sq-ink: var(--th-ok); background: var(--th-ok); }
/* in progress: lower half filled */
.sq-progress { --sq-ink: var(--th-info); background: linear-gradient(to top, var(--th-info) 50%, var(--th-info-tint) 50%); }
/* past due: hatched */
.sq-late { --sq-ink: var(--th-bad); background: repeating-linear-gradient(135deg, var(--th-bad) 0 2px, var(--th-bad-tint) 2px 4px); }
/* not started: solid outline on the bar track */
.sq-open { --sq-ink: var(--th-text-2); background: var(--th-surface-3); }
/* locked: neutral fill, a lock drawn inside (the lock, not a colour, says it) */
.sq-locked { --sq-ink: var(--th-text-3); background: var(--th-surface-2);
  --sq-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M5 7V5a3 3 0 0 1 6 0v2h1v7H4V7h1zm1.5 0h3V5a1.5 1.5 0 0 0-3 0v2z'/%3E%3C/svg%3E"); }
.sq-locked::before {
  content: ''; position: absolute; inset: 18%; background: var(--th-text-2); pointer-events: none;
  -webkit-mask: var(--sq-lock) center / contain no-repeat; mask: var(--sq-lock) center / contain no-repeat;
}
/* not assigned: faint dashed outline */
.sq-none { --sq-ink: var(--th-border); border-style: dashed; background: transparent; }

/* Detail on hover and on keyboard focus. squares.js shifts it back inside the window (--sq-tip-dx) and drops it below
   the square when there is no room above. */
.sq-tip {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(calc(-50% + var(--sq-tip-dx, 0px))); z-index: 20;
  display: none; flex-direction: column; gap: 2px; min-width: max-content; max-width: 28ch; padding: 6px 8px;
  background: var(--th-surface); color: var(--th-text); border: 1px solid var(--th-border-strong, var(--th-text));
  border-radius: var(--radius-card, 0); box-shadow: var(--th-shadow-soft, none);
  font-size: 12px; line-height: 1.3; text-align: left; white-space: nowrap; pointer-events: none;
}
.sq-tip.sq-tip-below { bottom: auto; top: calc(100% + 6px); }
.sq:hover > .sq-tip, .sq:focus-visible > .sq-tip { display: flex; }
.sq-tip-title { font-weight: 600; }
.sq-tip-due { font-family: 'DM Mono', ui-monospace, monospace; color: var(--th-text-2); }
.sq-tip-state { color: var(--th-text-2); }

.sq-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--th-text-2); }
.sq-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sq-legend .sq { --sq-size: 10px; }

/* Touch: the bottom sheet (Squares.sheet). On a screen with no hover the tooltip gives way to the sheet. */
@media (hover: none) {
  .sq-sheet-host .sq-tip { display: none !important; }
}
.sq-sel { outline: 2px solid var(--th-focus); outline-offset: 2px; z-index: 2; }
.sq-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--th-surface); color: var(--th-text); border-top: 2px solid var(--th-text); border-radius: 0;
  box-shadow: var(--th-shadow-soft, none);
}
.sq-sheet[hidden] { display: none; }
.sq-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sq-sheet-title { font-size: 16px; font-weight: 700; line-height: 1.3; padding-top: 10px; }
.sq-sheet-lines { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--th-text-2); }
.sq-sheet-close {
  flex: none; min-width: 44px; min-height: 44px; padding: 0; border: 1px solid var(--th-border); border-radius: 0;
  background: var(--th-surface-2); color: var(--th-text); font: inherit; font-size: 22px; line-height: 1; cursor: pointer;
}
.sq-sheet-open {
  min-height: 44px; padding: 0 20px; align-self: stretch; border: 0; border-radius: 0; cursor: pointer;
  background: var(--th-selected); color: var(--th-on-selected); font: inherit; font-size: 15px; font-weight: 700;
}
.sq-sheet-close:focus-visible, .sq-sheet-open:focus-visible { outline: 2px solid var(--th-focus); outline-offset: 2px; }
