/* ============================================================
   MeshGuard — MeshRDV configurator
   Aesthetic: Matrix rain + military/SAR + adventure
   Palette  : terminal green / SOS red / amber warn
   ============================================================ */

:root {
  --bg:         #050807;
  --bg-pane:   rgba(8, 14, 12, 0.78);
  --bg-pane-2: rgba(10, 20, 16, 0.55);
  --fg:         #c9f7d2;
  --fg-dim:     #6b9c78;
  --neon:       #00ff66;
  --neon-soft:  #00cc55;
  --neon-glow:  #00ff66cc;
  --sos:        #ff2d2d;
  --sos-glow:   #ff2d2dcc;
  --amber:      #ffaa00;
  --amber-soft: #cc8800;
  --line:       rgba(0, 255, 102, 0.18);
  --line-strong:rgba(0, 255, 102, 0.45);
  --mono:       'Share Tech Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;
  --display:    'Orbitron', 'Share Tech Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--neon); text-decoration: none; }
a:hover { color: var(--fg); text-shadow: 0 0 8px var(--neon-glow); }

/* --- Background canvas --- */
#matrix-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.45;
  pointer-events: none;
}

.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  mix-blend-mode: multiply;
}

/* --- Layout --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: 0.15em;
  font-size: 18px;
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon-glow);
}

.dot {
  width: 10px;
  height: 10px;
  background: var(--sos);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--sos-glow);
  animation: pulse-sos 1.4s ease-in-out infinite;
}

@keyframes pulse-sos {
  0%, 100% { opacity: 0.95; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.75); }
}

.cursor {
  display: inline-block;
  margin-left: 2px;
  animation: blink 1s steps(2, jump-none) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.topnav { display: flex; gap: 26px; }
.topnav a {
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s, text-shadow 0.2s;
}
.topnav a:hover {
  color: var(--neon);
  border-bottom-color: var(--neon);
  text-shadow: 0 0 8px var(--neon-glow);
}

main {
  position: relative;
  z-index: 5;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 64px 0 56px;
  position: relative;
}
.kicker {
  font-size: 13px;
  letter-spacing: 0.4em;
  color: var(--fg-dim);
  margin: 0 0 28px;
}
h1.glitch {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(64px, 14vw, 144px);
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--neon);
  text-shadow:
    0 0 24px var(--neon-glow),
    0 0 64px rgba(0, 255, 102, 0.35);
  position: relative;
  display: inline-block;
}
h1.glitch::before,
h1.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
h1.glitch::before {
  color: var(--sos);
  transform: translate(-2px, 0);
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: glitch-1 3.4s infinite steps(1);
}
h1.glitch::after {
  color: #00d4ff;
  transform: translate(2px, 0);
  mix-blend-mode: screen;
  opacity: 0.45;
  animation: glitch-2 2.7s infinite steps(1);
}
@keyframes glitch-1 {
  0%, 95%, 100% { transform: translate(-2px, 0); }
  96%           { transform: translate(-6px, 1px); }
  97%           { transform: translate(-1px, -2px); }
  98%           { transform: translate(-4px, 2px); }
}
@keyframes glitch-2 {
  0%, 94%, 100% { transform: translate(2px, 0); }
  95%           { transform: translate(6px, -1px); }
  96%           { transform: translate(1px, 2px); }
  97%           { transform: translate(4px, -2px); }
}

.tagline {
  margin: 16px 0 4px;
  font-size: 16px;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
}

.status-row {
  margin-top: 36px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 13px;
  letter-spacing: 0.08em;
  background: var(--bg-pane-2);
}
.status .led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-ok .led {
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon-glow);
}
.status-info .led {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 170, 0, 0.7);
}
.status-info { color: var(--amber); border-color: rgba(255, 170, 0, 0.35); }

/* --- Cards --- */
.card {
  background: var(--bg-pane);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 32px 36px;
  margin: 28px 0;
  position: relative;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 2px;
  pointer-events: none;
  background: linear-gradient(135deg,
    transparent 0%,
    transparent 45%,
    rgba(0, 255, 102, 0.08) 50%,
    transparent 55%,
    transparent 100%);
}
.card h2 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--neon);
  font-size: 20px;
  margin: 0 0 18px;
  text-shadow: 0 0 12px rgba(0, 255, 102, 0.35);
}
.card p { color: var(--fg); margin: 0 0 12px; }
.note {
  font-size: 13px;
  color: var(--fg-dim);
  font-style: italic;
  border-left: 2px solid var(--amber-soft);
  padding-left: 12px;
}
.bullets { padding-left: 20px; margin: 8px 0 0; }
.bullets li { margin: 6px 0; color: var(--fg); }
.bullets strong { color: var(--neon); }

code, kbd {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--amber);
  background: rgba(255, 170, 0, 0.08);
  border: 1px solid rgba(255, 170, 0, 0.25);
  padding: 1px 6px;
  border-radius: 2px;
}
kbd {
  color: var(--neon);
  background: rgba(0, 255, 102, 0.08);
  border-color: rgba(0, 255, 102, 0.3);
  font-weight: bold;
}

/* --- Form --- */
fieldset {
  border: 1px solid var(--line);
  padding: 18px 22px 22px;
  margin: 20px 0;
  border-radius: 2px;
  background: var(--bg-pane-2);
}
legend {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--neon);
  padding: 0 10px;
}

/* New cfg form layout */
.cfg-section { margin: 24px 0; }
.cfg-section .note { margin: 0 0 18px; font-size: 13px; color: var(--fg-dim); }
.cfg-section .field {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px 16px;
  margin: 14px 0;
  align-items: start;
}
.cfg-section .field .lbl {
  font-family: var(--display);
  letter-spacing: 0.06em;
  color: var(--neon);
  font-size: 13px;
  padding-top: 12px;
}
.cfg-section .field input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.cfg-section .field input:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 1px var(--neon-soft), 0 0 12px rgba(0, 255, 102, 0.25);
  background: rgba(0, 30, 15, 0.55);
}
.cfg-section .field input:invalid {
  border-color: rgba(255, 45, 45, 0.4);
}
.cfg-section .field .hint {
  grid-column: 2;
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
  font-style: italic;
  padding-top: 2px;
}
.cfg-section .field input::placeholder { color: var(--fg-dim); opacity: 0.6; }

/* Two fields side by side; stacks on narrow screens. Inside a row the fields
   switch to a vertical layout (label ABOVE the input, full width) instead of
   the default 2-column grid, which would squash the label into a narrow box. */
.field-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.field-row .field {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-row .field .lbl {
  padding-top: 0;
}
.field-row .field input {
  width: 100%;
}
.field-row .field .hint {
  grid-column: auto;
}
/* DFU prerequisite warning at the top of the DEPLOY card. */
.dfu-warn {
  border: 1px solid rgba(255, 170, 0, 0.45);
  background: rgba(255, 170, 0, 0.08);
  border-left: 3px solid var(--amber);
  color: var(--fg);
  padding: 12px 16px;
  margin: 0 0 18px;
  border-radius: 2px;
  font-size: 14px;
  line-height: 1.5;
}
.dfu-warn strong { color: var(--amber); }
.dfu-warn code {
  color: var(--amber);
  background: rgba(255, 170, 0, 0.12);
}

/* Reveal/hide (eye) button for masked sensitive fields. */
.btn-eye {
  font-size: 15px;
  padding: 6px 12px;
  filter: grayscale(0.5);
}
.btn-eye.on {
  background: rgba(0, 255, 102, 0.18);
  filter: none;
}

/* "(optionnel)" label hint in a legend */
.opt {
  color: var(--fg-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.psk-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.psk-row input {
  flex: 1 1 280px;
  font-size: 13px !important;
  letter-spacing: 0.06em !important;
}
.btn-small {
  background: rgba(0, 255, 102, 0.1);
  border: 1px solid var(--line-strong);
  color: var(--neon);
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.18em;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.18s;
  text-shadow: 0 0 6px rgba(0, 255, 102, 0.35);
}
.btn-small:hover {
  background: rgba(0, 255, 102, 0.2);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
}
.btn-small.btn-soft {
  color: var(--amber);
  background: rgba(255, 170, 0, 0.07);
  border-color: rgba(255, 170, 0, 0.3);
  text-shadow: 0 0 6px rgba(255, 170, 0, 0.35);
}
.btn-small.btn-soft:hover {
  background: rgba(255, 170, 0, 0.15);
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.3);
}

/* LICENSE section: visually distinct */
.license-section {
  border-color: rgba(255, 170, 0, 0.35);
  background: linear-gradient(180deg, rgba(255, 170, 0, 0.04) 0%, rgba(255, 170, 0, 0.01) 100%);
}
.license-section legend { color: var(--amber); }
.license-section .lbl { color: var(--amber); }
.license-section .field input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber-soft), 0 0 12px rgba(255, 170, 0, 0.25);
}

@media (max-width: 700px) {
  .cfg-section .field {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .cfg-section .field .lbl { padding-top: 0; }
  .cfg-section .field .hint { grid-column: 1; }
}

/* Legacy compact form (kept for ref) */
/* (Legacy boxed-label styles removed — labels are plain text now, see
   .cfg-section .field .lbl above.) */
fieldset input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
fieldset input::placeholder { color: var(--fg-dim); opacity: 0.7; }
fieldset input:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 1px var(--neon-soft), 0 0 12px rgba(0, 255, 102, 0.25);
  background: rgba(0, 30, 15, 0.55);
}
fieldset input:invalid {
  border-color: rgba(255, 45, 45, 0.5);
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-top: 24px;
}
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 20px 32px;
  background: linear-gradient(180deg, rgba(255, 45, 45, 0.18) 0%, rgba(255, 45, 45, 0.05) 100%);
  border: 1px solid var(--sos);
  color: var(--sos);
  font-family: var(--display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.22em;
  cursor: pointer;
  border-radius: 2px;
  text-shadow: 0 0 12px var(--sos-glow);
  box-shadow:
    0 0 18px rgba(255, 45, 45, 0.25),
    inset 0 0 24px rgba(255, 45, 45, 0.08);
  transition: all 0.18s;
  position: relative;
  overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 45, 45, 0.3), transparent);
  transition: left 0.6s;
}
.btn-primary:hover {
  background: linear-gradient(180deg, rgba(255, 45, 45, 0.32) 0%, rgba(255, 45, 45, 0.12) 100%);
  text-shadow: 0 0 18px var(--sos-glow);
  box-shadow:
    0 0 28px rgba(255, 45, 45, 0.45),
    inset 0 0 32px rgba(255, 45, 45, 0.18);
}
.btn-primary:hover::before { left: 100%; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary .btn-icon { font-size: 26px; }
.btn-primary .btn-hint {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  font-weight: 400;
  color: var(--fg-dim);
  text-shadow: none;
}

.status-msg {
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  min-height: 22px;
}
.status-msg.ok    { color: var(--neon); text-shadow: 0 0 8px var(--neon-glow); }
.status-msg.warn  { color: var(--amber); }
.status-msg.error { color: var(--sos); text-shadow: 0 0 8px var(--sos-glow); }

/* --- Deploy --- */
.deploy-card { border-color: var(--neon); box-shadow: 0 0 36px rgba(0, 255, 102, 0.18); }
.deploy-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.deploy-steps li {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--neon);
  background: var(--bg-pane-2);
}
.step-num {
  font-family: var(--display);
  font-weight: 900;
  font-size: 28px;
  color: var(--neon);
  text-shadow: 0 0 14px var(--neon-glow);
  min-width: 56px;
}
.deploy-steps strong { color: var(--neon); letter-spacing: 0.06em; }
.deploy-steps .hint  {
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.08em;
  margin: 6px 0 0;
  font-style: italic;
}

.download-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px 26px;
  border: 1px solid var(--neon);
  background: linear-gradient(180deg, rgba(0, 255, 102, 0.16) 0%, rgba(0, 255, 102, 0.04) 100%);
  color: var(--neon);
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.18em;
  text-shadow: 0 0 10px var(--neon-glow);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 16px rgba(0, 255, 102, 0.18);
  flex-wrap: wrap;
}
.btn-download:hover {
  background: linear-gradient(180deg, rgba(0, 255, 102, 0.28) 0%, rgba(0, 255, 102, 0.08) 100%);
  box-shadow: 0 0 28px rgba(0, 255, 102, 0.36);
  color: var(--fg);
}
.btn-download .btn-hint {
  flex-basis: 100%;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  font-weight: 400;
  color: var(--fg-dim);
  text-shadow: none;
  margin-top: 4px;
}
.pre-mission {
  font-size: 13px;
  padding: 16px;
  border: 1px dashed var(--amber-soft);
  color: var(--fg);
  background: rgba(255, 170, 0, 0.05);
  border-radius: 2px;
}
.pre-mission strong { color: var(--amber); letter-spacing: 0.1em; }

/* --- Control reference grid --- */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.ctrl-card {
  border: 1px solid var(--line);
  padding: 16px 18px;
  background: var(--bg-pane-2);
}
.ctrl-card h3 {
  font-family: var(--display);
  letter-spacing: 0.14em;
  font-size: 14px;
  color: var(--neon);
  margin: 0 0 10px;
}
.ctrl-card p { margin: 6px 0; font-size: 14px; color: var(--fg); }
.ctrl-card.sos { border-color: rgba(255, 45, 45, 0.45); }
.ctrl-card.sos h3 { color: var(--sos); text-shadow: 0 0 8px var(--sos-glow); }

/* --- Footer --- */
footer {
  position: relative;
  z-index: 5;
  padding: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.12em;
  border-top: 1px solid var(--line);
}

/* --- Responsive --- */
@media (max-width: 700px) {
  .topbar { padding: 14px 18px; }
  .topnav { display: none; }
  main { padding: 24px 16px 64px; }
  .card { padding: 22px 18px; }
  .hero { padding: 32px 0 36px; }
  h1.glitch { font-size: clamp(48px, 18vw, 100px); }
  .deploy-steps li { padding: 14px 12px; gap: 12px; }
  .step-num { font-size: 22px; min-width: 40px; }
  .btn-primary { font-size: 18px; padding: 16px 18px; }
}

/* Reduce motion for users that ask for it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #matrix-bg { display: none; }
}

/* ===== Login gate (JS-side access) ===================================== */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 5, 0.92);
  backdrop-filter: blur(4px);
}
.login-gate.hidden { display: none; }
.login-box {
  width: min(92vw, 380px);
  background: var(--bg-pane);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0, 255, 102, 0.12), inset 0 0 30px rgba(0, 255, 102, 0.04);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--neon);
  font-size: 18px;
}
.login-kicker {
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 0.22em;
  margin: 0;
}
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field .lbl {
  font-family: var(--display);
  letter-spacing: 0.06em;
  color: var(--neon);
  font-size: 12px;
}
.login-field input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px 14px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.1em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-field input:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 1px var(--neon-soft), 0 0 12px rgba(0, 255, 102, 0.25);
}
.login-btn { justify-content: center; width: 100%; }
.login-err {
  color: var(--sos);
  font-size: 13px;
  letter-spacing: 0.04em;
  margin: 0;
  min-height: 18px;
}
.login-err.shake { animation: login-shake 0.3s; }
@keyframes login-shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
