/*
  Cyberpunk Calculator Theme
  - Neon accents
  - Animated circuit + grid background
  - Centered calculator with glowing hover effects
*/

:root {
  --bg-0: #05070f;
  --bg-1: #0a1022;
  --bg-2: #0f172a;

  --neon-cyan: #00eaff;
  --neon-magenta: #ff00f7;
  --neon-lime: #a6ff00;
  --neon-amber: #ffea00;
  --grey-1: #93a4b8;
  --grey-2: #637289;

  --text: #e6f1ff;
  --text-dim: #9db1d1;

  --radius: 18px;
  --shadow-neon: 0 0 12px rgba(0, 234, 255, 0.45), 0 0 28px rgba(255, 0, 247, 0.25);
  --shadow-strong: 0 8px 40px rgba(0, 0, 0, 0.5);

  --key-size: 72px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 800px at 70% 10%, #0b1a3a 0%, var(--bg-2) 40%, var(--bg-1) 70%, var(--bg-0) 100%);
  font-family: "Share Tech Mono", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Background layers */
.background {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.grid-layer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 70% 10%, rgba(0, 234, 255, 0.08), transparent 60%),
    linear-gradient(180deg, rgba(255, 0, 247, 0.08), rgba(0, 234, 255, 0.08)),
    repeating-linear-gradient(
      0deg,
      rgba(0, 234, 255, 0.08) 0px,
      rgba(0, 234, 255, 0.08) 1px,
      transparent 1px,
      transparent 40px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 0, 247, 0.08) 0px,
      rgba(255, 0, 247, 0.08) 1px,
      transparent 1px,
      transparent 40px
    );
  animation: gridPan 30s linear infinite;
}

@keyframes gridPan {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-80px, -80px, 0); }
}

.circuit-layer {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  filter: drop-shadow(0 0 6px rgba(0, 234, 255, 0.25));
  background-image: url("data:image/svg+xml;utf8,\
    <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600'>\
      <defs>\
        <linearGradient id='g' x1='0' y1='0' x2='1' y2='1'>\
          <stop offset='0%' stop-color='%2300eaff' stop-opacity='0.6'/>\
          <stop offset='100%' stop-color='%23ff00f7' stop-opacity='0.6'/>\
        </linearGradient>\
      </defs>\
      <g stroke='url(%23g)' stroke-width='1.5' fill='none' stroke-linecap='round'>\
        <path d='M20 40h120v40h60v60h80'/>\
        <path d='M30 160h90v30h70v60h110'/>\
        <path d='M120 260h110v-40h90v-40h120'/>\
        <path d='M780 40h-140v60h-80v40h-60'/>\
        <path d='M760 180h-100v-40h-80v-40h-90'/>\
        <path d='M680 260h-120v-40h-100v-60h-70'/>\
        <circle cx='200' cy='120' r='3'/>\
        <circle cx='600' cy='120' r='3'/>\
        <circle cx='400' cy='200' r='3'/>\
        <circle cx='300' cy='280' r='3'/>\
        <circle cx='520' cy='280' r='3'/>\
      </g>\
    </svg>");
  background-size: 800px 600px;
  background-repeat: repeat;
  animation: circuitDrift 40s linear infinite;
}

@keyframes circuitDrift {
  0% { background-position: 0 0; }
  100% { background-position: 800px 600px; }
}

.scanlines {
  position: absolute;
  inset: 0;
  mix-blend-mode: overlay;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.08) 0px,
    rgba(255, 255, 255, 0.08) 1px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0) 4px
  );
  animation: scan 8s linear infinite;
}

@keyframes scan {
  0% { transform: translateY(-10%); opacity: 0.4; }
  50% { transform: translateY(10%); opacity: 0.2; }
  100% { transform: translateY(-10%); opacity: 0.4; }
}

/* Centering wrapper */
.wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* Calculator */
.calculator {
  width: min(96vw, 420px);
  background: linear-gradient(180deg, rgba(13, 22, 45, 0.8), rgba(7, 12, 25, 0.7));
  border: 1px solid rgba(0, 234, 255, 0.25);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong), 0 0 0 1px rgba(255, 0, 247, 0.15), var(--shadow-neon);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  position: relative;
  overflow: hidden;
}

.calculator::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--radius) + 2px);
  padding: 1px;
  background: linear-gradient(135deg, rgba(0,234,255,0.6), rgba(255,0,247,0.6));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  filter: blur(6px) saturate(140%);
}

.branding {
  padding: 16px 20px 4px 20px;
}

.brand-title {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--text-dim);
  text-shadow: 0 0 6px rgba(0, 234, 255, 0.4);
}

.display {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 0 20px 12px 20px;
}

.history {
  min-height: 18px;
  color: var(--grey-1);
  font-size: 14px;
  opacity: 0.9;
}

.current {
  min-height: 72px;
  font-size: clamp(36px, 7.5vw, 46px);
  line-height: 1.2;
  text-align: right;
  word-break: break-all;
  color: var(--text);
  text-shadow:
    0 0 6px rgba(0, 234, 255, 0.4),
    0 0 18px rgba(255, 0, 247, 0.2);
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 16px 18px 16px;
}

.key {
  height: var(--key-size);
  border-radius: 14px;
  border: 1px solid rgba(147, 164, 184, 0.25);
  background: radial-gradient(120% 120% at 30% 20%, rgba(19, 33, 63, 0.9) 0%, rgba(6, 12, 27, 0.85) 70%, rgba(4, 9, 20, 0.9) 100%);
  color: var(--text);
  font-size: 20px;
  letter-spacing: 1px;
  cursor: pointer;
  position: relative;
  outline: none;
  transition: transform 0.05s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), inset 0 -8px 18px rgba(0, 0, 0, 0.35);
}

.key:hover {
  border-color: rgba(0, 234, 255, 0.6);
  box-shadow: 0 6px 20px rgba(0, 234, 255, 0.18), 0 0 18px rgba(255, 0, 247, 0.12), inset 0 -8px 18px rgba(0, 0, 0, 0.35);
  filter: saturate(130%);
}

.key:active,
.key.active {
  transform: translateY(2px) scale(0.992);
  box-shadow: 0 2px 10px rgba(0, 234, 255, 0.18), 0 0 12px rgba(255, 0, 247, 0.12), inset 0 -4px 12px rgba(0, 0, 0, 0.5);
}

.key::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(0,234,255,0.35), rgba(255,0,247,0.25));
  opacity: 0;
  transition: opacity 0.2s ease;
  filter: blur(8px);
  pointer-events: none;
}

.key:hover::before { opacity: 1; }

.key-op {
  color: var(--neon-cyan);
  border-color: rgba(0, 234, 255, 0.45);
}

.key-op:hover {
  box-shadow: 0 10px 28px rgba(0, 234, 255, 0.22), 0 0 20px rgba(0, 234, 255, 0.25);
}

.key-func {
  color: var(--grey-1);
}

.key-eq {
  color: #0b0e15;
  background: linear-gradient(135deg, rgba(0,234,255,0.9), rgba(255,0,247,0.9));
  border-color: rgba(0, 234, 255, 0.8);
  text-shadow: none;
}

.key-eq:hover {
  box-shadow: 0 14px 32px rgba(255, 0, 247, 0.3), 0 0 26px rgba(0, 234, 255, 0.35);
  filter: saturate(150%);
}

.legend {
  padding: 6px 16px 16px 16px;
  color: var(--grey-2);
  text-align: center;
  font-size: 12px;
}

/* Focus ring */
.key:focus-visible {
  outline: 2px solid rgba(0, 234, 255, 0.8);
  outline-offset: 2px;
}

/* Responsive sizing */
@media (max-width: 420px) {
  :root { --key-size: 64px; }
  .current { min-height: 64px; font-size: clamp(32px, 10vw, 40px); }
}


