/* =========================================================
   S-AES CIPHER LAB — DESIGN TOKENS (same family as AES-128 lab)
   ========================================================= */

:root {
  --bg: #0D1117;
  --surface: #141B22;
  --surface-alt: #1B242D;
  --surface-raised: #202A34;
  --border: #29323C;
  --border-soft: #1F2830;
  --text-hi: #E7EBEE;
  --text-lo: #8B96A3;
  --text-faint: #576270;
  --gold: #E3A21A;
  --gold-dim: rgba(227, 162, 26, 0.14);
  --teal: #2FC9B3;
  --teal-dim: rgba(47, 201, 179, 0.14);
  --coral: #E2604F;
  --coral-dim: rgba(226, 96, 79, 0.14);
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --shadow-panel: 0 20px 60px -30px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: linear-gradient(135deg, #0D1117 0%, #0a1020 30%, #0c1528 60%, #0D1117 100%);
  background-size: 400% 400%;
  animation: gradientBG 18s ease infinite;
  color: var(--text-hi);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

@keyframes gradientBG {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* =================== PARTICLE CANVAS =================== */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

/* =================== GRID LINES OVERLAY =================== */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(47,201,179,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,201,179,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridPan 30s linear infinite;
}
@keyframes gridPan {
  0%   { background-position: 0 0; }
  100% { background-position: 60px 60px; }
}

.noise-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

code, .mono { font-family: 'JetBrains Mono', monospace; }
::selection { background: var(--gold-dim); color: var(--gold); }
button { font-family: inherit; cursor: pointer; }

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* =========================== HEADER =========================== */

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand-mark { 
  font-family: 'Space Grotesk', sans-serif; 
  font-weight: 700; 
  font-size: 20px; 
  letter-spacing: 0.02em; 
  color: var(--gold); 
  animation: pulseBrand 3s ease-in-out infinite;
}

@keyframes pulseBrand {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px var(--gold-dim); }
  50% { opacity: 0.8; text-shadow: 0 0 16px var(--gold); }
}
.brand-tag { font-size: 12.5px; color: var(--text-lo); }
.brand-meta { display: flex; gap: 8px; }
.meta-pill {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-lo);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; letter-spacing: 0.03em;
}

/* =========================== HERO =========================== */

.hero { position: relative; z-index: 1; padding: 64px 28px 48px; border-bottom: 1px solid var(--border-soft); }
.hero-inner { max-width: 1180px; margin: 0 auto; }
.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--gold); margin: 0 0 14px;
}
.hero-title {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: clamp(24px, 3.6vw, 38px);
  line-height: 1.2; margin: 0 0 44px; max-width: 680px; color: var(--text-hi);
  background: linear-gradient(90deg, #E7EBEE, #E3A21A, #2FC9B3, #E7EBEE);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textShine 6s linear infinite;
}

@keyframes textShine {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.pipeline { display: flex; align-items: center; flex-wrap: wrap; gap: 0; }
.pipe-stage {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  transition: border-color 0.2s ease;
}
.pipe-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); animation: pulseDot 3.2s ease-in-out infinite; }
.pipe-stage[data-stage="sub"] .pipe-dot { animation-delay: 0s; background: var(--teal); }
.pipe-stage[data-stage="shift"] .pipe-dot { animation-delay: 0.8s; background: var(--gold); }
.pipe-stage[data-stage="mix"] .pipe-dot { animation-delay: 1.6s; background: var(--coral); }
.pipe-stage[data-stage="add"] .pipe-dot { animation-delay: 2.4s; background: var(--teal); }
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 0.6; }
  50% { box-shadow: 0 0 0 5px transparent; opacity: 1; transform: scale(1.3); }
}
.pipe-label { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--text-lo); }
.pipe-wire { width: 36px; height: 1px; background: repeating-linear-gradient(90deg, var(--border) 0 6px, transparent 6px 10px); }
@media (max-width: 720px) { .pipeline { gap: 8px 0; } .pipe-wire { display: none; } }

/* =========================== PANEL SHELL =========================== */

.panel { position: relative; z-index: 1; border-bottom: 1px solid var(--border-soft); }
.panel-inner { max-width: 1180px; margin: 0 auto; padding: 40px 28px; }
.panel-title {
  font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 600; letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 10px; margin: 0 0 22px; color: var(--text-hi);
}
.panel-num {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--gold);
  border: 1px solid var(--gold-dim); background: var(--gold-dim); border-radius: var(--radius-s); padding: 2px 7px;
}

/* =========================== FORM =========================== */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-lo); letter-spacing: 0.01em; }
.field input {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 13px 14px; font-family: 'JetBrains Mono', monospace; font-size: 15px; letter-spacing: 0.12em;
  color: var(--text-hi); transition: border-color 0.15s ease, background 0.15s ease;
}
.field input::placeholder { color: var(--text-faint); letter-spacing: 0.05em; }
.field input:focus { border-color: var(--gold); background: var(--surface-alt); }
.field input.invalid { border-color: var(--coral); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }
.field-hint.error { color: var(--coral); }

.form-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.mode-switch { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.mode-btn { border: none; background: transparent; color: var(--text-lo); font-size: 13px; font-weight: 600; padding: 8px 18px; border-radius: 999px; transition: background 0.2s ease, color 0.2s ease; }
.mode-btn.active { background: var(--gold); color: #1A1305; }
.action-buttons { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn { border: 1px solid transparent; border-radius: var(--radius-m); padding: 11px 20px; font-size: 13.5px; font-weight: 600; transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: #1A1305; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-hi); }
.btn-ghost:hover { border-color: var(--text-lo); }

.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 34px; height: 20px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.2s ease; flex-shrink: 0; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-hi); transition: transform 0.2s ease; }
.toggle input:checked + .toggle-track { background: var(--teal); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(14px); }
.toggle-label { font-size: 12.5px; color: var(--text-lo); }

.error-msg { color: var(--coral); font-size: 13px; margin: 16px 0 0; min-height: 0; }
.error-msg:empty { display: none; }

.output-row { margin-top: 26px; padding-top: 24px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 12px; }
.output-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-lo); margin-bottom: 2px; letter-spacing: 0.02em; }
.output-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--teal-dim); border-radius: var(--radius-m); padding: 14px 16px; }
.output-box code { font-size: 16px; letter-spacing: 0.12em; color: var(--teal); word-break: break-all; }
.output-box-hex { border-color: var(--gold-dim); }
.output-hex-label { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--gold); font-weight: 700; }
.output-box-hex code { color: var(--gold); }
.copy-btn { flex-shrink: 0; background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-hi); border-radius: var(--radius-s); padding: 7px 12px; font-size: 12px; font-weight: 600; }
.copy-btn:hover { border-color: var(--teal); }
.copy-btn.copied { color: var(--teal); border-color: var(--teal); }

/* =========================== REFERENCE TABLES =========================== */

.ref-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.ref-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-l); padding: 18px; }
.ref-card h3 { font-family: 'Space Grotesk', sans-serif; font-size: 13.5px; margin: 0 0 14px; color: var(--text-hi); }
.ref-table { border-collapse: collapse; width: 100%; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.ref-table td { text-align: center; padding: 6px 4px; border: 1px solid var(--border-soft); color: var(--text-lo); }
.ref-table tr:first-child td { color: var(--text-faint); font-size: 10.5px; }
.ref-table tr:last-child td { color: var(--gold); font-weight: 600; }
.small-matrix { display: inline-flex; flex-direction: column; gap: 4px; font-size: 20px; color: var(--teal); background: var(--surface-alt); padding: 12px 20px; border-radius: var(--radius-m); border: 1px solid var(--border); }
.ref-note { font-size: 11.5px; color: var(--text-faint); margin: 12px 0 0; }
.rcon-list { display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--text-hi); }
.rcon-hex { color: var(--gold); }

/* =========================== WORKSPACE LAYOUT =========================== */

.workspace { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 40px 28px 80px; display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
@media (max-width: 880px) { .workspace { grid-template-columns: 1fr; } .round-nav { position: static !important; order: 2; } }
.round-nav { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; border-right: 1px solid var(--border-soft); padding-right: 16px; }
.round-nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); margin-bottom: 12px; font-weight: 600; }
.round-nav-list { display: flex; flex-direction: column; gap: 2px; }
.round-nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-s); font-size: 12.5px; color: var(--text-lo); background: none; border: 1px solid transparent; width: 100%; text-align: left; transition: background 0.15s ease, color 0.15s ease; }
.round-nav-item:hover { background: var(--surface); color: var(--text-hi); }
.round-nav-item.active { background: var(--gold-dim); color: var(--gold); border-color: var(--gold-dim); font-weight: 600; }
.round-nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.round-nav-item.active .dot { background: var(--gold); }
.round-nav::-webkit-scrollbar { width: 6px; }
.round-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* =========================== ROUND / STAGE CARDS =========================== */

.rounds-main { min-width: 0; }
.round-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-l); margin-bottom: 18px; overflow: hidden; scroll-margin-top: 90px; box-shadow: var(--shadow-panel); }
.round-card summary { list-style: none; cursor: pointer; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.round-card summary::-webkit-details-marker { display: none; }
.round-card-heading { display: flex; align-items: center; gap: 12px; }
.round-badge { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-weight: 600; color: var(--gold); background: var(--gold-dim); border-radius: var(--radius-s); padding: 3px 9px; }
.round-badge.decrypt { color: var(--coral); background: var(--coral-dim); }
.round-badge.key { color: var(--teal); background: var(--teal-dim); }
.round-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; }
.round-sub { font-size: 12px; color: var(--text-faint); }
.chevron { width: 18px; height: 18px; flex-shrink: 0; transition: transform 0.2s ease; color: var(--text-lo); }
.round-card[open] .chevron { transform: rotate(180deg); }
.round-body { padding: 0 22px 24px; display: flex; flex-direction: column; gap: 22px; }
.stage-block { border-top: 1px solid var(--border-soft); padding-top: 18px; }
.stage-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stage-name { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--text-hi); }
.stage-desc { font-size: 12px; color: var(--text-faint); }
.matrix-pair { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.matrix-block { display: flex; flex-direction: column; gap: 8px; }
.matrix-caption { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.matrix-arrow { color: var(--text-faint); font-size: 18px; }

/* --- nibble tile: 2x2 state matrix --- */
.state-table { border-collapse: separate; border-spacing: 6px; }
.state-table td { perspective: 400px; }
.nibble-tile {
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--surface-alt); border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace; color: var(--text-hi);
  transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(.4,.2,.2,1), background 0.3s ease, border-color 0.3s ease;
  flex-direction: column; gap: 1px;
}
.nibble-tile .nib-hex { font-size: 15px; font-weight: 700; }
.nibble-tile .nib-bin { font-size: 9px; color: var(--text-faint); letter-spacing: 0.05em; }
.nibble-tile.changed { border-color: var(--gold); background: var(--gold-dim); animation: flipTile 0.55s ease; }
.nibble-tile.changed .nib-hex { color: var(--gold); }
.nibble-tile.changed .nib-bin { color: var(--gold); opacity: 0.7; }
@keyframes flipTile { 0% { transform: rotateY(0deg); } 50% { transform: rotateY(90deg); } 100% { transform: rotateY(0deg); } }
.nibble-tile.key-tile { border-color: var(--teal-dim); }
.nibble-tile.key-tile.changed { border-color: var(--teal); background: var(--teal-dim); }
.nibble-tile.key-tile.changed .nib-hex { color: var(--teal); }

.gf-detail {
  margin-top: 12px; padding: 12px 14px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-m); font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-lo);
  display: flex; flex-direction: column; gap: 4px;
}
.gf-detail-title { color: var(--text-faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }

/* =========================== KEY EXPANSION SECTION =========================== */

.keyexp-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-l); padding: 22px; margin-bottom: 28px; box-shadow: var(--shadow-panel); }
.keyexp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.keyexp-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 16px; }
.keyexp-desc { font-size: 12.5px; color: var(--text-faint); margin: 0 0 18px; max-width: 640px; }

.word-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.word-step { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; padding: 10px 14px; background: var(--surface-alt); border: 1px solid var(--border-soft); border-radius: var(--radius-m); }
.word-step .w-name { color: var(--gold); font-weight: 700; min-width: 34px; }
.word-step .w-val { color: var(--text-hi); }
.word-step .w-eq { color: var(--text-faint); }

.roundkey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.roundkey-item { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 12px; }
.roundkey-item-label { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--teal); margin-bottom: 8px; }

/* =========================== STUB / EMPTY NOTE =========================== */

.stub-note { border: 1px dashed var(--coral-dim); background: rgba(226, 96, 79, 0.06); border-radius: var(--radius-m); padding: 14px 16px; font-size: 12.5px; color: var(--text-lo); line-height: 1.6; }
.stub-note strong { color: var(--coral); }
.stub-note code { color: var(--text-hi); }

/* =========================== FOOTER =========================== */

.site-footer { border-top: 1px solid var(--border-soft); padding: 28px; text-align: center; }
.site-footer p { font-size: 12px; color: var(--text-faint); margin: 0; }

/* =========================================================
   MODULE NAV (shared across DES / S-DES / AES / S-AES pages)
   ========================================================= */

.module-nav {
  position: sticky;
  top: 53px;
  z-index: 39;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.module-nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.module-nav-home {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-lo);
  text-decoration: none;
}
.module-nav-home:hover { color: var(--gold); }
.module-nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.module-nav-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-lo);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.module-nav-link:hover { background: var(--surface); color: var(--text-hi); }
.module-nav-link.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: var(--gold-dim);
  font-weight: 600;
}

/* =========================================================
   LANDING PAGE
   ========================================================= */

.landing-hero {
  padding: 110px 28px 80px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* Glowing orbs behind hero */
.landing-hero::before,
.landing-hero::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.landing-hero::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(227,162,26,0.12) 0%, transparent 70%);
  top: -120px; left: -80px;
  animation: orbFloat1 12s ease-in-out infinite;
}
.landing-hero::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(47,201,179,0.10) 0%, transparent 70%);
  bottom: -100px; right: -60px;
  animation: orbFloat2 15s ease-in-out infinite;
}
@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(60px, 40px) scale(1.1); }
  66%       { transform: translate(-30px, 60px) scale(0.95); }
}
@keyframes orbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(-50px, -40px) scale(1.12); }
}

.landing-hero-inner {
  max-width: 1180px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 2;
}

.landing-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold);
  margin: 0 0 22px;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease forwards 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.landing-eyebrow::before,
.landing-eyebrow::after {
  content: '';
  display: inline-block;
  width: 28px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.landing-eyebrow::after {
  background: linear-gradient(90deg, var(--gold), transparent);
}

.landing-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(32px, 5.5vw, 58px);
  line-height: 1.1;
  margin: 0 0 28px;
  opacity: 0;
  animation: fadeSlideUp 0.9s ease forwards 0.45s;
  /* Animated gradient text */
  background: linear-gradient(135deg, #E7EBEE 0%, #E3A21A 30%, #2FC9B3 55%, #E7EBEE 80%, #E3A21A 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeSlideUp 0.9s ease forwards 0.45s, textShine 5s linear 1.4s infinite;
}
.landing-title .accent {
  /* accent stays inside gradient - no override needed */
}

.landing-desc {
  font-size: 15px;
  color: var(--text-lo);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.75;
  opacity: 0;
  animation: fadeSlideUp 1s ease forwards 0.7s;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes textShine {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

.module-grid {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 28px 88px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  position: relative;
  z-index: 1;
}

/* Staggered card entrance animations */
.module-card:nth-child(1) { animation: cardEntrance 0.7s ease both 0.8s; }
.module-card:nth-child(2) { animation: cardEntrance 0.7s ease both 1.0s; }
.module-card:nth-child(3) { animation: cardEntrance 0.7s ease both 1.2s; }
.module-card:nth-child(4) { animation: cardEntrance 0.7s ease both 1.4s; }
@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.module-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  padding: 28px 26px;
  text-decoration: none;
  color: var(--text-hi);
  box-shadow: var(--shadow-panel);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  overflow: hidden;
  opacity: 0; /* reset so animation handles it */
}
.module-card:hover {
  transform: translateY(-6px);
  border-color: var(--card-accent, var(--gold));
  box-shadow: 0 24px 64px -20px rgba(0,0,0,0.7), 0 0 0 1px var(--card-accent, var(--gold)), 0 0 30px -8px var(--card-accent, var(--gold));
}
/* Shimmer swipe on hover */
.module-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.04) 50%, transparent 60%);
  background-size: 200% 100%;
  background-position: 200% 0;
  transition: background-position 0.5s ease;
  pointer-events: none;
}
.module-card:hover::after {
  background-position: -200% 0;
}
.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--gold));
  transition: height 0.25s ease;
}
.module-card:hover::before { height: 4px; }

.module-card-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--card-accent, var(--gold));
  background: var(--card-accent-dim, var(--gold-dim));
  border-radius: var(--radius-s);
  padding: 3px 9px;
  margin-bottom: 16px;
}
.module-card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 21px;
  margin: 0 0 10px;
  transition: color 0.2s ease;
}
.module-card:hover .module-card-title { color: var(--card-accent, var(--gold)); }
.module-card-desc {
  font-size: 13px;
  color: var(--text-lo);
  line-height: 1.6;
  margin: 0 0 20px;
}
.module-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.module-card-meta span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.module-card:hover .module-card-meta span {
  border-color: var(--card-accent, var(--gold));
  color: var(--card-accent, var(--gold));
  opacity: 0.7;
}
.module-card-go {
  margin-top: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--card-accent, var(--gold));
  display: flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.2s ease;
}
.module-card:hover .module-card-go { gap: 10px; }

.landing-note {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 72px;
  position: relative;
  z-index: 1;
}
.landing-note-box {
  border: 1px dashed var(--border);
  border-radius: var(--radius-l);
  padding: 22px 24px;
  font-size: 13px;
  color: var(--text-lo);
  line-height: 1.7;
}
.landing-note-box strong { color: var(--text-hi); }

/* =========================================================
   BIT-GROUP TILES (for DES / S-DES: 6-bit / 8-bit groups)
   ========================================================= */

.bit-group-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.bit-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.bit-group-cells {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.bit-cell {
  width: 22px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-hi);
  transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
}
.bit-cell.changed { border-color: var(--gold); background: var(--gold-dim); color: var(--gold); animation: flipTile 0.5s ease; }
.bit-group-label { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--text-faint); }

.byte-group { display: flex; gap: 6px; flex-wrap: wrap; }

.perm-table-wrap { overflow-x: auto; }
.perm-table {
  border-collapse: collapse;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.perm-table td {
  padding: 5px 8px;
  border: 1px solid var(--border-soft);
  color: var(--text-lo);
  text-align: center;
}
.perm-table tr:nth-child(odd) { background: rgba(255,255,255,0.015); }

.round-key-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.round-key-chip {
  flex-shrink: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-lo);
  min-width: 92px;
  text-align: center;
}
.round-key-chip .rk-label { color: var(--teal); font-weight: 700; display: block; margin-bottom: 4px; }

.ref-list {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--gold);
  line-height: 1.8;
  word-spacing: 4px;
}
.bit-strip { display: flex; gap: 4px; flex-wrap: wrap; }

/* =========================================================
   RESPONSIVE — MOBILE FIRST TWEAKS
   ========================================================= */

/* --- Tablet & small desktop (≤ 900px) --- */
@media (max-width: 900px) {
  .header-inner {
    padding: 12px 18px;
  }
  .brand-tag {
    display: none; /* terlalu panjang di tablet kecil */
  }
  .hero {
    padding: 48px 18px 36px;
  }
  .hero-title {
    font-size: clamp(20px, 3.5vw, 32px);
    margin-bottom: 28px;
  }
  .panel-inner {
    padding: 28px 18px;
  }
  .landing-hero {
    padding: 80px 18px 56px;
  }
  .module-grid {
    padding: 36px 18px 60px;
  }
  .landing-note {
    padding: 0 18px 48px;
  }
}

/* --- Mobile (≤ 600px) --- */
@media (max-width: 600px) {

  /* Header */
  .header-inner {
    padding: 10px 16px;
    gap: 10px;
  }
  .brand-mark { font-size: 17px; }
  .brand-meta { display: none; } /* simpan ruang di layar kecil */

  /* Module nav */
  .module-nav-inner {
    padding: 8px 16px;
    gap: 8px;
  }
  .module-nav-home { font-size: 11.5px; }
  .module-nav-link { font-size: 11px; padding: 5px 10px; }

  /* Landing hero */
  .landing-hero {
    padding: 60px 16px 44px;
  }
  .landing-eyebrow {
    font-size: 10.5px;
    letter-spacing: 0.12em;
  }
  .landing-eyebrow::before,
  .landing-eyebrow::after { width: 16px; }

  .landing-title {
    font-size: clamp(26px, 7.5vw, 38px);
    line-height: 1.15;
    margin-bottom: 20px;
  }
  .landing-desc {
    font-size: 13.5px;
    line-height: 1.65;
  }

  /* Module grid — single column */
  .module-grid {
    grid-template-columns: 1fr;
    padding: 24px 16px 48px;
    gap: 16px;
  }
  .module-card { padding: 22px 18px; }
  .module-card-title { font-size: 18px; }

  /* Landing note */
  .landing-note { padding: 0 16px 40px; }
  .landing-note-box { padding: 16px 18px; font-size: 12.5px; }

  /* Hero (module pages) */
  .hero { padding: 36px 16px 28px; }
  .hero-title {
    font-size: clamp(18px, 5.5vw, 28px);
    margin-bottom: 20px;
  }

  /* Panel & form */
  .panel-inner { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .field input {
    font-size: 13.5px;
    padding: 11px 12px;
    letter-spacing: 0.06em;
  }

  /* Form controls: stack vertically */
  .form-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .mode-switch { justify-content: center; }
  .action-buttons {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .btn {
    width: 100%;
    text-align: center;
    padding: 13px 16px;
    font-size: 14px;
  }
  .toggle { justify-content: center; }

  /* Output box */
  .output-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .output-box code { font-size: 13px; letter-spacing: 0.06em; }
  .copy-btn { width: 100%; text-align: center; }

  /* Workspace sidebar */
  .workspace {
    padding: 20px 16px 48px;
    gap: 20px;
  }
  .round-nav {
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
    padding-right: 0;
    padding-bottom: 14px;
    max-height: none;
  }
  .round-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  /* Round cards */
  .round-card summary { padding: 14px 16px; }
  .round-body { padding: 0 16px 18px; gap: 16px; }
  .round-title { font-size: 13.5px; }
  .round-sub { font-size: 11px; }

  /* Nibble tiles smaller on mobile */
  .nibble-tile { width: 44px; height: 44px; }
  .nibble-tile .nib-hex { font-size: 13px; }

  /* Bit cells */
  .bit-cell { width: 19px; height: 24px; font-size: 10.5px; }

  /* Particle canvas: disable on small/mobile to save battery */
  #particle-canvas { display: none; }

  /* Footer */
  .site-footer { padding: 20px 16px; }
  .site-footer p { font-size: 11px; }
}

/* --- Very small (≤ 380px, e.g. iPhone SE) --- */
@media (max-width: 380px) {
  .landing-title { font-size: clamp(22px, 8vw, 30px); }
  .module-card { padding: 18px 14px; }
  .module-card-title { font-size: 16px; }
  .field input { font-size: 12.5px; }
  .nibble-tile { width: 38px; height: 38px; }
  .nibble-tile .nib-hex { font-size: 12px; }
  .nibble-tile .nib-bin { display: none; } /* terlalu sempit */
}
