/* hidechat - Dark Terminal Aesthetic */
/* Fonts: Space Mono (monospace/code) + Syne (display) */

:root {
  --bg:         #0a0a0b;
  --bg-2:       #111113;
  --bg-3:       #18181b;
  --border:     #222226;
  --border-2:   #2e2e34;
  --text:       #e8e8ec;
  --text-muted: #6b6b78;
  --text-dim:   #3a3a42;
  --accent:     #39d98a;
  --accent-dim: #1a4a38;
  --accent-glow:#39d98a44;
  --danger:     #ff4d6d;
  --warn:       #ffb347;
  --blue:       #5b8df0;
  --mono:       'Space Mono', monospace;
  --display:    'Syne', sans-serif;
  --radius:     10px;
  --radius-lg:  16px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── NOISE & GRID TEXTURES ─────────────────────────────────────────── */
.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 128px;
}

.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.4;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
}

/* ── LANDING ───────────────────────────────────────────────────────── */
.landing {
  position: relative;
  z-index: 10;
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

/* LOGO */
.logo-block {
  text-align: center;
}

.logo-ascii {
  font-family: var(--display);
  font-size: clamp(52px, 10vw, 88px);
  font-weight: 800;
  letter-spacing: -4px;
  line-height: 1;
  margin-bottom: 12px;
}

.logo-hide {
  color: var(--text);
}

.logo-chat {
  color: var(--accent);
  position: relative;
}

.logo-chat::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  filter: blur(2px);
  opacity: 0.6;
}

.logo-tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.logo-sub {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto;
}

/* BADGES */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  background: #0d1f18;
  padding: 5px 12px;
  border-radius: 4px;
}

/* ACTION CARDS */
.action-cards {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 680px;
}

.card {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border-2);
  box-shadow: 0 0 40px #00000060;
}

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 4px;
}

.card h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  flex: 1;
}

.card-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  position: relative;
}

.card-divider::before,
.card-divider::after {
  content: '';
  width: 1px;
  flex: 1;
  background: var(--border);
}

.card-divider span {
  padding: 10px 0;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  justify-content: center;
}

.btn--primary {
  background: var(--accent);
  color: #0a1a12;
}

.btn--primary:hover {
  background: #47f0a0;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn--secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

.btn--secondary:hover {
  background: #0d1f18;
  border-color: var(--accent);
}

.btn--full {
  width: 100%;
  margin-top: 8px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* HOW IT WORKS */
.how-it-works {
  width: 100%;
  max-width: 680px;
}

.how-it-works h3 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.steps {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.step {
  flex: 1;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step:last-child { border-right: none; }

.step-num {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-dim);
  line-height: 1;
}

.step-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── PANELS ───────────────────────────────────────────────────────── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: none;
  backdrop-filter: blur(4px);
}

.panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: min(480px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 36px 32px 40px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.panel.active {
  transform: translateX(-50%) translateY(0);
}

.panel-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.panel-close:hover { color: var(--text); }

.panel-logo {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.panel-title {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.panel-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* FORMS */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-group input {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-group input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-dim);
}

.panel-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
}

/* ── CHAT PAGE ─────────────────────────────────────────────────────── */
body.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
  gap: 12px;
  z-index: 10;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-logo {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -1px;
  text-decoration: none;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-label {
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.room-id {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  background: var(--accent-dim);
  padding: 3px 10px;
  border-radius: 4px;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.peer-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--waiting {
  background: var(--warn);
  animation: pulse-warn 2s infinite;
}

.status-dot--connected {
  background: var(--accent);
  animation: pulse-green 2s infinite;
}

.status-dot--disconnected {
  background: var(--danger);
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  padding: 7px 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-copy:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.btn-leave {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid #3a1a20;
  border-radius: 7px;
  padding: 7px 12px;
  color: var(--danger);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-leave:hover {
  background: #1a080c;
}

/* ENCRYPTION BAR */
.enc-bar {
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  flex-shrink: 0;
}

.enc-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.enc-indicator.secured {
  color: var(--accent);
}

.enc-indicator.unsecured {
  color: var(--warn);
}

/* MESSAGES */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar {
  width: 4px;
}

.messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 4px;
}

.messages-inner {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100%;
  justify-content: flex-end;
}

/* WELCOME */
.welcome-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 40px 20px 20px;
  color: var(--text-muted);
}

.welcome-icon {
  opacity: 0.6;
}

.welcome-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.welcome-sub {
  font-size: 13px;
  max-width: 340px;
  line-height: 1.7;
  color: var(--text-muted);
}

.share-code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-3);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 8px;
}

.share-code-box span {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 3px;
}

.btn-inline-copy {
  background: var(--accent-dim);
  border: none;
  border-radius: 5px;
  padding: 4px 10px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s;
}

.btn-inline-copy:hover {
  background: #1e5c3a;
}

/* MESSAGE BUBBLES */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  animation: msg-in 0.2s ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg--mine {
  align-self: flex-end;
  align-items: flex-end;
}

.msg--theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-meta {
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg--mine .msg-bubble {
  background: var(--accent);
  color: #091a10;
  border-bottom-right-radius: 3px;
}

.msg--theirs .msg-bubble {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-bottom-left-radius: 3px;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* SYSTEM MESSAGES */
.msg-system {
  align-self: center;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 12px;
  background: var(--bg-3);
  border-radius: 20px;
  margin: 8px 0;
  border: 1px solid var(--border);
}

/* INPUT AREA */
.chat-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  padding: 12px 16px 16px;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.input-wrapper {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 10px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  width: 100%;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

textarea::placeholder {
  color: var(--text-dim);
}

.btn-send {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #091a10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-send:hover:not(:disabled) {
  background: #47f0a0;
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-send:disabled {
  background: var(--bg-3);
  color: var(--text-dim);
  cursor: not-allowed;
}

.footer-note {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  letter-spacing: 0.3px;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.modal h3 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.modal p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── LOADING STATE ────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── RESPONSIVE ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .landing {
    padding: 40px 16px 60px;
    gap: 32px;
  }

  .action-cards {
    flex-direction: column;
    gap: 0;
  }

  .card-divider {
    flex-direction: row;
    padding: 16px 0;
  }

  .card-divider::before,
  .card-divider::after {
    flex: 1;
    height: 1px;
    width: auto;
  }

  .steps {
    flex-direction: column;
  }

  .step {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .step:last-child { border-bottom: none; }

  .panel {
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 32px 20px 40px;
  }

  .chat-header {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .room-info { display: none; }

  .btn-copy span { display: none; }

  .msg { max-width: 85%; }
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  border-bottom-left-radius: 3px;
  width: fit-content;
  align-self: flex-start;
  animation: msg-in 0.2s ease-out;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── CSP-safe state classes (replaces all inline style= usage) ── */

/* Modal overlay: hidden by default, shown via class */
.modal-overlay          { display: none; }
.modal-overlay.is-open  { display: flex; }

/* Panel overlay: hidden by default, shown via class */
.panel-overlay          { display: none; }
.panel-overlay.is-open  { display: block; }

/* Textarea auto-resize: use a max-height + overflow trick */
/* Height is set via --textarea-h custom property which is CSP-safe */
#message-input {
  height: auto;
  max-height: 120px;
  overflow-y: auto;
}

/* Clipboard fallback helper - off-screen, not display:none (needs to be selectable) */
.visually-hidden-copy {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
