/* ============================================================
   crittografia.css — Crittografia di base
   Cesare, Vigenère, chiave pubblica/privata, hashing.
   Prefisso .cr-  ·  Usa base.css + lab.css.
   ============================================================ */

.cr-sec { position: relative; z-index: 2; }
.cr-mode-panel[hidden] { display: none; }

.cr-text {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: var(--ink); font-family: var(--font-mono); font-size: 1rem; line-height: 1.6;
  padding: 0.8rem 0.9rem; resize: vertical; min-height: 5rem; outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.cr-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.cr-field-label { display: block; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem; }
.cr-out {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-sunk);
  color: var(--ink); font-family: var(--font-mono); font-size: 1rem; line-height: 1.6;
  padding: 0.8rem 0.9rem; min-height: 3.4rem; white-space: pre-wrap; word-break: break-word;
}
.cr-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 760px) { .cr-grid2 { grid-template-columns: 1fr; } }

.cr-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.75rem; margin: 1.25rem 0; }
.slider { accent-color: var(--accent); cursor: pointer; }
.cr-shiftval { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600; color: var(--accent); min-width: 2.5rem; }
.cr-seg-modes { margin-bottom: 0; }

/* Alfabeto Cesare */
.cr-alpha { overflow-x: auto; padding-bottom: 0.4rem; margin-top: 0.5rem; }
.cr-alpha-row { display: flex; gap: 3px; min-width: max-content; }
.cr-acell { display: flex; flex-direction: column; align-items: center; min-width: 26px; }
.cr-acell .p { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-soft); }
.cr-acell .arr { font-size: 0.6rem; color: var(--ink-faint); line-height: 1; }
.cr-acell .c { font-family: var(--font-mono); font-size: 0.92rem; font-weight: 700; color: var(--accent); }

/* Vigenère righe allineate */
.cr-vig { overflow-x: auto; margin-top: 1rem; padding-bottom: 0.4rem; }
.cr-vig-row { display: flex; gap: 4px; min-width: max-content; }
.cr-vcol { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 24px; padding: 0.3rem 0; border-radius: 6px; }
.cr-vcol.alpha { background: var(--accent-wash); }
.cr-vcol b { font-family: var(--font-mono); font-size: 0.92rem; font-weight: 600; color: var(--ink); }
.cr-vcol .k { font-family: var(--font-mono); font-size: 0.78rem; color: #b9711d; }
[data-theme="dark"] .cr-vcol .k { color: #e6a44e; }
.cr-vcol .o { font-family: var(--font-mono); font-size: 0.92rem; font-weight: 700; color: var(--accent); }

/* Chiave pubblica/privata */
.cr-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
@media (max-width: 620px) { .cr-keys { grid-template-columns: 1fr; } }
.cr-keycard { border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; background: var(--bg); display: flex; gap: 0.9rem; align-items: flex-start; }
.cr-keycard.pub { border-color: color-mix(in srgb, #3fae6b 45%, var(--line)); }
.cr-keycard.priv { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cr-keyicon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; flex: 0 0 auto; }
.cr-keycard.pub .cr-keyicon { background: color-mix(in srgb, #3fae6b 18%, transparent); color: #2e8c55; }
.cr-keycard.priv .cr-keyicon { background: var(--accent-wash); color: var(--accent); }
.cr-keycard h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
.cr-keycard p { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.5; margin-top: 0.2rem; }

.cr-lockstage { text-align: center; padding: 1.5rem; border: 1px dashed var(--line); border-radius: 12px; background: var(--bg-sunk); margin-bottom: 1.25rem; }
.cr-lock { font-size: 3rem; line-height: 1; transition: transform 0.3s var(--ease); }
.cr-lockmsg { font-family: var(--font-mono); font-size: 1.05rem; margin-top: 0.8rem; word-break: break-word; min-height: 1.6rem; color: var(--ink); }
.cr-lockstate { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; margin-top: 0.5rem; }
.cr-lockstate.locked { color: #b9711d; }
.cr-lockstate.open { color: #3fae6b; }
.cr-keybtns { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; margin-top: 1rem; }

/* Toy RSA */
.cr-rsa { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line-soft); }
.cr-rsa-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.9rem 0; }
.cr-rsa-chip { font-family: var(--font-mono); font-size: 0.82rem; padding: 0.4rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.cr-rsa-chip b { color: var(--accent); }
.cr-rsa-flow { font-family: var(--font-mono); font-size: 0.9rem; color: var(--ink); line-height: 1.8; }
.cr-rsa-flow .hl { color: var(--accent); font-weight: 600; }

/* Hashing */
.cr-hash-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .cr-hash-pair { grid-template-columns: 1fr; } }
.cr-hex { font-family: var(--font-mono); font-size: 0.92rem; line-height: 1.7; word-break: break-all; padding: 0.8rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-sunk); min-height: 4rem; }
.cr-hex .diff { background: #e0533d; color: #fff; border-radius: 3px; padding: 0 1px; }
.cr-aval { margin-top: 1.25rem; text-align: center; }
.cr-aval-bar { height: 12px; border-radius: 100px; background: var(--bg-sunk); overflow: hidden; margin: 0.6rem 0; }
.cr-aval-fill { height: 100%; background: linear-gradient(90deg, #d9772b, #e0533d); width: 0; transition: width 0.4s var(--ease); }
.cr-aval-num { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 600; color: var(--accent); }

.cr-note { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.6; margin-top: 1.25rem; padding: 0.9rem 1.1rem; border-left: 3px solid var(--accent); background: var(--accent-wash); border-radius: 0 8px 8px 0; }
.cr-note b { color: var(--ink); }
.cr-explain { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.6; max-width: 70ch; margin-bottom: 1.25rem; }
.cr-explain b { color: var(--ink); }
