diff --git a/src/scripts/logicGates.js b/src/scripts/logicGates.js
index a39d333..8bc1d2c 100644
--- a/src/scripts/logicGates.js
+++ b/src/scripts/logicGates.js
@@ -32,12 +32,10 @@
let nextNodeId = 1;
let nextWireId = 1;
- let inputCount = 0;
- let outputCount = 0;
let isDraggingNode = null;
let dragOffset = { x: 0, y: 0 };
- let clickStartX = 0, clickStartY = 0; // Fixes switch drag conflict
+ let clickStartX = 0, clickStartY = 0;
let wiringStart = null;
let tempWirePath = null;
@@ -252,6 +250,23 @@
generateTruthTable();
}
+ /* --- Smart Label Generation --- */
+ function getNextInputLabel() {
+ let charCode = 65; // Starts at 'A'
+ while (Object.values(nodes).some(n => n.type === 'INPUT' && n.label === String.fromCharCode(charCode))) {
+ charCode++;
+ }
+ return String.fromCharCode(charCode);
+ }
+
+ function getNextOutputLabel() {
+ let idx = 1;
+ while (Object.values(nodes).some(n => n.type === 'OUTPUT' && n.label === ('Q' + idx))) {
+ idx++;
+ }
+ return 'Q' + idx;
+ }
+
/* --- Node Creation --- */
function createNodeElement(node) {
const el = document.createElement('div');
@@ -292,7 +307,6 @@
node.el = el;
if (node.type === 'INPUT') {
- // Custom click handler to prevent dragging from toggling the switch
el.querySelector('.switch').addEventListener('click', (e) => {
const dist = Math.hypot(e.clientX - clickStartX, e.clientY - clickStartY);
if (isDraggingNode || dist > 3) {
@@ -313,9 +327,9 @@
function spawnNode(type, gateType = null, dropX = null, dropY = null) {
let label = '';
- if (type === 'INPUT') { inputCount++; label = String.fromCharCode(64 + inputCount); }
- if (type === 'OUTPUT') { outputCount++; label = `Q${outputCount}`; }
- if (type === 'GATE') { label = gateType; }
+ if (type === 'INPUT') label = getNextInputLabel();
+ if (type === 'OUTPUT') label = getNextOutputLabel();
+ if (type === 'GATE') label = gateType;
const id = `node_${nextNodeId++}`;
@@ -468,8 +482,6 @@
workspace.querySelectorAll('.lg-node').forEach(el => el.remove());
nodes = {};
connections = [];
- inputCount = 0;
- outputCount = 0;
runSimulation();
});
@@ -481,9 +493,5 @@
});
initToolbox();
- spawnNode('INPUT', null, 80, 150);
- spawnNode('INPUT', null, 80, 250);
- spawnNode('GATE', 'AND', 320, 200);
- spawnNode('OUTPUT', null, 600, 200);
-
+ // Starts completely blank as requested!
})();
\ No newline at end of file
diff --git a/src/styles/base.css b/src/styles/base.css
deleted file mode 100644
index 46400b8..0000000
--- a/src/styles/base.css
+++ /dev/null
@@ -1,52 +0,0 @@
-/* src/styles/base.css */
-@import "./md3-tokens.css";
-html, body{ height:100%; }
-body{
- margin:0;
- font-family: var(--font-sans);
- background: var(--md-surface-2);
- color: var(--md-on-surface);
-}
-a{ color: var(--md-primary); text-decoration: none; }
-a:hover{ text-decoration: underline; }
-.container{
- max-width: 1100px;
- margin: 0 auto;
- padding: 16px;
-}
-.card{
- background: var(--md-surface);
- border: 1px solid var(--md-outline);
- border-radius: var(--radius-2);
- box-shadow: var(--shadow-1);
- padding: 16px;
-}
-.btn{
- display:inline-flex;
- gap:8px;
- align-items:center;
- justify-content:center;
- border-radius: 999px;
- border: 1px solid var(--md-outline);
- background: var(--md-surface);
- color: var(--md-on-surface);
- padding: 10px 14px;
- font-weight: 600;
- cursor: pointer;
-}
-.btn:hover{ filter: brightness(0.98); }
-.btn:focus{ outline:none; box-shadow: var(--md-focus); }
-.btn-primary{
- background: var(--md-primary);
- color: var(--md-on-primary);
- border-color: transparent;
-}
-.badge{
- display:inline-block;
- padding: 2px 10px;
- border-radius: 999px;
- font-size: 12px;
- border: 1px solid var(--md-outline);
- background: var(--md-surface-2);
-}
-code, pre{ font-family: var(--font-mono); }
diff --git a/src/styles/fonts.css b/src/styles/fonts.css
deleted file mode 100644
index 768cb39..0000000
--- a/src/styles/fonts.css
+++ /dev/null
@@ -1,11 +0,0 @@
-@font-face {
- font-family: "DSEG7";
- src: url("/fonts/DSEG7Classic-Regular.ttf") format("truetype");
- font-weight: normal;
- font-style: normal;
-}
-
-.dseg {
- font-family: "DSEG7", monospace;
- letter-spacing: 0.15em;
-}
diff --git a/src/styles/logic-gates.css b/src/styles/logic-gates.css
index 36d054d..2766597 100644
--- a/src/styles/logic-gates.css
+++ b/src/styles/logic-gates.css
@@ -1,15 +1,83 @@
-/* === LOGIC GATES CANVAS CSS === */
-.lg-workspace {
- position: relative;
+/* === FULL PAGE OVERRIDES FOR LOGIC GATES === */
+body:has(#logicPage) {
+ overflow: hidden; /* Prevents the entire page from scrolling */
+}
+
+body:has(#logicPage) .pageWrap {
+ max-width: 100% !important; /* Forces edge-to-edge canvas */
+ padding: 0 !important;
+ margin: 0 !important;
+ height: calc(100vh - var(--nav-h));
+ display: flex;
+ flex-direction: column;
+}
+
+#logicPage {
+ padding: 0 !important; /* CRITICAL: Stops the page/header from shifting when toolbox opens */
+ margin: 0 !important;
+}
+
+/* === MAIN CONTAINER === */
+.lg-container {
flex: 1;
+ display: flex;
+ flex-direction: column;
+ position: relative;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+}
+
+/* === FIXED HEADER (Ultra Compact) === */
+.lg-top-header {
+ width: 100%;
+ text-align: center;
+ padding: 8px 20px 8px; /* Extremely tight padding to maximize canvas */
+ background: var(--bg);
+ z-index: 10;
+ flex-shrink: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ border-bottom: 1px solid rgba(255,255,255,0.08); /* Clean separation line */
+}
+
+.lg-title {
+ font-family: var(--bit-font);
+ font-size: 32px;
+ letter-spacing: 0.12em;
+ text-transform: uppercase;
+ color: var(--text);
+ margin: 0 0 2px 0; /* Minimal gap between title and subtitle */
+ line-height: 1;
+}
+
+.lg-subtitle {
+ color: var(--muted);
+ font-size: 14px;
+ font-family: var(--ui-font);
+ font-weight: 500;
+ margin: 0;
+ line-height: 1.2;
+}
+
+.lg-subtitle kbd {
+ background: rgba(255,255,255,0.1);
+ padding: 2px 6px;
+ border-radius: 4px;
+ font-family: var(--ui-font);
+ color: #e8e8ee;
+}
+
+/* === DYNAMIC CANVAS === */
+.lg-workspace {
+ flex: 1; /* Automatically fills all remaining vertical space */
+ position: relative;
width: 100%;
- min-height: 750px;
background-color: transparent;
background-image: radial-gradient(rgba(255,255,255,0.12) 1px, transparent 1px);
background-size: 24px 24px;
- border: none;
- border-radius: 0;
- box-shadow: none;
overflow: hidden;
}
@@ -29,7 +97,7 @@
fill: none;
stroke-linecap: round;
transition: stroke 0.1s ease, filter 0.1s ease, stroke-width 0.1s ease;
- pointer-events: stroke; /* Allows wires to be clicked */
+ pointer-events: stroke;
cursor: pointer;
}
.lg-wire:hover {
@@ -56,7 +124,7 @@
pointer-events: none;
}
-/* Nodes (Borderless & Transparent) */
+/* Nodes */
.lg-node {
position: absolute;
background: transparent;
@@ -68,17 +136,12 @@
align-items: center;
cursor: grab;
z-index: 10;
- box-shadow: none;
- backdrop-filter: none;
user-select: none;
transition: filter 0.2s;
}
.lg-node:active { cursor: grabbing; z-index: 20; }
-.lg-node.selected {
- filter: drop-shadow(0 0 10px rgba(255,85,85,0.8));
-}
+.lg-node.selected { filter: drop-shadow(0 0 10px rgba(255,85,85,0.8)); }
-/* Node Labels (Seven-Segment, +2 Sizes Bigger) */
.lg-header {
font-size: 24px;
color: var(--muted);
@@ -88,40 +151,71 @@
margin-bottom: 6px;
}
-/* Container mapping SVGs to absolutely positioned connection dots */
.lg-gate-container {
position: relative;
display: inline-flex;
align-items: center;
}
-
-.lg-gate-svg {
- width: 100px;
- height: 50px;
- display: block;
-}
-
-.lg-line-svg {
- width: 30px;
- height: 50px;
- display: block;
-}
+.lg-gate-svg { width: 100px; height: 50px; display: block; }
+.lg-line-svg { width: 30px; height: 50px; display: block; }
/* Connection Ports */
.lg-port {
width: 16px; height: 16px; background: #a9acb8; border-radius: 50%; cursor: crosshair;
border: 3px solid var(--bg); box-shadow: 0 0 0 1px rgba(255,255,255,0.2); transition: all 0.2s;
position: absolute; z-index: 5;
- transform: translate(-50%, -50%); /* Centers the dot exactly over the coordinate */
+ transform: translate(-50%, -50%);
}
.lg-port:hover { transform: translate(-50%, -50%) scale(1.3); background: #fff; }
.lg-port.active { background: #28f07a; box-shadow: 0 0 12px rgba(40,240,122,0.8); border-color: #1f2027; }
-/* Draggable Toolbox Visual Gates Grid */
+/* === FLOATING TOOLBOX === */
+.toolboxToggle {
+ position: absolute;
+ top: 10px; /* Snug inside the thinner header */
+ right: 20px;
+ z-index: 90;
+ display: flex; align-items: center; gap: 10px; padding: 8px 14px;
+ border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.15);
+ backdrop-filter: blur(8px); color: rgba(232,232,238,.95); font-family: var(--bit-font);
+ font-weight: 800; font-size: 16px; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
+}
+.toolboxIcon { font-size: 20px; filter: drop-shadow(0 0 8px rgba(255,105,180,.35)); }
+.toolboxToggle:hover { border-color: rgba(255,255,255,.22); }
+
+.lg-toolbox {
+ position: absolute;
+ top: 60px; /* Sits right under the new thin header */
+ right: 20px;
+ bottom: 20px; /* Constrains the height so it scrolls internally */
+ width: var(--toolbox-w, 360px);
+ z-index: 80;
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ transform: translateX(0);
+ transition: transform 420ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease;
+ overflow-y: auto;
+ pointer-events: auto;
+ padding-right: 6px;
+}
+
+/* Faded Subdued Scrollbars */
+.lg-toolbox::-webkit-scrollbar { width: 6px; }
+.lg-toolbox::-webkit-scrollbar-track { background: transparent; }
+.lg-toolbox::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.05); border-radius: 10px; transition: background 0.3s; }
+.lg-toolbox:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }
+.lg-toolbox::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
+
+.lg-container.toolboxCollapsed .lg-toolbox {
+ transform: translateX(calc(100% + 40px));
+ opacity: 0;
+ pointer-events: none;
+}
+
+/* Toolbox Grid */
.tb-icon-grid {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 12px;
+ display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.tb-icon-box {
background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.15);
@@ -132,14 +226,6 @@
.tb-icon-box:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
.tb-icon-label { font-family: var(--ui-font); font-size: 11px; font-weight: 800; color: var(--text); letter-spacing: 1px; text-transform: uppercase; }
-/* Toolbox Scroll Fix */
-.panelCol {
- max-height: calc(100vh - var(--nav-h) - 30px) !important;
- overflow-y: auto;
- padding-bottom: 30px;
- pointer-events: auto;
-}
-
/* Truth Table */
.tt-summary {
font-family: var(--ui-font); font-size: 14px; font-weight: 800;
@@ -147,17 +233,15 @@
outline: none; margin-bottom: 10px; text-transform: uppercase;
}
.tt-table-wrap {
- width: 100%; max-height: 300px; overflow-y: auto; overflow-x: auto;
+ width: 100%; max-height: 250px; overflow-y: auto; overflow-x: auto;
border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2);
}
-.tt-table {
- width: 100%; border-collapse: collapse; text-align: center;
- font-family: var(--num-font); font-size: 14px; color: #e8e8ee;
-}
-.tt-table th {
- position: sticky; top: 0; background: rgba(31,32,39,0.95);
- padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.15);
- color: var(--muted); font-family: var(--bit-font); font-weight: normal;
-}
+.tt-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
+.tt-table-wrap::-webkit-scrollbar-track { background: transparent; }
+.tt-table-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
+.tt-table-wrap:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); }
+
+.tt-table { width: 100%; border-collapse: collapse; text-align: center; font-family: var(--num-font); font-size: 14px; color: #e8e8ee; }
+.tt-table th { position: sticky; top: 0; background: rgba(31,32,39,0.95); padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.15); color: var(--muted); font-family: var(--bit-font); font-weight: normal; }
.tt-table td { padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.tt-table .tt-on { color: #28f07a; text-shadow: 0 0 8px rgba(40,240,122,0.5); }
\ No newline at end of file
diff --git a/src/styles/md3-tokens.css b/src/styles/md3-tokens.css
deleted file mode 100644
index beb9cf3..0000000
--- a/src/styles/md3-tokens.css
+++ /dev/null
@@ -1,43 +0,0 @@
-/* src/styles/md3-tokens.css */
-/* MD3-inspired tokens tuned for education: high readability, clear contrast, calm surfaces */
-:root{
- /* Typography */
- --font-sans: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
- --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
- /* Spacing + shape */
- --radius-1: 10px;
- --radius-2: 16px;
- --radius-3: 22px;
- --shadow-1: 0 1px 2px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
- /* Color roles (keep simple) */
- --md-surface: #ffffff;
- --md-surface-2: #f6f7fb;
- --md-on-surface: #111318;
- --md-primary: #2f6fed; /* calm blue */
- --md-on-primary: #ffffff;
- --md-secondary: #5a5f72; /* muted */
- --md-on-secondary: #ffffff;
- --md-tertiary: #0f766e; /* teal for "practical" tools */
- --md-on-tertiary: #ffffff;
- --md-outline: #d7dbe7;
- --md-success: #1a7f37;
- --md-warning: #b54708;
- --md-danger: #b42318;
- /* Focus ring for accessibility */
- --md-focus: 0 0 0 3px rgba(47,111,237,.28);
-}
-@media (prefers-color-scheme: dark){
- :root{
- --md-surface: #0b0e14;
- --md-surface-2: #121725;
- --md-on-surface: #e8eaf2;
- --md-primary: #9bb6ff;
- --md-on-primary: #0b0e14;
- --md-secondary: #b8bccd;
- --md-on-secondary: #0b0e14;
- --md-tertiary: #4fd1c5;
- --md-on-tertiary: #0b0e14;
- --md-outline: #2b3244;
- --md-focus: 0 0 0 3px rgba(155,182,255,.25);
- }
-}
diff --git a/src/styles/site.css b/src/styles/site.css
deleted file mode 100644
index bcaa838..0000000
--- a/src/styles/site.css
+++ /dev/null
@@ -1,75 +0,0 @@
-:root{
- --bg: #1f2027;
- --panel: rgba(255,255,255,.04);
- --panel-border: rgba(255,255,255,.10);
- --text: #e8e8ee;
- --muted: #a9acb8;
- --accent: #33ff7a;
- --accent-dim: rgba(51,255,122,.15);
- --line: rgba(255,255,255,.12);
-}
-
-*{ box-sizing: border-box; }
-
-body{
- margin:0;
- font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
- background: var(--bg);
- color: var(--text);
-}
-
-.site-header{
- border-bottom: 1px solid rgba(255,255,255,.08);
- background: rgba(0,0,0,.12);
-}
-
-.site-header__inner{
- max-width: 1200px;
- margin: 0 auto;
- padding: 14px 20px;
- display:flex;
- align-items:center;
- justify-content:space-between;
- gap: 18px;
-}
-
-.brand{
- font-weight: 800;
- letter-spacing: .02em;
-}
-
-.nav{
- display:flex;
- gap: 14px;
- flex-wrap: wrap;
- justify-content:flex-end;
-}
-
-.nav__link{
- color: var(--muted);
- text-decoration:none;
- font-weight: 700;
- font-size: 13px;
-}
-.nav__link:hover{ color: var(--text); }
-
-.site-main{
- max-width: 1200px;
- margin: 0 auto;
- padding: 28px 20px 40px;
- min-height: calc(100vh - 140px);
-}
-
-.site-footer{
- border-top: 1px solid rgba(255,255,255,.08);
- background: rgba(0,0,0,.10);
-}
-
-.site-footer__inner{
- max-width: 1200px;
- margin: 0 auto;
- padding: 16px 20px;
- color: var(--muted);
- font-size: 12px;
- line-height: 1.5;
-}