@charset "UTF-8";

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Helvetica;
}

body {
    background-color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3em;
}

#calc {
    width: 100%;
    max-width: 400px;
    padding: .5em;
    background-color: #c4c4c4;
    color: #000;
    display: flex;
    flex-direction: column;
}

#calc h3 {
    font-size: 0.8em;
    font-weight: 300;
    color: #666;
}

#operations {
    text-align: right;
}

#previous-operation {
    min-height: 1.6em;
    color: #777;
    padding: 0.2em;
    overflow-wrap: break-word;
}

#current-operation {
    min-height: 1.6em;
    font-size: 3em;
    font-weight: 700;
    padding: 0.2em;
    overflow-wrap: break-word;
}

/* Keep numeric values prominent while presenting errors in a smaller format. */
#current-operation.is-error {
    min-height: 4.8rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    color: #842424;
    background-color: #f7e8e8;
    border-radius: 4px;
}

#buttons-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 3px;
}

#buttons-container button {
    height: 4em;
    background-color: #dbdbdb;
    font-size: 1.2em;
    border: 1px solid transparent;
    border-radius: 0;
    cursor: pointer;
} 

#buttons-container .number {
    background-color: #f3f3f3;
}

#buttons-container button:hover {
    background-color: #bababa;
    border-color: #999;
}

#buttons-container #equal-btn {
    grid-column: span 2;
    background-color: #75a5cb;
}

#buttons-container #equal-btn:hover {
    grid-column: span 2;
    background-color: #3a91d8;
}

/* Adapt the calculator to narrow screens without changing the desktop layout. */
@media (max-width: 480px) {
    body {
        padding: 1rem;
    }

    #current-operation {
        font-size: clamp(1.75rem, 8vw, 3rem);
    }

    #buttons-container button {
        font-size: 1rem;
    }
}
