@font-face {
    font-family: "Andika";
    src: url("../../fonts/Andika-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

#board {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}



#toolbar {
    position: sticky;
    top: 0;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2%;

    width: 100%;
    box-sizing: border-box;

    padding-bottom: 2vh;
    background: #ffff88;
}

#toolbar .image-button {
    width: var(--navigation-button-width);
}

#toolbar .zoom-button {
    width: var(--navigation-zoom-button-width);
}

#toolbar .image-button img,
#toolbar .zoom-button img {
    display: block;
    width: 100%;
    height: auto;
}





#letters button {
    width: 22%;
    margin-bottom: 0.8vh;
}

#letters img,
#toolbar img {
    width: 100%;
    height: auto;
    display: block;
}


.image-button:active {
    transform: scale(1.1);
    filter: brightness(1.5);
}

.image {
    width: 23vw;
    margin-left: 2%;
    margin-right: 2%;
    margin-bottom: 2%;
    padding: 0;
    background-color: #dcdcdc;
    border: 3px solid #999;
    color: #000;
    text-decoration: none;
}

.image:hover {
    padding: 1%;
    background-color: #dcdcdc;
    color: #000;
    text-decoration: none;
}

img {
    width: 100%;
    border: 0;
    margin: 0;
    padding: 0;
    background-color: transparent;
}

button {
    width: 23%;
    border: 0;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    background-color: transparent;
    transition: transform 0.3s ease,
                filter 0.3s ease;
}

button:hover {
    border: 3px solid #0000ff;
    text-decoration: none;
}

button:active {
    border: 3px solid #0000ff;
    text-decoration: none;
    transform: scale(1.1);
    filter: brightness(1.5);

}



#debugInfo {
    position: fixed;
    left: 6px;
    bottom: 6px;
    z-index: 99999;

    padding: 6px 8px;

    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #333;
    border-radius: 4px;

    color: #000;
    font-family: monospace;
    font-size: 11px;
    line-height: 1.35;

    pointer-events: none;
}


/* Android system-bar handling — shared by every page */

:root {
    --system-bar-color: #202020;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    box-sizing: border-box;
    font-family: "Andika", sans-serif;

    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

:root {
    --navigation-button-width: 28%;
    --navigation-zoom-button-width: 34%;

    /* Relative to the toolbar, so it scales with the navigation buttons. */
    --info-button-width: 5.4%;
    --info-button-gap: 4%;

    --left-decoration-width: 10vw;
    --left-decoration-height: 30vh;

    --right-decoration-width: 15vw;
    --right-decoration-height: 84vh;
}

body::before,
body::after {
    content: "";
    position: fixed;
    bottom: 0;

    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;

    z-index: 10;
}

body::before {
    left: 0;

    width: var(--left-decoration-width);
    height: var(--left-decoration-height);

    background-image:
        url("../images/classroom/decoration-left.webp");

    background-position: left bottom;
}

body::after {
    right: 0;

    width: var(--right-decoration-width);
    height: var(--right-decoration-height);

    background-image:
        url("../images/classroom/decoration-right-2.webp");

    background-position: right top;
}

/* Independent information button.
   It is absolutely positioned so the three learning-navigation buttons
   keep their existing widths and remain centred exactly as before. */
#toolbar {
    position: sticky;
}

#toolbar .info-button {
    position: absolute;
    top: 20;
    right: calc(96% + var(--info-button-gap));
    width: var(--info-button-width);
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

#toolbar .info-button img {
    display: block;
    width: 100%;
    height: auto;
}

#toolbar .info-button:hover,
#toolbar .info-button:focus-visible {
    border: 3px solid #0000ff;
    outline: none;
}

#toolbar .info-button:active {
    transform: scale(1.08);
    filter: brightness(1.12);
}


.page-error { margin: 1rem; padding: 0.75rem; color: #7a0000; background: #fff0f0; border: 1px solid #cc7777; }


/* -------------------------------------------------------------------------
   Global course canvas experiment
   10% left outer UI | 80% lesson board | 10% right outer UI
   All outer geometry is derived from --canvas-unit (1% of canvas width).
   Pages without .canvas-layout keep the established legacy behaviour above.
   ------------------------------------------------------------------------- */
body.canvas-layout {
    overflow: auto;
    min-width: 100%;
    min-height: 100vh;
}

body.canvas-layout::before,
body.canvas-layout::after {
    display: none;
}

.app-canvas-frame {
    position: relative;
    box-sizing: border-box;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.app-canvas {
    /*
     * Plain browser fit for the 900 x 1600 classroom sheet.
     * 56.25vh is the width of a 9:16 rectangle that is exactly one
     * viewport high.  min() therefore chooses whichever limit is tighter:
     * viewport width or viewport height.  No JS scaler is involved.
     */
    --canvas-width: min(100vw, 56.25vh);
    --canvas-unit: calc(var(--canvas-width) / 100);
    position: relative;
    box-sizing: border-box;
    width: var(--canvas-width);
    aspect-ratio: 9 / 16;
}

@supports (height: 100dvh) {
    .app-canvas {
        --canvas-width: min(100vw, 56.25dvh);
    }
}

/* Small touch displays in landscape deliberately enlarge the already-proven
   9:16 classroom sheet.  Internal geometry is untouched; the finished canvas
   simply becomes taller than the viewport and normal browser scrolling reveals
   the rest.  Portrait and desktop/mouse layouts keep the converged factory fit. */
@media (orientation: landscape) and (pointer: coarse) {
    .app-canvas {
        --canvas-width: min(100vw, 75vh);
    }
}

@supports (height: 100dvh) {
    @media (orientation: landscape) and (pointer: coarse) {
        .app-canvas {
            --canvas-width: min(100vw, 75dvh);
        }
    }
}

.canvas-layout #board {
    box-sizing: border-box;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.canvas-decoration {
    position: absolute;
    z-index: 10;
    display: block;
    height: auto;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.canvas-decoration-left {
    left: calc(var(--canvas-unit) * 1);
    bottom: 0;
    width: calc(var(--canvas-unit) * 8);
}

.canvas-decoration-right {
    right: calc(var(--canvas-unit) * 0.5);
    top: calc(var(--canvas-unit) * 3);
    width: calc(var(--canvas-unit) * 9.5);
}

/* -------------------------------------------------------------------------
   Shared display controls.
   They are real children of #app-canvas, so the final whole-canvas zoom
   scales and moves them together with the lesson, LEDs and decorations.
   "height" changes only canvas length.  "zoom" magnifies the finished canvas.
   ------------------------------------------------------------------------- */
.kru-display-controls {
    position: absolute;
    z-index: 12030;
    right: calc(var(--canvas-unit) * 1.0);
    top: calc(var(--canvas-unit) * 36);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--canvas-unit) * 3.2);
    pointer-events: auto;
    font-family: sans-serif;
}

.kru-display-control {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: calc(var(--canvas-unit) * 1.0);
    width: calc(var(--canvas-unit) * 6.2);
}

.kru-display-control-label {
    margin-bottom: calc(var(--canvas-unit) * .25);
    color: rgba(25,25,25,.72);
    font-size: calc(var(--canvas-unit) * 1.55);
    font-weight: 800;
    line-height: 1;
    text-transform: lowercase;
    user-select: none;
}

.kru-display-control button {
    appearance: none;
    -webkit-appearance: none;
    width: calc(var(--canvas-unit) * 4.6);
    min-width: calc(var(--canvas-unit) * 4.6);
    max-width: calc(var(--canvas-unit) * 4.6);
    height: calc(var(--canvas-unit) * 5.2);
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(25,25,25,.94);
    font-family: sans-serif;
    font-size: calc(var(--canvas-unit) * 4.1);
    font-weight: 900;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.kru-display-control button:active {
    transform: scale(.88);
}

.kru-display-control button:disabled {
    opacity: .24;
    cursor: default;
}

.kru-display-control button:focus-visible {
    outline: calc(var(--canvas-unit) * .18) solid rgba(0,0,0,.72);
    outline-offset: calc(var(--canvas-unit) * .22);
}

