/* ==========================================================================
   Python (app/commands/python.js)
   Editor + output (tabs on narrow windows, side by side when .is-wide) and a
   console. Motion lives in the "Python" section at the end of css/motion.css.
   ========================================================================== */

.py-app { --py-code-bg: color-mix(in srgb, var(--on-surface) 4%, var(--background, #0b0d12)); }
.py-app .py-hero { overflow: hidden; }
.py-app .py-hero-art { position: absolute; right: -24px; top: -20px; opacity: 0.14; pointer-events: none; transform: rotate(-12deg); }
.py-app .py-hero-art svg { width: 170px; height: 170px; stroke: #ffffff; }
.py-app .py-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .py-app .py-examples { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.py-app .py-ex { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 0; padding: 14px; border-radius: 20px; border: 1px solid var(--ok-line); background: var(--ok-card); color: var(--on-surface); font-family: var(--font-main); text-align: left; cursor: pointer; }
.py-app .py-ex strong { font-size: 0.92rem; }
.py-app .py-ex span { font-size: 0.76rem; color: var(--ok-muted); }
.py-app .py-file .ok-row-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 0.74rem; }

/* Editor */
.py-app .py-editor { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.py-app .py-tabs { display: flex; gap: 6px; padding: 8px 14px; flex-shrink: 0; }
.py-app .py-tabs button { position: relative; height: 34px; padding: 0 16px; border: 1px solid var(--ok-line-strong); border-radius: 999px; background: transparent; color: var(--on-surface); font: 600 0.84rem var(--font-main); cursor: pointer; }
.py-app .py-tabs button[aria-selected="true"] { border-color: transparent; background: var(--ok-ink); color: var(--ok-on-ink); }
.py-app .py-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.py-app .py-dot[hidden] { display: none; }
.py-app .py-pane { flex: 1; min-height: 0; display: none; flex-direction: column; }
.py-app .py-editor[data-tab="code"] .py-code-pane, .py-app .py-editor[data-tab="output"] .py-out-pane { display: flex; }
.py-app .py-editor.is-wide { flex-direction: row; flex-wrap: wrap; }
.py-app .py-editor.is-wide .py-tabs { display: none; }
.py-app .py-editor.is-wide .py-pane { display: flex; flex: 1 1 50%; }
.py-app .py-editor.is-wide .py-out-pane { border-left: 1px solid var(--ok-line); }

.py-app .py-code-wrap { position: relative; flex: 1; min-height: 0; display: flex; margin: 0 12px; border-radius: 18px; border: 1px solid var(--ok-line); background: var(--py-code-bg); overflow: hidden; }
.py-app .py-editor.is-wide .py-code-wrap { margin: 12px; }
.py-app .py-gutter { display: none; margin: 0; padding: 14px 8px 14px 12px; min-width: 2.6em; text-align: right; color: var(--ok-muted); opacity: 0.6; overflow: hidden; user-select: none; border-right: 1px solid var(--ok-line); }
.py-app .has-lines .py-gutter { display: block; }
.py-app .py-code { flex: 1; min-width: 0; margin: 0; padding: 14px; border: none; outline: none; resize: none; background: transparent; color: var(--on-surface); white-space: pre; overflow: auto; tab-size: 4; }
.py-app .is-wrap .py-code { white-space: pre-wrap; word-break: break-word; }
.py-app :is(.py-code, .py-gutter, .py-out) { font-family: var(--font-mono); font-size: 14px; line-height: 1.55; }
.py-app [data-font="s"] :is(.py-code, .py-gutter, .py-out, #py-con-in) { font-size: 12.5px; }
.py-app [data-font="l"] :is(.py-code, .py-gutter, .py-out, #py-con-in) { font-size: 16px; }
.py-app .py-keys { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.py-app .py-keys::-webkit-scrollbar { display: none; }
.py-app .py-keys[hidden] { display: none; }
.py-app .py-keys button { flex-shrink: 0; min-width: 40px; height: 38px; padding: 0 10px; border: 1px solid var(--ok-line); border-radius: 11px; background: var(--ok-card); color: var(--on-surface); font: 600 0.92rem var(--font-mono); cursor: pointer; touch-action: manipulation; }
.py-app .py-run { border-color: transparent; background: #16a34a; color: #ffffff; }
.py-app .py-run svg { margin-left: 2px; }
.py-app .py-spin { width: 16px; height: 16px; }

/* Output */
.py-app .py-out-head, .py-app .py-con-bar { display: flex; align-items: center; gap: 8px; padding: 6px 14px; flex-shrink: 0; }
.py-app .py-out-title { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ok-muted); }
.py-app .py-out-status { flex: 1; font-size: 0.76rem; color: var(--ok-muted); text-align: right; font-variant-numeric: tabular-nums; }
.py-app .py-out { flex: 1; min-height: 0; overflow: auto; margin: 0 12px 12px; padding: 12px 14px; border-radius: 18px; border: 1px solid var(--ok-line); background: var(--py-code-bg); }
.py-app .py-line { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; white-space: pre-wrap; word-break: break-word; color: var(--on-surface); }
.py-app .py-err { color: #f87171; }
.py-app .py-sys { color: var(--ok-muted); font-size: 0.85em; }
.py-app .py-in { color: #60a5fa; }
.py-app .py-res { color: #a3e635; }
.py-app .py-figure { display: block; max-width: 100%; margin: 8px 0; border-radius: 12px; background: #ffffff; }
.py-app .py-goto { margin-top: 8px; }

/* Console */
.py-app .py-console { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.py-app .py-con-out { margin-top: 12px; }
.py-app .py-con-form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px 12px; padding: 8px 8px 8px 14px; border-radius: 22px; border: 1px solid var(--ok-line-strong); background: var(--ok-card); flex-shrink: 0; }
.py-app .py-prompt { padding-bottom: 9px; font: 700 0.85rem var(--font-mono); color: #60a5fa; }
.py-app #py-con-in { flex: 1; min-height: 36px; max-height: 140px; padding: 8px 0; border: none; outline: none; resize: none; background: transparent; color: var(--on-surface); font-family: var(--font-mono); font-size: 16px; line-height: 1.4; }

/* Sheets */
.py-app .py-sheet .xa-sheet-card { gap: 12px; max-height: 86%; overflow-y: auto; }
.py-app .py-grab { align-self: center; width: 38px; height: 4px; border-radius: 2px; background: var(--ok-line-strong); flex-shrink: 0; }
.py-app .py-sheet-title { display: flex; flex-direction: column; gap: 2px; }
.py-app .py-sheet-title strong { font-size: 1.15rem; }
.py-app .py-sheet-title span, .py-app .py-sheet-note { font-size: 0.8rem; color: var(--ok-muted); margin: 0; }
.py-app .py-pkgs .ok-btn { flex-shrink: 0; min-width: 88px; }
@media (min-width: 760px) {
    .py-app .py-sheet { align-items: center; padding: 24px; }
    .py-app .py-sheet .xa-sheet-card { max-width: 480px; border-radius: 26px; border-bottom: 1px solid var(--ok-line); }
    .py-app .py-grab { display: none; }
}
@media (hover: hover) and (pointer: fine) {
    .py-app .py-ex:hover { border-color: var(--ok-line-strong); background: color-mix(in srgb, var(--on-surface) 4%, var(--ok-card)); }
}
html.kbd-nav .py-app :is(.py-ex, .py-file):focus-visible { outline: 2px solid var(--hue); outline-offset: 2px; }
