/* ============================================================
   CryptoSim – Global Stylesheet
   ============================================================ */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.1);
  --border-active: rgba(255, 255, 255, 0.25);

  --alice: #3B82F6;
  --alice-dark: #1D4ED8;
  --alice-glow: rgba(59, 130, 246, 0.35);
  --bob: #10B981;
  --bob-dark: #059669;
  --bob-glow: rgba(16, 185, 129, 0.35);
  --mallory: #EF4444;
  --mallory-dark: #B91C1C;
  --mallory-glow: rgba(239, 68, 68, 0.35);

  --text: #e6edf3;
  --text-muted: #7d8590;
  --text-dim: #484f58;
  --accent: #F59E0B;
  --success: #22C55E;
  --success-bg: rgba(34, 197, 94, 0.12);
  --error: #EF4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --info: #60A5FA;
  --info-bg: rgba(96, 165, 250, 0.1);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition: 0.25s ease;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--alice);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
select option { background: var(--bg-secondary); }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Site Header ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 1.25rem; font-weight: 700;
}
.logo-icon { font-size: 1.5rem; }
.logo-text { letter-spacing: -0.02em; }
.nav-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-link.active { background: var(--bg-card-hover); color: var(--text); }
.lang-selector { display: flex; gap: 0.25rem; }
.lang-btn {
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}
.lang-btn:hover { background: var(--bg-card); color: var(--text); }
.lang-btn.active {
  background: var(--bg-card);
  color: var(--accent);
  border-color: rgba(245, 158, 11, 0.3);
}

/* ── Hero ── */
.hero {
  padding: 5rem 0 3rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #e6edf3 0%, #7d8590 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 3rem;
}

/* ── Characters Intro ── */
.characters-intro {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 3rem;
  flex-wrap: wrap;
  margin-bottom: 4rem;
}
.char-intro {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem;
}
.char-intro .char-name {
  font-weight: 700; font-size: 1.1rem;
}
.char-intro .char-role {
  font-size: 0.85rem; color: var(--text-muted); text-align: center; max-width: 140px;
}
.char-intro.alice .char-name { color: var(--alice); }
.char-intro.bob .char-name { color: var(--bob); }
.char-intro.mallory .char-name { color: var(--mallory); }
.vs-divider { font-size: 1.5rem; color: var(--text-dim); margin-top: 2rem; }

/* ── Level Cards ── */
.levels { padding: 2rem 0 5rem; }
.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}
.level-card {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.level-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.level-card.lvl1::before { background: var(--alice); }
.level-card.lvl2::before { background: var(--bob); }
.level-card.lvl3::before { background: var(--accent); }
.level-card.lvl4::before { background: #F97316; }
.level-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.level-number {
  font-size: 3rem; font-weight: 900; font-style: italic;
  color: var(--text-dim); line-height: 1;
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
}
.level-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.level-card h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.level-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; flex: 1; }
.level-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.level-card.lvl1 .level-tag { background: rgba(59, 130, 246, 0.12); color: var(--alice); }
.level-card.lvl2 .level-tag { background: rgba(16, 185, 129, 0.12); color: var(--bob); }
.level-card.lvl3 .level-tag { background: rgba(245, 158, 11, 0.12); color: var(--accent); }
.level-card.lvl4 .level-tag { background: rgba(249, 115, 22, 0.14); color: #FB923C; }

/* ── Page Header (Level pages) ── */
.page-header {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.page-header .breadcrumb {
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.page-header .breadcrumb a:hover { color: var(--text); }
.page-header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-header .level-subtitle { color: var(--text-muted); font-size: 0.95rem; }

/* ── Info Box ── */
.info-box {
  background: var(--info-bg);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: #93C5FD;
  display: flex; gap: 0.75rem; align-items: flex-start;
}
.info-box .info-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }

/* ── Scene (Alice – Channel – Bob) ── */
.scene {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}
.scene-title {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}
.scene-actors {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 1rem;
}
.scene-channel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-width: 180px;
  position: relative;
}
.channel-wire {
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--alice), var(--bob));
  border-radius: 99px;
  position: relative;
  overflow: hidden;
}
.channel-wire-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.05em;
}

/* Message packet animation */
.msg-packet {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 20px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  opacity: 0;
  pointer-events: none;
}
.msg-packet.locked { background: var(--mallory); }
.msg-packet.unlocked { background: var(--success); }
.msg-packet.flying-right {
  animation: flyRight 1.2s ease-in-out forwards;
}
.msg-packet.intercepted {
  animation: flyIntercept 1s ease-in-out forwards;
}
@keyframes flyRight {
  0%   { left: 0%;   opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { left: calc(100% - 28px); opacity: 0; }
}
@keyframes flyIntercept {
  0%   { left: 0%;   opacity: 0; top: 50%; }
  10%  { opacity: 1; }
  50%  { left: calc(50% - 14px); opacity: 1; top: 50%; }
  80%  { left: calc(50% - 14px); opacity: 1; top: 120%; }
  100% { left: calc(50% - 14px); opacity: 0; top: 120%; }
}

/* Mallory in channel */
.mallory-intercept {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ── Actor Cards ── */
.actor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.actor-card.alice { border-top: 3px solid var(--alice); }
.actor-card.bob   { border-top: 3px solid var(--bob); }
.actor-card.mallory { border-top: 3px solid var(--mallory); }
.actor-card:has(.actor-active) { box-shadow: 0 0 0 2px var(--alice-glow); }

.actor-header {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem;
}
.actor-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.actor-avatar.alice   { background: rgba(59, 130, 246, 0.15); border: 2px solid var(--alice); }
.actor-avatar.bob     { background: rgba(16, 185, 129, 0.15); border: 2px solid var(--bob); }
.actor-avatar.mallory { background: rgba(239, 68, 68, 0.15);  border: 2px solid var(--mallory); }
.actor-name { font-weight: 700; font-size: 1.05rem; }
.alice .actor-name   { color: var(--alice); }
.bob .actor-name     { color: var(--bob); }
.mallory .actor-name { color: var(--mallory); }
.actor-role { font-size: 0.75rem; color: var(--text-muted); }

/* ── Controls ── */
.control-group {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.control-group label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.control-group input[type="text"],
.control-group input[type="number"],
.control-group textarea,
.control-group select {
  width: 100%;
}
.control-group textarea { resize: vertical; min-height: 70px; }
.range-row { display: flex; align-items: center; gap: 0.75rem; }
.range-row input[type="range"] { flex: 1; accent-color: var(--alice); }
.range-value {
  min-width: 2.5rem; text-align: center;
  font-family: var(--font-mono);
  font-weight: 700; color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.95rem;
}

/* ── Crypto Display ── */
.crypto-value {
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #E2E8F0;
  word-break: break-all;
  min-height: 2.5rem;
}
.crypto-value.highlight { color: var(--accent); border-color: rgba(245, 158, 11, 0.3); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--alice);
  color: white;
}
.btn-primary:hover { background: var(--alice-dark); transform: translateY(-1px); }
.btn-success {
  background: var(--bob);
  color: white;
}
.btn-success:hover { background: var(--bob-dark); transform: translateY(-1px); }
.btn-danger {
  background: var(--mallory);
  color: white;
}
.btn-danger:hover { background: var(--mallory-dark); transform: translateY(-1px); }
.btn-warning {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-warning:hover { filter: brightness(1.1); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }
.btn:disabled {
  opacity: 0.4; cursor: not-allowed;
  transform: none !important;
}
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Status Messages ── */
.status-msg {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  display: flex; gap: 0.5rem; align-items: flex-start;
  animation: fadeSlideIn 0.3s ease;
  margin-top: 0.75rem;
}
.status-msg.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.2); }
.status-msg.error   { background: var(--error-bg);   color: var(--error);   border: 1px solid rgba(239, 68, 68, 0.2); }
.status-msg.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.status-msg.info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(96, 165, 250, 0.2); }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Panels ── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.panel-title {
  font-size: 0.9rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) { .panel-grid { grid-template-columns: 1fr; } }

/* ── Key Display ── */
.key-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 0.8rem; font-weight: 600;
}
.key-badge.public  { background: rgba(59,130,246,0.12); color: var(--alice); border: 1px solid rgba(59,130,246,0.25); }
.key-badge.private { background: rgba(239,68,68,0.12);  color: var(--mallory); border: 1px solid rgba(239,68,68,0.25); }

/* ── Caesar Wheel ── */
.caesar-wheel-container {
  overflow-x: auto;
  padding: 0.5rem 0;
}
.caesar-wheel {
  display: flex; flex-direction: column; gap: 4px;
  width: max-content;
  margin: 0 auto;
}
.caesar-row {
  display: flex;
}
.caesar-cell {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem; font-weight: 600;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}
.caesar-cell.original { color: var(--alice); }
.caesar-cell.shifted  { color: var(--accent); background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); }
.caesar-row-label {
  width: 80px;
  font-size: 0.7rem; color: var(--text-muted);
  display: flex; align-items: center;
  font-weight: 600; letter-spacing: 0.04em;
}

/* ── Brute Force Table ── */
.brute-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}
.brute-table th {
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
  text-transform: uppercase;
}
.brute-table td {
  padding: 0.4rem 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  word-break: break-all;
}
.brute-table tr.highlight-row td { background: var(--success-bg); color: var(--success); }
.brute-table tbody tr:hover td { background: rgba(255,255,255,0.03); }

/* ── RSA Key Panel ── */
.key-params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.key-param {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.key-param-label {
  font-size: 0.7rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}
.key-param-value {
  font-family: var(--font-mono);
  font-size: 1.1rem; font-weight: 700;
  color: var(--accent);
}
.key-param.public-param .key-param-value { color: var(--alice); }
.key-param.private-param .key-param-value { color: var(--mallory); }

/* ── Hash display ── */
.hash-output {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  word-break: break-all;
  letter-spacing: 0.05em;
  color: #34D399;
  min-height: 3rem;
}
.hash-char {
  display: inline-block;
  transition: color 0.15s, background 0.15s;
  border-radius: 2px;
  padding: 0 1px;
}
.hash-char.changed { color: var(--error); background: rgba(239, 68, 68, 0.2); }

/* ── Certificate Visual ── */
.cert-card {
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
}
.cert-card::before {
  content: '📜 Zertifikat';
  position: absolute; top: -0.75rem; left: 1rem;
  background: var(--bg-primary);
  padding: 0 0.5rem;
  font-size: 0.75rem; font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.cert-field {
  display: flex; gap: 0.5rem; margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.cert-field-label { color: var(--text-muted); min-width: 100px; font-weight: 600; }
.cert-field-value { font-family: var(--font-mono); color: var(--text); }

/* ── Step Progress ── */
.step-list { display: flex; flex-direction: column; gap: 1rem; }
.step-item {
  display: flex; gap: 1rem; align-items: flex-start;
}
.step-num {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition);
}
.step-item.active .step-num { background: var(--alice); border-color: var(--alice); color: white; }
.step-item.done .step-num { background: var(--success); border-color: var(--success); color: white; }
.step-item.failed .step-num { background: var(--error); border-color: var(--error); color: white; }
.step-content { flex: 1; padding-top: 0.2rem; }
.step-title { font-weight: 600; margin-bottom: 0.2rem; }
.step-detail { font-size: 0.85rem; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .scene-actors {
    grid-template-columns: 1fr;
  }
  .scene-channel {
    flex-direction: row;
    min-width: auto;
  }
  .channel-wire { height: 2px; }
  .site-header .container { flex-wrap: wrap; }
  .nav-links { display: none; }
}

/* ── Utilities ── */
.text-alice   { color: var(--alice); }
.text-bob     { color: var(--bob); }
.text-mallory { color: var(--mallory); }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-mono    { font-family: var(--font-mono); }
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
