/* Web flasher (flash.html) — builds on site.css tokens. */

/* ---------- Hero animation ---------- */
.fl-hero { align-items: center; }
.fl-flow { margin: 0; position: relative; }
.fl-flow::before {
  content: ""; position: absolute; inset: 10% 5%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(124, 58, 237, 0.16), transparent 75%);
}
.fl-flow img { position: relative; width: 100%; height: auto; }
.fl-flow figcaption {
  display: grid; grid-template-columns: 1.3fr 0.9fr 1.35fr 1.3fr; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.fl-flow figcaption span::before { content: "→ "; color: var(--primary-hover); }
.fl-flow figcaption span:first-child::before { content: ""; }

/* ---------- Unsupported browser ---------- */
.fl-unsupported {
  display: flex; align-items: center; gap: 22px; margin-bottom: 28px; padding: 22px 24px;
  border-radius: var(--r-lg); border: 1px solid rgba(239, 68, 68, 0.35);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.03));
}
.fl-unsupported[hidden] { display: none; }
.fl-unsupported .anim-icon { height: 72px; filter: grayscale(0.4); }
.fl-unsupported p { color: var(--text-2); margin-top: 8px; max-width: 70ch; }

/* ---------- Layout ---------- */
.fl-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
@media (max-width: 1000px) { .fl-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .fl-step { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .fl-step + .fl-step::before { display: none; }
  .fl-step-no { width: 42px; height: 42px; border-radius: 13px; }
  .fl-flow figcaption { font-size: 10px; }
}

/* ---------- Steps ---------- */
.fl-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.fl-step {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 18px;
  padding: clamp(18px, 2.2vw, 28px); border-radius: var(--r-lg);
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.015);
  transition: border-color 300ms var(--ease), background-color 300ms var(--ease), opacity 300ms, box-shadow 300ms;
}
.fl-step + .fl-step::before {
  content: ""; position: absolute; left: calc(clamp(18px, 2.2vw, 28px) + 25px); top: -15px; width: 2px; height: 14px;
  background: var(--line-strong);
}
.fl-step.is-active {
  border-color: var(--primary-line);
  background: linear-gradient(135deg, rgba(156, 92, 255, 0.08), rgba(59, 130, 246, 0.03));
  box-shadow: 0 24px 60px -40px rgba(124, 58, 237, 0.9);
}
.fl-step.is-locked { opacity: 0.5; }
.fl-step.is-locked .fl-step-body { pointer-events: none; }
.fl-step-no {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  font-family: var(--sans); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--primary-hover); background: var(--primary-soft); border: 1px solid var(--primary-line);
  transition: background 300ms, color 300ms, border-color 300ms;
}
.fl-step-no svg { position: absolute; width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; }
.fl-step.is-done .fl-step-no { background: var(--ok); border-color: transparent; color: transparent; }
.fl-step.is-done .fl-step-no svg { stroke-dashoffset: 0; transition: stroke-dashoffset 420ms 120ms var(--ease); }
.fl-step.is-active .fl-step-no { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 10px 26px -12px rgba(124, 58, 237, 0.9); }
.fl-step-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.fl-step-head em { font-style: normal; color: var(--text-2); }
.fl-step-body { min-width: 0; }

/* Display choice */
.fl-drivers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
@media (max-width: 1240px) { .fl-drivers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fl-driver {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px; cursor: pointer;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color 200ms, background-color 200ms, transform 220ms var(--ease);
}
.fl-driver:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.fl-driver input { position: absolute; opacity: 0; pointer-events: none; }
.fl-driver:has(input:checked) { border-color: var(--primary); background: linear-gradient(160deg, rgba(156, 92, 255, 0.16), rgba(18, 18, 25, 0.9)); }
.fl-driver:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 3px; }
.fl-driver-art { display: block; height: 58px; }
.fl-driver-art img { height: 100%; width: auto; filter: grayscale(1) brightness(0.8); opacity: 0.6; transition: filter 300ms, opacity 300ms, transform 300ms var(--ease); }
.fl-driver--small .fl-driver-art img { height: 76%; margin-top: 7%; }
.fl-driver:has(input:checked) .fl-driver-art img { filter: none; opacity: 1; transform: scale(1.06); }
.fl-driver-text { display: flex; flex-direction: column; gap: 2px; }
.fl-driver-text b { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.fl-driver-text small { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }
.fl-badge {
  position: absolute; top: 10px; right: 10px; padding: 3px 8px; border-radius: var(--pill);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #fff; background: var(--grad);
}

.fl-panel-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; margin-top: 16px; }
.fl-panel-row p { margin: 0; font-size: 14px; }
.fl-seg { display: inline-flex; padding: 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.fl-seg label { position: relative; cursor: pointer; }
.fl-seg input { position: absolute; opacity: 0; pointer-events: none; }
.fl-seg span {
  display: block; padding: 7px 18px; border-radius: 9px; font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; color: var(--muted); transition: background 200ms, color 200ms;
}
.fl-seg input:checked + span { background: var(--primary-soft); color: #fff; box-shadow: inset 0 0 0 1px var(--primary-line); }
.fl-seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Buttons with an icon */
.fl-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.fl-actions .btn--ink { gap: 12px; padding-left: 10px; }
.fl-btn-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: rgba(0, 0, 0, 0.28); overflow: hidden; }
.fl-btn-ico img { width: 30px; height: 30px; }
.btn[disabled] .fl-btn-ico img { filter: grayscale(1); }
.btn.is-busy { pointer-events: none; }
.btn.is-busy .arrow { animation: fl-spin 900ms linear infinite; }
.fl-hint { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.fl-hint b { color: var(--text-2); font-weight: 600; }
.fl-device {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--pill);
  font-family: var(--mono); font-size: 12px; color: var(--text-2); background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.35);
}
.fl-device::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: fl-ping 1.8s infinite; }
.fl-device[hidden] { display: none; }

/* Checkbox */
.fl-check { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.fl-check input { position: absolute; opacity: 0; pointer-events: none; }
.fl-check small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.fl-check-box {
  flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px; border: 1px solid var(--line-strong);
  display: grid; place-items: center; transition: background 160ms, border-color 160ms;
}
.fl-check input:checked + .fl-check-box { background: var(--danger); border-color: transparent; }
.fl-check input:checked + .fl-check-box::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.fl-check input:focus-visible + .fl-check-box { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Status panel ---------- */
.fl-panel {
  position: sticky; top: calc(var(--header-h) + 20px);
  padding: clamp(20px, 2.4vw, 30px); border-radius: var(--r-xl); border: 1px solid var(--line);
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(124, 58, 237, 0.12), transparent 70%),
    var(--bg-2);
}
@media (max-width: 1000px) { .fl-panel { position: relative; top: 0; } }

.fl-stage { position: relative; width: min(240px, 70%); aspect-ratio: 1; margin: 6px auto 18px; display: grid; place-items: center; }
.fl-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.fl-ring circle { fill: none; stroke-width: 5; }
.fl-ring-dash { stroke: var(--line-strong); stroke-dasharray: 2 9; transform-origin: 100px 100px; animation: fl-turn 30s linear infinite; }
.fl-ring-track { stroke: rgba(255, 255, 255, 0.06); opacity: 0; transition: opacity 300ms; }
.fl-ring-fill {
  stroke: url(#fl-grad); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100;
  filter: drop-shadow(0 0 6px rgba(156, 92, 255, 0.6)); transition: stroke-dashoffset 300ms var(--ease), stroke 300ms;
}
.fl-stage-chip { position: relative; width: 58%; height: auto; transition: transform 500ms var(--ease), opacity 300ms; }
.fl-stage-pct {
  position: absolute; font-size: clamp(40px, 4.4vw, 58px); font-weight: 700; letter-spacing: -0.04em;
  font-variation-settings: "wdth" 86; font-variant-numeric: tabular-nums; opacity: 0; transform: scale(0.8);
  transition: opacity 300ms, transform 400ms var(--ease);
}
.fl-stage-pct small { font-size: 0.45em; color: var(--muted); margin-left: 2px; }
.fl-stage-done, .fl-stage-err { position: absolute; width: 38%; height: 38%; fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.fl-stage-done { stroke: #fff; stroke-dasharray: 48; stroke-dashoffset: 48; }
.fl-stage-err { stroke: #fff; }
.fl-spark { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }

/* idle: slow dashed orbit around the board */
.fl-stage[data-state="idle"] .fl-stage-chip { animation: fl-bob 4s ease-in-out infinite; }
/* busy (connecting, downloading): a comet runs round the ring */
.fl-stage[data-state="busy"] .fl-ring-track { opacity: 1; }
.fl-stage[data-state="busy"] .fl-ring-fill { stroke-dasharray: 22 78; animation: fl-orbit 1.1s linear infinite; transition: none; }
.fl-stage[data-state="busy"] .fl-stage-chip { animation: fl-bob 1.6s ease-in-out infinite; }
/* ready: connected, full soft ring */
.fl-stage[data-state="ready"] .fl-ring-track { opacity: 1; }
.fl-stage[data-state="ready"] .fl-ring-fill { stroke-dashoffset: 0; opacity: 0.35; }
.fl-stage[data-state="ready"] .fl-stage-chip { transform: scale(1.06); }
/* writing: the ring is the progress bar, the number replaces the board */
.fl-stage[data-state="writing"] .fl-ring-track { opacity: 1; }
.fl-stage[data-state="writing"] .fl-ring-dash { opacity: 0; }
.fl-stage[data-state="writing"] .fl-stage-chip { opacity: 0; transform: scale(0.6); }
.fl-stage[data-state="writing"] .fl-stage-pct { opacity: 1; transform: none; }
/* done */
.fl-stage[data-state="done"] .fl-ring-dash { opacity: 0; }
.fl-stage[data-state="done"] .fl-ring-fill { stroke: var(--ok); stroke-dashoffset: 0; filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.7)); }
.fl-stage[data-state="done"] .fl-stage-chip { opacity: 0; transform: scale(0.6); }
.fl-stage[data-state="done"]::before, .fl-stage[data-state="error"]::before {
  content: ""; position: absolute; width: 52%; height: 52%; border-radius: 50%; animation: fl-pop 500ms var(--ease) both;
}
.fl-stage[data-state="done"]::before { background: var(--ok); box-shadow: 0 0 60px -6px rgba(34, 197, 94, 0.8); }
.fl-stage[data-state="done"] .fl-stage-done { opacity: 1; stroke-dashoffset: 0; transition: stroke-dashoffset 500ms 250ms var(--ease); }
.fl-stage[data-state="done"] .fl-spark { animation: fl-burst 900ms var(--ease) both; }
/* error */
.fl-stage[data-state="error"] .fl-ring-dash { opacity: 0; }
.fl-stage[data-state="error"] .fl-ring-fill { stroke: var(--danger); stroke-dashoffset: 0; filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6)); }
.fl-stage[data-state="error"] .fl-stage-chip { opacity: 0; }
.fl-stage[data-state="error"]::before { background: var(--danger); }
.fl-stage[data-state="error"] .fl-stage-err { opacity: 1; }
.fl-stage[data-state="error"] { animation: fl-shake 420ms var(--ease); }

.fl-status { text-align: center; }
.fl-status b { display: block; font-size: 20px; font-weight: 650; letter-spacing: -0.015em; }
.fl-status span { display: block; margin: 6px auto 0; max-width: 40ch; font-size: 14px; color: var(--muted); }
.fl-kv { margin-top: 22px; }
.fl-kv li { grid-template-columns: 96px minmax(0, 1fr); font-size: 14px; }
.fl-kv span { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.fl-after { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.fl-after[hidden] { display: none; }

.fl-log { margin-top: 18px; border-top: 1px solid var(--line); }
.fl-log summary {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 0 6px; cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.fl-log summary::-webkit-details-marker { display: none; }
.fl-log summary::before { content: "+"; margin-right: 8px; color: var(--primary-hover); }
.fl-log[open] summary::before { content: "−"; }
.fl-log summary { justify-content: flex-start; }
.fl-copy { margin-left: auto; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; font-family: var(--mono); font-size: 11px; color: var(--muted); cursor: pointer; }
.fl-copy:hover { color: #fff; border-color: var(--line-strong); }
.fl-log pre {
  margin: 8px 0 0; max-height: 220px; overflow: auto; padding: 12px 14px; border-radius: var(--r-sm);
  background: #030305; border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; line-height: 1.55;
  color: #a7a7b8; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Motion ---------- */
@keyframes fl-spin { to { transform: rotate(360deg); } }
@keyframes fl-turn { to { transform: rotate(360deg); } }
@keyframes fl-orbit { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -100; } }
@keyframes fl-bob { 50% { transform: translateY(-5px); } }
@keyframes fl-pop { from { transform: scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fl-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes fl-ping { 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
@keyframes fl-burst {
  from { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55), 0 0 0 0 rgba(156, 92, 255, 0.4); }
  to { box-shadow: 0 0 0 26px rgba(34, 197, 94, 0), 0 0 0 52px rgba(156, 92, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .fl-stage *, .fl-stage, .fl-stage::before, .fl-device::before { animation: none !important; }
}

/* .btn sets display, so [hidden] needs the help. */
.fl-actions [hidden], .fl-after [hidden] { display: none !important; }
