/* Turtle Code only — the program beside the drawing, the editor, the command
   chips and the output. Everything else on this page comes from
   assets/css/game-shell.css. */

/* ---------- the program beside the drawing ----------
   On a wide screen the program sits on the left and the drawing on the
   right, sized from the screen height so nothing needs a scroll. The
   panels move below. */
@media (min-width: 981px) {
    .game {
        grid-template-columns: 1fr;
    }
    .play {
        display: flex;
        gap: 16px;
        align-items: stretch;
        justify-content: center;
    }
    .play .stage {
        flex: 0 1 auto;
        margin: 0;
    }
    .play .coder {
        flex: 0 0 420px;
        /* the drawing alone sets the row's height; the program scrolls inside */
        contain: size;
    }
    .play .code {
        flex: 1;
        min-height: 0;
    }
    .side {
        grid-template-columns: 1.3fr 1fr 1fr;
        align-items: start;
    }
}

.coder {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.code-bar label {
    white-space: nowrap;
    font-family: "Bricolage Grotesque";
    font-weight: 700;
    font-size: 17px;
}
.code-bar select {
    font: 600 13px "Inter", sans-serif;
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    cursor: pointer;
}
.code-bar select:hover,
.code-bar select:focus-visible {
    border-color: var(--blue);
    outline: none;
}

/* ---------- the editor: a see-through textarea over highlighted text ---------- */
.code {
    --lh: 22px; /* LH in game.js */
    position: relative;
    display: flex;
    height: 300px;
    border: 2px solid var(--line);
    border-radius: var(--r-md);
    background: var(--paper);
    overflow: hidden;
    font: 500 15px / var(--lh) "DM Mono", monospace;
    transition: border-color 0.15s;
}
.code:focus-within {
    border-color: var(--blue);
    background: var(--surface);
}
.gutter {
    flex: none;
    width: 38px;
    padding-block: 10px;
    overflow: hidden;
    background: var(--tint);
    color: #9aa0bf;
    text-align: right;
    user-select: none;
}
.gutter span {
    display: block;
    height: var(--lh);
    padding-right: 8px;
    font-size: 12px;
}
.gutter span.now {
    color: #8a5d00;
    font-weight: 600;
}
.gutter span.err {
    color: #d8452c;
    font-weight: 600;
}
.code-main {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.code-hl,
.code-main textarea {
    margin: 0;
    padding: 10px 12px;
    font: inherit;
    line-height: var(--lh);
    letter-spacing: 0;
    white-space: pre;
    tab-size: 4;
}
.code-hl {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 100%;
    pointer-events: none;
    color: var(--ink);
}
.code-main textarea {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: transparent;
    caret-color: var(--ink);
    overflow: auto;
}
.code-main textarea::selection {
    background: rgba(47, 107, 255, 0.22);
    color: transparent;
}
.code-mark {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--lh);
    pointer-events: none;
}
.code-mark[hidden] {
    display: none;
}
.code-mark.now {
    background: #fff3cf;
}
.code-mark.err {
    background: #ffe3dc;
}

.t-kw {
    color: #7b3fd0;
    font-weight: 500;
}
.t-fn {
    color: var(--blue-deep);
}
.t-str {
    color: #c25412;
}
.t-num {
    color: #0e8f80;
}
.t-const {
    color: #7b3fd0;
}
.t-com {
    color: #9aa0bf;
    font-style: italic;
}

.code-keys {
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: -2px;
}

/* ---------- command chips ---------- */
.snips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.snips button {
    border: 1.5px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 3px 9px;
    font: 500 12.5px "DM Mono", monospace;
    color: var(--blue-deep);
    white-space: nowrap;
}
.snips button:hover {
    background: var(--tint);
    border-color: var(--blue);
}

/* ---------- run ---------- */
.run-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}
.run-btn {
    border: none;
    border-radius: var(--r-md);
    padding: 10px 30px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 0 var(--blue-deep);
    transition:
        transform 0.1s,
        box-shadow 0.1s,
        background 0.15s;
}
.run-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--blue-deep);
}
.run-btn.stop {
    background: var(--coral);
    box-shadow: 0 4px 0 #d8452c;
}
.run-btn.stop:active {
    box-shadow: 0 1px 0 #d8452c;
}

/* ---------- output: print(), notes and errors ---------- */
.console {
    flex: 0 0 112px;
    min-height: 64px;
    overflow-y: auto;
    background: var(--tint);
    border-radius: var(--r-md);
    padding: 8px 12px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.console[data-empty]::before {
    content: "Output — what print() shows, and help if something goes wrong.";
    color: var(--ink-soft);
    font-size: 13px;
}
.console pre {
    margin: 0;
    font: 500 14px/1.45 "DM Mono", monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.console .note {
    color: var(--ink-soft);
    font-size: 13px;
}
.console .err {
    background: #fff;
    border-left: 4px solid var(--coral);
    border-radius: var(--r-sm);
    padding: 8px 10px;
    line-height: 1.4;
}
.console .err.soft {
    border-left-color: var(--yellow);
}
.console .err b {
    color: #d8452c;
}
.console .err .hint {
    margin-top: 4px;
    color: var(--ink);
    font-weight: 600;
}
.err-line {
    font: 600 12px "DM Mono", monospace;
    background: #ffe3dc;
    color: #b83a22;
    border-radius: 999px;
    padding: 1px 8px;
    margin-right: 2px;
}
.err.soft .err-line {
    background: #fff3cf;
    color: #8a5d00;
}

/* ---------- the drawing ---------- */
.stage {
    background: #fff;
    border: 1.5px solid var(--line);
}
.coords {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    font: 500 12px "DM Mono", monospace;
    color: var(--ink-soft);
    pointer-events: none;
}
.coords[hidden] {
    display: none;
}

/* ---------- panels ---------- */
.rules code,
.cheats code {
    font: 500 12.5px "DM Mono", monospace;
    color: var(--blue-deep);
    background: var(--tint);
    border-radius: 6px;
    padding: 1px 5px;
    white-space: nowrap;
}
.cheats dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    font-size: 13px;
    color: var(--ink-soft);
}
.cheats dt {
    font-weight: 700;
    color: var(--ink);
}
.cheats dd {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
}

/* ---------- small screens: the drawing first, the program under it ---------- */
@media (max-width: 980px) {
    .play {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .play .stage {
        order: -1;
    }
    .console {
        flex-basis: auto;
        max-height: 200px;
    }
}
@media (max-width: 560px) {
    .code {
        height: 260px;
        font-size: 14px;
    }
    .side {
        grid-template-columns: 1fr;
    }
}
