/* Global Reset and Body Layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* Container and Typography */
.container {
    width: 100%;
    max-width: 450px;
}

h1 {
    text-align: center;
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: #1a1a1a;
}

/* Card Layout */
.calculator-card {
    background: #ffffff;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Form Group Setup */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

/* Number Input and Validation */
.valueInput {
    padding: 10px 12px;
    font-size: 16px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}
input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background-color: #e9ecef;
    border-color: #dee2e6;
    color: #6c757d;
}

/* Light mode fix — same idea, the styled border replaces the outline */
.valueInput:focus {
    outline: none;
}

valueInput:user-invalid {
    border-color: #dc3545;
    background-color: #fdf2f2;
}

valueInput:user-valid {
    border-color: #198754;
    background-color: #f4fbf7;
}

/* Action Button */
#solveButton {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background-color: #0d6efd;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 1.5rem;
}

#solveButton:hover {
    background-color: #0b5ed7;
}

#solveButton:active {
    background-color: #0a58ca;
}

/* Output Display Box */
.result-box {
    background-color: #f1f3f5;
    padding: 1rem;
    border-radius: 6px;
    font-size: 1rem;
    border-left: 4px solid #6c757d;

    /* Stack label on top, name below, button at the bottom */
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.result-box .label {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;             /* demoted to a subtle header */
}

#latinName {
    color: #212529;
    font-style: italic;
    font-size: 1rem;
    line-height: 1.5;
    word-break: break-word;     /* prevents overflow on very long compound names */
}

#stt {
    align-self: flex-start;     /* hugs the left edge, doesn't stretch full width */
    margin-top: 0.4rem;
    padding: 5px 14px;
    font-size: 0.85rem;
    border: 1.5px solid #ced4da;
    border-radius: 5px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

#stt:hover:not(:disabled) {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

#stt:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Page header row (title + gear button) ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: center;   /* keeps title centred */
    position: relative;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin-bottom: 0;          /* header row handles spacing now */
}

#settingsBtn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s, background-color 0.2s;
}

#settingsBtn:hover {
    color: #212529;
    background-color: #e9ecef;
}

/* ── Overlay backdrop ── */
.modal-overlay {
    position: fixed;
    inset: 0;                  /* shorthand for top/right/bottom/left: 0 */
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    /* Hidden by default — opacity + pointer-events gives a fade effect */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* ── Modal card ── */
.modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: min(360px, 90vw);   /* responsive, never wider than viewport */
    padding: 1.25rem 1.5rem;

    /* Slight upward pop on open */
    transform: translateY(12px) scale(0.97);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
    transform: translateY(0) scale(1);
}

/* ── Modal header ── */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1rem;
    color: #6c757d;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
}

.close-btn:hover {
    background-color: #f1f3f5;
    color: #212529;
}

/* ── Checkbox rows ── */
.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
    color: #495057;
    cursor: pointer;
    user-select: none;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0d6efd;     /* tints the checkbox to match your blue */
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-row:hover span {
    color: #212529;
}

/* ── Dark Mode ── */
/* All dark-mode overrides are scoped under [data-theme="dark"] on <html>.
   This means every rule here only activates when JS sets that attribute. */

/* ── Dark Mode (Monokai-inspired) ──
   Monokai's palette is built on warm dark grays, not cold blue-blacks.
   The classic background is #272822 — a brownish charcoal that reads
   as "dark" without feeling like a void. Surfaces step up in warmth
   from there, and text is a creamy off-white (#f8f8f2) rather than
   pure white, which would feel harsh against these backgrounds. */

[data-theme="dark"] body {
    background-color: #1e1f1a;   /* one step darker than Monokai bg, for the page itself */
    color: #f8f8f2;              /* Monokai's iconic creamy text color */
}

[data-theme="dark"] h1 {
    color: #f8f8f2;
}

/* The card sits at the true Monokai background color — warm charcoal */
[data-theme="dark"] .calculator-card {
    background: #272822;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] label {
    color: #a59f85;              /* Monokai's comment color — muted but warm */
}

/* Inputs step slightly lighter than the card surface */
[data-theme="dark"] input[type="text"] {
    background-color: #3e3d32;   /* Monokai's selection/highlight color */
    border-color: #49483e;       /* just a touch lighter than the input bg */
    color: #f8f8f2;
}

[data-theme="dark"] input[type="text"]::placeholder {
    color: #75715e;              /* Monokai comment gray — readable but quiet */
}

[data-theme="dark"] input[type="text"]:focus {
    border-color: #a6e22e;
    border-radius: 3px;
    background-color: #3e3d32;
    outline: none;   /* kills the browser's default blue ring so only your green border shows */
}

/* Result box matches the input surfaces so it feels cohesive */
[data-theme="dark"] .result-box {
    background-color: #3e3d32;
    border-left-color: #75715e;
}

[data-theme="dark"] .result-box .label {
    color: #75715e;
}

[data-theme="dark"] #latinName {
    color: #f8f8f2;
}

[data-theme="dark"] #stt {
    background: #272822;
    border-color: #49483e;
    color: #a59f85;
}

[data-theme="dark"] #stt:hover:not(:disabled) {
    background-color: #3e3d32;
    border-color: #75715e;
}

[data-theme="dark"] #settingsBtn {
    color: #a59f85;
}

[data-theme="dark"] #settingsBtn:hover {
    color: #f8f8f2;
    background-color: #3e3d32;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* Modal sits at the same Monokai bg level as the card */
[data-theme="dark"] .modal {
    background: #272822;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .modal-header h2 {
    color: #f8f8f2;
}

[data-theme="dark"] .close-btn {
    color: #a59f85;
}

[data-theme="dark"] .close-btn:hover {
    background-color: #3e3d32;
    color: #f8f8f2;
}

[data-theme="dark"] .checkbox-row {
    color: #a59f85;
}

[data-theme="dark"] .checkbox-row:hover span {
    color: #f8f8f2;
}
[data-theme="dark"] input:disabled {
    background-color: #272822;
    border-color: #3e3d32;
    color: #49483e;
    opacity: 0.6;
}
