/* Pragmata / Diana hacking easter egg — polished HUD + mode transitions */

:root {
  --diana-cyan: #5cf0ff;
  --diana-cyan-dim: rgba(92, 240, 255, 0.35);
  --diana-blue: #2eb8ff;
  --diana-green: #3dff8a;
  --diana-red: #ff3d55;
  --diana-pink: #ff4ec8;
}

/* ── Portfolio fade when entering / leaving hack ── */
.page {
  transition:
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.5s ease,
    visibility 0s linear 0s;
}

body.diana-mode {
  overflow: hidden;
}

body.diana-mode .page {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.96) translateY(8px);
  filter: blur(6px) saturate(0.6);
  transition:
    opacity 0.4s ease,
    transform 0.45s ease,
    filter 0.4s ease,
    visibility 0s linear 0.4s;
}

/* Keep page hidden while overlay is exiting, then fade Carrd back in */
body.diana-leaving .page {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.98) translateY(4px);
  filter: blur(4px);
}

body.diana-mode .crt-overlay {
  opacity: 0.62;
  transition: opacity 0.5s ease;
}

body.diana-mode .glitch-field {
  visibility: hidden;
  content-visibility: hidden;
}

body.diana-mode .glitch-canvas {
  opacity: 0.2;
}

.crt-overlay,
.glitch-canvas,
.glitch-field {
  transition: opacity 0.5s ease;
}

/* ── Overlay shell ── */
.diana-hack {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.5s;
}

.diana-hack.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

.diana-hack.is-open.is-closing {
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0.45s;
  visibility: visible;
}

.diana-hack.is-closing .diana-bg {
  opacity: 0;
  transform: scale(1.03);
  transition-duration: 0.4s;
}

.diana-hack.is-closing .diana-vignette {
  opacity: 0;
  transition-duration: 0.35s;
  transition-delay: 0s;
}

.diana-hack[hidden] {
  display: flex !important;
}

.diana-hack:not(.is-open):not(.is-closing)[hidden] {
  display: none !important;
}

.diana-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 25% 35%, rgba(0, 120, 180, 0.28), transparent 60%),
    radial-gradient(ellipse 70% 50% at 78% 65%, rgba(0, 60, 120, 0.32), transparent 55%),
    radial-gradient(circle at 50% 50%, rgba(8, 24, 40, 0.4), transparent 70%),
    linear-gradient(165deg, #03060c 0%, #071420 42%, #040a12 100%);
  opacity: 0;
  transform: scale(1.04);
  transition:
    opacity 0.55s ease,
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.diana-hack.is-open .diana-bg {
  opacity: 1;
  transform: scale(1);
}

.diana-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.45;
  pointer-events: none;
  animation: diana-scan 8s linear infinite;
}

.diana-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(92, 240, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 240, 255, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  opacity: 0.7;
  pointer-events: none;
  animation: diana-grid-drift 20s linear infinite;
}

@keyframes diana-scan {
  from { background-position: 0 0; }
  to { background-position: 0 100px; }
}

@keyframes diana-grid-drift {
  from { transform: translate(0, 0); }
  to { transform: translate(32px, 32px); }
}

.diana-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 28%, rgba(0, 0, 0, 0.55) 70%, rgba(0, 0, 0, 0.88) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease 0.1s;
}

.diana-hack.is-open .diana-vignette {
  opacity: 1;
}

.diana-boot {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  letter-spacing: 0.22em;
  color: var(--diana-cyan);
  text-shadow: 0 0 20px rgba(92, 240, 255, 0.55);
  background: rgba(2, 8, 14, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.diana-hack.is-booting .diana-boot {
  opacity: 1;
}

.diana-boot span {
  font-size: clamp(11px, 2.4vw, 13px);
  animation: diana-boot-flicker 0.12s steps(2) infinite;
}

.diana-boot small {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(160, 220, 240, 0.55);
}

@keyframes diana-boot-flicker {
  50% { opacity: 0.72; }
}

/* ── Stage ── */
.diana-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
  width: min(980px, 100%);
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  filter: blur(8px);
  transition:
    opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.12s,
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.12s,
    filter 0.55s ease 0.12s;
}

.diana-hack.is-open:not(.is-booting) .diana-stage {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

.diana-hack.is-closing .diana-stage {
  opacity: 0;
  transform: translateY(-10px) scale(0.97);
  filter: blur(4px);
  transition-duration: 0.35s;
  transition-delay: 0s;
}

.diana-hint {
  flex: 1 1 210px;
  max-width: 270px;
  padding: 18px 18px 16px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  color: rgba(190, 235, 255, 0.78);
  font-size: 11px;
  line-height: 1.7;
  background: linear-gradient(160deg, rgba(8, 28, 44, 0.72), rgba(4, 14, 24, 0.55));
  border: 1px solid var(--diana-cyan-dim);
  box-shadow:
    0 0 24px rgba(0, 160, 220, 0.12),
    inset 0 0 24px rgba(0, 80, 120, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 2px;
  transform: translateX(-12px);
  opacity: 0;
  transition:
    opacity 0.5s ease 0.28s,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.28s;
}

.diana-hack.is-open:not(.is-booting) .diana-hint {
  opacity: 1;
  transform: translateX(0);
}

.diana-hint-title {
  color: var(--diana-cyan);
  letter-spacing: 0.16em;
  font-size: 12px;
  margin-bottom: 12px;
  text-shadow: 0 0 16px rgba(92, 240, 255, 0.5);
}

.hint-exe {
  color: var(--diana-green);
  font-weight: 600;
  text-shadow: 0 0 8px rgba(61, 255, 138, 0.4);
}

.diana-keys {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(92, 240, 255, 0.15);
  color: rgba(160, 200, 220, 0.55);
}

.diana-keys kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid rgba(92, 240, 255, 0.4);
  border-radius: 3px;
  color: #b8f7ff;
  background: rgba(0, 50, 75, 0.55);
  font-size: 10px;
  box-shadow: 0 0 8px rgba(92, 240, 255, 0.15);
}

/* ── Hacking panel ── */
.diana-panel {
  position: relative;
  width: min(440px, 88vw);
  aspect-ratio: 1;
  padding: 46px 40px 44px;
  background:
    linear-gradient(145deg, rgba(12, 48, 72, 0.65) 0%, rgba(4, 16, 30, 0.82) 55%, rgba(6, 22, 36, 0.78) 100%);
  border: 1px solid rgba(92, 240, 255, 0.42);
  box-shadow:
    0 0 0 1px rgba(92, 240, 255, 0.08),
    0 0 50px rgba(0, 180, 255, 0.22),
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 0 80px rgba(0, 100, 150, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: scale(0.92) rotateX(4deg);
  opacity: 0;
  transition:
    opacity 0.5s ease 0.2s,
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.2s,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.diana-hack.is-open:not(.is-booting) .diana-panel {
  opacity: 1;
  transform: scale(1) rotateX(0);
}

.diana-panel::before,
.diana-panel::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--diana-cyan);
  opacity: 0.7;
  pointer-events: none;
}

.diana-panel::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
  box-shadow: -2px -2px 10px rgba(92, 240, 255, 0.2);
}

.diana-panel::after {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
  box-shadow: 2px 2px 10px rgba(92, 240, 255, 0.2);
}

.diana-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.diana-corners span {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(92, 240, 255, 0.45);
}

.diana-corners span:nth-child(1) {
  top: 8px;
  right: 8px;
  border-left: none;
  border-bottom: none;
}

.diana-corners span:nth-child(2) {
  bottom: 8px;
  left: 8px;
  border-right: none;
  border-top: none;
}

.diana-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(92, 240, 255, 0.2);
  pointer-events: none;
}

.diana-ring-a {
  inset: -20px;
  border-color: rgba(92, 240, 255, 0.22);
  box-shadow:
    0 0 30px rgba(0, 180, 255, 0.1),
    inset 0 0 30px rgba(0, 180, 255, 0.05);
  animation: diana-pulse-ring 3.2s ease-in-out infinite;
}

.diana-ring-b {
  inset: -38px;
  border-style: dashed;
  border-color: rgba(92, 240, 255, 0.14);
  opacity: 0.85;
  animation: diana-spin 56s linear infinite;
}

.diana-ring-c {
  inset: -54px;
  border-color: rgba(92, 240, 255, 0.08);
  animation: diana-spin 90s linear infinite reverse;
}

@keyframes diana-spin {
  to { transform: rotate(360deg); }
}

@keyframes diana-pulse-ring {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.015); }
}

.diana-hud-top,
.diana-hud-bottom {
  position: absolute;
  left: 40px;
  right: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(190, 245, 255, 0.9);
  text-shadow: 0 0 10px rgba(92, 240, 255, 0.4);
  pointer-events: none;
}

.diana-hud-top { top: 16px; }
.diana-hud-bottom { bottom: 16px; }

#diana-damage {
  color: #9ef7ff;
}

#diana-status {
  color: var(--diana-cyan);
  animation: diana-status-pulse 2.4s ease-in-out infinite;
}

@keyframes diana-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.diana-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 6px;
  background:
    linear-gradient(180deg, rgba(0, 40, 65, 0.45), rgba(0, 20, 40, 0.55));
  border: 1px solid rgba(92, 240, 255, 0.32);
  box-shadow:
    inset 0 0 40px rgba(0, 120, 170, 0.18),
    0 0 20px rgba(0, 160, 220, 0.08);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.diana-grid.is-drawing {
  cursor: grabbing;
}

.diana-grid.is-drawing .diana-cell {
  cursor: grabbing;
}

.diana-cell {
  position: relative;
  border: 1px solid rgba(80, 210, 255, 0.2);
  background: rgba(0, 45, 75, 0.18);
  padding: 0;
  cursor: crosshair;
  min-width: 0;
  min-height: 0;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.12s ease;
}

.diana-cell:hover {
  border-color: rgba(180, 245, 255, 0.55);
  background: rgba(0, 90, 130, 0.28);
  box-shadow: inset 0 0 12px rgba(92, 240, 255, 0.12);
}

.diana-cell.is-trail {
  background: rgba(0, 190, 255, 0.28);
  border-color: rgba(120, 235, 255, 0.65);
  box-shadow:
    inset 0 0 14px rgba(0, 210, 255, 0.3),
    0 0 8px rgba(0, 180, 255, 0.2);
  animation: diana-trail-in 0.2s ease;
}

@keyframes diana-trail-in {
  from { transform: scale(0.86); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}

.diana-cell.is-cursor {
  z-index: 3;
  border-color: #fff;
  background: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 0 1.5px #fff,
    0 0 18px rgba(255, 255, 255, 0.55),
    inset 0 0 12px rgba(255, 255, 255, 0.12);
}

.diana-cell.is-cursor::before,
.diana-cell.is-cursor::after {
  content: '';
  position: absolute;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  z-index: 4;
}

/* crosshair ticks */
.diana-cell.is-cursor::before {
  width: 7px;
  height: 2px;
  top: 50%;
  left: -7px;
  transform: translateY(-50%);
  box-shadow:
    0 0 8px #fff,
    calc(100% + 14px) 0 0 #fff,
    calc(100% + 14px) 0 8px #fff;
}

.diana-cell.is-cursor::after {
  width: 2px;
  height: 7px;
  left: 50%;
  top: -7px;
  transform: translateX(-50%);
  box-shadow:
    0 0 8px #fff,
    0 calc(100% + 14px) 0 #fff,
    0 calc(100% + 14px) 8px #fff;
}

.diana-cell.type-x {
  background: rgba(18, 26, 34, 0.9);
  border-color: rgba(70, 80, 90, 0.55);
  cursor: not-allowed;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4);
}

.diana-cell .icon {
  display: block;
  width: 56%;
  height: 56%;
  margin: 0 auto;
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}

.diana-cell .icon.exe {
  width: 50%;
  height: 50%;
  border: 2.5px solid var(--diana-green);
  border-radius: 50%;
  border-top-color: transparent;
  box-shadow: 0 0 14px rgba(61, 255, 138, 0.6);
  background: transparent;
  animation: diana-exe-spin 2.8s linear infinite;
}

.diana-cell .icon.exe::after {
  content: '';
  position: absolute;
  top: -16%;
  left: 50%;
  width: 2.5px;
  height: 46%;
  background: var(--diana-green);
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(61, 255, 138, 0.75);
  border-radius: 2px;
}

@keyframes diana-exe-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.diana-cell.type-e {
  background: rgba(20, 90, 45, 0.4);
  border-color: rgba(90, 255, 150, 0.6);
  box-shadow: inset 0 0 16px rgba(61, 255, 138, 0.15);
  animation: diana-exe-glow 1.8s ease-in-out infinite;
}

@keyframes diana-exe-glow {
  0%, 100% { box-shadow: inset 0 0 12px rgba(61, 255, 138, 0.12), 0 0 0 rgba(61, 255, 138, 0); }
  50% { box-shadow: inset 0 0 18px rgba(61, 255, 138, 0.22), 0 0 12px rgba(61, 255, 138, 0.2); }
}

.diana-cell .icon.blue {
  background: var(--diana-blue);
  box-shadow: 0 0 12px rgba(46, 184, 255, 0.65);
  clip-path: polygon(
    35% 0%, 65% 0%, 65% 35%, 100% 35%, 100% 65%,
    65% 65%, 65% 100%, 35% 100%, 35% 65%, 0% 65%, 0% 35%, 35% 35%
  );
}

.diana-cell.type-b {
  background: rgba(0, 75, 130, 0.38);
  border-color: rgba(90, 210, 255, 0.5);
}

.diana-cell .icon.err {
  background: var(--diana-red);
  box-shadow: 0 0 14px rgba(255, 61, 85, 0.65);
  clip-path: polygon(50% 10%, 90% 86%, 10% 86%);
  animation: diana-err-blink 1.4s steps(2) infinite;
}

@keyframes diana-err-blink {
  50% { opacity: 0.75; filter: brightness(1.2); }
}

.diana-cell.type-r {
  background: rgba(95, 8, 22, 0.5);
  border-color: rgba(255, 70, 90, 0.6);
}

.diana-cell .icon.weapon {
  background: var(--diana-pink);
  box-shadow: 0 0 14px rgba(255, 78, 200, 0.6);
  border-radius: 2px;
  clip-path: polygon(10% 40%, 55% 40%, 55% 25%, 90% 50%, 55% 75%, 55% 60%, 10% 60%);
}

.diana-cell.type-w {
  background: rgba(95, 8, 65, 0.45);
  border-color: rgba(255, 90, 210, 0.55);
  animation: diana-weapon-pulse 2s ease-in-out infinite;
}

@keyframes diana-weapon-pulse {
  0%, 100% { box-shadow: inset 0 0 8px rgba(255, 78, 200, 0.1); }
  50% { box-shadow: inset 0 0 16px rgba(255, 78, 200, 0.25), 0 0 10px rgba(255, 78, 200, 0.15); }
}

.diana-cell .icon.start {
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
}

.diana-jam,
.diana-success {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: clamp(18px, 4vw, 28px);
  letter-spacing: 0.2em;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
  backdrop-filter: blur(2px);
}

.diana-jam {
  color: var(--diana-red);
  background: rgba(40, 0, 10, 0.62);
  text-shadow: 0 0 22px rgba(255, 40, 70, 0.8);
}

.diana-success {
  color: var(--diana-green);
  background: rgba(0, 28, 16, 0.62);
  text-shadow: 0 0 22px rgba(80, 255, 140, 0.8);
  font-size: clamp(13px, 3vw, 18px);
}

.diana-jam.show,
.diana-success.show {
  opacity: 1;
  animation: diana-flash 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.diana-hack.is-jammed .diana-panel {
  animation: diana-shake 0.4s steps(4);
  border-color: rgba(255, 70, 90, 0.8);
}

.diana-hack.is-success .diana-panel {
  border-color: rgba(90, 255, 150, 0.8);
  box-shadow:
    0 0 0 1px rgba(90, 255, 150, 0.15),
    0 0 50px rgba(80, 255, 140, 0.3),
    inset 0 0 60px rgba(40, 180, 90, 0.12);
}

@keyframes diana-flash {
  from { opacity: 0; filter: blur(8px); transform: scale(1.02); }
  to   { opacity: 1; filter: blur(0); transform: scale(1); }
}

@keyframes diana-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 1px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-3px, 0); }
  80% { transform: translate(2px, 1px); }
}

@media (max-width: 720px) {
  .diana-stage {
    flex-direction: column;
    gap: 18px;
    padding: 16px;
  }

  .diana-hint {
    max-width: 100%;
    order: 2;
    text-align: center;
    transform: translateY(10px);
  }

  .diana-hack.is-open:not(.is-booting) .diana-hint {
    transform: translateY(0);
  }

  .diana-panel {
    width: min(350px, 92vw);
    padding: 38px 22px 36px;
  }

  .diana-hud-top,
  .diana-hud-bottom {
    left: 22px;
    right: 22px;
    font-size: 10px;
  }

  .diana-ring-a,
  .diana-ring-b,
  .diana-ring-c {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .diana-hack,
  .diana-stage,
  .diana-panel,
  .diana-hint,
  .diana-bg,
  .page {
    transition-duration: 0.01ms !important;
  }

  .diana-ring-a,
  .diana-ring-b,
  .diana-ring-c,
  .diana-bg::before,
  .diana-bg::after,
  .diana-cell .icon.exe,
  .diana-cell.type-e,
  .diana-cell.type-w,
  .diana-cell .icon.err,
  #diana-status {
    animation: none !important;
  }
}
