/* The family app shell (RM839) - js/apps/shared/shell.js, about.js, linkui.js.
 *
 * Graphite, exactly as DESIGN.md has it for the Player: every value is a token from css/tokens.css; radius 0; no
 * shadow, blur, glow or gradient; Spectral reads, IBM Plex Sans operates, IBM Plex Mono measures; the accent is spent
 * once per view (each app decides what that one thing is - the Player's is the open record). 44px touch targets,
 * 14px functional text floor (--t-ui), the page gutter is never zero (slop G4).
 *
 * FROZEN for the fan-out like the JS: an app adds css/apps/<app>.css after this file and overrides there. */

:root {
  --tf-top-h: 92px;           /* banner 36 + title row 56 */
  --tf-tabs-h: 58px;
  --tf-safe-t: env(safe-area-inset-top, 0px);
  --tf-safe-b: env(safe-area-inset-bottom, 0px);
  --tf-gutter: var(--s-4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body.tf-app {
  background: var(--aa-ground); color: var(--aa-ink-body);
  font-family: var(--aa-operate); font-size: var(--t-ui); line-height: 1.5;
}
[hidden] { display: none !important; }

/* ---------------- masthead ---------------- */
.tf-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding: var(--tf-safe-t) var(--tf-gutter) 0;
  background: var(--aa-sheet); border-bottom: 1px solid var(--aa-rule);
}
.tf-banner {
  height: 36px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--aa-hairline);
}
.tf-word { font-family: var(--aa-read); font-weight: 600; font-size: var(--t-ui); color: var(--aa-ink); letter-spacing: .01em; }
.tf-tag { font-family: var(--aa-measure); font-size: var(--t-meta); letter-spacing: .12em; color: var(--aa-ink-muted); }
.tf-topbar { min-height: 56px; display: flex; align-items: center; gap: var(--s-3); }
.tf-title {
  margin: 0; flex: 1 1 auto; min-width: 0;
  font-family: var(--aa-read); font-weight: 400; font-size: var(--t-4); color: var(--aa-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tf-actions { display: flex; gap: var(--s-2); flex: 0 0 auto; }
.tf-actions .tf-btn { min-height: 40px; padding: var(--s-1) var(--s-3); }

/* ---------------- panes and the thumb index ---------------- */
.tf-panes {
  position: fixed; left: 0; right: 0;
  top: calc(var(--tf-top-h) + var(--tf-safe-t));
  bottom: calc(var(--tf-tabs-h) + var(--tf-safe-b));
  background: var(--aa-ground);
}
.tf-no-tabs .tf-panes { bottom: var(--tf-safe-b); }
.tf-pane {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--s-4) var(--tf-gutter) var(--s-8);
}
.tf-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tf-tabs-h) + var(--tf-safe-b)); padding-bottom: var(--tf-safe-b);
  display: flex; background: var(--aa-sheet); border-top: 1px solid var(--aa-rule);
}
.tf-tab {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: none; border: none; border-top: 2px solid transparent; border-radius: 0;
  color: var(--aa-ink-muted); font-family: var(--aa-operate); font-size: var(--t-meta); padding: 0 2px;
  cursor: pointer; min-height: 44px;
  transition: color var(--aa-dur-state) var(--aa-ease), border-color var(--aa-dur-state) var(--aa-ease);
}
.tf-tab .tf-ti { display: flex; font-size: var(--t-4); line-height: 1; }
.tf-tab .tf-ti svg { width: 22px; height: 22px; }
.tf-tab .tf-tl { font-family: var(--aa-read); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tf-tab:hover { color: var(--aa-ink); }
.tf-tab.active { color: var(--aa-ink); border-top-color: var(--aa-rule); background: var(--aa-recess); }
@media (min-width: 600px) {
  .tf-tab { flex-direction: row; gap: var(--s-2); font-size: var(--t-ui); }
}

/* ---------------- controls (brand 6.4) ---------------- */
.tf-btn, .tf-app button {
  background: none; color: var(--aa-ink);
  border: 1px solid var(--aa-rule); border-radius: 0;
  padding: var(--s-2) var(--s-4); min-height: 44px;
  font-family: var(--aa-operate); font-size: var(--t-ui); font-weight: 500; line-height: 1.2;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  transition: background var(--aa-dur-state) var(--aa-ease), border-color var(--aa-dur-state) var(--aa-ease),
              color var(--aa-dur-state) var(--aa-ease);
}
.tf-app .tf-tab { border: none; border-top: 2px solid transparent; padding: 0 2px; }   /* the generic button padding out-ranks .tf-tab and squeezed labels (RM842 found it) */
.tf-app .tf-tab.active { border-top-color: var(--aa-rule); }
.tf-btn:hover, .tf-app button:hover { border-color: var(--aa-ink); }
.tf-btn:active, .tf-app button:active { background: var(--aa-recess); }
.tf-btn:disabled, .tf-app button:disabled { opacity: .45; cursor: not-allowed; }
/* primary: filled ink, never the accent (the accent belongs to the one thing each view marks) */
.tf-btn.primary { background: var(--aa-ink); color: var(--aa-ground); border-color: var(--aa-ink); }
.tf-btn.primary:hover { background: var(--aa-ink-body); border-color: var(--aa-ink-body); }
.tf-btn.danger { border-color: var(--aa-warn); color: var(--aa-warn); }
.tf-btn.quiet { border-color: transparent; color: var(--aa-ink-muted); }
.tf-btn.block { width: 100%; }

.tf-input, .tf-app input[type=text], .tf-app input[type=number], .tf-app input[type=search], .tf-app select,
.tf-app textarea {
  background: var(--aa-recess); color: var(--aa-ink); border: 1px solid var(--aa-rule); border-radius: 0;
  font-family: var(--aa-operate); font-size: var(--t-body); padding: var(--s-2) var(--s-3); min-height: 44px;
  width: 100%;
}
.tf-app textarea { line-height: 1.45; resize: vertical; }
.tf-paste { font-family: var(--aa-measure); font-size: var(--t-ui); }
.tf-label { display: block; margin: var(--s-4) 0 var(--s-1); color: var(--aa-ink-muted); font-size: var(--t-ui); }

/* ---------------- text ---------------- */
.tf-prose { font-family: var(--aa-read); font-size: var(--t-body); color: var(--aa-ink-body); line-height: 1.55; max-width: var(--aa-prose); margin: 0 0 var(--s-3); }
.tf-h2 { font-family: var(--aa-read); font-weight: 400; font-size: var(--t-3); color: var(--aa-ink); margin: var(--s-5) 0 var(--s-2); }
.tf-h3 { font-family: var(--aa-read); font-weight: 600; font-size: var(--t-body); color: var(--aa-ink); margin: var(--s-5) 0 var(--s-2); }
.tf-meta { font-family: var(--aa-measure); font-size: var(--t-meta); letter-spacing: .06em; color: var(--aa-ink-muted); margin: 0 0 var(--s-2); }
.tf-small { font-size: var(--t-ui); color: var(--aa-ink-muted); line-height: 1.5; margin: 0 0 var(--s-3); }
.tf-num { font-family: var(--aa-measure); font-variant-numeric: tabular-nums; }
.tf-alert { border-left: 2px solid var(--aa-warn); padding: var(--s-2) var(--s-3); color: var(--aa-warn); margin: var(--s-3) 0 0; }
.tf-empty { border: 1px dashed var(--aa-rule); padding: var(--s-5) var(--s-4); color: var(--aa-ink-muted); text-align: left; }
.tf-empty .tf-prose { color: var(--aa-ink-body); }

/* ---------------- layout helpers ---------------- */
.tf-row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; margin: var(--s-3) 0; }
.tf-row-end { justify-content: flex-end; }
.tf-stack { display: flex; flex-direction: column; gap: var(--s-2); }
.tf-stack > .tf-btn { justify-content: flex-start; }
.tf-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
/* a ruled roster (the Ledger register): rows separated by hairlines, no cards with shadows */
.tf-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--aa-hairline); }
.tf-list > li { border-bottom: 1px solid var(--aa-hairline); padding: var(--s-3) 0; display: flex; gap: var(--s-3); align-items: center; }
.tf-card { background: var(--aa-sheet); border: 1px solid var(--aa-hairline); padding: var(--s-4); margin: 0 0 var(--s-3); }

/* ---------------- sheets ---------------- */
.tf-sheet-host { position: fixed; inset: 0; z-index: 80; display: none; }
.tf-sheet-host.open { display: block; }
.tf-sheet-wrap { position: absolute; inset: 0; }
.tf-sheet-back { position: absolute; inset: 0; background: var(--aa-recess); opacity: .84; }
.tf-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88%;
  display: flex; flex-direction: column;
  background: var(--aa-sheet); border-top: 1px solid var(--aa-rule);
  padding-bottom: var(--tf-safe-b);
}
@media (min-width: 720px) {
  .tf-sheet { left: 50%; right: auto; width: 560px; transform: translateX(-50%); top: 6%; bottom: auto; max-height: 88%;
              border: 1px solid var(--aa-rule); }
  .tf-sheet.wide { width: 720px; }
}
.tf-sheet-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--tf-gutter); border-bottom: 1px solid var(--aa-hairline); }
.tf-sheet-title { margin: 0; flex: 1 1 auto; font-family: var(--aa-read); font-weight: 400; font-size: var(--t-4); color: var(--aa-ink); }
.tf-app .tf-sheet-x { min-width: 44px; padding: 0; border-color: transparent; }
.tf-sheet-x svg { width: 20px; height: 20px; }
.tf-sheet-body { overflow-y: auto; padding: var(--s-4) var(--tf-gutter) var(--s-5); }

/* ---------------- toast ---------------- */
#tfToast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 90;
  bottom: calc(var(--tf-tabs-h) + var(--tf-safe-b) + var(--s-5));
  max-width: calc(100vw - 32px); width: max-content;
  background: var(--aa-sheet); border: 1px solid var(--aa-rule); color: var(--aa-ink);
  padding: var(--s-2) var(--s-3); display: none; align-items: center; gap: var(--s-2);
  pointer-events: none; overflow-wrap: break-word;
}
#tfToast::before { content: ''; flex: 0 0 auto; width: 8px; height: 12px; background: var(--aa-ink); }
#tfToast.show { display: flex; }
#tfToast.warn, #tfToast.bad { border-color: var(--aa-warn); color: var(--aa-warn); }
#tfToast.warn::before, #tfToast.bad::before { background: var(--aa-warn); }
#tfToast.ok::before { background: var(--aa-ok); }

/* ---------------- the family list (About) ---------------- */
.tf-family { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--aa-hairline); }
.tf-family-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--aa-hairline); }
.tf-family-text { flex: 1 1 auto; min-width: 0; }
.tf-family-name { font-family: var(--aa-read); font-weight: 600; color: var(--aa-ink); }
.tf-family-tag { color: var(--aa-ink-muted); font-size: var(--t-ui); }
.tf-family-go { flex: 0 0 auto; white-space: nowrap; }

/* ---------------- boot screen (inline-styled in each index.html; removed by mountShell) ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
