/* ===================== RESET & VARIABLES ===================== */
:root {
  --bg: #080d1a;
  --bg2: #0d1525;
  --surface: rgba(255,255,255,0.04);
  --surface2: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.1);
  --cyan: #00d4ff;
  --purple: #a855f7;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 16px;
  --radius-sm: 8px;
  --nav-h: 64px;
  --font: 'Inter', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

/* ===================== NAVBAR ===================== */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(8,13,26,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  height: 100%; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem;
  background: linear-gradient(to right, var(--cyan), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav-lock { font-size: 1.3rem; }
.nav-links { display: flex; gap: 8px; }
.nav-link {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--muted);
  transition: color .2s, background .2s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-menu-btn { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }
@media(max-width:640px){ .nav-links{display:none;} .nav-menu-btn{display:block;} }

/* ===================== HERO ===================== */
.hero {
  min-height: 100vh;
  padding-top: var(--nav-h);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, rgba(0,212,255,.12), transparent 50%),
              radial-gradient(ellipse at 80% 30%, rgba(168,85,247,.12), transparent 50%),
              var(--bg);
}
.hero-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 60px 60px;
}
.hero-particles { position: absolute; inset: 0; pointer-events: none; }
.particle {
  position: absolute; border-radius: 50%;
  background: var(--cyan); opacity: .4;
  animation: float-particle linear infinite;
}
@keyframes float-particle {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: .4; }
  90%  { opacity: .4; }
  100% { transform: translateY(-20px) scale(1); opacity: 0; }
}
.hero-content {
  flex: 1; padding: 60px 40px; max-width: 680px; position: relative; z-index: 2;
  animation: fadeInUp .9s ease both;
}
.hero-visual { flex: 1; display: flex; justify-content: center; align-items: center; position: relative; z-index: 2; }
@media(max-width:900px){ .hero{ flex-direction: column; text-align: center; } .hero-visual{ margin-top: 40px; } }
.hero-badge {
  display: inline-block; margin-bottom: 20px;
  padding: 6px 16px; border-radius: 999px;
  background: rgba(0,212,255,.1); border: 1px solid rgba(0,212,255,.3);
  color: var(--cyan); font-size: .85rem; font-weight: 600;
}
.hero-title { font-size: clamp(2.8rem, 6vw, 5rem); font-weight: 800; line-height: 1.1; margin-bottom: 20px; }
.accent-cyan { background: linear-gradient(to right, var(--cyan), #60efff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.accent-purple { background: linear-gradient(to right, var(--purple), #e879f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-subtitle { color: var(--muted); font-size: 1.1rem; margin-bottom: 32px; max-width: 520px; }
.hero-cta { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 48px; }
.btn-primary {
  padding: 14px 28px; border-radius: var(--radius-sm); font-weight: 700; font-size: .95rem;
  background: linear-gradient(135deg, var(--cyan), var(--purple)); color: #000;
  transition: opacity .2s, transform .2s; display: inline-block;
}
.btn-primary:hover { opacity: .9; transform: translateY(-2px); }
.btn-ghost {
  padding: 14px 28px; border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  transition: background .2s; display: inline-block;
}
.btn-ghost:hover { background: var(--surface); }
.hero-stats { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: var(--cyan); font-family: var(--mono); }
.stat-lbl { font-size: .8rem; color: var(--muted); }
.stat-divider { width: 1px; height: 40px; background: var(--border); }

/* Cipher Wheel Canvas */
.cipher-wheel-container { position: relative; filter: drop-shadow(0 0 40px rgba(0,212,255,.3)); }
#cipherWheelCanvas { border-radius: 50%; }

/* ===================== SECTIONS ===================== */
.section { padding: 100px 20px; }
.section-dark { background: var(--bg2); }
.container { max-width: 1200px; margin: 0 auto; }
.section-header { text-align: center; margin-bottom: 60px; }
.section-tag {
  display: inline-block; margin-bottom: 12px;
  padding: 5px 14px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: .8rem; font-weight: 600; color: var(--muted);
  letter-spacing: .05em;
}
.section-header h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; margin-bottom: 12px; }
.section-header p { color: var(--muted); font-size: 1.05rem; }

/* ===================== TIMELINE ===================== */
.timeline { position: relative; padding: 20px 0; }
.timeline::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; background: linear-gradient(to bottom, var(--cyan), var(--purple));
  transform: translateX(-50%);
}
.tl-item {
  display: flex; align-items: flex-start; gap: 32px;
  margin-bottom: 48px; position: relative;
  opacity: 0; transform: translateY(30px);
  transition: all .6s ease;
}
.tl-item.visible { opacity: 1; transform: translateY(0); }
.tl-item:nth-child(odd) { flex-direction: row; padding-right: calc(50% + 40px); }
.tl-item:nth-child(even) { flex-direction: row-reverse; padding-left: calc(50% + 40px); }
.tl-dot {
  position: absolute; left: 50%; top: 20px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--cyan); border: 3px solid var(--bg);
  transform: translateX(-50%); z-index: 1;
  box-shadow: 0 0 16px var(--cyan);
}
.tl-card {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: transform .2s, border-color .2s;
}
.tl-card:hover { transform: translateY(-4px); border-color: var(--cyan); }
.tl-era { font-size: .75rem; font-weight: 700; color: var(--cyan); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.tl-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.tl-card p { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.tl-emoji { font-size: 2rem; margin-bottom: 8px; }
@media(max-width:700px){
  .timeline::before { left: 20px; }
  .tl-item { flex-direction: column !important; padding: 0 0 0 52px !important; }
  .tl-dot { left: 20px; }
}

/* ===================== LABORATORY ===================== */
.tab-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; margin-bottom: 32px;
}
.tab-btn {
  flex: 1; padding: 10px 16px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: background .2s, color .2s;
}
.tab-btn.active { background: linear-gradient(135deg, var(--cyan), var(--purple)); color: #000; }
.lab-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
@media(max-width:800px){ .lab-grid{ grid-template-columns: 1fr; } }
.lab-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.panel-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.panel-header span { font-size: 1.5rem; }
.panel-header h3 { font-size: 1.15rem; font-weight: 700; }
.cipher-info {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 20px;
  font-size: .88rem; color: var(--muted); line-height: 1.5;
  border-left: 3px solid var(--cyan);
}
.cipher-controls { margin-bottom: 20px; }
.cipher-controls label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: 8px; }
.cipher-controls strong { color: var(--cyan); font-family: var(--mono); }
.hidden { display: none !important; }
.hint-text { font-size: .85rem; color: var(--muted); font-style: italic; }
.slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; background: var(--surface2); border-radius: 3px; outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--cyan); cursor: pointer; box-shadow: 0 0 8px var(--cyan);
}
.text-input {
  width: 100%; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--mono); font-size: .95rem;
  outline: none; transition: border-color .2s;
}
.text-input:focus { border-color: var(--cyan); }
.io-area { margin-bottom: 16px; }
.io-label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; }
.io-box {
  width: 100%; padding: 14px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--mono); font-size: .95rem;
  resize: vertical; outline: none; transition: border-color .2s;
}
.io-box:focus { border-color: var(--cyan); }
.output-box { color: var(--cyan); }
.btn-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.btn-accent {
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--cyan), var(--purple)); color: #000;
  font-weight: 700; cursor: pointer; font-size: .9rem; transition: opacity .2s;
}
.btn-accent:hover { opacity: .85; }
.btn-accent-sm { padding: 8px 16px; border: none; border-radius: var(--radius-sm); background: var(--purple); color: #fff; font-weight: 600; cursor: pointer; font-size: .85rem; }
.btn-ghost-sm {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; transition: all .2s;
}
.btn-ghost-sm:hover { border-color: var(--cyan); color: var(--cyan); }

/* Visualization Panel */
.vis-panel { display: flex; flex-direction: column; }
.vis-content { flex: 1; min-height: 160px; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.freq-analysis { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.freq-analysis h4 { font-size: .9rem; font-weight: 700; margin-bottom: 12px; color: var(--muted); }
.freq-chart { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.freq-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.freq-bar { width: 18px; background: var(--purple); border-radius: 2px 2px 0 0; transition: height .4s, background .3s; }
.freq-bar.high { background: var(--cyan); }
.freq-lbl { font-size: .6rem; color: var(--muted); font-family: var(--mono); }

/* Caesar alphabet visualization */
.alpha-vis { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
.alpha-pair { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.alpha-plain { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.alpha-cipher-ch { font-family: var(--mono); font-size: .75rem; font-weight: 700; color: var(--cyan); }

/* ===================== CRYPTANALYSIS ===================== */
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media(max-width:800px){ .analysis-grid{ grid-template-columns: 1fr; } }
.analysis-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.analysis-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.analysis-card p { color: var(--muted); font-size: .9rem; margin-bottom: 16px; line-height: 1.6; }
.freq-italian { display: flex; gap: 3px; align-items: flex-end; height: 70px; margin-top: 16px; }
.challenge-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px;
}
.challenge-text { font-family: var(--mono); font-size: .85rem; color: var(--amber); word-break: break-all; line-height: 1.6; }
.challenge-controls label { font-size: .85rem; color: var(--muted); }
.challenge-controls strong { color: var(--cyan); }
.trial-result {
  margin-top: 12px; font-family: var(--mono); font-size: .85rem;
  color: var(--green); min-height: 40px; word-break: break-all; line-height: 1.5;
}

/* ===================== RSA ===================== */
.rsa-explainer { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media(max-width:900px){ .rsa-explainer{ grid-template-columns: 1fr; } }
.rsa-analogy, .rsa-math {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
}
.rsa-analogy h3, .rsa-math h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 24px; }
.analogy-steps { display: flex; flex-direction: column; gap: 16px; }
.a-step { display: flex; align-items: center; gap: 16px; background: var(--surface2); border-radius: var(--radius-sm); padding: 14px; }
.a-icon { font-size: 1.8rem; }
.a-step p { font-size: .9rem; color: var(--muted); }
.a-arrow { text-align: center; font-size: 1.4rem; color: var(--purple); }
.math-steps { display: flex; flex-direction: column; gap: 16px; }
.math-step {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--surface2); border-radius: var(--radius-sm); padding: 14px;
}
.step-num {
  min-width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #000; font-weight: 800; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.math-step strong { font-size: .9rem; display: block; margin-bottom: 8px; }
.math-result { font-family: var(--mono); color: var(--cyan); font-size: .9rem; margin-top: 6px; }
.prime-pickers { display: flex; gap: 16px; margin-top: 10px; }
.prime-pickers label { font-size: .85rem; color: var(--muted); margin-right: 6px; }
.prime-select {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--mono);
}
.rsa-encrypt-row { display: flex; gap: 10px; margin-top: 10px; }
.rsa-input {
  padding: 8px 12px; width: 120px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--mono); font-size: .9rem;
}

/* ===================== PGP ===================== */
.pgp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 48px; }
@media(max-width:800px){ .pgp-grid{ grid-template-columns: 1fr; } }
.pgp-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; text-align: center;
  transition: transform .2s, border-color .2s;
}
.pgp-card:hover { transform: translateY(-4px); border-color: var(--purple); }
.pgp-icon { font-size: 2.5rem; margin-bottom: 16px; }
.pgp-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.pgp-card p { color: var(--muted); font-size: .88rem; line-height: 1.6; }
.pgp-flow {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
}
.pgp-flow h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 24px; }
.flow-steps { display: flex; gap: 0; flex-wrap: wrap; }
.flow-step {
  flex: 1; min-width: 140px; display: flex; flex-direction: column; align-items: center;
  padding: 16px 8px; position: relative; opacity: .3; transition: opacity .5s;
}
.flow-step.active { opacity: 1; }
.flow-step::after {
  content: '→';
  position: absolute; right: -8px; top: 50%;
  transform: translateY(-50%); color: var(--muted); font-size: 1.2rem;
}
.flow-step:last-child::after { display: none; }
.flow-icon { font-size: 2rem; margin-bottom: 8px; }
.flow-label { font-size: .8rem; font-weight: 600; text-align: center; }
.flow-desc { font-size: .72rem; color: var(--muted); text-align: center; margin-top: 4px; }

/* ===================== QUIZ ===================== */
.quiz-box {
  max-width: 700px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px;
}
.quiz-q { font-size: 1.1rem; font-weight: 700; margin-bottom: 24px; }
.quiz-opts { display: flex; flex-direction: column; gap: 12px; }
.quiz-opt {
  padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s; font-size: .95rem; background: var(--surface2); color: var(--text);
}
.quiz-opt:hover { border-color: var(--cyan); }
.quiz-opt.correct { border-color: var(--green); background: rgba(16,185,129,.15); color: var(--green); }
.quiz-opt.wrong { border-color: var(--red); background: rgba(239,68,68,.15); color: var(--red); }
.quiz-feedback { margin-top: 16px; font-size: .9rem; color: var(--muted); min-height: 40px; }
.quiz-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 32px; }
.quiz-progress { font-size: .85rem; color: var(--muted); }
.quiz-score-box { text-align: center; }
.quiz-score-box h3 { font-size: 1.4rem; font-weight: 800; margin-bottom: 8px; }
.quiz-score-big { font-size: 3rem; font-weight: 900; font-family: var(--mono); color: var(--cyan); }

/* ===================== FOOTER ===================== */
.footer { background: var(--bg2); border-top: 1px solid var(--border); padding: 60px 20px 32px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; max-width: 1200px; margin: 0 auto 40px; }
@media(max-width:700px){ .footer-grid{ grid-template-columns: 1fr; } }
.footer-brand { font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; }
.footer-desc { color: var(--muted); font-size: .88rem; line-height: 1.6; }
.footer-heading { font-weight: 700; margin-bottom: 12px; font-size: .9rem; }
.footer-list { list-style: none; }
.footer-list li { color: var(--muted); font-size: .88rem; margin-bottom: 8px; }
.footer-link { color: var(--cyan); font-size: .88rem; transition: opacity .2s; }
.footer-link:hover { opacity: .7; }
.footer-bottom { max-width: 1200px; margin: 0 auto; border-top: 1px solid var(--border); padding-top: 24px; text-align: center; color: var(--muted); font-size: .82rem; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--green); color: #000; font-weight: 700;
  padding: 12px 20px; border-radius: var(--radius-sm);
  opacity: 0; transform: translateY(10px); transition: all .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===================== ANIMATIONS ===================== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
