/* ═══════════════════════════════════════════════════════════════════
   offchat — OPSEC-grade ephemeral chat
   Design: ultra-minimal · digital noir · terminal aesthetic
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ───────────────────────────────────────────────── */
:root {
  --bg: #060608;
  --bg-subtle: #0a0a10;
  --surface: #0e0e16;
  --surface-hover: #12121c;
  --border: #1a1a28;
  --border-focus: #2a2a40;

  --accent: #00ffa3;
  --accent-dim: rgba(0, 255, 163, 0.12);
  --accent-glow: rgba(0, 255, 163, 0.25);
  --accent-ghost: rgba(0, 255, 163, 0.06);

  --text: #c0c0d0;
  --text-bright: #e8e8f0;
  --text-muted: #505068;
  --text-dim: #35354a;

  --danger: #ff2d55;
  --danger-dim: rgba(255, 45, 85, 0.15);
  --warning: #ffb800;
  --warning-dim: rgba(255, 184, 0, 0.15);

  --font: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  user-select: none;
}

input,
button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

::selection {
  background: var(--accent-dim);
  color: var(--accent);
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--border-focus);
}

/* ─── Ambient Background ──────────────────────────────────────────── */
.ambient-grid {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0, 255, 163, 0.03) 0%, transparent 60%),
    repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(0, 255, 163, 0.008) 2px,
      rgba(0, 255, 163, 0.008) 4px);
  pointer-events: none;
  z-index: 0;
}

/* subtle vignette */
.ambient-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 50%, var(--bg) 100%);
}

/* ═══════════════════════════════════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════════════════════════════════ */
.landing {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 40px;
  padding: 24px;
}

/* ─── Hero / Logo ─────────────────────────────────────────────────── */
.landing__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeInUp 0.6s ease-out;
}

.logo-mark {
  opacity: 0.5;
  margin-bottom: 4px;
}

.logo {
  font-size: clamp(3.2rem, 10vw, 5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo__off {
  color: var(--text-bright);
}

.logo__chat {
  color: var(--accent);
  text-shadow:
    0 0 20px var(--accent-glow),
    0 0 60px rgba(0, 255, 163, 0.1);
}

.tagline {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: lowercase;
}

/* ─── Input Area ──────────────────────────────────────────────────── */
.landing__input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 540px;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

.input-container {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 6px 0 20px;
  height: 64px;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.input-container:focus-within {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent-dim),
    0 0 20px var(--accent-ghost),
    0 4px 24px rgba(0, 0, 0, 0.4);
}

.input-prefix {
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
}

.input-room {
  flex: 1;
  height: 100%;
  color: var(--accent);
  font-weight: 500;
  caret-color: var(--accent);
  min-width: 0;
}

.input-room::placeholder {
  color: var(--text-dim);
  font-weight: 300;
}

.btn-go {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-go:not(:disabled):hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.btn-go:disabled {
  opacity: 0.3;
  cursor: default;
}

.input-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.input-hint kbd {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Footer ──────────────────────────────────────────────────────── */
.landing__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.footer-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.footer-info strong {
  color: var(--text);
  font-weight: 500;
}

.blink-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent-glow);
}

.footer-badges {
  display: flex;
  gap: 8px;
}

.badge {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-ghost);
  color: var(--accent);
  border: 1px solid rgba(0, 255, 163, 0.08);
}

/* ═══════════════════════════════════════════════════════════════════
   CHAT PAGE
   ═══════════════════════════════════════════════════════════════════ */
.chat-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ─── Chat Header ─────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 6, 8, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

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

.logo-sm {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-muted);
}

.logo-sm .accent {
  color: var(--accent);
}

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

.header-sep {
  color: var(--text-dim);
  font-weight: 300;
}

.room-id {
  color: var(--text);
  font-weight: 400;
  font-size: 1.05rem;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.btn-icon.copied {
  color: var(--accent);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
}

.presence {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
}

.presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 3s ease-in-out infinite;
}

.timer {
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

.timer.warning {
  color: var(--warning);
}

.timer.critical {
  color: var(--danger);
  animation: timerPulse 1s ease-in-out infinite;
}

.encryption-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  opacity: 0.6;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-ghost);
}

/* ─── Messages Area ───────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.messages__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  font-size: 1rem;
  color: var(--text-dim);
  text-align: center;
}

.messages__empty .dim {
  font-size: 0.85rem;
  opacity: 0.5;
}

/* Message row */
.message {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  font-size: 1.05rem;
  animation: msgIn 0.2s ease-out;
}

.msg-time {
  color: var(--text-dim);
  font-size: 0.85rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.msg-name {
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
  font-size: 1rem;
}

.msg-name.self {
  color: var(--text-muted);
}

.msg-text {
  color: var(--text-bright);
  word-break: break-word;
}

/* ─── File Messages ───────────────────────────────────────────────── */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 220px;
  max-width: 400px;
  flex-wrap: wrap;
  transition: border-color var(--transition);
}

.file-card:hover {
  border-color: var(--border-focus);
}

.file-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.file-name {
  color: var(--text-bright);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.file-download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
}

.file-download:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.file-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  opacity: 0.9;
}

.file-preview:hover {
  opacity: 1;
}

/* File upload button */
.btn-file {
  flex-shrink: 0;
}

.btn-file.uploading {
  animation: pulse 1s ease-in-out infinite;
  color: var(--accent);
}

/* System messages */
.message.system {
  gap: 0;
}

.msg-system {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
}

/* ─── Chat Footer / Input ─────────────────────────────────────────── */
.chat-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  background: rgba(6, 6, 8, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.my-codename {
  color: var(--accent);
  font-weight: 500;
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.prompt-arrow {
  color: var(--text-dim);
  font-weight: 300;
  flex-shrink: 0;
}

.msg-input {
  flex: 1;
  height: 100%;
  color: var(--text-bright);
  caret-color: var(--accent);
  font-weight: 400;
  min-width: 0;
}

.msg-input::placeholder {
  color: var(--text-dim);
  font-weight: 300;
}

.msg-input:disabled {
  opacity: 0.3;
}

/* ─── Error Overlay ───────────────────────────────────────────────── */
[hidden] {
  display: none !important;
}

.error-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 8, 0.95);
  backdrop-filter: blur(20px);
}

.error-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 460px;
  padding: 40px;
}

.error-box h2 {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--danger);
}

.error-box p {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.btn-back {
  display: inline-block;
  margin-top: 10px;
  padding: 12px 28px;
  font-size: 1rem;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}

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

/* ═══════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.2;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

@keyframes timerPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .landing {
    gap: 32px;
    padding: 20px 16px;
  }

  .input-container {
    height: 44px;
    padding: 0 4px 0 12px;
  }

  .chat-header {
    padding: 0 12px;
  }

  .messages {
    padding: 12px;
  }

  .chat-footer {
    padding: 10px 12px;
  }

  .footer-badges {
    flex-wrap: wrap;
    justify-content: center;
  }

  .encryption-badge span {
    display: none;
  }
}

/* ─── Toast Notification ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 0.95rem;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}