/* Shared styles for hostlocal */

/* ─── Site nav (shared across all pages) ─── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 16, 38, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.site-nav .nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #e6eef8;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.site-nav .nav-logo .logo-mark-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  image-rendering: auto;
}

.site-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.site-nav .nav-links a {
  display: block;
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition:
    color 0.15s,
    background 0.15s;
}

.site-nav .nav-links a:hover {
  color: #e6eef8;
  background: rgba(255, 255, 255, 0.05);
}

.site-nav .nav-links a.active {
  color: #e6eef8;
}

/* ─── Landing page ─── */
.landing-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-body main {
  flex: 1;
}

/* Hero */
.hero {
  text-align: center;
  padding: 80px 24px 60px;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, #e6eef8 30%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
}

.hero .tagline {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 480px;
  margin: 0 auto 12px;
  line-height: 1.6;
}

/* CORS notice */
.cors-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.18);
  color: #ffdca6;
  font-size: 0.85rem;
  cursor: default;
}

.cors-notice .cors-toggle {
  background: none;
  border: none;
  color: #fbbf24;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* anchor variant (replaces button on landing page) */
a.cors-toggle {
  color: #fbbf24;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* CORS modal / popover */
.cors-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.cors-modal-backdrop[hidden] {
  display: none;
}

.cors-modal {
  background: #0d1929;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 520px;
  width: 100%;
  position: relative;
}

.cors-modal h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #e6eef8;
}

.cors-modal p {
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.cors-modal p:last-of-type {
  margin-bottom: 0;
}

.cors-modal code {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.88em;
  color: #e6eef8;
}

.cors-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s;
}

.cors-modal-close:hover {
  color: #e6eef8;
}

/* Steps */
.steps-section {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 72px;
}

.steps-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: start;
  gap: 0;
}

.step {
  text-align: center;
  padding: 0 8px;
}

.step-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(6, 182, 212, 0.12));
  border: 1px solid rgba(124, 58, 237, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
}

.step h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e6eef8;
  margin-bottom: 6px;
}

.step p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.step-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 24px; /* align with icon center */
  color: rgba(124, 58, 237, 0.5);
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* CTA section */
.cta-section {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.cta-card {
  background: rgba(11, 18, 32, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(2, 6, 23, 0.6);
}

.cta-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.cta-card .cta-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 24px;
}

.cta-input-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.cta-input-row:focus-within {
  border-color: rgba(124, 58, 237, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.cta-prefix {
  padding: 0 8px 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
  user-select: none;
}

.cta-port-input {
  flex: 1;
  min-width: 0;
  padding: 13px 8px;
  background: none;
  border: none;
  color: #e6eef8;
  font-size: 1rem;
  outline: none;
  /* hide number spinners */
  -moz-appearance: textfield;
}

.cta-port-input::-webkit-inner-spin-button,
.cta-port-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.cta-start-btn {
  flex-shrink: 0;
  padding: 13px 22px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.cta-start-btn:hover {
  opacity: 0.9;
}

.cta-start-btn:active {
  opacity: 0.8;
}

/* Landing footer */
.landing-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding: 20px 24px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

/* About page */
.about-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.about-body main {
  flex: 1;
  max-width: 740px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  width: 100%;
}

.about-body h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.about-body .about-lead {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 40px;
}

.about-body h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 40px 0 12px;
  color: #e6eef8;
}

.about-body p {
  color: #b8c8dc;
  line-height: 1.7;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.about-body main ul,
.about-body main ol {
  padding-left: 20px;
  color: #b8c8dc;
  line-height: 1.7;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.about-body main li {
  margin-bottom: 6px;
}

.about-body code {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.88em;
  color: #e6eef8;
}

.about-body pre {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: #b8c8dc;
}

.about-body a {
  color: #7c3aed;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.faq-item {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 20px 0 4px;
}

.faq-item:last-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.faq-q {
  font-size: 0.98rem;
  font-weight: 600;
  color: #e6eef8;
  margin-bottom: 8px;
}

.faq-a {
  color: #b8c8dc;
  font-size: 0.92rem;
  line-height: 1.65;
}

/* Responsive */
@media (max-width: 600px) {
  .steps-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .step-arrow {
    display: none;
  }
  .hero {
    padding: 48px 20px 40px;
  }
  .cta-card {
    padding: 24px 20px;
  }
  .cta-input-row {
    flex-direction: column;
    border-radius: 10px;
    border: none;
    gap: 8px;
    background: none;
  }
  .cta-input-row:focus-within {
    box-shadow: none;
  }
  .cta-port-input {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 14px;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
  }
  .cta-prefix {
    display: none;
  }
  .cta-port-input::placeholder {
    content: 'e.g. 3000';
  }
  .cta-start-btn {
    border-radius: 8px;
    width: 100%;
    padding: 13px;
  }
}

:root {
  --bg: #0f1724;
  --card: #0b1220;
  --muted: #94a3b8;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --success: #16a34a;
  --error: #ef4444;
  --warn: #f59e0b;
  --glass: rgba(255, 255, 255, 0.03);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial;
  background: linear-gradient(180deg, #071026 0%, #0b1220 100%);
  color: #e6eef8;
}

/* Host UI layout */
.host-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.host-body main.container,
.host-body > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* When .container is direct child of host-body (legacy), keep compat */
.host-body .container {
  width: 100%;
  max-width: 860px;
}

.host-body .card {
  background: var(--card);
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(2, 6, 23, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.host-body h1 {
  margin: 0 0 8px 0;
  font-weight: 700;
  font-size: 28px;
}

.host-body label {
  font-size: 13px;
  color: var(--muted);
}

.host-body input[type='text'],
.host-body input[readonly] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--glass);
  color: inherit;
  width: 100%;
  outline: none;
}

.host-body input:focus {
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.6);
}

/* Host dashboard overrides for the cta-input-row inside a card */
.host-body .card .cta-input-row {
  border-radius: 8px;
}

.host-body .card #stop-btn {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
}

.host-body .card #stop-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

.host-body .card #stop-btn:not([hidden]) {
  display: block;
}

.host-body .card .controls:has(#stop-btn:not([hidden])) {
  display: flex !important;
}

/* When tunnel is active, hide the port input row */
.host-body .card #port-input-row.tunnel-active {
  display: none;
}

/* port label hidden when tunnel active */
.host-body .card label[for='port'].hidden {
  display: none;
}

.host-body .btn {
  appearance: none;
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
}

.host-body .btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 600;
}

.host-body .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.host-body #share-row:not([hidden]) {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

.host-body .status {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
}

.host-body .notice {
  margin-top: 6px;
  padding: 10px;
  border-left: 4px solid var(--warn);
  background: rgba(245, 158, 11, 0.06);
  color: #ffdca6;
  border-radius: 6px;
}

.host-body .footer {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
}

.host-body .status.connected {
  background: rgba(22, 163, 74, 0.08);
  color: var(--success);
}

.host-body .status.error {
  background: rgba(239, 68, 68, 0.06);
  color: var(--error);
}

.host-body .status.connecting {
  background: rgba(245, 158, 11, 0.06);
  color: var(--warn);
}

.host-body .copy-toast {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(22, 163, 74, 0.9);
  color: white;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  animation: fadeOut 1.5s ease-out forwards;
}

@keyframes fadeOut {
  0%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.host-body #preview-row:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.host-body .preview-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.host-body #host-preview {
  width: 100%;
  height: 240px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: #fff;
}

.host-body .preview-error {
  font-size: 12px;
  color: var(--error);
  padding: 6px 8px;
  background: rgba(239, 68, 68, 0.06);
  border-radius: 6px;
  border-left: 3px solid var(--error);
}

/* Viewer UI layout */
.viewer-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.viewer-body .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.viewer-body header.status {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.viewer-body header.status h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
  color: #fff;
}

.viewer-body #status-message {
  font-size: 0.95rem;
  color: var(--muted);
}

.viewer-body header.status.connecting {
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.06), transparent);
  border-left: 6px solid var(--warn);
}

.viewer-body header.status.connected {
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.06), transparent);
  border-left: 6px solid var(--success);
}

.viewer-body header.status.error {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.06), transparent);
  border-left: 6px solid var(--error);
}

.viewer-body main#main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.viewer-body #error {
  max-width: 1100px;
  margin: 12px auto;
  padding: 12px;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.06);
  color: var(--error);
  display: none;
}

.viewer-body #error.visible {
  display: block;
}

.viewer-body #iframe-container {
  position: relative;
  flex: 1;
  display: block;
  max-width: 1100px;
  margin: 12px auto;
  width: 100%;
}

.viewer-body iframe#tunnel-frame {
  width: 100%;
  height: calc(100vh - 140px);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  background: #fff;
}

.viewer-body iframe#tunnel-frame.hidden {
  display: none;
}

.viewer-body .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.6), rgba(2, 6, 23, 0.7));
  backdrop-filter: blur(3px);
}

.viewer-body .overlay.hidden {
  display: none;
}

.viewer-body .overlay .overlay-content {
  background: rgba(255, 255, 255, 0.03);
  padding: 28px;
  border-radius: 10px;
  text-align: center;
  max-width: 640px;
}

.viewer-body .overlay h2 {
  margin: 0 0 8px 0;
  font-size: 1.6rem;
  color: #fff;
}

.viewer-body .overlay p {
  margin: 0;
  color: var(--muted);
}

.viewer-body footer.help {
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.9rem;
  color: var(--muted);
}

/* Common utilities */
.hidden {
  display: none;
}

/* Shared button styles (unscoped — usable outside .host-body) */
.btn {
  appearance: none;
  border: 0;
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  cursor: pointer;
  font-size: 0.95rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 600;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inline status message for async form submissions */
.subdomain-status {
  margin-top: 8px;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.subdomain-status.success {
  color: #4ade80;
}

.subdomain-status.error {
  color: #f87171;
}

/* --- Viewer panel (host UI) --- */
.host-body .viewers-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.host-body .viewers-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
}

.host-body .viewer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--glass);
  font-size: 13px;
  color: #e6eef8;
}

/* The "light" indicator */
.host-body .viewer-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted); /* default: grey / connecting */
  box-shadow: none;
  transition:
    background 0.3s,
    box-shadow 0.3s;
}

.host-body .viewer-light.green {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.host-body .viewer-light.yellow {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}

.host-body .viewer-light.red {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
}

.host-body #viewers-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .host-body .card {
    padding: 20px 16px;
  }
  .host-body .controls {
    flex-direction: column;
  }
}

@media (max-width: 700px) {
  .viewer-body iframe#tunnel-frame {
    height: calc(100vh - 180px);
  }
  .viewer-body .container {
    padding: 10px;
  }
}

.host-body #qr-panel:not([hidden]) {
  display: flex;
  justify-content: flex-start;
  padding: 8px 0 4px;
}

.host-body #qr-canvas {
  border-radius: 6px;
  image-rendering: pixelated; /* keep QR modules crisp */
}
