/* Terminal Linux simulé (os-terminal.html). Éléments communs : css/sim.css. Tout est préfixé .tm. */

.tm {
  display: block;
}

/* ---------- mise en page : sur petit écran la mission passe avant le terminal ---------- */

.tm-main {
  display: grid;
  gap: 1rem;
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "mission" "term" "tree" "ref";
}

.tm-mission {
  grid-area: mission;
}
.tm-termwrap {
  grid-area: term;
}
.tm-treecard {
  grid-area: tree;
}
.tm-ref {
  grid-area: ref;
}

@media (min-width: 1000px) {
  .tm-main {
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
    grid-template-areas: "term mission" "term tree" "term ref";
    grid-template-rows: auto auto 1fr;
  }
}

/* ---------- la fenêtre du terminal ---------- */

.tm-termwrap {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.tm-window {
  display: flex;
  flex-direction: column;
  background: #14141a;
  color: #f1ede4;
  border: 1px solid #14141a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px -14px rgba(20, 20, 26, 0.5);
}

.tm-window:focus-within {
  box-shadow: 0 0 0 3px rgba(239, 74, 52, 0.55), 0 12px 30px -14px rgba(20, 20, 26, 0.5);
}

.tm-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.8rem;
  background: #1e1e26;
  border-bottom: 1px solid #2d2d37;
}

.tm-dots {
  display: inline-flex;
  gap: 5px;
}

.tm-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a3a44;
}

.tm-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sm-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: #d9d6cd;
}

.tm-btn {
  padding: 0.2rem 0.6rem;
  border: 1px solid #5c5c66;
  border-radius: 8px;
  background: transparent;
  color: #e6e3da;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.tm-btn:hover {
  background: #2d2d37;
}

.tm-btn:focus-visible {
  outline: 3px solid #ff8a72;
  outline-offset: 2px;
}

.tm-screen {
  height: 440px;
  padding: 0.8rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family: var(--sm-mono);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variant-ligatures: none;
  cursor: text;
}

.tm-screen:focus-visible {
  outline: none;
}

.tm-line {
  min-height: 1.55em;
}

.tm-user {
  color: #9ed88a;
  font-weight: 700;
}

.tm-path {
  color: #8cc7ff;
  font-weight: 700;
}

.tm-cmd {
  color: #ffffff;
}

.tm-err {
  color: #ff9a8a;
}

.tm-dim {
  color: #a9a69d;
}

.tm-c-dir {
  color: #8cc7ff;
  font-weight: 700;
}

.tm-c-exe {
  color: #9ed88a;
  font-weight: 700;
}

.tm-inputrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.55rem 1rem 0.75rem;
  border-top: 1px solid #2d2d37;
  font-family: var(--sm-mono);
  font-size: 14px;
}

.tm-prompt {
  flex: 0 1 auto;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-input {
  flex: 1;
  min-width: 0;
  padding: 0.2rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  caret-color: #ff8a72;
}

.tm-keys code {
  background: rgba(20, 20, 26, 0.07);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

@media (max-width: 700px) {
  .tm-screen {
    height: 52vh;
    min-height: 260px;
  }

  /* le bouton « Support » flottant couvre la fin de la ligne de commande : on le cache pendant la frappe */
  body:has(.tm-window:focus-within) .report-fab {
    display: none;
  }
}

/* ---------- mission ---------- */

.tm-mission__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tm-mission__top .sm-label {
  margin: 0;
}

.tm-m-title {
  margin: 0.1rem 0 0.2rem;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.3;
}

.tm-m-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.tm-m-story {
  margin-top: 0.5rem;
  color: var(--sm-ink-2);
  font-size: 0.9rem;
}

.tm-m-goal {
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.75rem;
  border-left: 4px solid var(--sm-accent-deep);
  background: var(--sm-cream);
  border-radius: 0 9px 9px 0;
  font-weight: 700;
}

.tm-mission .sm-verdict {
  margin-top: 0.8rem;
}

.tm-mission__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.tm-mission__actions .sm-btn {
  min-height: 38px;
  padding: 0.3rem 0.85rem;
}

.tm-hint {
  margin-top: 0.7rem;
  padding: 0.55rem 0.75rem;
  border-radius: 9px;
  background: var(--sm-warn-soft);
  color: var(--sm-warn);
  font-size: 0.9rem;
}

.tm-hint code {
  font-weight: 800;
}

.tm-list {
  margin-top: 0.9rem;
  border-top: 1px dashed var(--sm-line-2);
  padding-top: 0.6rem;
}

.tm-list summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--sm-ink-2);
}

.tm-list[open] summary {
  margin-bottom: 0.5rem;
}

.tm-list h3 {
  margin: 0.7rem 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sm-ink-2);
}

.tm-li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sm-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.tm-li:hover {
  background: var(--sm-cream);
}

.tm-li.is-current {
  background: var(--sm-cream-2);
  font-weight: 800;
}

.tm-li__n {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sm-cream-2);
  font-size: 0.75rem;
  font-weight: 800;
}

.tm-li.is-done .tm-li__n {
  background: var(--sm-ok);
  color: #fff;
}

.tm-li__t {
  flex: 1;
}

/* ---------- arborescence ---------- */

.tm-treecard__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.tm-treecard__top .sm-label {
  margin: 0;
}

.tm-tree {
  max-height: 360px;
  overflow: auto;
  padding: 0.4rem;
  border: 1px solid var(--sm-line-2);
  border-radius: 10px;
  background: #fff;
  font-family: var(--sm-mono);
  font-size: 12.5px;
  line-height: 1.45;
}

.tm-tn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.25rem 0.1rem calc(0.25rem + var(--d, 0) * 1rem);
  border-radius: 6px;
  white-space: nowrap;
}

.tm-tn.is-cwd {
  background: var(--sm-accent-soft);
  color: var(--sm-accent-ink);
  font-weight: 800;
}

.tm-tn__tg {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--sm-ink);
  cursor: pointer;
}

.tm-tn__tg svg {
  transition: transform 0.12s ease;
}

.tm-tn__tg[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

.tm-tn__tg:hover {
  background: var(--sm-cream-2);
}

.tm-tn__sp {
  flex: none;
  width: 18px;
}

.tm-tn__name.is-dir {
  font-weight: 800;
}

.tm-tn__here {
  flex: none;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--sm-accent-deep);
  color: #fff;
  font-family: "Manrope", sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
}

.tm-tn__perm {
  margin-left: auto;
  padding-left: 0.8rem;
  color: var(--sm-ink-3);
  font-size: 0.72rem;
}

.tm-tn.is-cwd .tm-tn__perm {
  color: var(--sm-accent-ink);
}

/* ---------- rappel sur les droits ---------- */

.tm-ref__art {
  margin: 0 0 0.8rem;
  padding: 0.7rem 0.9rem;
  overflow: auto;
  border-radius: 10px;
  background: #14141a;
  color: #f1ede4;
  font-family: var(--sm-mono);
  font-size: 12.5px;
  line-height: 1.5;
}

.tm-ref__t {
  margin-bottom: 0.6rem;
}

.tm-ref__t td:last-child,
.tm-ref__t th:last-child {
  text-align: center;
}
