/* ═══════════════════════════════════════════════════════════════════════════
   ems-toolhome.css: every tool page (assets/js/ems-toolhome.js) and the tools
   library under it (EMSKit.library).

   Tyler 11-08: "the tools need to feel branded and interactive ... unique
   with different colors depending on what type of thing they are ... some
   type of organization for colors ... even at the top it needs to carry that
   same branding".

   Every tool sets --tc (its OWN colour, EMSToolHome TOOL_COLOR, 11-09: one
   journey in shades of one colour read as copies), --tc-2 (a deeper shade)
   and --tj (its journey's colour, still on the journey label).
   Each journey also has its own surface pattern ([data-j], section 1), so a
   Translate tool reads as "A -> B", Prepare as ruled paper, Land as a target:
   the same family of shapes, never the same card twice.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. The journey patterns (hero, workspace head, library cards) ──────── */
[data-j] { --th-pat: repeating-linear-gradient(135deg, rgba(255, 255, 255, .08) 0 2px, transparent 2px 14px); --th-pat-size: auto; }
[data-j="start"] { --th-pat: repeating-linear-gradient(135deg, rgba(255, 255, 255, .09) 0 3px, transparent 3px 16px); }
[data-j="explore"] { --th-pat: radial-gradient(rgba(255, 255, 255, .26) 1.2px, transparent 1.4px); --th-pat-size: 16px 16px; }
[data-j="translate"] { --th-pat: linear-gradient(135deg, transparent 46%, rgba(255, 255, 255, .13) 46% 54%, transparent 54%), linear-gradient(45deg, transparent 46%, rgba(255, 255, 255, .13) 46% 54%, transparent 54%); --th-pat-size: 22px 44px; }
[data-j="prepare"] { --th-pat: repeating-linear-gradient(0deg, rgba(255, 255, 255, .10) 0 1px, transparent 1px 13px), linear-gradient(90deg, transparent 38px, rgba(255, 255, 255, .16) 38px 40px, transparent 40px); }
[data-j="land"] { --th-pat: repeating-radial-gradient(circle at 88% 50%, rgba(255, 255, 255, .13) 0 2px, transparent 2px 22px); }
[data-j="thrive"] { --th-pat: repeating-linear-gradient(90deg, rgba(255, 255, 255, .12) 0 10px, transparent 10px 22px); --th-pat-size: auto; }
[data-j="life"] { --th-pat: repeating-radial-gradient(circle at 50% 140%, transparent 0 14px, rgba(255, 255, 255, .12) 14px 16px); }
[data-j="mentoring"] { --th-pat: radial-gradient(circle at 30% 40%, rgba(255, 255, 255, .16) 0 9px, transparent 10px), radial-gradient(circle at 70% 60%, rgba(255, 255, 255, .10) 0 6px, transparent 7px); --th-pat-size: 40px 40px; }
[data-j="mentor"] { --th-pat: repeating-linear-gradient(45deg, rgba(255, 255, 255, .07) 0 1px, transparent 1px 10px), repeating-linear-gradient(-45deg, rgba(255, 255, 255, .07) 0 1px, transparent 1px 10px); }

/* ── 2. The hero: every tool page's head ────────────────────────────────── */
/* The plain title it replaces. */
body.is-toolpage .content > .topbar { display: none; }
#toolHero { position: relative; isolation: isolate; overflow: hidden; max-width: 1120px; margin: 0 auto 20px; border-radius: 22px; color: #fff;
  background: linear-gradient(118deg, var(--tc-2) 0%, var(--tc) 58%, color-mix(in srgb, var(--tc) 72%, #fff) 125%);
  box-shadow: 0 1px 2px rgba(14, 21, 71, .12), 0 18px 40px -22px color-mix(in srgb, var(--tc) 70%, transparent); }
#toolHero[hidden] { display: none; }
#toolHero::before { content: ""; position: absolute; inset: 0; z-index: -1; background-image: var(--th-pat); background-size: var(--th-pat-size); opacity: .9;
  -webkit-mask-image: linear-gradient(100deg, transparent 18%, #000 70%); mask-image: linear-gradient(100deg, transparent 18%, #000 70%); }
/* The brand: the flag's red and white along the foot. */
#toolHero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; z-index: 1;
  background: linear-gradient(90deg, var(--ems-red-500), var(--ems-red-500) 18%, rgba(190, 30, 45, 0) 62%); }
.th-art { position: absolute; right: -18px; top: 50%; z-index: -1; transform: translateY(-50%) rotate(-10deg); color: #fff; opacity: .12; pointer-events: none; }
.th-art svg { display: block; }
.th-in { display: flex; align-items: center; gap: 20px; padding: 26px 30px 28px; }
.th-in > .tb { flex: none; box-shadow: 0 0 0 4px rgba(255, 255, 255, .22), 0 10px 22px -10px rgba(0, 0, 0, .45); }
.th-id { min-width: 0; }
.th-k { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 6px; font: 600 12px/1.2 var(--ems-font-ui); letter-spacing: .07em; text-transform: uppercase; }
.th-j { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 999px; background: rgba(255, 255, 255, .17); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
.th-step { color: rgba(255, 255, 255, .78); }
.th-t { margin: 0; font: 800 30px/1.15 var(--ems-font-display); letter-spacing: -.015em; color: #fff; }
.th-p { margin: 8px 0 0; max-width: 70ch; font: 400 15.5px/1.55 var(--ems-font-body); color: rgba(255, 255, 255, .9); }

/* ── 3. The home: Start on the left, history on the right ───────────────── */
.th-home { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.th-card { position: relative; overflow: hidden; padding: 24px 26px 26px; border-radius: 20px; background: var(--ems-surface); box-shadow: var(--ems-lift); }
.th-card-band { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, var(--tc-2), var(--tc)); }
.th-card-k { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 8px; font: 700 12px/1.2 var(--ems-font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--tc); }
.th-card-t { margin: 0; font: 800 23px/1.2 var(--ems-font-display); color: var(--ems-navy-800); }
.th-card-l { margin: 8px 0 0; max-width: 54ch; color: var(--ems-mute); font-size: 15px; line-height: 1.55; }
.th-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 20px 0 22px; }
.th-acts .primary.th-go { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--tc); color: #fff;
  font: 700 15.5px/1 var(--ems-font-ui); box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--tc) 85%, transparent); transition: transform var(--ems-dur) var(--ems-ease-out), box-shadow var(--ems-dur), background var(--ems-dur); }
.th-acts .primary.th-go:hover { background: var(--tc-2); transform: translateY(-1px); box-shadow: 0 14px 26px -12px color-mix(in srgb, var(--tc) 90%, transparent); }
.th-acts .primary.th-go svg { transition: transform var(--ems-dur) var(--ems-ease-out); }
.th-acts .primary.th-go:hover svg { transform: translateX(3px); }
.th-acts .th-new { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; border-radius: 999px; }
.th-done { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.th-done li { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border-radius: 12px; background: var(--ems-soft); font-size: 14px; line-height: 1.4; min-width: 0; }
.th-done b { flex: none; font: 600 13px/1.4 var(--ems-font-ui); color: var(--ems-navy-700); }
.th-done span { min-width: 0; color: var(--ems-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The steps, as a path: what the walk-through will ask. */
.th-path { list-style: none; margin: 0; padding: 16px 0 0; border-top: 1px solid var(--ems-line); display: flex; flex-wrap: wrap; gap: 8px 6px; counter-reset: none; }
.th-path li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--ems-soft); font: 600 13px/1.2 var(--ems-font-ui); color: var(--ems-ink-2); }
.th-path li + li::before { content: ""; width: 10px; height: 2px; margin-left: -10px; margin-right: 2px; background: var(--ems-line-2); border-radius: 2px; }
.th-path-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--tc); font: 700 12px/1 var(--ems-font-ui); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tc) 45%, #fff); }
.th-path li.is-done .th-path-n { background: var(--tc); color: #fff; box-shadow: none; }
.th-path li.is-here { background: color-mix(in srgb, var(--tc) 11%, #fff); color: var(--tc-2); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tc) 40%, #fff); }
/* History */
.th-hist-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.th-hist-h h2 { margin: 0; font: 800 18px/1.3 var(--ems-font-display); color: var(--ems-navy-800); }
.th-count { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--tc) 12%, #fff); color: var(--tc-2); font: 700 12.5px/1 var(--ems-font-ui); }
.th-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.th-item { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 12px; border-radius: 14px; background: var(--ems-soft); cursor: pointer;
  transition: background var(--ems-dur), transform var(--ems-dur) var(--ems-ease-out), box-shadow var(--ems-dur); }
.th-item:hover, .th-item:focus-visible { background: #fff; transform: translateY(-1px); box-shadow: var(--ems-lift-hover), inset 0 0 0 1.5px color-mix(in srgb, var(--tc) 35%, #fff); }
.th-item:focus-visible { outline: 2px solid var(--tc); outline-offset: 2px; }
.th-item-ic { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: color-mix(in srgb, var(--tc) 13%, #fff); color: var(--tc); }
.th-item-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.th-item-t b { font: 600 14.5px/1.3 var(--ems-font-ui); color: var(--ems-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-item-t small { font: 500 12.5px/1.3 var(--ems-font-ui); color: var(--ems-mute-2); }
.th-item-s { margin-top: 3px; font-size: 13.5px; line-height: 1.45; color: var(--ems-mute); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.th-item-go { flex: none; align-self: center; color: var(--ems-faint); transition: transform var(--ems-dur) var(--ems-ease-out), color var(--ems-dur); }
.th-item:hover .th-item-go { color: var(--tc); transform: translateX(3px); }
.th-more { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font: 600 14px/1 var(--ems-font-ui); color: var(--tc-2); text-decoration: none; }
.th-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 18px; border-radius: 16px; border: 1.5px dashed var(--ems-line-2); color: var(--ems-mute); }
.th-empty-ic { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--tc) 11%, #fff); color: var(--tc); margin-bottom: 4px; }
.th-empty b { font: 700 15px/1.3 var(--ems-font-ui); color: var(--ems-navy-800); }
.th-empty p { margin: 0; max-width: 36ch; font-size: 14px; line-height: 1.5; }

/* ── 4. The workspace: near-full-screen, the page blurred behind ─────────── */
body.ths-open { overflow: hidden; }
.ths { position: fixed; inset: 0; z-index: 9000; }
.ths[hidden] { display: none; }
.ths-scrim { position: absolute; inset: 0; background: rgba(14, 21, 71, .34); -webkit-backdrop-filter: blur(7px) saturate(1.05); backdrop-filter: blur(7px) saturate(1.05); }
.ths-panel { position: absolute; top: 18px; bottom: 18px; left: 50%; width: min(1480px, calc(100% - 44px)); transform: translateX(-50%); display: flex; flex-direction: column; overflow: hidden;
  border-radius: 22px; background: var(--ems-canvas); box-shadow: 0 30px 80px -20px rgba(14, 21, 71, .55), 0 0 0 1px rgba(255, 255, 255, .5); }
.ths-head { position: relative; isolation: isolate; flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px; color: #fff;
  background: linear-gradient(110deg, var(--tc-2), var(--tc) 70%); }
.ths-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--ems-red-500), var(--ems-red-500) 14%, rgba(190, 30, 45, 0) 50%); }
.ths-art { position: absolute; inset: 0; z-index: -1; background-image: var(--th-pat); background-size: var(--th-pat-size); opacity: .8;
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 85%); mask-image: linear-gradient(90deg, transparent 30%, #000 85%); }
.ths-logo { flex: none; height: 40px; width: auto; padding: 4px 10px; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.ths-tb .tb { display: grid; box-shadow: 0 0 0 3px rgba(255, 255, 255, .22); }
.ths-names { flex: 1; min-width: 0; }
.ths-where { display: block; font: 600 11.5px/1.2 var(--ems-font-ui); letter-spacing: .07em; text-transform: uppercase; color: rgba(255, 255, 255, .8); }
.ths-title { margin: 2px 0 0; font: 800 20px/1.2 var(--ems-font-display); color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ths-save { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .15); font: 600 12.5px/1 var(--ems-font-ui); color: rgba(255, 255, 255, .92); }
.ths-save[hidden] { display: none; }
.ths-x { flex: none; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; transition: background var(--ems-dur), transform var(--ems-dur) var(--ems-ease-out); }
.ths-x:hover { background: rgba(255, 255, 255, .28); transform: rotate(90deg); }
.ths-x:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ths-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 26px 30px 48px; }
.ths-body { max-width: 1280px; margin: 0 auto; }
/* The tool's own colour, all the way in (Tyler 11-09: "after you press Start
   and you're actually inside of the tool, the colors aren't super basic ...
   they have their own uniqueness"). The kit and every tool are written in the
   app's navy tokens, so the workspace re-points those tokens at --tc (the
   tool's colour, EMSToolHome TOOL_COLOR): the step pills, numbers, buttons,
   chips, pickers, the preview's headings and the canvas all wear the tool,
   with no tool's own CSS touched. Red (needs you) and green (done) stay. */
.ths[data-tool], .th-home {
  --ems-navy-50: color-mix(in srgb, var(--tc) 8%, #fff);
  --ems-navy-100: color-mix(in srgb, var(--tc) 15%, #fff);
  --ems-navy-200: color-mix(in srgb, var(--tc) 28%, #fff);
  --ems-navy-300: color-mix(in srgb, var(--tc) 48%, #fff);
  --ems-navy-400: color-mix(in srgb, var(--tc) 76%, #fff);
  --ems-navy-500: var(--tc);
  --ems-navy-600: color-mix(in srgb, var(--tc) 88%, #0e1547);
  --ems-navy-700: color-mix(in srgb, var(--tc) 74%, #0e1547);
  --ems-navy-800: color-mix(in srgb, var(--tc) 48%, #10142c);
  --ems-navy-900: color-mix(in srgb, var(--tc) 30%, #0b0f22);
  --ems-canvas: color-mix(in srgb, var(--tc) 9%, #eceff5);
  --ems-soft: color-mix(in srgb, var(--tc) 4%, #f5f6fa);
  --ems-soft-2: color-mix(in srgb, var(--tc) 9%, #edf0f6);
  --ems-focus: 0 0 0 4px color-mix(in srgb, var(--tc) 24%, transparent);
}
.ths[data-tool] button.primary, .ths[data-tool] a.primary { box-shadow: 0 1px 2px rgba(14, 21, 71, .18), 0 8px 18px -8px color-mix(in srgb, var(--tc) 70%, transparent); }
/* The open step carries the tool's band, like its home card. */
.ths[data-tool] .ek-sec.is-open { box-shadow: inset 0 4px 0 var(--tc), var(--ems-raise); }
.ths[data-tool] .ek-pill.is-here { box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--tc) 85%, transparent); }
/* The tool's own mark, large and faint, at the head's right (like the hero). */
.ths-art .ths-mark { position: absolute; right: 120px; top: 50%; transform: translateY(-50%) rotate(-10deg); color: #fff; opacity: .16; }
.ths-art .ths-mark svg { display: block; }
@media (max-width: 760px) { .ths-art .ths-mark { right: 56px; } }
/* The kit inside: the workspace head already names the tool. */
.ths .ek-id > .ek-plate, .ths .ek-k > span:first-child, .ths .ek-k > span[aria-hidden], .ths .ek-purpose { display: none; }
@media (min-width: 1100px) {
  .ths .ek-head { top: -26px; }
  .ths .ek .ek-side { top: 130px; max-height: calc(100vh - 230px); }
}
.ths.is-in .ths-scrim { animation: thsFade .28s ease-out both; }
.ths.is-in .ths-panel { animation: thsIn .36s var(--ems-ease-out) both; }
.ths.is-out .ths-scrim { animation: thsFade .2s ease-in reverse both; }
.ths.is-out .ths-panel { animation: thsOut .2s ease-in both; }
@keyframes thsFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes thsIn { from { opacity: 0; transform: translateX(-50%) translateY(22px) scale(.985); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes thsOut { to { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.99); } }
/* Toasts and the feedback tools sit above it. */
body.ths-open .toast { z-index: 10070; }
/* A saved version, to read again. */
.thv { max-width: 920px; margin: 0 auto; }
.thv-h { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.thv-k { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 4px; font: 700 12px/1.2 var(--ems-font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--tc); }
.thv-t { margin: 0; font: 800 24px/1.2 var(--ems-font-display); color: var(--ems-navy-800); }
.thv-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.thv-acts button { display: inline-flex; align-items: center; gap: 6px; }
.thv-acts .primary { background: var(--tc); border-color: var(--tc); }
.thv-del:hover { color: var(--ems-red-600); }
.thv-confirm { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--ems-red-50); color: var(--ems-red-700); }
.thv-confirm[hidden] { display: none; }
.thv-confirm span { display: flex; gap: 8px; }
.thv-confirm .thv-yes { background: var(--ems-red-500); border-color: var(--ems-red-500); }
.thv-doc .ek-paper { box-shadow: var(--ems-lift); }

/* ── 5. Narrow screens ──────────────────────────────────────────────────── */
@media (max-width: 899px) {
  .th-home { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  #toolHero { border-radius: 18px; margin-bottom: 14px; }
  .th-in { padding: 20px 18px 22px; gap: 14px; align-items: flex-start; }
  .th-in > .tb { --tb-s: 48px !important; }
  .th-t { font-size: 24px; }
  .th-p { font-size: 14.5px; }
  .th-art { opacity: .08; }
  .th-card { padding: 20px 18px 20px; }
  .th-card-t { font-size: 20px; }
  .th-acts .primary.th-go, .th-acts .th-new { flex: 1 1 auto; justify-content: center; }
  .ths-panel { top: 0; bottom: 0; width: 100%; border-radius: 0; }
  .ths-head { gap: 10px; padding: 10px 10px 10px 12px; }
  .ths-logo, .ths-save { display: none; }
  .ths-title { font-size: 17px; }
  .ths-scroll { padding: 18px 14px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .ths.is-in .ths-panel, .ths.is-in .ths-scrim, .ths.is-out .ths-panel, .ths.is-out .ths-scrim { animation: none; }
  .th-item:hover, .ths-x:hover { transform: none; }
}
