@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;800&display=swap");

:root {
  --calc-rotation: 25deg;
}

html {
  height: 100%;
  overflow: hidden;
}
body {
  align-items: center;
  background: #2c3539;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 0.5rem; /* Reduced from 0.8rem */
  height: 100%;
  justify-content: center;
  margin: 0;
  padding: 0;
  width: 100%;
  overflow: hidden; /* Prevent scrolling */
}

footer {
  text-align: center;
  font-size: 0.8rem; /* Reduced from 1rem */
  font-family: sans-serif;
  user-select: none;
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}

.calc-base {
  background: linear-gradient(145deg, #333333, #222222);
  border-radius: 1.5rem;
  box-shadow: 
    5px 5px 15px rgba(0, 0, 0, 0.6),
    -5px -5px 15px rgba(255, 255, 255, 0.1),
    inset 0 2px 2px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  height: 85vh; /* Reduced from 90vh to 85vh */
  width: 380px; /* Fixed width instead of max-width */
  position: relative;
  overflow: hidden;
  padding-bottom: 0.5rem; /* Reduced padding */
  border: 2px solid #444;
}

/*Display styling*/
.display {
  background: #c8e6c9;
  display: flex;
  flex: 0 0 15%; /* Further reduced from 18% to 15% */
  flex-direction: column;
  font-family: "Orbitron", sans-serif;
  margin: 10px 10px 5px 10px; /* Further reduced margins */
  text-align: right;
  position: relative;
  border-radius: 8px;
  box-shadow: 
    inset 0 2px 5px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(255, 255, 255, 0.3);
  padding: 5px;
  border: 1px solid #444;
}

/* Indicators styling */
.indicators {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 5px 10px;
  position: absolute;
  box-sizing: border-box;
  top: 0;
}

.memory-indicator {
  background-color: transparent;
  color: #d32f2f;
  font-weight: bold;
  font-size: 1rem; /* Increased from 0.8rem to 1rem */
  display: none;
  text-shadow: 0 0 2px rgba(255, 50, 50, 0.4);
  padding: 2px 5px;
  border-radius: 3px;
}

.memory-indicator.active {
  display: block;
  animation: pulse 2s infinite;
}

.system-indicator {
  background-color: #2d5f8b;
  color: white;
  font-size: 0.9rem; /* Increased from 0.7rem to 0.9rem */
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 
    inset 0 1px 2px rgba(255, 255, 255, 0.3),
    inset 0 -1px 2px rgba(0, 0, 0, 0.3);
  border: 1px solid #204a70;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

.display > .upper-display {
  color: black;
  flex: 1 1 50%;
  font-size: 1.5rem; /* Reduced from 1.8rem to 1.5rem */
  font-weight: 900;
  margin: 1.2rem 0.8rem 0.3rem 0;  /* Reduced margins */
  user-select: none;
}

.display > .input {
  color: black;
  flex: 1 1 50%;
  font-size: 1.5rem;  /* Reduced from 1.8rem to 1.5rem */
  font-weight: 900;   /* Matching font weight */
  margin: 0.3rem 0.8rem 0.5rem 0;  /* Reduced margins */
  user-select: none;
}

/*Buttons styling*/
.buttons {
  align-items: center;
  display: grid;
  flex: 1 1 40%;
  gap: 0.3rem; /* Reduced gap */
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  margin: 0.3rem 0.8rem 0.5rem 0.8rem; /* Reduced margins */
  max-height: 95%;
  text-align: center;
  justify-items: center;
}

.buttons > div {
  align-items: center;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #333333, #222222);
  border-radius: 50%;
  box-shadow: 
    2px 2px 5px rgba(0, 0, 0, 0.5),
    -1px -1px 3px rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  width: 95%;
  height: 95%;
  justify-content: center;
  position: relative;
  transition: transform 0.2s;
  font-size: 1.1rem; /* Reduced from 1.2rem */
  cursor: pointer;
  border: 1px solid #444;
}

.buttons > div::before {
  border-radius: 50%;
  content: "";
  inset: 0;
  position: absolute;
}

/* Add a subtle inner highlight effect */
.buttons > div::after {
  content: "";
  position: absolute;
  top: 5%;
  left: 10%;
  width: 40%;
  height: 30%;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 60%);
  border-radius: 50%;
  pointer-events: none;
}

.buttons > div:hover {
  /* Removed hover effect */
}

.buttons > div:active {
  transform: scale(0.92);
  box-shadow: inset 3px 3px 8px rgba(0, 0, 0, 0.7);
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
  z-index: 10;
}

/* Box-shadow water ripple effect */
.buttons > .numeral:active {
  animation: ripple-blue 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.buttons > .operator:active {
  animation: ripple-orange 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.buttons > .others:active {
  animation: ripple-red 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

/* Specific animation for the negate button */
.buttons > div[id="negate"]:active {
  animation: ripple-purple 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

@keyframes ripple-purple {
  0% {
    box-shadow: 0 0 0 rgba(180, 100, 255, 0.9);
  }
  20% {
    box-shadow: 0 0 15px 8px rgba(180, 100, 255, 0.8);
  }
  40% {
    box-shadow: 0 0 30px 15px rgba(180, 100, 255, 0.7);
  }
  60% {
    box-shadow: 0 0 45px 25px rgba(180, 100, 255, 0.6);
  }
  80% {
    box-shadow: 0 0 60px 35px rgba(180, 100, 255, 0.4);
  }
  100% {
    box-shadow: 0 0 80px 50px rgba(180, 100, 255, 0);
  }
}

@keyframes ripple-blue {
  0% {
    box-shadow: 0 0 0 rgba(100, 200, 255, 0.9);
  }
  20% {
    box-shadow: 0 0 15px 8px rgba(100, 200, 255, 0.8);
  }
  40% {
    box-shadow: 0 0 30px 15px rgba(100, 200, 255, 0.7);
  }
  60% {
    box-shadow: 0 0 45px 25px rgba(100, 200, 255, 0.6);
  }
  80% {
    box-shadow: 0 0 60px 35px rgba(100, 200, 255, 0.4);
  }
  100% {
    box-shadow: 0 0 80px 50px rgba(100, 200, 255, 0);
  }
}

@keyframes ripple-orange {
  0% {
    box-shadow: 0 0 0 rgba(255, 165, 0, 0.9);
  }
  20% {
    box-shadow: 0 0 15px 8px rgba(255, 165, 0, 0.8);
  }
  40% {
    box-shadow: 0 0 30px 15px rgba(255, 165, 0, 0.7);
  }
  60% {
    box-shadow: 0 0 45px 25px rgba(255, 165, 0, 0.6);
  }
  80% {
    box-shadow: 0 0 60px 35px rgba(255, 165, 0, 0.4);
  }
  100% {
    box-shadow: 0 0 80px 50px rgba(255, 165, 0, 0);
  }
}

@keyframes ripple-red {
  0% {
    box-shadow: 0 0 0 rgba(255, 100, 100, 0.9);
  }
  20% {
    box-shadow: 0 0 15px 8px rgba(255, 100, 100, 0.8);
  }
  40% {
    box-shadow: 0 0 30px 15px rgba(255, 100, 100, 0.7);
  }
  60% {
    box-shadow: 0 0 45px 25px rgba(255, 100, 100, 0.6);
  }
  80% {
    box-shadow: 0 0 60px 35px rgba(255, 100, 100, 0.4);
  }
  100% {
    box-shadow: 0 0 80px 50px rgba(255, 100, 100, 0);
  }
}

/* Animation keyframes removed, replaced by specific ripple animations */

.buttons p {
  font-family: sans-serif;
  font-size: 1.1rem; /* Slightly reduced from 1.2rem */
  font-weight: 900;
  margin: 0;
  padding: 0;
  user-select: none;
  position: relative;
  z-index: 2; /* Make text appear above the splash effect */
}

.buttons > div[id="4"] {
  grid-row-start: 3;
}

.buttons > div[id="0"] {
  border-radius: 1rem;
  grid-column: span 2;
  aspect-ratio: auto; /* Override the 1:1 aspect ratio for this button */
  width: 98%; /* Slightly reduced width to prevent overflow */
  height: 95%; /* Increased from 85% to 95% */
  margin: auto; /* Center the button */
  min-height: auto; /* Remove min-height constraint */
  transition: transform 0.2s, box-shadow 0.2s;
}

.buttons > div[id="negate"] {
  border-radius: 50%;
  grid-column-start: 1;
  grid-row: 5;
  background-color: #7030a0; /* Purple background */
  color: white;
  font-weight: bold;
}

.buttons > div[id="dot"] {
  grid-row-start: 2;
  grid-column-start: 4;
}

.buttons > div[id="clear"] {
  grid-row-start: 3;
  grid-column-start: 4;
}

.buttons > div[id="equal"] {
  border-radius: 1rem;
  grid-row: span 2;
  aspect-ratio: auto; /* Override the 1:1 aspect ratio for this button */
  height: 93%; /* Reduced slightly from 95% */
  width: 93%; /* Reduced slightly from 95% */
  min-height: auto; /* Remove min-height constraint */
  margin: auto; /* Center the button */
  transition: transform 0.2s, box-shadow 0.2s;
}

.buttons > .numeral {
  background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
  color: #fff;
  border: 1px solid #444;
}

.buttons > .operator {
  background: linear-gradient(145deg, #ff8c00, #e67e00);
  color: #fff;
  border: 1px solid #d47200;
}

.buttons > .others {
  background: linear-gradient(145deg, #4b4b4b, #383838);
  color: #fff;
  border: 1px solid #555;
}

.buttons > div[id="clear"] {
  background: linear-gradient(145deg, #ff4d4d, #e64444);
  color: #fff;
  border: 1px solid #d13939;
}

.buttons > div[id="equal"] {
  background: linear-gradient(145deg, #4caf50, #43a047);
  color: #fff;
  border: 1px solid #388e3c;
}

.buttons > div[id="negate"] {
  background: linear-gradient(145deg, #7e57c2, #673ab7);
  color: #fff;
  border: 1px solid #5e35b1;
}

.new-buttons > .memory {
  background: linear-gradient(145deg, #e91e63, #d81b60);
  color: #fff;
  border: 1px solid #c2185b;
}

.new-buttons > .conversion {
  background: linear-gradient(145deg, #2196f3, #1e88e5);
  color: #fff;
  border: 1px solid #1976d2;
}

.new-buttons {
  align-items: center;
  display: grid;
  flex: 0 0 12%; /* Further reduced from 15% to 12% */
  gap: 0.25rem; /* Further reduced gap */
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  margin: 0.3rem 0.8rem; /* Reduced margins */
  max-height: 100%;
  text-align: center;
}

.new-buttons > div {
  align-items: center;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #333333, #222222);
  border-radius: 50%;
  box-shadow: 
    2px 2px 5px rgba(0, 0, 0, 0.5),
    -1px -1px 3px rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  width: 95%;
  height: 95%;
  justify-content: center;
  position: relative;
  transition: transform 0.2s;
  font-size: 1rem; /* Slightly reduced from 1.1rem */
  cursor: pointer;
  border: 1px solid #444;
}

.new-buttons > div::before {
  border-radius: 50%;
  content: "";
  inset: 0;
  position: absolute;
}

/* Add a subtle inner highlight effect */
.new-buttons > div::after {
  content: "";
  position: absolute;
  top: 5%;
  left: 10%;
  width: 40%;
  height: 30%;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 60%);
  border-radius: 50%;
  pointer-events: none;
}

.new-buttons > div:hover {
  /* Removed hover effect */
}

.new-buttons > div:active {
  transform: scale(0.92);
  box-shadow: inset 3px 3px 8px rgba(0, 0, 0, 0.7);
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
  z-index: 10;
}

/* Box-shadow water ripple effect for new buttons */
.new-buttons > .memory:active {
  animation: ripple-pink 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.new-buttons > .conversion:active {
  animation: ripple-green 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

@keyframes ripple-pink {
  0% {
    box-shadow: 0 0 0 rgba(255, 105, 180, 0.9);
  }
  20% {
    box-shadow: 0 0 15px 8px rgba(255, 105, 180, 0.8);
  }
  40% {
    box-shadow: 0 0 30px 15px rgba(255, 105, 180, 0.7);
  }
  60% {
    box-shadow: 0 0 45px 25px rgba(255, 105, 180, 0.6);
  }
  80% {
    box-shadow: 0 0 60px 35px rgba(255, 105, 180, 0.4);
  }
  100% {
    box-shadow: 0 0 80px 50px rgba(255, 105, 180, 0);
  }
}

@keyframes ripple-green {
  0% {
    box-shadow: 0 0 0 rgba(120, 255, 120, 0.9);
  }
  20% {
    box-shadow: 0 0 15px 8px rgba(120, 255, 120, 0.8);
  }
  40% {
    box-shadow: 0 0 30px 15px rgba(120, 255, 120, 0.7);
  }
  60% {
    box-shadow: 0 0 45px 25px rgba(120, 255, 120, 0.6);
  }
  80% {
    box-shadow: 0 0 60px 35px rgba(120, 255, 120, 0.4);
  }
  100% {
    box-shadow: 0 0 80px 50px rgba(120, 255, 120, 0);
  }
}

.new-buttons p {
  font-family: sans-serif;
  font-size: 0.75rem; /* Further reduced from 0.85rem */
  font-weight: 900;
  margin: 0;
  padding: 0;
  user-select: none;
  position: relative;
  z-index: 2; /* Make text appear above the splash effect */
}
