/* YAT — device toolbox. Step rail borrowed from transit platform signage:
   solid square numerals, hairline track, everything below the current step
   held back until it can actually do something. */

.step {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0 1.6rem;
  border-top: 1px solid var(--ink);
  padding-top: 1.8rem;
  padding-bottom: 2.2rem;
  position: relative;
}

.step-rail { position: relative; }
.step-rail::after {              /* the track running down between numerals */
  content: "";
  position: absolute;
  left: 1.35rem; top: 3.1rem; bottom: -2.2rem;
  width: 1px; background: var(--rule);
}
.step:last-of-type .step-rail::after { display: none; }

.step-num {
  display: flex; align-items: center; justify-content: center;
  width: 2.7rem; height: 2.7rem;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 1.05rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  position: relative; z-index: 1;
}

.step[data-state="locked"] .step-num { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--rule); }
.step[data-state="active"] .step-num { background: var(--seal); }
.step[data-state="done"] .step-num { background: var(--seal); }
.step[data-state="done"] .step-num::after {
  content: "✓"; position: absolute; font-size: 1rem;
  inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--seal); color: #fff;
}

.step[data-state="locked"] .step-body > *:not(.step-title):not(.step-lede) { opacity: 0.4; }
.step[data-state="locked"] .step-title, .step[data-state="locked"] .step-lede { color: var(--ink-3); }
.step[data-state="locked"] button:not(.always-on),
.step[data-state="locked"] input,
.step[data-state="locked"] select { pointer-events: none; }

.step-title { font-size: clamp(1.3rem, 3.2vw, 1.65rem); margin-bottom: 0.5rem; }
.step-title .en { font-size: 0.48em; }
.step-lede { color: var(--ink-2); max-width: 42rem; margin-bottom: 1.5rem; }

/* ---------- model picker ---------- */

.models { border: 0; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 0.75rem;
          grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.models legend { padding: 0; margin-bottom: 0.6rem; }

.model {
  display: flex; gap: 0.75rem; align-items: flex-start;
  border: 1px solid var(--rule); background: #fff; padding: 0.85rem 1rem; cursor: pointer;
}
.model:hover { border-color: var(--ink); }
.model:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.model.is-disabled { opacity: 0.5; cursor: not-allowed; background: var(--paper-2); }
.model input { margin-top: 0.35rem; accent-color: var(--seal); flex: none; }
.model-name { display: block; font-family: var(--serif); font-size: 1.05rem; }
.model-note { display: block; font-size: 0.8rem; color: var(--ink-3); margin-top: 0.15rem; }
.model-note .en { display: block; }

/* ---------- release box ---------- */

.release {
  border: 1px solid var(--rule); border-left: 3px solid var(--ink-3);
  background: var(--paper-2); padding: 0.9rem 1.1rem; margin-bottom: 1.4rem;
}
.release[data-state="ok"] { border-left-color: var(--seal); background: #fff; }
.release[data-state="none"] { border-left-color: var(--ink-3); }
.release .label { display: block; margin-bottom: 0.3rem; }
.release-line { font-size: 0.92rem; margin: 0; }
.release-line + .release-line { margin-top: 0.35rem; }
.release dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 1rem;
              margin: 0.6rem 0 0; font-size: 0.82rem; }
.release dt { color: var(--ink-3); }
.release dd { margin: 0; font-family: var(--mono); font-size: 0.92em; word-break: break-all; }

/* ---------- actions / checks ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; margin-top: 1rem;
         font-size: 0.85rem; color: var(--ink-2); cursor: pointer; max-width: 34rem; }
.check input { margin-top: 0.25rem; accent-color: var(--seal); }
.check .en { display: block; color: var(--ink-3); font-size: 0.92em; }

/* ---------- progress ---------- */

.progress { margin-top: 1.4rem; }
.progress-track { height: 10px; background: var(--paper-3); border: 1px solid var(--rule); }
.progress-bar { height: 100%; width: 0; background: var(--seal); transition: width 0.15s linear; }
.progress-label { font-size: 0.8rem; color: var(--ink-2); margin: 0.45rem 0 0;
                  font-family: var(--mono); }

/* ---------- post-flash verification ---------- */

/* Same shape as .release: a bordered slab whose left edge carries the state,
   so "asking", "running" and "no answer" read at a glance without colour
   being the only signal. */
.verify {
  border: 1px solid var(--rule); border-left: 3px solid var(--ink-3);
  background: var(--paper-2); padding: 1rem 1.15rem;
}
.verify[data-state="busy"] { border-left-color: var(--ink); background: #fff; }
.verify[data-state="ok"] { border-left-color: var(--seal); background: #fff; }
.verify[data-state="err"] { border-left-color: var(--seal); background: var(--seal-wash); }

.verify-line { font-size: 0.95rem; margin: 0; }
.verify-line .en { display: block; color: var(--ink-3); font-size: 0.85em; margin-top: 0.15rem; }
.verify[data-state="ok"] .verify-line { font-family: var(--serif); font-size: 1.2rem; }
.verify-detail {
  font-family: var(--mono); font-size: 0.76rem; color: var(--ink-3);
  margin: 0.55rem 0 0; word-break: break-word;
}
.verify .actions { margin-top: 1rem; }

/* ---------- hand-off ---------- */

.handoff { display: flex; flex-wrap: wrap; gap: 0.8rem 1.1rem; align-items: center; }
.handoff .btn:first-child { font-size: 1rem; padding: 0.85rem 1.7rem; }
.countdown {
  font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- ?dev=serial block ---------- */

.dev-block { border-top: 3px double var(--ink); margin-top: 3.5rem; }
.dev-flag {
  display: inline-block; background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em;
  padding: 0.1rem 0.45rem; margin-right: 0.5rem; vertical-align: 0.1em;
}
.dev-block .step-num { font-size: 0.85rem; letter-spacing: 0.02em; }

/* ---------- console ---------- */

.console {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  background: #14120e; color: #e6e0d3;
  border: 1px solid var(--ink);
  padding: 0.9rem 1rem; margin-top: 1.2rem;
  height: 22rem; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.console-short { height: 12rem; }
.console:empty::before { content: "—"; color: #6c6558; }

/* A locked step has nothing to print yet — a dimmed black slab is just a big
   grey rectangle, so an empty console waits as a light placeholder instead.
   Once it has real lines (the no-WebSerial notice, say) it reads normally. */
.step[data-state="locked"] .console { opacity: 1; }
.step[data-state="locked"] .console:empty {
  background: var(--paper-2); color: var(--ink-3);
  border: 1px dashed var(--rule); height: 7rem;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 1rem;
}
.step[data-state="locked"] .console:empty::before {
  content: "連接裝置後，日誌會在這裡出現。The log appears here once a device is connected.";
  font-family: var(--sans); font-size: 0.85rem; line-height: 1.5; color: var(--ink-3);
}
.console .l-err { color: #f0937f; }
.console .l-ok { color: #a8cf9a; }
.console .l-tx { color: #8fb6d8; }
.console .l-meta { color: #8c8474; }

.send-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.send-row input { flex: 1 1 14rem; max-width: none; font-family: var(--mono); font-size: 0.85rem; }

/* ---------- improv ---------- */

.ssid-row { display: flex; gap: 0.5rem; align-items: center; max-width: 30rem; }
.ssid-row input { flex: 1 1 auto; }

.device-info {
  border: 1px solid var(--rule); background: #fff; padding: 0.9rem 1.1rem;
  margin-bottom: 1.4rem;
}
.device-info dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1.2rem;
                  margin: 0.4rem 0 0; font-size: 0.85rem; }
.device-info dt { color: var(--ink-3); }
.device-info dd { margin: 0; font-family: var(--mono); }

.improv-status { margin-top: 1rem; font-size: 0.9rem; min-height: 1.5rem; }
.improv-status[data-tone="err"] { color: var(--seal); }
.improv-status[data-tone="ok"] { color: var(--ink); }
.improv-status[data-tone="busy"] { color: var(--ink-2); }
.improv-status .en { display: block; color: var(--ink-3); font-size: 0.85em; }

/* ---------- fallback / details ---------- */

.fallback { margin-top: 1.6rem; border-top: 1px solid var(--rule); padding-top: 0.9rem; }
.fallback summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.fallback summary::marker { color: var(--seal); }
.fallback[open] summary { margin-bottom: 0.8rem; }
.fallback p, .fallback li { font-size: 0.9rem; color: var(--ink-2); }

.steps-list { padding-left: 1.2rem; margin: 0 0 0.8rem; }
.steps-list li { margin-bottom: 0.5rem; }
.steps-list .en { display: block; color: var(--ink-3); font-size: 0.86em; }

/* ---------- protocol table ---------- */

.protocol { margin-top: 1.8rem; }
.protocol .label { display: block; margin-bottom: 0.4rem; }

.proto-table { width: 100%; border-collapse: collapse; margin-top: 0.7rem; font-size: 0.88rem; }
.proto-table th {
  text-align: left; font-family: var(--sans); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--ink); padding: 0 0.9rem 0.4rem 0;
}
.proto-table td { border-bottom: 1px solid var(--rule); padding: 0.55rem 0.9rem 0.55rem 0;
                  vertical-align: top; color: var(--ink-2); }
.proto-table td:first-child { white-space: nowrap; color: var(--ink); }
.proto-table.wide td:first-child { white-space: normal; width: 34%; }
.proto-table .en { display: block; color: var(--ink-3); font-size: 0.86em; }

@media (max-width: 46rem) {
  .step { grid-template-columns: 1fr; gap: 0.9rem; }
  .step-rail::after { display: none; }
  .proto-table td:first-child { white-space: normal; }
  .proto-table, .proto-table tbody, .proto-table tr, .proto-table td { display: block; width: auto; }
  .proto-table thead { display: none; }
  .proto-table tr { border-bottom: 1px solid var(--rule); padding: 0.6rem 0; }
  .proto-table td { border: 0; padding: 0 0 0.2rem; }
  .proto-table.wide td:first-child { width: auto; font-weight: 600; }
}
