/* The diagram editor (erd-edit.js). The drawn boxes and lines use the same
   look as the Unit 07 diagrams (widgets/erd.html), scoped to the editor;
   the fields laid over each box are sized in the box's own units (a 24px
   header, 18px rows) so they sit on the drawn rows at any zoom. */

.erd-ed{margin:1.2rem 0}
.erd-ed .ed-bar{display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; margin:0 0 .5rem}
.erd-ed .ed-bar .ed-gap{flex:1}
.erd-ed .ed-bar .w-btn:disabled{opacity:.45; cursor:default; border-color:var(--line); color:var(--ink)}
.erd-ed .ed-canvas{position:relative; overflow:hidden; height:460px; background:var(--paper); background-image:radial-gradient(var(--line) 1px, transparent 1px); background-size:20px 20px; border:1px solid var(--line); border-radius:8px; cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; outline:none}
.erd-ed .ed-canvas.panning{cursor:grabbing}
.erd-ed .ed-world{position:absolute; left:0; top:0; transform-origin:0 0}
.erd-ed .ed-layer{position:absolute; left:0; top:0}
.erd-ed .ed-hint{position:absolute; inset:0; margin:0; display:flex; align-items:center; justify-content:center; color:var(--slate); pointer-events:none}
.erd-ed .ed-hint[hidden]{display:none}

/* ---------- the drawing (as in widgets/erd.html) ---------- */
.erd-ed .erd-svg{position:absolute; overflow:visible; font-family:var(--mono)}
.erd-ed .t-box{fill:var(--card); stroke:var(--line); stroke-width:1.2}
.erd-ed .t-head{fill:var(--paper)}
.erd-ed .t-name{fill:var(--ink); font-size:14px; font-weight:700}
.erd-ed .c-bg{fill:transparent}
.erd-ed .c-name{fill:var(--ink); font-size:12.5px}
.erd-ed .c-type{fill:var(--slate); font-size:10.5px}
.erd-ed .c-uq{fill:var(--accent); font-size:9.5px; font-weight:700}
.erd-ed .c-key{fill:var(--accent); font-size:10px; font-weight:700}
.erd-ed .c-star{fill:var(--ink); font-size:13px; font-weight:700}
.erd-ed .c-keyicon{fill:none; stroke:var(--accent); stroke-width:1.5}
.erd-ed .rel path.line{fill:none; stroke:var(--slate); stroke-width:1.3}
.erd-ed .rel path.hit{fill:none; stroke:transparent; stroke-width:14; cursor:pointer}
.erd-ed.ro .rel path.hit{cursor:inherit}
.erd-ed .rel .mark{stroke:var(--slate); stroke-width:1.3; fill:none}
.erd-ed .rel:hover path.line,.erd-ed .rel:hover .mark{stroke:var(--ink)}
.erd-ed .rel.on path.line,.erd-ed .rel.on .mark{stroke:var(--accent); stroke-width:2}
.erd-ed .end-hit{fill:transparent; cursor:pointer}
/* a line's end targets sit on top of every line (erd-edit.js draws them last) */
.erd-ed .end-hit:hover{fill:var(--accent-soft); stroke:var(--accent); stroke-width:1}
.erd-ed .ed-temp{fill:none; stroke:var(--accent); stroke-width:1.5; stroke-dasharray:4 3; pointer-events:none}
/* while editing, the fields show the names, types and toggles */
.erd-ed:not(.ro) .erd-tables text,.erd-ed:not(.ro) .c-keyicon{display:none}

/* ---------- the fields over each box ---------- */
.erd-ed .ed-t{position:absolute; cursor:default; font-family:var(--mono); font-size:12.5px; line-height:1; color:var(--ink)}
.erd-ed .ed-t.moving{opacity:.85}
.erd-ed .ed-t input{font:inherit; color:inherit; background:transparent; border:0; border-radius:3px; padding:0 2px; margin:0; min-width:0; height:100%; outline:none}
.erd-ed .ed-t input::placeholder{color:var(--slate); opacity:.7; font-weight:400}
.erd-ed .ed-t input:hover{background:var(--chrome)}
.erd-ed .ed-t input:focus{background:var(--accent-soft); box-shadow:inset 0 0 0 1px var(--accent)}
.erd-ed .ed-t button{font:inherit; background:none; border:0; padding:0; margin:0; color:inherit; cursor:pointer; line-height:1}

.erd-ed .ed-t .ed-head{height:24px; display:flex; align-items:center; gap:4px; padding:0 4px 0 8px; cursor:move}
.erd-ed .ed-t .ed-tname{font-size:14px; font-weight:700; height:19px; cursor:text}
.erd-ed .ed-t .ed-head .ed-x{margin-left:auto}
.erd-ed .ed-t .ed-rows{padding-top:2px}
.erd-ed .ed-t .ed-c{height:18px; display:flex; align-items:center; position:relative}
.erd-ed .ed-t .ed-c.target{background:var(--accent-soft); box-shadow:inset 0 0 0 1px var(--accent)}
.erd-ed .ed-t .ed-c.moving{background:var(--chrome)}
.erd-ed .ed-t .ed-grip{flex:0 0 10px; height:12px; margin-left:1px; cursor:grab; background-image:radial-gradient(var(--slate) 1px, transparent 1.2px); background-size:4px 4px; background-position:2px 0; opacity:0}
.erd-ed .ed-t .ed-cname{flex:1 1 auto; font-size:12.5px}
.erd-ed .ed-t .ed-ctype{flex:0 0 var(--type-w, 100px); font-size:10.5px; color:var(--slate); text-align:right}
.erd-ed .ed-t .ed-tog{flex:0 0 auto; height:15px; color:var(--slate); opacity:0; border-radius:3px}
.erd-ed .ed-t .ed-key{width:17px; display:flex; align-items:center; justify-content:center}
.erd-ed .ed-t .ed-key svg{width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:1.6}
.erd-ed .ed-t .ed-nn,.erd-ed .ed-t .ed-uq{width:18px; font-size:9px; font-weight:700; margin-left:2px}
.erd-ed .ed-t .ed-tog[aria-pressed="true"]{color:var(--accent); opacity:1}
.erd-ed .ed-t .ed-tog:focus-visible,.erd-ed .ed-t .ed-add:focus-visible{outline:1.5px solid var(--accent); outline-offset:-1px; opacity:1}
.erd-ed .ed-t .ed-x{flex:0 0 14px; height:15px; color:var(--slate); font-size:13px; opacity:0}
.erd-ed .ed-t .ed-x:hover{color:var(--ink)}
.erd-ed .ed-t .ed-link{flex:0 0 12px; height:18px; cursor:crosshair; position:relative; opacity:0}
.erd-ed .ed-t .ed-link::after{content:""; position:absolute; left:3px; top:5px; width:6px; height:6px; border-radius:50%; border:1.5px solid var(--accent); background:var(--card)}
.erd-ed .ed-t .ed-link:hover::after{background:var(--accent)}
.erd-ed .ed-t .ed-add{display:block; height:18px; padding:0 10px; font-size:11px; color:var(--accent); opacity:.8}
.erd-ed .ed-t .ed-add:hover{opacity:1; text-decoration:underline}
.erd-ed .ed-t .ed-drop{position:absolute; left:4px; right:4px; height:2px; background:var(--accent); pointer-events:none}

/* the controls that are off show while the pointer is on the table, or a field in it has focus */
.erd-ed .ed-t:hover .ed-grip,.erd-ed .ed-t:focus-within .ed-grip,
.erd-ed .ed-t:hover .ed-x,.erd-ed .ed-t:focus-within .ed-x,
.erd-ed .ed-t:hover .ed-link,.erd-ed .ed-t:focus-within .ed-link{opacity:1}
.erd-ed .ed-t:hover .ed-tog,.erd-ed .ed-t:focus-within .ed-tog{opacity:.45}
.erd-ed .ed-t .ed-tog:hover{opacity:1}
.erd-ed .ed-t .ed-tog[aria-pressed="true"]{opacity:1}

/* ---------- the diagram question on a practice page (practice-diagram.js) ---------- */
.sqlx.diagram .erd-ed{margin:1rem 0 .4rem}
.sqlx.diagram .dg-try{margin-top:1.4rem; padding-top:1rem; border-top:1px solid var(--line)}
.sqlx.diagram .dg-try-label{margin:0; font-weight:700}
.sqlx.diagram .dg-try .sqlx-note{margin:.3rem 0 0}
/* the try box's directions read like the prompt, in the page's own text color */
.sqlx.diagram .dg-try-text{margin:.3rem 0 .7rem; font-size:.95rem; color:var(--ink)}
.sqlx.diagram .dg-try-text p{margin:0 0 .5rem}
.sqlx.diagram .dg-try-text p:last-child{margin-bottom:0}
.sqlx.diagram .dg-sql{margin-top:.8rem}
.sqlx.diagram .dg-sql summary{cursor:pointer; color:var(--slate)}
/* the tables Run made, side by side, each as wide as it needs, wrapping onto new lines */
.sqlx.diagram .dg-state.show{display:flex; flex-wrap:wrap; gap:.8rem 1.4rem; align-items:flex-start}
.sqlx.diagram .dg-state .state-label{flex:0 0 100%; margin:0}
.sqlx.diagram .dg-state .state-table{margin:0; max-width:100%; min-width:0}
