/* (c) 2026 Wayne State University. All rights reserved. */
.tm {
  --tm-pull-h: 44px;
  --tm-gap: var(--sl-space-2);
  --tm-pad-top: max(env(safe-area-inset-top, 0px), var(--sl-space-1));
  --tm-pad-bottom: max(env(safe-area-inset-bottom, 0px), var(--sl-space-2));
  --tm-pad-left: max(env(safe-area-inset-left, 0px), var(--sl-space-3));
  --tm-pad-right: max(env(safe-area-inset-right, 0px), var(--sl-space-3));
  --tm-hold: 450ms;
}
html.tm, .tm body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  margin: 0;
  background: var(--sl-bg);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.tm-sheet {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--tm-pad-top) + var(--sl-space-3)) var(--tm-pad-right)
    calc(var(--tm-pull-h) + var(--tm-pad-bottom) + var(--sl-space-3)) var(--tm-pad-left);
  box-sizing: border-box;
  background: var(--sl-bg);
  color: var(--sl-text-1);
}
.tm-sheet__title { margin: 0; font-size: var(--sl-fs-6); outline: none; }
.tm-sheet__sub { margin: var(--sl-space-1) 0 var(--sl-space-3); font-size: var(--sl-fs-2); color: var(--sl-text-2); }
.tm-sheet__blocks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--tm-gap);
}
.tm-key {
  padding: var(--sl-space-2) var(--sl-space-3);
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius-md);
  background: var(--sl-surface);
}
.tm-key__title { margin: 0; font-size: var(--sl-fs-3); font-weight: 700; color: var(--sl-brand); }
.tm-key__note { margin: 0 0 var(--sl-space-1); font-size: var(--sl-fs-1); color: var(--sl-text-3); }
.tm-key__rows { margin: 0; }
.tm-key__rows div {
  display: flex;
  justify-content: space-between;
  gap: var(--sl-space-3);
  padding: 3px 0;
  border-top: 1px solid var(--sl-border);
  font-size: var(--sl-fs-3);
  line-height: var(--sl-lh-2);
}
.tm-key__rows div:first-child { border-top: 0; }
.tm-key__rows dt { color: var(--sl-text-2); }
.tm-key__rows dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.tm-front {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--sl-bg);
  box-shadow: var(--sl-shadow-2);
  touch-action: none;
  transition: transform var(--sl-dur) var(--sl-ease);
  will-change: transform;
}
.tm-front.is-dragging { transition: none; }
.tm-front.is-sheet { transform: translateY(calc(100% - var(--tm-pull-h) - var(--tm-pad-bottom))); }

.tm-pull {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: calc(var(--tm-pull-h) + var(--tm-pad-top));
  padding: var(--tm-pad-top) 0 0;
  border: 0;
  background: transparent;
  color: var(--sl-text-3);
  font: inherit;
  font-size: var(--sl-fs-1);
  cursor: pointer;
}
.tm-front.is-sheet .tm-pull { padding-top: 0; height: calc(var(--tm-pull-h) + var(--tm-pad-bottom));
  padding-bottom: var(--tm-pad-bottom); }
.tm-pull__grip { width: 40px; height: 5px; border-radius: var(--sl-radius-pill); background: var(--sl-border-control); }
.tm-pull:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: -4px; }

.tm-front__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0 var(--tm-pad-right) var(--tm-pad-bottom) var(--tm-pad-left);
}
.tm-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sl-space-3);
  margin-bottom: var(--sl-space-2);
}
.tm-head__title { margin: 0; font-size: var(--sl-fs-6); line-height: 1.15; color: var(--sl-text-1); }
.tm-home {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--sl-border);
  border-radius: 50%;
  background: var(--sl-surface);
  box-shadow: var(--sl-shadow-1);
  color: var(--sl-brand);
  transition: transform var(--sl-dur-fast) var(--sl-ease), background var(--sl-dur-fast) var(--sl-ease);
}
.tm-home svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; }
.tm-home:active { transform: scale(0.94); background: var(--sl-brand-tint); }
.tm-home:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.tm-head__sub { margin: 2px 0 0; font-size: var(--sl-fs-2); color: var(--sl-text-2); }
.tm-head__sub a { color: var(--sl-link); text-underline-offset: 2px; }

.tm-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: var(--tm-gap);
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tm-grid li { display: flex; min-height: 0; }
.tm-square {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  padding: var(--sl-space-2);
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius-lg);
  background: var(--sl-surface);
  color: var(--sl-text-1);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: transform var(--sl-dur-fast) var(--sl-ease), background var(--sl-dur-fast) var(--sl-ease);
}
.tm-square:active { transform: scale(0.97); background: var(--sl-surface-subtle); }
.tm-square:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.tm-square__title { font-size: var(--sl-fs-3); font-weight: 700; line-height: var(--sl-lh-1); overflow-wrap: anywhere; }
.tm-square__sub { font-size: var(--sl-fs-1); color: var(--sl-text-3); }
.tm-square--key { border-color: var(--sl-brand); background: var(--sl-brand); color: var(--sl-on-brand); }
.tm-square--key .tm-square__sub { color: var(--sl-on-brand); }
.tm-square--key:active { background: var(--sl-brand-hover); }
.tm-square--quiet { background: var(--sl-surface-sunken); }

.tm-foot {
  flex: none;
  margin: var(--sl-space-2) 0 0;
  font-size: var(--sl-fs-1);
  text-align: center;
  color: var(--sl-text-3);
}

@media (orientation: landscape) and (max-height: 560px) {
  .tm { --tm-pull-h: 32px; }
  .tm-grid { grid-template-columns: repeat(5, 1fr); }
  .tm-head__title { font-size: var(--sl-fs-5); }
  .tm-head { margin-bottom: var(--sl-space-1); }
  .tm-foot { margin-top: var(--sl-space-1); }
}
@media (min-width: 700px) and (min-height: 700px) {
  .tm-front__body, .tm-sheet > * { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }
  .tm-grid { max-height: 760px; }
  .tm-square__title { font-size: var(--sl-fs-4); }
}

.tm-detail {
  position: fixed;
  inset: 0;
  z-index: var(--sl-z-dialog);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--tm-pad-top) + var(--sl-space-3)) var(--tm-pad-right)
    calc(var(--tm-pad-bottom) + var(--sl-space-5)) var(--tm-pad-left);
  box-sizing: border-box;
  background: var(--sl-surface);
  color: var(--sl-text-1);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}
.tm-detail[hidden] { display: none; }
.tm-detail__body { max-width: 640px; margin: 0 auto; }
.tm-detail__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sl-space-1) var(--sl-space-2);
  margin: 0 48px var(--sl-space-3) 0;
  font-size: var(--sl-fs-6);
  line-height: 1.2;
}
.tm-detail__close {
  position: fixed;
  top: calc(var(--tm-pad-top) + var(--sl-space-1));
  right: var(--tm-pad-right);
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius-pill);
  background: var(--sl-surface);
  color: var(--sl-text-2);
  font: inherit;
  font-size: var(--sl-fs-5);
  line-height: 1;
  cursor: pointer;
}
.tm-detail__close:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.tm-detail__hint { max-width: 640px; margin: var(--sl-space-4) auto 0; font-size: var(--sl-fs-1); color: var(--sl-text-3); }

.tm-ring {
  position: fixed;
  z-index: calc(var(--sl-z-dialog) + 1);
  width: 150px;
  height: 150px;
  margin: -75px 0 0 -75px;
  pointer-events: none;
}
.tm-ring[hidden] { display: none; }
.tm-ring__track { fill: var(--sl-brand-tint); }
.tm-ring__fill {
  fill: none;
  stroke: var(--sl-brand);
  stroke-width: 40;
  stroke-dasharray: 125.7;
  stroke-dashoffset: 125.7;
  transform: rotate(-90deg);
  transform-origin: 40px 40px;
}
.tm-ring.is-growing .tm-ring__fill { stroke-dashoffset: 0; transition: stroke-dashoffset var(--tm-hold) linear; }

.tm-shield { position: fixed; inset: 0; z-index: calc(var(--sl-z-dialog) + 2); touch-action: none; }
.tm-shield[hidden] { display: none; }

.tm-terms { margin: 0; }
.tm-term { padding: var(--sl-space-2) 0; border-top: 1px solid var(--sl-border); }
.tm-term:first-child { border-top: 0; padding-top: 0; }
.tm-term dt { font-size: var(--sl-fs-4); line-height: var(--sl-lh-2); }
.tm-term__abbr { font-weight: 700; color: var(--sl-brand); }
.tm-term__name { color: var(--sl-text-2); }
.tm-term dd { margin: 2px 0 0; font-size: var(--sl-fs-4); line-height: var(--sl-lh-4); }
.tm-eeg {
  display: block;
  width: 100%;
  margin: var(--sl-space-2) 0 0;
  padding: 0;
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius-md);
  background: var(--sl-surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
.tm-eeg:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.tm-eeg__canvas { display: block; width: 100%; height: 104px; }
.tm-eeg[data-rows="2"] .tm-eeg__canvas { height: 150px; }
.tm-eeg[data-rows="3"] .tm-eeg__canvas { height: 196px; }
.tm-eeg__note {
  display: block;
  padding: var(--sl-space-1) var(--sl-space-2) var(--sl-space-2);
  font-size: var(--sl-fs-2);
  line-height: var(--sl-lh-3);
  color: var(--sl-text-2);
}
.tm-eeg__more { color: var(--sl-link); white-space: nowrap; }
.tm-eeg__row { display: flex; align-items: center; gap: var(--sl-space-1); padding-left: var(--sl-space-2); }
.tm-eeg__row .tm-eeg__canvas { flex: 1 1 auto; min-width: 0; }
.tm-headmap { flex: 0 0 auto; width: 72px; height: 76px; }
.tm-headmap__outline { fill: none; stroke: var(--sl-text-3); stroke-width: .05; }
.tm-headmap__dot { fill: var(--sl-text-3); }
.tm-headmap__chain { stroke: var(--sl-text-1); stroke-width: .07; stroke-linecap: round; }
.tm-headmap__side { fill: var(--sl-text-2); font-weight: 700; font-family: system-ui, sans-serif; text-anchor: middle; }
.tm-headmap__breach { fill: var(--sl-cursor); fill-opacity: .28; stroke: var(--sl-cursor); stroke-width: .05; }

.tm-full {
  position: fixed;
  inset: 0;
  z-index: calc(var(--sl-z-dialog) + 1);
  display: flex;
  flex-direction: column;
  gap: var(--sl-space-2);
  padding: calc(var(--tm-pad-top) + var(--sl-space-2)) var(--tm-pad-right)
    calc(var(--tm-pad-bottom) + var(--sl-space-2)) var(--tm-pad-left);
  box-sizing: border-box;
  background: var(--sl-surface);
  color: var(--sl-text-1);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  cursor: pointer;
}
.tm-full[hidden] { display: none; }
.tm-full__state { margin: 0; font-size: var(--sl-fs-2); font-weight: 600; color: var(--sl-brand); }
.tm-full__head { display: flex; align-items: flex-start; gap: var(--sl-space-2); }
.tm-full__title { flex: 1; margin: 0; font-size: var(--sl-fs-4); line-height: var(--sl-lh-3); }
.tm-full__close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius-pill);
  background: var(--sl-surface);
  color: var(--sl-text-2);
  font: inherit;
  font-size: var(--sl-fs-5);
  line-height: 1;
  cursor: pointer;
}
.tm-full__close:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.tm-full__eeg { flex: 1; min-height: 0; width: 100%; }
.tm-full__note { margin: 0; font-size: var(--sl-fs-1); color: var(--sl-text-3); }

.tm-about { margin: 0 0 var(--sl-space-3); font-size: var(--sl-fs-4); line-height: var(--sl-lh-4); }
.tm-about--cite { font-size: var(--sl-fs-2); color: var(--sl-text-2); }
.tm-about a { color: var(--sl-link); }

@media (prefers-reduced-motion: reduce) {
  .tm-front, .tm-square { transition: none; }
}
