/* ==========================================================================
 * g100-trace.css · Goal100 Learning · Trace & Write Studio · tracing pad
 * Styles for the widget made by g100-trace.js (class prefix .g100t-).
 * Uses the Goal100 brand tokens with fallbacks, light and dark, and respects
 * reduced motion. touch-action:none is set on the canvas ONLY, so the page
 * still scrolls everywhere else.
 * ========================================================================== */
.g100t, .g100t-modal-box {
  --g100t-ink: var(--g100-ink, #1b1d33);
  --g100t-bg: var(--g100-bg, #f5f6fb);
  --g100t-card: var(--g100-card, #ffffff);
  --g100t-line: var(--g100-line, #dfe2ef);
  --g100t-muted: var(--g100-muted, #5d6280);
  --g100t-accent: var(--g100-accent, #4338ca);
  --g100t-on-accent: #ffffff;
  --g100t-done: var(--g100-done, #15803d);
  --g100t-gold: var(--g100-gold, #b7791f);
  --g100t-paper: #ffffff;
  --g100t-line-top: #7c9be8;
  --g100t-line-mid: #7c9be8;
  --g100t-line-base: #d6455a;
  --g100t-line-desc: #c9cee3;
  --g100t-track: #e7e9f6;
  --g100t-dots: #70779a;
  --g100t-start: #15803d;
  --g100t-badge: #1b1d33;
  --g100t-badge-text: #ffffff;
}
.g100t {
  color: var(--g100t-ink);
  font-family: var(--g100-font, "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif);
  font-size: 18px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
@media (prefers-color-scheme: dark) {
  .g100t, .g100t-modal-box {
    --g100t-ink: var(--g100-ink, #e8eaf6);
    --g100t-bg: var(--g100-bg, #11131f);
    --g100t-card: var(--g100-card, #1a1d2e);
    --g100t-line: var(--g100-line, #2c3047);
    --g100t-muted: var(--g100-muted, #aab0cf);
    --g100t-accent: var(--g100-accent, #a5b4fc);
    --g100t-on-accent: #11131f;
    --g100t-done: var(--g100-done, #4ade80);
    --g100t-gold: var(--g100-gold, #f6c560);
    --g100t-paper: #1a1d2e;
    --g100t-line-top: #5b6ea8;
    --g100t-line-mid: #5b6ea8;
    --g100t-line-base: #f08a8a;
    --g100t-line-desc: #3a3f5c;
    --g100t-track: #2a2e45;
    --g100t-dots: #9aa1c6;
    --g100t-start: #4ade80;
    --g100t-badge: #e8eaf6;
    --g100t-badge-text: #11131f;
  }
}
.g100t *, .g100t *::before, .g100t *::after { box-sizing: border-box; }
.g100t [hidden] { display: none !important; }

/* header: big letter, name, Listen */
.g100t-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.g100t-big {
  flex: 0 0 auto; width: 60px; height: 60px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--g100t-accent); color: var(--g100t-on-accent);
  font-family: var(--g100-display, "Fraunces", Georgia, serif); font-size: 34px; font-weight: 700; line-height: 1;
}
.g100t-big.g100t-cur { font-style: italic; }
.g100t-ttl { flex: 1 1 auto; min-width: 0; }
.g100t-name { margin: 0; font-family: var(--g100-display, "Fraunces", Georgia, serif); font-size: 24px; line-height: 1.15; font-weight: 700; overflow-wrap: anywhere; }
.g100t-sub { margin: 2px 0 0; color: var(--g100t-muted); font-size: 17px; }
.g100t-listen { display: flex; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }

/* buttons */
.g100t-btn {
  font: inherit; font-weight: 700; color: var(--g100t-ink);
  min-height: 48px; min-width: 48px; padding: 10px 16px; border-radius: 14px;
  border: 2px solid var(--g100t-line); background: var(--g100t-card);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}
.g100t-btn:hover { border-color: var(--g100t-accent); }
.g100t-btn:active { transform: translateY(1px); }
.g100t-btn:focus-visible, .g100t-cv:focus-visible { outline: 3px solid var(--g100t-accent); outline-offset: 3px; }
.g100t-btn:disabled { opacity: .55; cursor: default; }
.g100t-mini { padding: 8px 12px; font-size: 16px; }
.g100t-main {
  width: 100%; min-height: 60px; font-size: 21px; border-color: var(--g100t-accent);
  background: var(--g100t-accent); color: var(--g100t-on-accent);
  box-shadow: 0 4px 0 rgba(27, 29, 51, .22);
}
.g100t-main:hover { filter: brightness(1.06); }
.g100t-sec { font-size: 16px; flex: 1 1 auto; }

/* 1-2-3 steps */
.g100t-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.g100t-step { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; min-width: 0; font-size: 17px; }
.g100t-stepn {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; font-size: 14px; line-height: 24px; text-align: center;
  background: var(--g100t-line); color: var(--g100t-ink);
}
.g100t-stept { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g100t-step[aria-pressed="true"] { background: var(--g100t-accent); border-color: var(--g100t-accent); color: var(--g100t-on-accent); }
.g100t-step[aria-pressed="true"] .g100t-stepn { background: var(--g100t-on-accent); color: var(--g100t-accent); }

/* a picture (Shape builder) has no Write step */
.g100t[data-kind="picture"] .g100t-step[data-step="write"] { display: none; }
.g100t[data-kind="picture"] .g100t-steps { grid-template-columns: repeat(2, 1fr); }

/* stage: pad + side panel */
.g100t-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.g100t-pad {
  position: relative; height: clamp(280px, 50vh, 560px); border-radius: 14px; overflow: hidden;
  background: var(--g100t-paper); border: 2px solid var(--g100t-line);
  box-shadow: 0 6px 18px rgba(27, 29, 51, .08);
}
.g100t-cv { display: block; width: 100%; height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.g100t[data-step="watch"] .g100t-cv { cursor: default; }
.g100t-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.g100t-cap {
  margin: 0; min-height: 56px; padding: 10px 14px; border-radius: 14px; font-size: 19px; font-weight: 700;
  background: var(--g100t-card); border: 2px dashed var(--g100t-line);
}
.g100t-cap:empty { display: none; }
.g100t-row { display: flex; flex-wrap: wrap; gap: 8px; }
.g100t-note { margin: 0; min-height: 0; color: var(--g100t-muted); font-size: 16px; }
.g100t-note:empty { display: none; }

/* result */
.g100t-res { padding: 12px 14px; border-radius: 14px; background: var(--g100t-card); border: 2px solid var(--g100t-line); text-align: center; }
.g100t-stars { font-size: 44px; line-height: 1; letter-spacing: 6px; color: var(--g100t-muted); }
.g100t-star.on { color: var(--g100t-gold); }
.g100t-star.on.gold { text-shadow: 0 0 14px rgba(246, 197, 96, .9); }
.g100t-msg { margin: 8px 0 0; font-size: 21px; font-weight: 700; }
.g100t-tip { margin: 6px 0 0; font-size: 18px; }
.g100t-goal { margin: 6px 0 0; font-size: 16px; color: var(--g100t-muted); }

@media (min-width: 820px) {
  .g100t-stage { grid-template-columns: minmax(0, 1fr) 310px; align-items: start; }
  .g100t-pad { height: clamp(320px, calc(100vh - 290px), 600px); height: clamp(320px, calc(100dvh - 290px), 600px); }
  .g100t[data-hand="left"] .g100t-stage { grid-template-columns: 310px minmax(0, 1fr); }
  .g100t[data-hand="left"] .g100t-side { order: -1; }
  .g100t-sec { flex: 1 1 100%; }
}
/* left-hand mode: controls move to the left so the writing hand does not cover them */
.g100t[data-hand="left"] .g100t-head { flex-direction: row-reverse; }
.g100t[data-hand="left"] .g100t-listen { justify-content: flex-start; }
.g100t[data-hand="left"] .g100t-row { flex-direction: row-reverse; }

@media (max-width: 480px) {
  .g100t { font-size: 17px; }
  .g100t-big { display: none; }
  .g100t[data-kind="word"] .g100t-big, .g100t[data-kind="picture"] .g100t-big { display: flex; width: 48px; height: 48px; font-size: 26px; }
  .g100t-name { font-size: 21px; }
  .g100t-step { font-size: 15px; padding: 6px 4px; gap: 4px; }
  .g100t-stepi { display: none; }
  .g100t-mini { padding: 8px 10px; font-size: 15px; }
  .g100t-pad { height: clamp(260px, 46vh, 460px); }
}

/* dialog used by G100Trace.open() */
.g100t-modal { position: fixed; inset: 0; z-index: 2000; background: rgba(17, 19, 31, .62); display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 12px; }
.g100t-modal-box { width: min(1040px, 100%); background: var(--g100-bg, #f5f6fb); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.g100t-modal-box .g100t-x { align-self: flex-end; flex: 0 0 auto; }
@media (prefers-color-scheme: dark) { .g100t-modal-box { background: var(--g100-bg, #11131f); } }

@media (prefers-reduced-motion: reduce) {
  .g100t-btn { transition: none; }
}
@media (forced-colors: active) {
  .g100t-step[aria-pressed="true"] { outline: 3px solid Highlight; }
}
