/* Te Mātāwai Reo Interactives — component styles. Every colour, space, radius and shadow is a token from tokens.json. */
.tm-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tm-icon { flex: none; display: block; }
[class^="tm-"], [class*=" tm-"] { box-sizing: border-box; font-family: var(--font-sans); }
.tm-btn:focus-visible, .tm-tile:focus-visible, .tm-choice:focus-visible, .tm-listen:focus-visible, .tm-mic:focus-visible,
.tm-macrons__key:focus-visible, .tm-typed__input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Button */
.tm-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--size-touch); padding: 0 var(--space-5); border-radius: var(--radius-md); border: 2px solid transparent; font-size: 17px; line-height: 24px; font-weight: 500; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease; }
.tm-btn--lg { min-height: 56px; padding: 0 var(--space-6); font-size: 20px; }
.tm-btn--primary { background: var(--primary); color: var(--on-primary); }
.tm-btn--accent { background: var(--accent); color: var(--on-accent); }
.tm-btn--secondary { background: var(--surface-raised); color: var(--text); border-color: var(--line-control); }
.tm-btn--ghost { background: none; color: var(--text); padding: 0 var(--space-3); }
.tm-btn--ghost:hover:not(:disabled) { background: var(--surface-muted); }
.tm-btn:hover:not(:disabled) { box-shadow: var(--shadow-tile); }
.tm-btn:active:not(:disabled) { transform: translateY(1px); }
.tm-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ListenButton */
.tm-listen { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--size-touch); padding: 0 var(--space-4) 0 var(--space-3); border-radius: var(--radius-pill); border: 2px solid var(--line-control); background: var(--surface-raised); color: var(--text); font-size: 15px; font-weight: 500; cursor: pointer; }
.tm-listen--compact { padding: 0; width: var(--size-touch); justify-content: center; }
.tm-listen.is-playing { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* RoleTag */
.tm-role { display: inline-flex; align-items: center; padding: 2px var(--space-2); border-radius: var(--radius-sm); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .04em; white-space: nowrap; }
.tm-role--tense { background: var(--role-tense); color: var(--white); }
.tm-role--verb { background: var(--role-verb); color: var(--white); }
.tm-role--subject { background: var(--role-subject); color: var(--white); }
.tm-role--object { background: var(--role-object); color: var(--dark-blue); }
.tm-role--place { background: var(--role-place); color: var(--dark-blue); }
.tm-role--particle { background: var(--role-particle); color: var(--white); }

/* KupuTile */
.tm-tile { position: relative; display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: var(--space-1); min-height: var(--size-tile); min-width: var(--size-tile); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--line); background: var(--tile); color: var(--on-tile); box-shadow: var(--shadow-tile); cursor: pointer; text-align: left; transition: transform .12s ease, box-shadow .12s ease; }
.tm-tile:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.tm-tile__kupu { font-size: 22px; line-height: 28px; font-weight: 500; }
.tm-tile__gloss { font-size: 13px; line-height: 18px; font-style: italic; color: var(--on-tile); opacity: .75; }
.tm-tile--selected { border-color: var(--focus); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.tm-tile--placed { box-shadow: none; }
.tm-tile--correct { background: var(--correct); color: var(--on-correct); border-color: var(--correct); box-shadow: none; padding-right: var(--space-6); }
.tm-tile--incorrect { background: var(--incorrect); color: var(--on-incorrect); border-color: var(--incorrect); box-shadow: none; padding-right: var(--space-6); }
.tm-tile__state { position: absolute; top: 6px; right: 6px; }
.tm-tile--disabled, .tm-tile:disabled { background: var(--surface-muted); color: var(--text-muted); border-style: dashed; border-color: var(--line-control); box-shadow: none; cursor: default; transform: none; }
.tm-tile--disabled .tm-role, .tm-tile:disabled .tm-role { opacity: .35; }
.tm-tile--disabled .tm-tile__kupu, .tm-tile:disabled .tm-tile__kupu { opacity: .55; }

/* SentenceBuilder */
.tm-builder { display: flex; flex-direction: column; gap: var(--space-5); color: var(--text); }
.tm-builder__instruction { margin: 0; font-size: 20px; line-height: 28px; font-weight: 500; }
.tm-builder__target { margin: var(--space-1) 0 0; font-size: 15px; line-height: 22px; font-style: italic; color: var(--text-muted); }
.tm-builder__sentence { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); padding: var(--space-5); border-radius: var(--radius-lg); background: var(--surface-muted); }
.tm-builder__punct { font-size: 28px; line-height: var(--size-tile); font-weight: 700; }
.tm-slot { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.tm-slot__empty { display: block; min-width: 96px; min-height: var(--size-tile); border-radius: var(--radius-md); border: 2px dashed var(--line-control); }
.tm-builder__tray { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tm-builder__actions, .tm-choices__actions, .tm-scenario__next { display: flex; justify-content: flex-end; gap: var(--space-3); }

/* FeedbackBanner */
.tm-feedback { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg); }
.tm-feedback--correct { background: var(--correct); color: var(--on-correct); }
.tm-feedback--incorrect { background: var(--incorrect); color: var(--on-incorrect); }
.tm-feedback--hint { background: var(--hint); color: var(--on-hint); box-shadow: inset 0 0 0 1px var(--line-control); }
.tm-feedback--info { background: var(--surface-muted); color: var(--text); }
.tm-feedback__icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; }
.tm-feedback__body { flex: 1; min-width: 0; }
.tm-feedback__title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.tm-feedback__text { margin-top: 2px; font-size: 16px; line-height: 24px; }
.tm-feedback__gloss { margin: 2px 0 0; font-size: 15px; line-height: 22px; font-style: italic; }
.tm-feedback__action { align-self: center; }
.tm-feedback__action .tm-btn--secondary { background: var(--white); color: var(--dark-blue); border-color: var(--dark-blue); }
.tm-feedback__action .tm-btn--primary { background: var(--dark-blue); color: var(--white); }

/* ActivityHeader and scene bands (gradients from tokens) */
.tm-header { position: relative; overflow: hidden; display: flex; align-items: center; gap: var(--space-5); padding: var(--space-6); border-radius: var(--radius-lg) var(--radius-xl) var(--radius-lg) var(--radius-lg); color: var(--white); }
.tm-header--dawn { background: var(--gradient-dawn); }
.tm-header--depth { background: var(--gradient-depth); }
.tm-header--energy { background: var(--gradient-energy); }
.tm-header--warm { background: var(--gradient-warm); }
.tm-header--sky { background: var(--gradient-sky); }
.tm-header--tide { background: var(--gradient-tide); }
/* Same colour pairs as assets/whanau.js, so an activity header matches its sentence-structure card. */
.tm-header--reremahi { background: linear-gradient(to top right, var(--dark-blue) 15%, var(--fuchsia)); }
.tm-header--rerehangu { background: linear-gradient(to top right, var(--purple) 15%, var(--teal)); }
.tm-header--rerekaimahi { background: linear-gradient(to top right, var(--fuchsia) 15%, var(--orange)); }
.tm-header--rerewa { background: linear-gradient(to top right, var(--dark-blue) 15%, var(--blue)); }
.tm-header--rereingoa { background: linear-gradient(to top right, var(--dark-blue) 15%, var(--teal)); }
.tm-header--reretau { background: linear-gradient(to top right, var(--dark-purple) 15%, var(--bright-fuchsia)); }
.tm-header--rereahua { background: linear-gradient(to top right, var(--blue) 15%, var(--teal)); }
.tm-header--rerepanga { background: linear-gradient(to top right, var(--dark-purple) 15%, var(--purple)); }
.tm-header--rereputake { background: linear-gradient(to top right, var(--purple) 15%, var(--orange)); }
.tm-header__logo { width: 140px; height: auto; flex: none; position: relative; z-index: 1; }
.tm-header__text { position: relative; z-index: 1; min-width: 0; }
.tm-header__eyebrow, .tm-scenario__eyebrow { margin: 0 0 var(--space-2); font-size: 13px; line-height: 16px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; }
.tm-header__title { margin: 0; font-size: 36px; line-height: 44px; font-weight: 700; }
.tm-header__subtitle { margin: var(--space-1) 0 0; font-size: 20px; line-height: 28px; font-weight: 500; }
.tm-header__pattern { position: absolute; top: 0; bottom: 0; right: var(--space-6); width: 96px; background-repeat: repeat-y; background-size: 96px auto; opacity: .35; }

/* ScenarioProgress */
.tm-progress { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: var(--space-2); }
.tm-progress__step { display: flex; align-items: center; gap: var(--space-2); }
.tm-progress__step + .tm-progress__step::before { content: ""; width: 20px; height: 2px; background: currentColor; opacity: .5; }
.tm-progress__node { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-pill); border: 2px solid currentColor; font-size: 13px; font-weight: 700; }
.tm-progress__step.is-done .tm-progress__node { background: var(--correct); color: var(--on-correct); border-color: var(--correct); }
.tm-progress__step.is-retry .tm-progress__node { background: var(--incorrect); color: var(--on-incorrect); border-color: var(--incorrect); }
.tm-progress__step.is-current .tm-progress__node { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tm-scenario__scene .tm-progress__step.is-current .tm-progress__node { background: var(--white); color: var(--dark-blue); border-color: var(--white); }
.tm-progress { color: var(--text); }
.tm-scenario__scene .tm-progress { color: var(--white); }
.tm-progress__label { font-size: 13px; line-height: 18px; font-weight: 500; }
.tm-progress__step:not(.is-current) .tm-progress__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* KoreroBubble */
.tm-korero { display: flex; align-items: flex-end; gap: var(--space-3); max-width: 640px; }
.tm-korero--right { flex-direction: row-reverse; margin-left: auto; }
.tm-korero__avatar { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: var(--radius-pill); background: var(--fuchsia); color: var(--white); font-size: 20px; font-weight: 700; }
.tm-korero--right .tm-korero__avatar { background: var(--blue); }
.tm-korero__bubble { position: relative; padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm); background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-card); border: 1px solid var(--line); }
.tm-korero--right .tm-korero__bubble { border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg); }
.tm-korero__speaker { margin: 0 0 var(--space-1); font-size: 15px; line-height: 20px; font-weight: 500; color: var(--text-accent); }
.tm-korero__role { color: var(--text-muted); font-weight: 400; }
.tm-korero__reo { margin: 0; font-size: 24px; line-height: 32px; font-weight: 500; }
.tm-korero__gloss { margin: var(--space-1) 0 0; font-size: 15px; line-height: 22px; font-style: italic; color: var(--text-muted); }
.tm-korero__listen { position: absolute; top: var(--space-2); right: var(--space-2); }
.tm-korero__bubble:has(.tm-korero__listen) { padding-right: 64px; }

/* ChoiceList */
.tm-choices { display: flex; flex-direction: column; gap: var(--space-4); color: var(--text); }
.tm-choices__prompt { margin: 0; font-size: 20px; line-height: 28px; font-weight: 500; }
.tm-choices__list { display: grid; gap: var(--space-3); }
.tm-choices--kupu .tm-choices__list { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tm-choice { display: flex; align-items: center; gap: var(--space-3); min-height: var(--size-tile); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--line-control); background: var(--surface-raised); color: var(--text); text-align: left; cursor: pointer; box-shadow: var(--shadow-tile); }
.tm-choice:hover:not(:disabled) { border-color: var(--text); }
.tm-choice__letter { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-pill); border: 2px solid currentColor; font-size: 14px; font-weight: 700; }
.tm-choice__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tm-choice__label { font-size: 22px; line-height: 28px; font-weight: 500; }
.tm-choice__gloss { font-size: 15px; line-height: 22px; font-style: italic; color: var(--text-muted); }
.tm-choice__parts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.tm-choice__part { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.tm-choice__partkupu { font-size: 20px; line-height: 26px; font-weight: 500; }
.tm-choice--selected { border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus), var(--shadow-lift); }
.tm-choice--selected .tm-choice__letter { background: var(--focus); border-color: var(--focus); color: var(--surface); }
.tm-choice--correct { background: var(--correct); color: var(--on-correct); border-color: var(--correct); box-shadow: none; }
.tm-choice--incorrect { background: var(--incorrect); color: var(--on-incorrect); border-color: var(--incorrect); box-shadow: none; }
.tm-choice--correct .tm-choice__gloss, .tm-choice--incorrect .tm-choice__gloss { color: inherit; }
.tm-choice--correct .tm-role, .tm-choice--incorrect .tm-role { box-shadow: 0 0 0 2px var(--dark-blue); }
.tm-choice--disabled { opacity: .5; box-shadow: none; cursor: default; }

/* MacronKeys */
.tm-macrons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tm-macrons__key { min-width: var(--size-touch); min-height: var(--size-touch); padding: 0 var(--space-3); border-radius: var(--radius-sm); border: 2px solid var(--line-control); background: var(--surface-raised); color: var(--text); font-size: 20px; font-weight: 500; cursor: pointer; }
.tm-macrons__key:hover { background: var(--surface-muted); }
.tm-macrons__shift { font-size: 13px; letter-spacing: .08em; }
.tm-macrons__shift.is-on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* TypedResponse */
.tm-typed { display: flex; flex-direction: column; gap: var(--space-3); color: var(--text); }
.tm-typed__prompt { font-size: 20px; line-height: 28px; font-weight: 500; }
.tm-typed__field { display: flex; gap: var(--space-2); align-items: stretch; }
.tm-typed__input { flex: 1; min-width: 0; min-height: 56px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--line-control); background: var(--surface-raised); color: var(--text); font-size: 22px; font-weight: 400; }
.tm-typed__input::placeholder { color: var(--text-muted); font-style: italic; font-size: 18px; }
.tm-typed__field.is-correct .tm-typed__input { border-color: var(--correct); border-width: 3px; }
.tm-typed__field.is-incorrect .tm-typed__input { border-color: var(--incorrect); border-width: 3px; }
.tm-typed__field.is-macrons .tm-typed__input { border-color: var(--hint); border-width: 3px; }
.tm-typed__field .tm-btn { min-height: 56px; }

/* SpokenResponse */
.tm-spoken { display: flex; flex-direction: column; gap: var(--space-4); color: var(--text); }
.tm-spoken__target { position: relative; padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg); background: var(--surface-muted); }
.tm-spoken__target .tm-listen { position: absolute; top: var(--space-3); right: var(--space-3); }
.tm-spoken__targetlabel { margin: 0 0 var(--space-1); font-size: 13px; line-height: 16px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--text-muted); }
.tm-spoken__reo { margin: 0; font-size: 30px; line-height: 40px; font-weight: 500; }
.tm-spoken__gloss { margin: var(--space-1) 0 0; font-size: 15px; line-height: 22px; font-style: italic; color: var(--text-muted); }
.tm-spoken__control { display: flex; align-items: center; gap: var(--space-5); }
.tm-mic { display: grid; place-items: center; width: var(--size-mic); height: var(--size-mic); flex: none; border-radius: var(--radius-pill); border: 0; background: var(--accent); color: var(--on-accent); cursor: pointer; box-shadow: var(--shadow-lift); }
.tm-mic:disabled { opacity: .45; cursor: not-allowed; }
.tm-spoken.is-listening .tm-mic { background: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 8px var(--surface-muted), var(--shadow-lift); }
.tm-spoken.is-correct .tm-mic { background: var(--correct); color: var(--on-correct); }
.tm-spoken.is-incorrect .tm-mic { background: var(--incorrect); color: var(--on-incorrect); }
.tm-spoken__label { display: flex; align-items: center; gap: var(--space-3); margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.tm-spoken__sub { margin: 2px 0 0; font-size: 15px; line-height: 22px; color: var(--text-muted); }
.tm-spoken__transcript { margin: 0; font-size: 18px; line-height: 28px; }
.tm-spoken__transcript span { color: var(--text-muted); }
.tm-bars { display: inline-flex; align-items: center; gap: 3px; height: 20px; }
.tm-bars span { width: 4px; height: 6px; border-radius: 2px; background: var(--text-accent); }
.tm-bars.is-active span { animation: tm-bar 0.9s ease-in-out infinite; }
@keyframes tm-bar { 0%, 100% { height: 6px; } 50% { height: 20px; } }
@media (prefers-reduced-motion: reduce) { .tm-bars.is-active span { animation: none; height: 14px; } .tm-tile, .tm-btn { transition: none; } }

/* BranchingScenario */
.tm-scenario { border-radius: var(--radius-lg) var(--radius-xl) var(--radius-lg) var(--radius-lg); overflow: hidden; background: var(--surface-raised); box-shadow: var(--shadow-card); border: 1px solid var(--line); }
.tm-scenario__scene { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-5); flex-wrap: wrap; padding: var(--space-5) var(--space-6); color: var(--white); }
.tm-scenario__title { margin: 0; font-size: 28px; line-height: 36px; font-weight: 700; }
.tm-scenario__setting { margin: var(--space-1) 0 0; font-size: 16px; line-height: 24px; font-style: italic; }
.tm-scenario__body { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-6); }

/* IconButton + ActivityNav */
.tm-iconbtn { display: inline-grid; place-items: center; width: var(--size-touch); height: var(--size-touch); border-radius: var(--radius-md); border: 0; background: none; color: inherit; cursor: pointer; }
.tm-iconbtn:hover:not(:disabled) { background: var(--surface-muted); }
.tm-iconbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tm-iconbtn:disabled { opacity: .45; cursor: not-allowed; }
/* Option icons: hover colour and label appear immediately. Native title tooltips wait 1–2s. */
[data-ring] { position: relative; }
[data-ring]:hover,
[data-ring]:focus-within { background: var(--text-accent) !important; color: var(--white) !important; }
[data-ring][data-optip]::after {
  content: attr(data-optip);
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-family: var(--font-sans, sans-serif);
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: var(--shadow-lift);
}
[data-ring][data-optip]:hover::after,
[data-ring][data-optip]:focus-within::after { opacity: 1; }
.tm-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow-tile); }
.tm-nav__start, .tm-nav__end { display: flex; gap: var(--space-1); }
.tm-nav__middle { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.tm-nav__title { margin: 0; font-size: 15px; line-height: 20px; font-weight: 500; }
.tm-nav__steps { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-2); }
.tm-nav__step { display: grid; color: var(--text-muted); }
.tm-nav__step.is-puawai { color: var(--text); }
.tm-nav__step.is-koru { color: var(--text-accent); }
