/* GLOBAL */
:root {
    --font:"Oswald", sans-serif;
    --bg:#1E212B;
    --text:#e7e7e7;
    --touch:#007EA7;
    --hover:#01698c;
    --shadow:0 12px 40px rgba(0,0,0,.28);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
    margin: 0%;
}

#calc {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height:100vh;
    min-height:100dvh;
    font-family: var(--font);
    color: var(--text);
    margin: 0%;
    padding: clamp(16px, 4vw, 40px);
    background:
        radial-gradient(circle at 30% 30%, #0ea5e933, transparent 40%),
        radial-gradient(circle at 70% 70%, #ef444433, transparent 40%),
        linear-gradient(135deg, #020617, #1e293b);
    background-size: 200% 200%;
    animation: bgDrift 18s ease-in-out infinite alternate;
}

h1{
    font-size: clamp(1.8rem, 6vw, 3rem);
    text-align: center;
    color: #e2e8f0;
    letter-spacing: 2px;
    text-shadow: 0 5px 20px rgba(255,255,255,0.15);
    margin: 0 0 clamp(16px, 3vh, 28px);
    animation: fadeDown 0.6s ease both;
}

/* CALCULATOR BOX */

.calculator-box {
    border: 5px solid var(--text);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(14px, 3vh, 24px);
    padding: clamp(18px, 4vw, 30px) clamp(14px, 3vw, 20px);
    background-color: var(--bg);
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    width: 100%;
    max-width: 460px;
    margin: auto;
    animation: popIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* CALCULATOR INPUT */

.history-line {
    height:clamp(48px, 9vh, 70px);
    background-color: var(--text);
    color:#334155;
    width:100%;
    margin-bottom: 0%;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    padding:0px 20px;
    text-align: right;
    font-family: var(--font);
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    border:none;
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-line {
    width:100%;
    border:none;
    padding:0px 20px;
    margin-top: 0%;
    height:clamp(56px, 11vh, 70px);
    background-color: #f8fafc;
    color:#0F172A;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    text-align: right;
    font-family: var(--font);
    font-weight: 600;
    font-size: clamp(1.6rem, 7vw, 2.2rem);
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-line.flash {
    animation: flashLine 0.35s ease;
}

/* CALCULATOR BUTTONS */
.calc-buttons { /*button lines layout*/
    width:100%;
    display: flex;
    flex-direction: column;
    gap:clamp(8px, 2vw, 12px);
}

.line {  /*button lines*/
    display: flex;
    justify-content: space-between;
    gap: clamp(8px, 2vw, 12px);
}

.calc-button { /*global button styling*/
    flex: 1 1 0;
    aspect-ratio: 1 / 1;
    min-width: 0;
    border-radius: 999px;
    padding:0%;
    font-size: clamp(1.3rem, 5vw, 2rem);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font);
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    user-select: none;
    border: none;
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.calc-button:hover {
    transform: translateY(-2px);
}

.calc-button:active,
.calc-button.pressed {
    transform: scale(0.92);
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.3);
}

.op { /*operator buttons*/
    background: #334155;
    color: white;
}

.op:hover {
    background: #475569;
}

.op:active,
.op.pressed {
    background: #1E293B;
}

.num { /*number buttons*/
    background: #F1F5F9;
    color: #0F172A;
}

.num:hover {
    background: #E2E8F0;
}

.num:active,
.num.pressed {
    background: #CBD5F5;
}

.clear { /*clear button*/
    flex: 1 1 100%;
    aspect-ratio: auto;
    height: clamp(48px, 9vh, 64px);
    background: #EF4444;
    color: white;
}

.clear:hover {
    background: #DC2626;
}

.clear:active,
.clear.pressed {
    background: #B91C1C;
}

.result { /*result button*/
    flex: 2 1 0;
    aspect-ratio: auto;
    height: clamp(56px, 11vw, 80px);
    background: #0EA5E9;
    color: white;
}

.result:hover {
    background: #0284C7;
}

.result:active,
.result.pressed {
    background: #0369A1;
}

/* The "0" key sits beside "=" on the last row; let it grow too. */
.line-5 .num {
    aspect-ratio: auto;
    height: clamp(56px, 11vw, 80px);
}

/* ANIMATIONS */
@keyframes popIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes flashLine {
    0%   { background-color: #f8fafc; }
    40%  { background-color: #bae6fd; }
    100% { background-color: #f8fafc; }
}

@keyframes bgDrift {
    from { background-position: 0% 0%; }
    to   { background-position: 100% 100%; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
