/* THEME TOKENS
   ==================================================
   DARK IS THE DEFAULT. The base :root block is the dark palette; light applies only when
   the user has explicitly chosen it. prefers-color-scheme is deliberately NOT consulted,
   so a first visit is dark regardless of the visitor's OS setting.

   Because "dark" is now simply the absence of a choice, every dark-only rule in this file
   is written as :root:not([data-theme="light"]) - one guard direction throughout, and no
   duplicated declaration blocks.

   To go back to following the OS instead: put the light values on bare :root, wrap the
   dark values in @media (prefers-color-scheme: dark) guarded by
   :root:not([data-theme="light"]), and repeat them under :root[data-theme="dark"].

   --bg-canvas is the same in both palettes on purpose. Node and edge colours come from
   Color.DARK_GREY / Color.LIGHT_GREY in pynode_graphlib.py, so a dark graph
   canvas would destroy their contrast. In dark mode the Output panel is a light rectangle
   inside dark chrome. That is intentional - please don't "fix" it. */

:root {
    /* Tells the browser to render native widgets - inputs, buttons, scrollbars -
       in the matching scheme. Without this, native form controls (such as the field
       the console injects for input()) stay light-mode white on a dark page. */
    color-scheme: dark;

    --bg-page: #0e0e10;
    --bg-body: #141416;
    --bg-app: #1b1b1d;
    --bg-panel: #1e1e1e;
    --bg-inset: #252526;
    --bg-chrome: #2d2d30;
    --bg-button: #3a3a3d;
    --bg-button-live: #4a4a4f;
    --bg-chip: #37373a;
    --bg-canvas: #FFFFFF;

    --border: #3f3f46;
    --rule: #3f3f46;
    --divider-dark: #1a1a1c;
    --divider-light: #4a4a50;

    --text: #e6e6e6;
    --text-invert: #ffffff;
    --text-muted: #8a8a8a;
    --link: #4ec9b0;

    --shadow: rgba(0, 0, 0, 0.6);
    --shadow-soft: rgba(0, 0, 0, 0.5);
    --shadow-strong: rgba(0, 0, 0, 0.85);
    --shadow-mid: rgba(0, 0, 0, 0.7);

    --c-ok: #6dd36d;
    --c-err: #ff6b6b;
    --c-warn: #e0a030;
}

:root[data-theme="light"] {
    color-scheme: light;

    --bg-page: #525252;
    --bg-body: #ECECEC;
    --bg-app: #BBBBBB;
    --bg-panel: #FFFFFF;
    --bg-inset: #F0F0F0;
    --bg-chrome: #525252;
    --bg-button: #ACACAC;
    --bg-button-live: #6E6E6E;
    --bg-chip: #E0E0E0;
    --bg-canvas: #FFFFFF;

    --border: #B1B1B1;
    --rule: #B0B0B0;
    --divider-dark: #2E2E2E;
    --divider-light: #6A6A6A;

    --text: #000000;
    --text-invert: #FFFFFF;
    --text-muted: #CBCBCB;
    --link: teal;

    --shadow: rgba(0, 0, 0, 0.2);
    --shadow-soft: rgba(0, 0, 0, 0.15);
    --shadow-strong: rgba(0, 0, 0, 0.75);
    --shadow-mid: rgba(0, 0, 0, 0.5);

    --c-ok: green;
    --c-err: red;
    --c-warn: #a06000;
}

html {
    font-size: 14px;
}

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 1em 0;
    padding: 0;
}

/* PAGE COLORS
   ================================================== */

html, body {
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease;
    font-family: "Arial";
    -webkit-font-smoothing: antialiased;
    font-smoothing: antialiased;
    font-weight: 400;
    font-style: normal;
    text-align: left;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg-chrome);
}

/* GENERAL
   ================================================== */

body .pynodeContainer {
    background-color: var(--bg-body);
}

body .footerText {
    color: var(--text-muted);
}

body .pageInfoWrapper {
    background-color: var(--bg-chrome);
}

/* MAIN TYPE STYLES AND LINKS
   ================================================== */

@font-face {
    font-family: Oswald;
    src: url('Oswald-Regular.ttf');
}

h1 {
    color: var(--text);
    font: 3.2rem/1.1 'Oswald', 'Arial', sans-serif;
    margin: 0;
}

h2 {
    color: var(--text);
    font: 1.8rem/1.1 'Oswald', 'Arial', sans-serif;
    margin: 0;
}

h3 {
    font: 1.4rem/1.1 'Oswald', 'Arial', sans-serif;
    margin: 0;
}

h4 {
    font: 1.2rem/1.1 'Oswald', 'Arial', sans-serif;
    margin: 0;
}

h5 {
    font: 1.0rem/1.1 'Oswald', 'Arial', sans-serif;
    margin: 0;
}

p {
    font: 1.2rem/1.1 Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
    font-size: 14px;
    color: var(--text);
    margin: 0;
}

a {
    text-decoration: none;
    color: var(--link);
}

a:hover {
    text-decoration: none;
}

a.anchor {
    display: block;
    position: relative;
    top: -150px;
    visibility: hidden;
}

/* FONT STYLES
   ================================================== */

.pageTextSmall {
    margin: 0;
    font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
    font-size: 11px;
    color: var(--text);
}

.pageTextGap {
    margin: 0;
    font-size: 5px;
}

.footerText {
    margin: 0;
    font-size: 12px;
}

/* CONTAINERS
   ================================================== */

.pynodeContainer {
    min-width: 900px;
    min-height: 100%;
    position: relative;
    overflow: hidden;
}

.pynodeOutputContainer {
    min-width: 430px;
    min-height: 360px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.pynodeEditorContainer {
    min-width: 100px;
    min-height: 100px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.pynodeConsoleContainer {
    min-width: 100px;
    min-height: 100px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* PYNODE
   ================================================== */

body.pynode .pageWholeWrapper {
    width: 100%;
    padding-bottom: 100px;
}

body.pynode .pageBanner {
    width: 100%;
    height: 20px;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 20px;
    background-color: var(--bg-chrome);
    color: var(--text-invert);
}

body.pynode .pageTopWrapper {
    height: 500px;
    position: relative;
}

body.pynode .appWrapper {
    height: 760px;
    background-color: var(--bg-app);
    position: relative;
    padding-bottom: 20px;
    padding-top: 20px;
    box-shadow: inset 0 16px 20px -20px var(--shadow-strong), inset 0 -16px 20px -20px var(--shadow-mid);
}

body.pynode .appContainer {
    height: 100%;
    width: 100%;
    visibility: hidden;
    max-width: 1500px;
}

body.pynode .appLeft {
    width: calc(100% - 560px);
    padding-left: 20px;
    float: left;
    height: 100%;
}

body.pynode .editorWrapper, body.pynode_editor .editorWrapper {
    width: 100%;
    height: 100%;
    background-color: var(--bg-panel);
    box-shadow: 0 0 20px 0px var(--shadow);
    border-bottom: 10px solid var(--bg-chrome);
    box-sizing: border-box;
}

body.pynode #editorBox {
    width: 100%;
    height: 100%;
    visibility: hidden;
}

body.pynode_editor #editorBox {
    width: 100%;
    height: calc(100% - 40px);
}

body.pynode .editorButtonBar, body.pynode_output .editorButtonBar {
    width: 100%;
    height: 35px;
    background-color: var(--bg-inset);
    padding-top: 5px;
    padding-left: 0px;
}

body.pynode .editorButton, body.pynode_output .editorButton {
    width: 100px;
    height: 23px;
    background-color: var(--bg-button);
    padding-top: 7px;
    padding-left: 5px;
    color: var(--text-invert);
    margin-left: 5px;
    float: left;
}

body.pynode .editorButtonIcon, body.pynode_output .editorButtonIcon {
    float: left;
    padding-right: 5px;
    margin-top: -1px;
}

body.pynode .buttonBarLayoutPanel, body.pynode_output .buttonBarLayoutPanel {
    float: right;
    padding-top: 2px;
    padding-left: 20px;
    width: 80px;
}

body.pynode .layoutButtonOn, body.pynode_output .layoutButtonOn {
    width: 22px;
    height: 22px;
    padding-top: 2px;
    padding-left: 2px;
    float: left;
    margin-right: 8px;
    background-color: var(--bg-chip);
    box-shadow: inset 0px 0px 6px 0px var(--shadow);
}

body.pynode .layoutButtonOff, body.pynode_output .layoutButtonOff {
    width: 22px;
    height: 22px;
    padding-top: 2px;
    padding-left: 2px;
    float: left;
    margin-right: 8px;
    cursor: pointer;
}

body.pynode #runPlay, body.pynode_output #runPlay {
    display: inherit;
}

body.pynode #runPlayLoad, body.pynode_output #runPlayLoad {
    display: none;
}

body.pynode #runPause, body.pynode_output #runPause {
    display: none;
}

body.pynode #runResume, body.pynode_output #runResume {
    display: none;
}

body.pynode .editorHeader {
    height: 20px;
    width: 100%;
    background-color: var(--bg-inset);
}

/* Monaco sizes itself to this container via automaticLayout, so it must be a normal
   in-flow box. The old rules were position:absolute with a placeholder 100px width that
   js/resize.js overwrote at runtime; that hack is no longer needed. */
body.pynode #editor {
    width: 100%;
    height: 710px;
}

body.pynode_editor #editor {
    width: 100%;
    height: calc(100% - 50px);
}

body.pynode .appRight {
    width: 500px;
    float: right;
    padding-right: 20px;
    height: 100%;
}

body.pynode .outputWrapper {
    width: 500px;
    height: 490px;
    background-color: var(--bg-panel);
    box-shadow: 0 0 20px 0px var(--shadow);
    border-bottom: 10px solid var(--bg-chrome);
    box-sizing: border-box;
}

body.pynode_output .outputWrapper {
    width: 100%;
    height: 100%;
    background-color: var(--bg-panel);
    border-bottom: 10px solid var(--bg-chrome);
    box-sizing: border-box;
}

body.pynode_output .outputPageWrapper {
    width: 100%;
    height: 100%;
    background-color: var(--bg-app);
}

body.pynode_editor .editorPageWrapper {
    width: 100%;
    height: 100%;
    background-color: var(--bg-app);
}

body.pynode_console .consolePageWrapper {
    width: 100%;
    height: 100%;
    background-color: var(--bg-app);
}

body.pynode #outputBox {
    width: 500px;
    height: 400px;
    background-color: var(--bg-canvas);
}

body.pynode_output #outputBox {
    width: 100%;
    height: calc(100% - 80px);
    background-color: var(--bg-canvas);
}

body.pynode #output {
    width: 500px;
    height: 400px;
    display: block;
}

body.pynode_output .outputClass {
    width: 100%;
    height: 100%;
    display: block;
}

body.pynode .consoleWrapper {
    width: 500px;
    height: 250px;
    margin-top: 20px;
    background-color: var(--bg-panel);
    box-shadow: 0 0 20px 0px var(--shadow);
    border-bottom: 10px solid var(--bg-chrome);
    box-sizing: border-box;
}

body.pynode_console .consoleWrapper {
    width: 100%;
    height: 100%;
    background-color: var(--bg-panel);
    box-shadow: 0 0 20px 0px var(--shadow);
    border-bottom: 10px solid var(--bg-chrome);
    box-sizing: border-box;
}

body.pynode .consoleBox, body.pynode_console .consoleBox {
    background-color: var(--bg-inset);
    width: calc(100% - 25px);
    height: calc(100% - 62px);
    padding-top: 10px;
    padding-bottom: 12px;
    padding-left: 10px;
    padding-right: 15px;
}

body.pynode #console, body.pynode_console #console {
    width: 100%;
    height: 100%;
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    padding-left: 2px;
    font-family: monospace;
    overflow-y: auto;
}

/* The field input() appends to the console. Styled to vanish into the transcript so the
   line reads like a REPL prompt rather than a form. */
.consoleInput {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    min-width: 12ch;
}

body.pynode .appSectionTitle, body.pynode_output .appSectionTitle, body.pynode_editor .appSectionTitle, body.pynode_console .appSectionTitle {
    color: var(--text-invert);
    background-color: var(--bg-chrome);
    padding-left: 10px;
    width: calc(100% - 10px);
    height: 30px;
    padding-top: 10px;
}

body.pynode .appSectionEnlarge, body.pynode_output .appSectionEnlarge {
    float: right;
    padding-right: 10px;
}

body.pynode .appSectionBarIcon, body.pynode_editor .appSectionBarIcon {
    width: 30px;
    height: 20px;
    margin-bottom: 2px;
    float: right;
}

body.pynode .appSectionBarIconFirst, body.pynode_editor .appSectionBarIconFirst {
    width: 20px;
    height: 20px;
    float: right;
    padding-left: 12px;
}

body.pynode .appSectionBarIconDivider, body.pynode_editor .appSectionBarIconDivider {
    width: 0px;
    height: 28px;
    margin-top: -4px;
    float: right;
    border-right: 1px solid var(--divider-dark);
    border-left: 1px solid var(--divider-light);

}

body.pynode .pageBottomWrapper {
    height: 400px;
    height: auto;
    position: relative;
}

body.pynode .pynodeGithubStar {
    float: right;
    height: 50px;
}

body.pynode .pynodeLogo {
    width: 135px;
    height: 130px;
    padding-top: 15px;
    float: left;
}

body.pynode .pynodeTitle {
    height: 105px;
    font: 6.0rem/1.1 'Oswald', sans-serif;
}

body.pynode .pynodeSubtitle {
    height: 20px;
    padding-bottom: 8px;
}

body.pynode .pynodeAuthorSubtitle {
    /* Indent past the floated logo explicitly instead of relying on line-box wrapping.
       The second line sits below the logo's bottom edge, so it stops wrapping and snaps
       back to the left. 135px == .pynodeLogo width, so this matches the title's edge. */
    margin-left: 135px;
    height: auto;        /* was 20px - only ever fit one line */
    padding-bottom: 10px;
}

body.pynode .pynodeAuthorSubtitle h5 {
    line-height: 1.6;
}

body.pynode .pynodeDescription {
    height: 50px;
}


body.pynode code {
    font-family: monospace;
    font: 1.0rem/1.5 monospace;
    border: 1px solid var(--border);
    background-color: var(--bg-inset);
    padding-left: 2px;
    padding-right: 2px;
    padding-bottom: 1px;
}

body.pynode .codeInline {
    border: none;
}

body.pynode li {
    margin: 5px 0px;
}

/* GENERAL
   ================================================== */
.pageTop {
    width: 750px;
    height: calc(100% - 70px);
    margin-top: 50px;
    margin-left: calc(50% - 425px);
    box-shadow: 0 0 20px 0px var(--shadow-soft);
    background-color: var(--bg-panel);
    padding-left: 50px;
    padding-right: 50px;
    padding-top: 40px;
}

.pageWhole {
    width: 750px;
    margin-left: calc(50% - 425px);
    box-shadow: 0 0 20px 0px var(--shadow-soft);
    background-color: var(--bg-panel);
    padding-left: 50px;
    padding-right: 50px;
    padding-top: 50px;
    padding-bottom: 50px;
    margin-top: 30px;
}

body .floatLeft {
    float: left;
}

body .floatRight {
    float: right;
}

/* FOOTER
   ================================================== */

.pageInfoWrapper {
    width: 100%;
    height: 12px;
    text-align: center;
    padding-top: 5px;
    padding-bottom: 5px;
    position: absolute;
    bottom: 0;
}

.pageInfoWrapperHome {
    width: 100%;
    height: 10px;
    text-align: center;
    padding-top: 5px;
    padding-bottom: 5px;
}
/* THEME CONTROLS AND DARK-MODE ASSET FIXES
   ================================================== */

/* These three used to get background-color and cursor set from JavaScript as INLINE
   styles (index.html / pynode_output.html), which beat any stylesheet rule and so
   defeated theming entirely. The JS was deleted; this is where they live now. */
body.pynode #run, body.pynode #stop, body.pynode #restart,
body.pynode_output #run, body.pynode_output #stop, body.pynode_output #restart {
    background-color: var(--bg-button-live);
    cursor: pointer;
}

/* Injected by js/pynode_theme.js into the .appSectionTitle icon strip, which is the one
   header structure all four documents share. Children there are float:right. */
.themeToggle {
    float: right;
    width: 20px;
    height: 20px;
    padding-left: 12px;
    cursor: pointer;
    color: var(--text-invert);
}

.themeToggle svg {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    fill: currentColor;
}

/* Which glyph shows is pure CSS. Dark is the default, so the moon is the default glyph
   and the sun appears only under an explicit light choice. */
.themeToggle .iconSun { display: none; }
.themeToggle .iconMoon { display: inline; }

:root[data-theme="light"] .themeToggle .iconSun { display: inline; }
:root[data-theme="light"] .themeToggle .iconMoon { display: none; }

/* Raster fixes for dark chrome. play/pause/stop/restart/resize/import/save are white
   glyphs on transparent and already read correctly, so they are left alone. These do not: */
:root:not([data-theme="light"]) .layoutButtonOn img,
:root:not([data-theme="light"]) .layoutButtonOff img { filter: brightness(1.8); }

/* logo.png is black artwork on an OPAQUE white square: invert makes it white-on-black,
   then screen against the dark panel drops the black away, leaving just the glyph. */
:root:not([data-theme="light"]) .pynodeLogo img { filter: invert(1); mix-blend-mode: screen; }

