/* ============================================================
   Calculadora em C — estilo
   ------------------------------------------------------------
   Tema escuro de tons opacos: cinza-azulado profundo, sem cor
   saturada. A única ênfase é a tecla "=", num azul-aço contido.
   ============================================================ */

:root {
    --fundo:        #101319;   /* página                       */
    --superficie:   #161A22;   /* corpo da calculadora         */
    --tecla:        #1E2430;   /* funções e operadores         */
    --tecla-num:    #262D3B;   /* dígitos (um passo mais claro)*/
    --tecla-ativa:  #303848;
    --borda:        #2B3240;
    --texto:        #E7EAEF;
    --texto-fraco:  #8B95A5;
    --acento:       #5F7E9E;   /* azul-aço opaco (tecla "=")   */
    --acento-forte: #6F8FAF;

    --raio: 12px;
}

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

body {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: var(--fundo);
    color: var(--texto);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

.calculadora {
    width: min(23rem, 100%);
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: calc(var(--raio) + 6px);
    padding: 1rem;
    box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.8);
}

/* ---------- visor ---------- */
.visor {
    padding: 0.75rem 0.5rem 1rem;
    text-align: right;
    overflow: hidden;
}

.visor-historico {
    min-height: 1.4em;
    font-size: 0.9rem;
    color: var(--texto-fraco);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;              /* corta pela esquerda quando não cabe */
}

.visor-valor {
    font-size: 2.6rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* valores longos encolhem em degraus (classe posta pelo app.js) */
.visor-valor.--medio   { font-size: 2rem; }
.visor-valor.--pequeno { font-size: 1.5rem; }
.visor-valor.--erro    { font-size: 1.35rem; color: var(--texto-fraco); }

/* ---------- teclado ---------- */
.teclado {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.tecla {
    font: inherit;
    font-size: 1.15rem;
    color: var(--texto);
    background: var(--tecla);
    border: 1px solid transparent;
    border-radius: var(--raio);
    padding: 0.95rem 0;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease,
                transform 0.06s ease;
}

.tecla--num { background: var(--tecla-num); font-weight: 600; }

.tecla--fn,
.tecla--op { color: #C6CDD8; }

.tecla:hover  { background: var(--tecla-ativa); }
.tecla:active { transform: scale(0.97); }

.tecla:focus-visible {
    outline: none;
    border-color: var(--acento-forte);
}

.tecla--igual {
    background: var(--acento);
    color: #0F141B;
    font-weight: 700;
}

.tecla--igual:hover { background: var(--acento-forte); }

/* tecla "presa" (feedback quando o atalho de teclado é usado) */
.tecla.--apertada { background: var(--tecla-ativa); transform: scale(0.97); }
.tecla--igual.--apertada { background: var(--acento-forte); }

/* ---------- rodapé ---------- */
.rodape {
    margin-top: 0.9rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--texto-fraco);
}

.rodape a {
    color: var(--texto-fraco);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rodape a:hover { color: var(--texto); }

@media (prefers-reduced-motion: reduce) {
    .tecla { transition: none; }
    .tecla:active,
    .tecla.--apertada { transform: none; }
}
