/* ==========================================================================
   T-Embed Flipper Zero Port Webflasher — styles.css
   Design system: DESIGN.md (all tokens trace to Section 2/3/4).
   Direction: Linear/Vercel premium minimal — dark-mode-first, one indigo
   accent, translucent borders, luminance stacking depth, sans-first type.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens (DESIGN.md Section 2, 3, 4)
   -------------------------------------------------------------------------- */
:root {
  /* Color */
  --bg: #08090a;
  --surface-1: #0f1011;
  --surface-2: #191a1b;
  --surface-3: #28282c;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.08);
  --text-1: #f7f8f8;
  --text-2: #d0d6e0;
  --text-3: #8a8f98;
  --text-4: #62666d;
  --accent: #5e6ad2;
  --accent-bright: #7170ff;
  --accent-hover: #828fff;
  --accent-contrast: #ffffff;
  --success: #27a644;
  --success-bright: #10b981;
  --on-success: #0b1a12;
  --error: #e5484d;
  --error-strong: #ff6369;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   3. Card (panel)
   -------------------------------------------------------------------------- */
.card {
  width: 100%;
  max-width: 560px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: var(--space-6);
}

header.card-header {
  margin-bottom: var(--space-5);
}

h1 {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.011em;
  text-wrap: balance;
}

.sub {
  color: var(--text-2);
  font-size: 13px;
  margin-top: var(--space-1);
}

main {
  width: 100%;
}

/* --------------------------------------------------------------------------
   4. Step rows
   -------------------------------------------------------------------------- */
.step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.step.done .step-num {
  background: var(--success-bright);
  border-color: var(--success-bright);
  color: var(--on-success);
}

.step.done .step-text {
  color: var(--success-bright);
}

.step-text {
  font-size: 14px;
  color: var(--text-1);
}

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
  width: 100%;
  padding: 8px 16px;
  margin-top: var(--space-4);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 150ms ease-out, transform 100ms ease-out, opacity 150ms ease-out;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Connect — primary indigo */
#connectBtn {
  background: var(--accent);
  color: var(--accent-contrast);
}

#connectBtn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#connectBtn:disabled {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-4);
}

/* Flash — success green. NO pulse, NO glow, NO animation. */
#flashBtn {
  background: var(--success);
  color: #ffffff;
}

#flashBtn:hover:not(:disabled) {
  background: var(--success-bright);
}

#flashBtn:disabled {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-4);
}

/* --------------------------------------------------------------------------
   6. Firmware version badge
   -------------------------------------------------------------------------- */
.fwver {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.fwver .tag {
  border: 1px solid var(--accent-bright);
  border-radius: 2px;
  padding: 2px 8px;
  font-weight: 400;
  color: var(--accent-bright);
}

.fwver .ld {
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   7. Status line (aria-live)
   -------------------------------------------------------------------------- */
.status {
  margin-top: var(--space-4);
  font-size: 14px;
  color: var(--text-2);
  min-height: 21px;
}

.status.err {
  color: var(--error-strong);
}

.status.ok {
  color: var(--success-bright);
}

/* --------------------------------------------------------------------------
   8. Progress bar (transform scaleX only)
   -------------------------------------------------------------------------- */
.progress-wrap {
  display: none;
  margin-top: var(--space-3);
}

.progress-wrap.show {
  display: block;
}

.progress-bar {
  width: 100%;
  height: 2px;
  border-radius: 9999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 150ms ease-out;
}

.progress-label {
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   9. Log console
   -------------------------------------------------------------------------- */
.log {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
}

.log.show {
  display: block;
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */
.foot {
  margin-top: var(--space-5);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* --------------------------------------------------------------------------
   11. GitHub button (ghost-secondary, 6px radius)
   -------------------------------------------------------------------------- */
.github-row {
  margin-top: var(--space-6);
  text-align: center;
}

.github-btn {
  display: inline-block;
  padding: 10px 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}

.github-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-1);
}

.github-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.github-btn:active {
  transform: translateY(1px);
}

/* --------------------------------------------------------------------------
   12. Confirm dialog
   -------------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 420px;
  margin: 0 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: var(--space-6);
  box-shadow: rgba(0, 0, 0, 0.4) 0px 8px 24px;
}

.modal h2 {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.modal p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
}

.modal .warn {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: 6px;
  border: 1px solid var(--error);
  background: rgba(229, 72, 77, 0.06);
  color: var(--error-strong);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.modal .warn svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.erase-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms ease-out;
}

.erase-row:hover {
  background: var(--surface-3);
}

.erase-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--error);
  cursor: pointer;
  flex-shrink: 0;
}

.erase-row .erase-txt {
  font-size: 14px;
  font-weight: 500;
  color: var(--error);
}

.erase-row .erase-sub {
  font-size: 12px;
  color: var(--text-3);
}

.modal-btns {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.modal-btns .btn {
  margin-top: 0;
  width: auto;
  flex: 1;
}

#modalCancel {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
}

#modalCancel:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-1);
}

#modalFlash {
  background: var(--success);
  color: #ffffff;
}

#modalFlash:hover:not(:disabled) {
  background: var(--success-bright);
}

/* --------------------------------------------------------------------------
   13. Reduced motion — kill all transitions/animations
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
