/* ============================================================
   CalcSE Web — Calculator Styles
   ============================================================ */

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

body {
    background: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

#calculator {
    width: 380px;
    background: #2d3338;
    border-radius: 14px;
    padding: 10px 14px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* ---------- Status Bar ---------- */

#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 700;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}
#mode-indicators { color: #ff8c26; }
#mode-indicators .alpha-ind { color: #9454db; }
#mode-indicators .screen-ind { color: #d1e0d1; margin-left: 6px; }
#angle-mode {
    color: white;
    font-size: 11px;
    background: rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 3px;
    transition: color 0.2s, background 0.2s;
}
#angle-mode.deg { color: #ff8c26; background: rgba(255,140,38,0.15); }

/* ---------- Display ---------- */

#display-container {
    position: relative;
    height: 170px;
    margin: 0 2px 6px;
    border-radius: 6px;
    overflow: hidden;
    border: 1.5px solid rgba(0,0,0,0.5);
    background: #0f1419;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}
.screen.active { display: block; }
canvas.screen.active { display: block; }

/* Home display */
#home-screen {
    padding: 8px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    color: #d1e0d1;
}
.hist-input { text-align: right; margin-bottom: 1px; }
.hist-output { text-align: right; font-weight: 500; margin-bottom: 4px; }
.hist-output.error { color: #f26657; }
.input-line { display: flex; align-items: center; }
.cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: #8cd98c;
    animation: blink 1.06s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Y= Editor */
#y-editor-screen {
    padding: 6px 8px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    color: #d1e0d1;
}
.eq-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
    cursor: pointer;
}
.eq-toggle {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid;
    flex-shrink: 0;
    cursor: pointer;
}
.eq-toggle.on { background: currentColor; }
.eq-label { font-weight: 700; width: 28px; flex-shrink: 0; }
.eq-text {
    flex: 1;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(255,255,255,0.03);
    min-height: 20px;
    display: flex;
    align-items: center;
}
.eq-row.selected .eq-text { background: rgba(255,255,255,0.08); }
.eq-hint {
    font-size: 9px;
    color: #667766;
    padding-top: 4px;
}

/* Window Settings */
#window-screen {
    padding: 8px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    color: #d1e0d1;
}
.win-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.win-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}
.win-label { width: 50px; font-weight: 500; }
.win-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: none;
    border-radius: 3px;
    color: #d1e0d1;
    font-family: inherit;
    font-size: 12px;
    padding: 2px 4px;
    outline: none;
}
.win-input:focus { background: rgba(255,255,255,0.1); }
.win-divider { border-top: 1px solid rgba(255,255,255,0.1); margin: 6px 0; }

/* Table View */
#table-screen {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 11px;
    color: #d1e0d1;
}
.tbl-header {
    display: flex;
    background: rgba(255,255,255,0.06);
    font-weight: 700;
    border-bottom: 1px solid rgba(128,128,128,0.3);
}
.tbl-row { display: flex; border-bottom: 1px solid rgba(128,128,128,0.08); }
.tbl-cell {
    flex: 1;
    text-align: right;
    padding: 2px 4px;
    min-height: 17px;
    border-left: 1px solid rgba(128,128,128,0.15);
    overflow: hidden;
    white-space: nowrap;
}
.tbl-cell:first-child { border-left: none; }
.tbl-cell.x-col { flex: 0 0 65px; }

/* Menu Overlay */
#menu-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    background: #1a1e24;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    border: 0.5px solid rgba(128,128,128,0.3);
    z-index: 10;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}
#menu-overlay.hidden { display: none; }
.menu-title { font-size: 13px; font-weight: 700; color: #d1e0d1; margin-bottom: 6px; }
.menu-item {
    display: flex;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    color: #d1e0d1;
    background: rgba(255,255,255,0.03);
    margin-bottom: 2px;
}
.menu-item:hover { background: rgba(255,255,255,0.1); }
.menu-num { color: #ff8c26; font-weight: 700; width: 14px; text-align: right; }
.menu-sep { color: #667766; }

/* ---------- Function Keys ---------- */

#function-keys {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
    padding: 0 2px;
}

/* ---------- Button Area ---------- */

#modifier-dpad {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}
#modifier-rows { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.mod-row { display: flex; gap: 4px; }
.mod-row > .btn-wrap { flex: 1; }

#dpad {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.dpad-row { display: flex; gap: 2px; }
.dpad-btn {
    width: 30px;
    height: 26px;
    border: none;
    border-radius: 5px;
    background: #3d4448;
    color: white;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.dpad-btn:active { transform: scale(0.94); opacity: 0.85; }

#main-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.grid-row { display: flex; gap: 4px; }

/* ---------- Calculator Buttons ---------- */

.btn-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
}
.btn-second {
    font-size: 8px;
    font-weight: 600;
    color: #ff8c26;
    text-align: center;
    height: 10px;
    line-height: 10px;
    overflow: hidden;
    white-space: nowrap;
}

.calc-btn {
    position: relative;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s, opacity 0.08s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.calc-btn:active { transform: scale(0.94); opacity: 0.85; }

/* Button height variants */
.calc-btn.h-func { height: 28px; font-size: 11px; }
.calc-btn.h-std  { height: 36px; font-size: 12px; }
.calc-btn.h-num  { height: 36px; font-size: 16px; }

/* Button color styles */
.btn-number    { background: #d1d1d1; color: #1a1a1a; }
.btn-operation { background: #1a8599; color: white; }
.btn-function  { background: #4d5458; color: white; }
.btn-second    { /* label style, not button */ }
.btn-s-second  { background: #eb8426; color: white; }
.btn-s-alpha   { background: #6b38a8; color: white; }
.btn-modifier  { background: #42484c; color: white; }
.btn-enter     { background: #147a7a; color: white; font-size: 14px !important; }
.btn-funcKey   { background: #384044; color: white; }
.btn-on        { background: #42484c; color: white; }

/* Alpha label in corner */
.alpha-lbl {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 7px;
    font-weight: 700;
    color: #9454db;
}

/* Highlight state when 2nd/alpha active */
.calc-btn.second-highlight { background: rgba(235,132,38,0.25) !important; }
.calc-btn.alpha-highlight  { background: rgba(148,84,219,0.2) !important; }
