/* Catculator - A cute cat-themed scientific calculator */
/* Coded by Nate */

/* Keyframe Animations */
@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(10deg);
    }
}

@keyframes float-reverse {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-15px) rotate(-10deg);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 200, 100, 0.5), 0 3px 8px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 200, 100, 0.8), 0 3px 12px rgba(0, 0, 0, 0.4);
    }
}

@keyframes title-bounce {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
    }

    50% {
        transform: translateX(-50%) scale(1.05);
    }
}

@keyframes wiggle {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&display=swap');

/* Custom paw cursor */
body,
body * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cellipse cx='16' cy='20' rx='8' ry='6' fill='%23D2691E'/%3E%3Ccircle cx='8' cy='12' r='4' fill='%23D2691E'/%3E%3Ccircle cx='16' cy='8' r='4' fill='%23D2691E'/%3E%3Ccircle cx='24' cy='12' r='4' fill='%23D2691E'/%3E%3Ccircle cx='10' cy='18' r='3' fill='%23FFB6C1'/%3E%3Ccircle cx='16' cy='16' r='3' fill='%23FFB6C1'/%3E%3Ccircle cx='22' cy='18' r='3' fill='%23FFB6C1'/%3E%3Cellipse cx='16' cy='23' rx='5' ry='4' fill='%23FFB6C1'/%3E%3C/svg%3E") 16 16, auto;
}

body {
    background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 50%, #87CEEB 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    margin: 0;
    font-family: 'Fredoka', 'Verdana', sans-serif;
    /* Safe sans-serif fallback */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* Floating decorations */
.floating-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.paw-print {
    position: absolute;
    font-size: 30px;
    opacity: 0.3;
    animation: float 4s ease-in-out infinite;
}

.fish {
    position: absolute;
    font-size: 25px;
    opacity: 0.4;
    animation: float-reverse 5s ease-in-out infinite;
}

.yarn {
    position: absolute;
    font-size: 28px;
    opacity: 0.35;
    animation: wiggle 2s ease-in-out infinite;
}

/* Calculator Container - SCALABLE HUB */
.calculator-container {
    position: relative;

    /* Responsive Sizing Logic */
    width: min(95vw, 450px);
    /* Max 450px, scales down on mobile */
    aspect-ratio: 450 / 800;
    /* Lock Aspect Ratio */
    height: auto;
    /* Height driven by width + aspect ratio */

    background-image: url("cat_bg.png");
    background-size: 100% 100%;
    /* Stretch background exact to container */
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
    margin: auto;

    /* Container Query for Font Scaling */
    container-type: inline-size;
}

/* Catculator Title */
.catculator-title {
    position: absolute;
    top: 1.25%;
    /* 10px / 800px */
    left: 50%;
    transform: translateX(-50%);

    font-family: 'Fredoka', 'Verdana', sans-serif;
    font-size: 8.5cqi;
    /* Container Query Inline size ~ 38px/450px */
    font-weight: bold;
    color: #663300;

    text-shadow:
        2px 2px 0px #fff, -2px -2px 0px #fff,
        2px -2px 0px #fff, -2px 2px 0px #fff,
        3px 3px 6px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    white-space: nowrap;
    animation: title-bounce 2s ease-in-out infinite;
}

/* Fallback for browsers without container queries */
@supports not (container-type: inline-size) {
    .catculator-title {
        font-size: 7vw;
    }

    @media (min-width: 450px) {
        .catculator-title {
            font-size: 38px;
        }
    }
}


/* Display Screen */
.calc-display {
    position: absolute;
    top: 24.375%;
    /* 195px / 800px - Adjusted to sit perfectly on eyes */
    left: 50%;
    transform: translateX(-50%);

    width: 55.5%;
    /* 250px / 450px */
    height: 6.875%;
    /* 55px / 800px */

    background: linear-gradient(145deg, #fffef5 0%, #fff8dc 100%);
    color: #333;
    padding: 0 4%;
    /* Responsive padding */
    border-radius: 15px;

    font-size: 6cqi;
    /* Responsive Text */
    font-family: 'Fredoka', sans-serif;
    font-weight: bold;
    text-align: right;
    border: 3px solid #8B4513;
    animation: pulse-glow 2s ease-in-out infinite;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: visible;
}

@supports not (container-type: inline-size) {
    .calc-display {
        font-size: 24px;
    }
}

#display {
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cat reaction emoji */
.cat-reaction {
    position: absolute;
    top: -80%;
    /* Relative to display height */
    right: -10%;
    font-size: 120%;
    /* Relative to display font size */
    z-index: 1002;
    animation: wiggle 0.5s ease-in-out;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
}

/* Belly Spacer */
.belly-spacer {
    height: 67%;
    /* Push buttons lower onto belly */
    width: 100%;
}

/* Button Grid */
.button-grid {
    padding: 0 4%;
    width: 100%;
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 0.8%;
    /* Tightened gap to save vertical space (was 1.2%) */
    margin-bottom: 0.8%;
}

/* Button styling */
.btn {
    width: 10.5%;
    /* Slightly smaller for more compact grid */
    aspect-ratio: 1 / 1;
    /* Square buttons */

    border-radius: 45% 45% 50% 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);

    font-size: 4.5cqi;
    /* Responsive font */
    font-weight: bold;
    font-family: 'Fredoka', 'Verdana', sans-serif;
    transition: all 0.15s ease;
    cursor: pointer;
}

@supports not (container-type: inline-size) {
    .btn {
        font-size: 18px;
    }
}

.btn-placeholder {
    width: 10.5%;
    aspect-ratio: 1 / 1;
    visibility: hidden;
}

/* Number buttons */
.btn-number {
    background: linear-gradient(145deg, #CD853F 0%, #A0522D 50%, #8B4513 100%);
    color: white;
    border-color: #5D4037;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-number:hover {
    background: linear-gradient(145deg, #DEB887 0%, #CD853F 50%, #A0522D 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4), 0 0 20px rgba(255, 200, 100, 0.5);
}

.btn-number:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Function buttons */
.btn-function {
    background: linear-gradient(145deg, #FFA07A 0%, #FA8072 50%, #E9967A 100%);
    color: white;
    border-color: #CD5C5C;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-function:hover {
    background: linear-gradient(145deg, #FFB6A0 0%, #FFA07A 50%, #FA8072 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4), 0 0 20px rgba(255, 200, 100, 0.5);
}

.btn-function:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}
