/* ─── Reset ─────────────────────────────────────────────────────────────── */

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

/* ─── Base ───────────────────────────────────────────────────────────────── */

:root {
  --bg:            #0a0c0a;
  --surface:       #0e120e;
  --border:        #1f2e1f;
  --border-bright: #2e4a2e;
  --text:          #7abf7a;
  --text-dim:      #3d6b3d;
  --text-muted:    #2a4a2a;
  --corrupted:     #4a3a1a;
  --corrupted-dim: #2a2010;
  --accent:        #a8d8a8;
  --warn:          #c8a030;
  --warn-dim:      #7a5c10;
  --glow:          rgba(122, 191, 122, 0.08);
  --glow-strong:   rgba(122, 191, 122, 0.18);
  --new:           #78c0d8;
  --new-dim:       rgba(120, 192, 216, 0.15);
  --font:          'Courier New', Courier, monospace;
}

html, body {
  height: 100%;
}

body {
  background-color: #050705;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  /* Subtle scanline overlay */
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

/* ─── Console shell ──────────────────────────────────────────────────────── */

.console {
  width: min(860px, 100%);
  min-height: 100vh;
  background-color: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 60px rgba(0, 0, 0, 0.8),
    inset 0 0 120px var(--glow);
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-bright);
  background-color: var(--bg);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.console-header-left,
.console-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.console-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.console-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

/* ─── Integrity bar ──────────────────────────────────────────────────────── */

.integrity-bar {
  display: inline-block;
  width: 80px;
  height: 6px;
  background-color: var(--border);
  border: 1px solid var(--border-bright);
  position: relative;
  overflow: hidden;
}

.integrity-fill {
  display: block;
  width: 34%;
  height: 100%;
  background-color: var(--warn);
  box-shadow: 0 0 8px var(--warn-dim);
}

.integrity-value {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--warn);
}

/* ─── Console body ───────────────────────────────────────────────────────── */

.console-body {
  flex: 1;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── Messages ───────────────────────────────────────────────────────────── */

.message {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.message:first-child {
  border-top: 1px solid var(--border);
}

.message.corrupted {
  padding: 0.5rem 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.corrupted .message-meta {
  margin-bottom: 0.2rem;
}

.message-id {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}

.message-timestamp {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.message-status {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  margin-left: auto;
}

.message-new-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.75rem;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  color: var(--new);
}

.new-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--new);
  box-shadow: 0 0 6px var(--new);
  animation: pulse 2s ease-in-out infinite;
}

.corrupted-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--warn);
}

.restore-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--warn);
  animation: pulse 1.6s ease-in-out infinite;
}

/* ─── Readable message body ──────────────────────────────────────────────── */

.readable .message-body {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(168, 216, 168, 0.4);
}


/* ─── Corrupted message body ─────────────────────────────────────────────── */

.corrupted .message-body {
  padding: 0.5rem 0;
}

.corrupted-text {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--corrupted);
  letter-spacing: 0.05em;
  user-select: none;
}

.corrupted-text .glitch {
  color: var(--warn-dim);
  animation: flicker 30s step-end infinite;
}

.corrupted .message-status {
  display: none;
}

.restore-notice {
  margin-top: 0.5rem;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.restore-notice::after {
  content: '● RESTORING...';
  color: var(--warn);
  letter-spacing: 0.12em;
  animation: pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
  margin-left: 1rem;
}

.unrecoverable .restore-notice::after {
  content: '● UNRECOVERABLE';
  animation: none;
  color: var(--warn-dim);
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */

.console-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--border-bright);
  background-color: var(--bg);
}

.footer-note {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--text);
}

.cursor {
  font-size: 0.85rem;
  color: var(--text);
  animation: blink 1.1s step-end infinite;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes flicker {
  0%   { opacity: 1; }
  2%   { opacity: 0.3; }
  3%   { opacity: 1; }
  5%   { opacity: 0.15; }
  6%   { opacity: 1; }
  100% { opacity: 1; }
}

/* ─── Narrow layout (max-width: 600px) ──────────────────────────────────── */

@media (max-width: 600px) {
  .console-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Clip corrupted text to a single line */
  .corrupted-text {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    line-height: 1.8;
  }

  /* Bottom row: // RECOVERY IN PROGRESS on left, ● RESTORING... on right */
  .restore-notice {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0;
  }

  .restore-notice::before {
    content: '// RECOVERY IN PROGRESS';
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
  }

  .restore-notice::after {
    content: '● RESTORING...';
    font-size: 0.6rem;
    color: var(--warn);
    letter-spacing: 0.12em;
    animation: pulse 1.6s ease-in-out infinite;
    flex-shrink: 0;
  }

  .unrecoverable .restore-notice::before {
    content: '// DATA UNRECOVERABLE';
  }

  .unrecoverable .restore-notice::after {
    content: '● UNRECOVERABLE';
    animation: none;
    color: var(--warn-dim);
  }
}
