/* Test hall (tl-): run the environmental tests with your own hands.
   A day screen like the designer's clean room. Logical properties throughout
   for Arabic. */

.tl {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.tl > * {
  min-width: 0;
}

/* ---------- Top bar ---------- */
.tl-top {
  display: flex;
  align-items: center;
  gap: 10px 20px;
  padding: 10px 20px;
  border-block-end: 1px solid var(--vellum-line);
  background: rgba(230, 236, 232, 0.94);
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.tl-heading {
  flex: 1 1 260px;
  min-width: 0;
}

.tl-kicker {
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--graphite-2);
  margin: 0 0 2px;
}

.tl-heading h1 {
  font-size: var(--step-3);
  font-stretch: 70%;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-stats {
  display: flex;
  gap: 6px;
  margin: 0;
  flex-wrap: wrap;
}

.tl-stats div {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--vellum-line);
  border-radius: var(--radius-m);
  padding: 5px 11px;
  min-width: 84px;
}

.tl-stats div.is-tight {
  border-color: var(--warn);
  box-shadow: inset 3px 0 0 var(--warn);
}

.tl-stats dt {
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.tl-stats dd {
  margin: 0;
  font-weight: 800;
  font-size: var(--step-1);
  font-stretch: 80%;
  white-space: nowrap;
}

.tl-stats dd small {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--graphite-2);
  font-stretch: 100%;
}

/* ---------- Body: the 3D hall and the side panel ---------- */
.tl-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 31vw, 450px);
  min-height: 0;
}

.tl-stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  background: #dfe6e2;
  overflow: hidden;
}

.tl-3d {
  position: absolute;
  inset: 0;
}

.tl-3d canvas {
  touch-action: none;
  cursor: pointer;
}

.tl-hint {
  position: absolute;
  inset-block-end: 12px;
  inset-inline-start: 50%;
  translate: -50% 0;
  margin: 0;
  max-inline-size: calc(100% - 24px);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 25, 34, 0.78);
  color: var(--chalk);
  font-size: var(--step--1);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[dir='rtl'] .tl-hint {
  translate: 50% 0;
}

.tl-hint kbd {
  min-width: 1.4em;
  padding: 0 4px;
  font-size: 0.72rem;
}

.tl.is-operating .tl-hint {
  display: none;
}

.tl-prompt {
  position: absolute;
  inset-block-end: 56px;
  inset-inline-start: 50%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  background: rgba(244, 247, 245, 0.96);
  border: 1px solid var(--vellum-line);
  border-inline-start: 4px solid var(--teal);
  border-radius: 10px;
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.55);
  font-weight: 700;
  white-space: nowrap;
  animation: tl-pop 0.25s ease-out;
}

[dir='rtl'] .tl-prompt {
  translate: 50% 0;
}

.tl-prompt kbd {
  color: var(--graphite);
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(36, 26, 2, 0.4);
}

@keyframes tl-pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- Side panel ---------- */
.tl-side {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-inline-start: 1px solid var(--vellum-line);
  background: rgba(236, 241, 238, 0.97);
  padding: 14px 16px 20px;
}

.tl-camp-h,
.tl-con-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tl-camp-h h2,
.tl-con-h h2 {
  font-size: var(--step-2);
  font-stretch: 72%;
  font-weight: 850;
}

.tl-con-h > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tl-phase {
  font-size: var(--step--1);
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--graphite);
  color: var(--vellum);
}

.tl-lede,
.tl-what {
  color: var(--graphite-2);
  margin: 6px 0 12px;
  font-size: 0.9375rem;
}

.tl-muted {
  color: var(--graphite-2);
  font-size: var(--step--1);
}

.tl-fine {
  color: var(--graphite-2);
  font-size: var(--step--1);
  margin: 8px 0 0;
}

.tl-ico {
  inline-size: 26px;
  block-size: 26px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Station cards */
.tl-stations {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.tl-st {
  background: #f8faf9;
  border: 1px solid var(--vellum-line);
  border-inline-start: 4px solid var(--teal);
  border-radius: 10px;
  padding: 10px 12px;
}

.tl-st-done {
  border-inline-start-color: var(--graphite-3);
}

.tl-st-off {
  border-inline-start-color: var(--vellum-line);
  opacity: 0.8;
}

.tl-st-h {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.tl-st-h .tl-ico {
  color: var(--teal);
  margin-block-start: 2px;
}

.tl-st-done .tl-st-h .tl-ico {
  color: var(--graphite-3);
}

.tl-st h3 {
  font-size: var(--step-1);
  font-stretch: 78%;
}

.tl-st-status {
  margin: 1px 0 0;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--teal);
}

.tl-st-done .tl-st-status,
.tl-st-off .tl-st-status {
  color: var(--graphite-2);
}

.tl-st-finds,
.tl-st-cost {
  margin: 6px 0 0;
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.tl-st-cost {
  margin-block-start: 2px;
}

.tl-st-act {
  display: flex;
  gap: 6px;
  margin-block-start: 9px;
  flex-wrap: wrap;
}

/* Known flaws */
.tl-known {
  margin-block-start: 16px;
  padding-block-start: 12px;
  border-block-start: 1px dashed var(--vellum-line);
}

.tl-known h3 {
  font-size: var(--step-1);
  font-stretch: 78%;
  margin-block-end: 6px;
}

.tl-flaws {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tl-flaws li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
  font-size: 0.875rem;
}

.tl-flaws li .btn {
  grid-column: 2;
  justify-self: start;
}

.tl-flaw-t small {
  display: block;
  color: var(--graphite-2);
  font-size: var(--step--1);
}

.tl-plan {
  margin: 10px 0 0;
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.tl-autoall {
  margin-block-start: 14px;
  inline-size: 100%;
}

/* ---------- Console ---------- */
.tl-console {
  animation: tl-pop 0.25s ease-out;
}

.tl-con-h .tl-ico {
  color: var(--teal);
}

.tl-x {
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  inline-size: 36px;
  block-size: 36px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--graphite-2);
}

.tl-x:hover {
  background: rgba(35, 40, 46, 0.08);
}

.tl-steps {
  list-style: none;
  margin: 8px 0 4px;
  padding: 0;
  display: flex;
  gap: 4px;
  font-size: var(--step--1);
  font-weight: 700;
}

.tl-steps li {
  flex: 1;
  padding: 4px 6px;
  border-block-end: 3px solid var(--vellum-line);
  color: var(--graphite-3);
}

.tl-steps li.now {
  border-color: var(--gold);
  color: var(--graphite);
}

.tl-steps li.done {
  border-color: var(--teal);
  color: var(--teal);
}

.tl-setups {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tl-setups legend {
  font-weight: 800;
  margin-block-end: 6px;
  padding: 0;
}

.tl-setup {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 11px;
  border: 1.5px solid var(--vellum-line);
  border-radius: 10px;
  background: #f8faf9;
  cursor: pointer;
}

.tl-setup:hover {
  border-color: var(--graphite-3);
}

.tl-setup.is-on {
  border-color: var(--graphite);
  background: #fff;
  box-shadow: 0 6px 16px -12px rgba(0, 0, 0, 0.5);
}

.tl-setup input {
  margin-block-start: 3px;
  accent-color: var(--graphite);
}

.tl-setup-t b {
  display: block;
  font-size: 0.9375rem;
}

.tl-setup-t em {
  display: inline-block;
  font-style: normal;
  font-size: 0.6875rem;
  font-weight: 800;
  color: var(--gold-ink);
  background: rgba(217, 162, 27, 0.18);
  border-radius: 999px;
  padding: 1px 7px;
  margin-block: 2px;
}

.tl-setup-t small {
  display: block;
  color: var(--graphite-2);
  font-size: var(--step--1);
  margin-block-start: 2px;
}

.tl-setup-c {
  text-align: end;
  font-weight: 800;
  font-stretch: 80%;
  white-space: nowrap;
}

.tl-setup-c small {
  display: block;
  font-weight: 600;
  color: var(--graphite-2);
  font-size: var(--step--1);
  font-stretch: 100%;
}

.tl-con-act {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 12px;
}

.tl-con-act .btn.primary {
  flex: 1 1 auto;
}

.tl-con-act kbd {
  color: #241a02;
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(36, 26, 2, 0.45);
}

/* Live run */
.tl-live {
  min-block-size: 2.9em;
  margin: 10px 0 6px;
  font-weight: 700;
  font-size: 0.9375rem;
}

.tl-progress {
  block-size: 4px;
  background: var(--vellum-line);
  border-radius: 2px;
  overflow: hidden;
}

.tl-progress span {
  display: block;
  block-size: 100%;
  inline-size: 0;
  background: var(--gold);
}

.tl-accel {
  display: block;
  inline-size: 100%;
  margin-block-start: 8px;
  border-radius: 6px;
}

.tl-rule {
  margin: 10px 0 8px;
  padding: 8px 10px;
  background: rgba(217, 162, 27, 0.12);
  border-inline-start: 3px solid var(--gold);
  border-radius: 6px;
  font-size: 0.875rem;
}

.tl-rule b {
  display: block;
  font-size: var(--step--1);
}

.tl-axis {
  font-size: 0.6875rem;
  color: var(--graphite-2);
  text-align: end;
  margin-block-end: 10px;
}

.tl-rows {
  display: grid;
  gap: 6px;
}

.tl-row {
  display: grid;
  grid-template-columns: 22px minmax(84px, 0.8fr) minmax(0, 1.6fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 8px;
  padding: 6px 8px;
  border: 1.5px solid var(--vellum-line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: start;
  position: relative;
}

.tl-row:hover {
  border-color: var(--graphite-3);
}

.tl-row[aria-pressed='true'] {
  border-color: var(--redpen);
  box-shadow: inset 0 0 0 1px var(--redpen);
  background: #fdf6f5;
}

.tl-row-k {
  grid-row: 1 / span 2;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--graphite-2);
  border: 1px solid var(--vellum-line);
  border-radius: 4px;
  text-align: center;
  line-height: 18px;
}

.tl-row-n {
  grid-row: 1 / span 2;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
}

.tl-row-n small {
  display: block;
  font-weight: 500;
  color: var(--graphite-2);
  font-size: 0.6875rem;
}

.tl-row canvas {
  grid-row: 1 / span 2;
  display: block;
  inline-size: 100%;
  block-size: 56px;
  border-radius: 4px;
  direction: ltr;
}

.tl-row-flag {
  position: absolute;
  inset-block-start: -8px;
  inset-inline-end: 8px;
  font-size: 0.6875rem;
  font-weight: 800;
  color: #fff;
  background: var(--redpen);
  border-radius: 999px;
  padding: 1px 8px;
  display: none;
}

.tl-row[aria-pressed='true'] .tl-row-flag {
  display: block;
}

/* Result card */
.tl-result {
  margin-block-start: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--vellum-line);
  border-block-start: 4px solid var(--teal);
  box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.55);
}

.tl-result-warn {
  border-block-start-color: var(--warn);
}

.tl-res-kicker {
  margin: 0;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--graphite-2);
}

.tl-result h3 {
  font-size: var(--step-2);
  font-stretch: 72%;
  margin: 2px 0 8px;
}

.tl-res-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.tl-res-f p {
  margin: 0 0 6px;
}

.tl-res-if {
  display: block;
  margin-block-start: 3px;
  font-size: 0.8125rem;
  color: var(--graphite-2);
}

.tl-res-f small {
  display: block;
  color: var(--warn);
  font-weight: 700;
}

.tl-res-fix {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.tl-res-fix .tl-fine {
  margin: 0;
}

.tl-res-fa {
  margin: 0 0 8px;
  color: var(--warn);
  font-weight: 600;
  font-size: 0.875rem;
}

.tl-res-cost {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--graphite-2);
}

.tl-res-cost b {
  color: var(--redpen);
}

.tl-src {
  margin: 12px 0 0;
  font-size: var(--step--1);
  color: var(--graphite-2);
  padding-inline-start: 10px;
  border-inline-start: 2px solid var(--vellum-line);
}

.tl-src a {
  color: var(--teal);
  font-weight: 700;
}

.tl-locked {
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--vellum-line);
  font-weight: 700;
}

/* ---------- Empty state ---------- */
.tl-empty {
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.tl-empty-card {
  max-inline-size: 520px;
  background: #f4f7f5;
  border: 1px solid var(--vellum-line);
  border-radius: 12px;
  padding: 22px;
}

.tl-empty-card h1 {
  font-size: var(--step-3);
  font-stretch: 72%;
  margin-block-end: 8px;
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  .tl {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-rows: auto auto;
  }

  .tl-top {
    padding: 8px 16px;
    gap: 8px 12px;
  }

  .tl-heading {
    flex-basis: calc(100% - 140px);
  }

  .tl-heading h1 {
    font-size: var(--step-2);
    white-space: normal;
  }

  .tl-stats {
    inline-size: 100%;
    max-inline-size: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tl-stats div {
    min-width: 0;
    flex: 1 0 auto;
    padding: 4px 8px;
  }

  .tl-stats dd {
    font-size: var(--step-0);
  }

  .tl-body {
    display: block;
  }

  .tl-stage {
    block-size: 46vh;
    min-block-size: 280px;
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
  }

  .tl-side {
    border-inline-start: 0;
    border-block-start: 1px solid var(--vellum-line);
    overflow: visible;
    padding: 12px 16px 28px;
  }

  .tl-hint {
    white-space: normal;
    border-radius: 10px;
    inline-size: max-content;
  }

  .tl-prompt {
    inset-block-end: 12px;
  }

  .tl-row {
    grid-template-columns: 20px minmax(70px, 0.75fr) minmax(0, 1.6fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tl-prompt,
  .tl-console {
    animation: none;
  }
}

/* The character controller's hint and thumb joystick sit above the hint line. */
.tl-stage {
  --ctl-safe-bottom: 56px;
}
