/* ==========================================================================
   General styles
   ========================================================================== */

/* Resets & General Styles */
body {
    font-family: Roboto, "Noto Sans TC", "Droid Sans", "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Noto Sans CJK TC", sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ==========================================================================
   Layout & Container Styles
   ========================================================================== */

/* Main container */
.container {
    width: 100%;
    max-width: 700px;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Typography
   ========================================================================== */

/* Headings */
h1 {
    text-align: center;
    color: #2c3e50;
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 15px;
}

/* Paragraphs */
p {
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.95em;
    color: #5a5a5a;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

/* Textarea */
textarea#displayTextbox {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    font-size: 1em;
    resize: vertical;
    background-color: #fff;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    font-family: Roboto, "Noto Sans TC", "Droid Sans", "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Noto Sans CJK TC", sans-serif;
    line-height: 1.7;
    font-weight: 400;
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */

/* Button Grid */
.button-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
}

/* General Button Styles */
button {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    background-color: #5dade2;
    color: white;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease, transform 0.1s ease;
    text-align: center;
    flex-grow: 1;
    min-width: 80px;
}

button:hover {
    background-color: #3498db;
}

button:active {
    transform: scale(0.97);
}

/* Specific Button Colors */
#notButton,
#andButton,
#orButton {
    background-color: #f39c12;
}

#notButton:hover,
#andButton:hover,
#orButton:hover {
    background-color: #e67e22;
}

#clearButton {
    background-color: #e74c3c;
}

#clearButton:hover {
    background-color: #c0392b;
}

/* Copy Button */
#copyButton {
    background-color: #2ecc71;
    width: 100%;
    margin-top: 10px;
}

#copyButton:hover {
    background-color: #27ae60;
}

/* Functional Buttons Grouping */
.functional-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
}

.functional-buttons button {
    flex-basis: calc(25% - 10px);
    min-width: 70px;
}

/* ==========================================================================
   Mobile-Specific Styles (Responsive Design)
   ========================================================================== */

/* Media query for screens smaller than 600px */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    p {
        font-size: 0.9em;
    }

    textarea#displayTextbox {
        padding: 10px;
        font-size: 0.95em;
    }

    .button-grid button,
    .functional-buttons button {
        flex-basis: calc(25% - 6px);
        min-width: 55px;
        padding: 10px 5px;
        font-size: 1em;
    }

    #copyButton {
        padding: 15px;
        font-size: 1.2em;
    }

    /* Media query for screens smaller than 400px */
    @media (max-width: 400px) {

        .button-grid button,
        .functional-buttons button {
            flex-basis: calc(33.333% - 6px);
            min-width: 50px;
            padding: 8px 4px;
            font-size: 0.95em;
        }
    }
}

/* ==========================================================================
   Toast Notification Styles
   ========================================================================== */

/* Toast container */
.toast {
    position: fixed;
    bottom: calc(25vh - 10px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 5px;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s;
    font-size: 0.9em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Show class to trigger the toast */
.toast.show {
    opacity: 1;
    bottom: 25vh;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    margin-top: 16px;
    font-size: 0.85em;
    color: #888;
    text-align: center;
}

footer a {
    color: #5dade2;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   親密度 Modal
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-panel {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.modal-title {
    font-size: 1.2em;
    color: #2c3e50;
    margin: 0;
}

.modal-preview {
    width: 100%;
    box-sizing: border-box;
    background-color: #f4f7f6;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 1.4em;
    text-align: center;
    color: #333;
    min-height: 50px;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.modal-preview.is-empty {
    color: #aaa;
    font-weight: normal;
    font-size: 1em;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.modal-preview.shake {
    animation: shake 0.3s ease;
}

.modal-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
}

.keypad-btn {
    padding: 14px 0;
    font-size: 1.1em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    flex-grow: 0;
    min-width: unset;
}

.keypad-btn:active {
    transform: scale(0.95);
}

.keypad-spacer {
    background: transparent;
    pointer-events: none;
}

.num-btn {
    background-color: #ecf0f1;
    color: #2c3e50;
}

.num-btn:hover {
    background-color: #bdc3c7;
}

.dash-btn {
    background-color: #ecf0f1;
    color: #2c3e50;
}

.dash-btn:hover {
    background-color: #bdc3c7;
}

.backspace-btn {
    background-color: #f39c12;
    color: white;
}

.backspace-btn:hover {
    background-color: #e67e22;
}

.cancel-btn {
    grid-column: span 2;
    background-color: #e74c3c;
    color: white;
}

.cancel-btn:hover {
    background-color: #c0392b;
}

.confirm-btn {
    grid-column: span 2;
    background-color: #2ecc71;
    color: white;
}

.confirm-btn:hover {
    background-color: #27ae60;
}

@media (max-width: 600px) {
    .modal-panel {
        width: 260px;
        padding: 16px;
    }

    .keypad-btn {
        padding: 12px 0;
        font-size: 1em;
    }
}