/* ============================================================
   ALGEMEEN
   ============================================================ */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    background: #f3f4f6;
    color: #222;
}


/* ============================================================
   HOOFDCONTAINER
   ============================================================ */

.app {
    width: min(1200px, calc(100% - 30px));

    margin: 15px auto;
}


/* ============================================================
   HEADER
   ============================================================ */

.app-header {
    margin-bottom: 14px;
}

.app-header h1 {
    margin: 0 0 4px 0;

    font-size: 28px;
    font-weight: 600;
}

.app-header p {
    margin: 0;

    color: #666;
    font-size: 14px;
}

.math {
    font-family: "Times New Roman", serif;
    font-style: italic;
}


/* ============================================================
   INSTELLINGEN
   ============================================================ */

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;

    gap: 12px;

    padding: 12px;

    background: white;

    border: 1px solid #ddd;
    border-radius: 7px;
}

.control-group {
    display: flex;
    flex-direction: column;

    gap: 4px;
}

.control-group label {
    font-size: 12px;
    font-weight: bold;

    color: #555;
}

.control-group input {
    height: 34px;

    padding: 5px 8px;

    border: 1px solid #bbb;
    border-radius: 4px;

    background: white;

    font-size: 14px;
}

.control-group input:focus {
    outline: 2px solid #999;
    outline-offset: 1px;
}


/* ============================================================
   BESTAND
   ============================================================ */

#fileInput {
    max-width: 230px;
}


/* ============================================================
   FUNCTIE
   ============================================================ */

.function-group {
    flex: 1 1 250px;
}

#functionInput {
    width: 100%;

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size: 16px;
}


/* ============================================================
   NUMERIEKE INVOER
   ============================================================ */

#canvasWidth,
#canvasHeight {
    width: 100px;
}

#viewScale {
    width: 90px;
}


/* ============================================================
   KNOPPEN
   ============================================================ */

.buttons {
    display: flex;
    flex-wrap: wrap;

    gap: 8px;

    margin: 9px 0;
}

button {
    padding: 7px 13px;

    border: 1px solid #aaa;
    border-radius: 4px;

    background: white;
    color: #222;

    font-size: 13px;

    cursor: pointer;

    transition:
        background 0.15s,
        border-color 0.15s;
}

button:hover {
    background: #e8e8e8;
    border-color: #777;
}

button:active {
    transform: translateY(1px);
}

button.primary {
    background: #333;
    color: white;

    border-color: #333;
}

button.primary:hover {
    background: #111;
}


/* ============================================================
   VOORBEELDFUNCTIES
   ============================================================ */

.examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;

    gap: 5px;

    margin: 8px 0;

    font-size: 12px;
}

.examples strong {
    margin-right: 3px;
}

.examples code {
    padding: 4px 7px;

    background: #e2e2e2;

    border-radius: 4px;

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size: 12px;

    cursor: pointer;

    user-select: none;
}

.examples code:hover {
    background: #ccc;
}


/* ============================================================
   STATUS
   ============================================================ */

.status-panel {
    display: flex;
    flex-wrap: wrap;

    gap: 6px 25px;

    margin-bottom: 9px;

    padding: 8px 11px;

    background: white;

    border: 1px solid #ddd;
    border-radius: 5px;

    color: #555;

    font-size: 12px;
}

.status-panel strong {
    color: #222;
}


/* ============================================================
   CANVAS-CONTAINER
   ============================================================ */

.canvas-container {
    /*
       De container gebruikt de beschikbare schermruimte,
       maar wordt nooit breder dan de applicatie.
    */

    width: 100%;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 8px;

    background: #222;

    border-radius: 6px;

    overflow: hidden;
}


/* ============================================================
   CANVAS
   ============================================================ */

canvas {
    display: block;

    /*
       BELANGRIJK:

       De echte canvasresolutie kan bijvoorbeeld 1000 × 700
       blijven.

       CSS schaalt alleen de WEERGAVE.

       Daardoor blijft de berekening en gedownloade PNG
       gewoon op volledige resolutie.
    */

    max-width: 100%;

    /*
       Maximaal 60% van de hoogte van het browservenster.
       Daardoor blijft er boven het canvas ruimte over voor
       alle bediening.
    */

    max-height: 60vh;

    /*
       Beide op auto betekent dat de verhouding van het
       canvas behouden blijft.
    */

    width: auto;
    height: auto;

    background: black;

    border: 1px solid #555;
}


/* ============================================================
   UITLEG ONDER CANVAS
   ============================================================ */

.app-footer {
    margin-top: 8px;

    color: #666;

    font-size: 11px;
    line-height: 1.35;
}

.app-footer p {
    margin: 3px 0;
}


/* ============================================================
   MIDDELGROTE SCHERMEN
   ============================================================ */

@media (max-width: 1000px) {

    .app {
        width: calc(100% - 20px);
        margin: 10px auto;
    }

    canvas {
        max-height: 55vh;
    }
}


/* ============================================================
   KLEINE SCHERMEN
   ============================================================ */

@media (max-width: 700px) {

    .app-header h1 {
        font-size: 22px;
    }

    .controls {
        gap: 8px;
        padding: 9px;
    }

    .function-group {
        flex-basis: 100%;
    }

    #fileInput {
        max-width: 100%;
    }

    .status-panel {
        flex-direction: column;
        gap: 4px;
    }

    canvas {
        max-height: 50vh;
    }
}


/* ============================================================
   ZEER LAGE SCHERMEN
   bijvoorbeeld laptop met weinig verticale ruimte
   ============================================================ */

@media (max-height: 750px) {

    .app {
        margin-top: 8px;
        margin-bottom: 8px;
    }

    .app-header {
        margin-bottom: 8px;
    }

    .app-header h1 {
        font-size: 24px;
    }

    .controls {
        padding: 8px;
    }

    canvas {
        max-height: 52vh;
    }

    .app-footer {
        font-size: 10px;
    }
}