/* LLD Learn canvas (/lld/learn/<slug>). The page uses PRISM's workspace shell (base + canvas bundles), so panels, tabs,
   palette rows, toolbar and typography come from there. This file only adds the class boxes, the relationship lines
   and the right-panel forms, and uses the same tokens (--c-*, --t-*) as the rest of the app. */

/* The workspace keeps its panels and canvas light in both themes (as the HLD Learn mode does), while the shared --c-* tokens
   flip with the theme. So this page uses the exact slate and blue values the workspace itself uses (left-panel-v2.css,
   the right panel and the HLD nodes), not the theme tokens. Inter only, same sizes as the HLD settings controls. */
.lld-canvas-page {
  --lld-surface: var(--c-white);
  --lld-bg: rgb(248 250 252);
  --lld-text: rgb(15 23 42);
  --lld-body: rgb(30 41 59);
  --lld-text-2: rgb(100 116 139);
  --lld-border: rgb(203 213 225);
  --lld-accent: rgb(59 130 246);
  --lld-bad: rgb(185 28 28);
}

.lld-stage-nav { align-items: center; }
.lld-stage-count { padding: 0 10px; font-size: var(--t-small); font-weight: 600; color: var(--lld-text-2); white-space: nowrap; }
.lld-stage-nav .wab-btn:disabled { opacity: 0.4; cursor: default; }
/* Same two looks the header gives its other actions: the main one is the orange call to action, the other is plain */
.ws-header #lld-next { background: var(--c-cta); color: var(--c-cta-ink); }
.ws-header #lld-next:hover:not(:disabled) { background: var(--c-cta-hover); }
.ws-header #lld-prev { background: transparent; color: var(--wh-text-2); }
.ws-header #lld-prev:hover:not(:disabled) { background: color-mix(in srgb, var(--wh-text) 8%, transparent); color: var(--wh-text); }

/* Canvas content */
.lld-nodes { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.canvas.is-connecting, .canvas.is-connecting .lld-node { cursor: crosshair; }
.lld-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; margin: 0; padding: 7px 14px;
  border: 1px solid var(--lld-border); border-radius: 999px; background: var(--lld-surface); color: var(--lld-text);
  font-size: var(--t-small); font-weight: 600; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.lld-hint[hidden] { display: none; }

/* A class box */
.lld-node {
  position: absolute; box-sizing: border-box; pointer-events: auto; cursor: grab; user-select: none;
  background: var(--lld-surface); color: var(--lld-text); border: 1px solid var(--lld-border); border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.lld-node:hover { border-color: var(--lld-text-2); }
.lld-node--interface { border-color: var(--lld-accent); }
.lld-node--abstract { border-style: dashed; border-color: var(--lld-accent); }
.lld-node--enum { border-style: dotted; }
.lld-node.is-new { border-color: var(--lld-accent); border-width: 2px; background: color-mix(in srgb, var(--lld-accent) 8%, var(--lld-surface)); }
.lld-node.is-changed { border-color: var(--lld-accent); border-style: dashed; border-width: 2px; }
.lld-node.is-selected, .lld-node.is-new.is-selected { border-color: var(--lld-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--lld-accent) 30%, transparent); }
.lld-badge {
  position: absolute; top: -9px; right: 20px; padding: 1px 7px; border-radius: 999px; background: var(--lld-accent); color: var(--c-white);
  font-size: var(--t-micro); font-weight: 700; letter-spacing: 0.04em; pointer-events: none;
}
.lld-node-head { display: flex; flex-direction: column; align-items: center; padding: 7px 10px 6px; text-align: center; }
.lld-stereo { font-size: var(--t-caption); color: var(--lld-text-2); line-height: 1.2; }
.lld-name { font-size: var(--t-body); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.lld-name.is-italic { font-style: italic; }
.lld-node-sec { padding: 6px 10px; border-top: 1px solid var(--lld-border); }
.lld-node-sec.is-empty { min-height: 10px; padding: 4px 10px; }
.lld-member { font-size: var(--t-small); line-height: 1.5; color: var(--lld-text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Ports: drag from one to another class to draw a line */
.lld-port {
  position: absolute; width: 11px; height: 11px; padding: 0; border-radius: 50%; cursor: crosshair; opacity: 0; transition: opacity 0.12s ease;
  background: var(--lld-surface); border: 2px solid var(--lld-accent);
}
.lld-node:hover .lld-port, .lld-node.is-selected .lld-port { opacity: 1; }
.lld-port--top { left: calc(50% - 5.5px); top: -6px; }
.lld-port--bottom { left: calc(50% - 5.5px); bottom: -6px; }
.lld-port--left { top: calc(50% - 5.5px); left: -6px; }
.lld-port--right { top: calc(50% - 5.5px); right: -6px; }

/* Delete cross: top-right corner of a hovered or selected class, and on the middle of a selected line */
.lld-del {
  position: absolute; top: -9px; right: -9px; width: 20px; height: 20px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--lld-border); background: var(--lld-surface); color: var(--lld-text-2); cursor: pointer; opacity: 0; transition: opacity 0.12s ease;
}
.lld-del:hover { color: var(--lld-bad); border-color: var(--lld-bad); }
.lld-node:hover .lld-del, .lld-node.is-selected .lld-del { opacity: 1; }
.lld-edge-del { cursor: pointer; pointer-events: all; }
.lld-edge-del circle { fill: var(--lld-surface); stroke: var(--lld-border); stroke-width: 1; }
.lld-edge-del path { stroke: var(--lld-text-2); stroke-width: 1.8; stroke-linecap: round; fill: none; }
.lld-edge-del:hover circle { stroke: var(--lld-bad); }
.lld-edge-del:hover path { stroke: var(--lld-bad); }

/* Relationship lines */
.lld-line { stroke: var(--lld-text-2); stroke-width: 1.4; fill: none; }
.lld-line.is-dash { stroke-dasharray: 5 4; }
.lld-line.is-preview { stroke: var(--lld-accent); stroke-dasharray: 4 3; pointer-events: none; }
.lld-hit { stroke: transparent; stroke-width: 14; cursor: pointer; pointer-events: stroke; }
.lld-edge:hover .lld-line { stroke: var(--lld-text); }
.lld-edge.is-selected .lld-line { stroke: var(--lld-accent); stroke-width: 2.2; }
.lld-mark { stroke: var(--lld-text-2); stroke-width: 1.2; }
.lld-mark--hollow { fill: var(--lld-surface); }
.lld-mark--solid { fill: var(--lld-text-2); }
.lld-mark--open { fill: none; }
.lld-edge-label { fill: var(--lld-accent); font-size: var(--t-body); font-weight: 600; paint-order: stroke; stroke: var(--lld-bg); stroke-width: 3px; pointer-events: none; }

/* Palette rows for classes and relationships */
.lld-icon { width: 20px; height: 20px; color: var(--lld-text-2); }
.lld-rel-item { cursor: pointer; }
.lld-rel-item.is-active { background: color-mix(in srgb, var(--lld-accent) 14%, transparent); border-color: var(--lld-accent); }
#lld-palette .lp2-empty[hidden] { display: none; }

/* Right panel */
.lld-view { padding: 4px 16px 20px; overflow-y: auto; }
.lld-view[hidden] { display: none !important; }
.lld-problem-text { margin: 12px 0 4px; font-size: var(--t-body); line-height: 1.5; color: var(--lld-body); }
.lld-list { margin: 6px 0 12px; padding-left: 18px; font-size: var(--t-body); line-height: 1.5; color: var(--lld-body); }
.lld-list li { margin: 0 0 6px; }
.lld-plain a { color: var(--lld-accent); text-decoration: none; }
.lld-goal { margin: 4px 0 12px; font-size: var(--t-body); color: var(--lld-text-2); }
.lld-note-name { margin-bottom: 4px; font-size: var(--t-small); font-weight: 700; color: var(--lld-text); }
.lld-stage-picker { margin: 10px 0 6px; }
.lld-select, .lld-input {
  width: 100%; box-sizing: border-box; padding: 7px 9px; border: 1px solid var(--lld-border); border-radius: 8px;
  background: var(--lld-bg); color: var(--lld-text); font: inherit; font-size: var(--t-body);
}
.lld-input { font-size: var(--t-small); }
#lld-name-input { font-family: inherit; font-size: var(--t-body); font-weight: 600; }
.lld-input:focus, .lld-select:focus { outline: none; border-color: var(--lld-accent); }
.lld-field { margin: 12px 0; }
.lld-field-label { display: block; margin: 0 0 6px; }
.lld-members { margin: 14px 0; }
.lld-member-row { display: flex; gap: 6px; margin: 0 0 6px; }
.lld-icon-btn { flex: none; font-family: inherit; width: 30px; border: 1px solid var(--lld-border); border-radius: 8px; background: var(--lld-surface); color: var(--lld-text-2); font-size: 16px; line-height: 1; cursor: pointer; }
.lld-icon-btn:hover { color: var(--lld-bad); border-color: var(--lld-bad); }
.lld-add { padding: 4px 0; border: 0; background: none; color: var(--lld-accent); font: inherit; font-size: var(--t-small); font-weight: 600; cursor: pointer; }
.lld-btn { display: block; margin: 10px 0 0; padding: 7px 14px; border: 1px solid var(--lld-border); border-radius: 8px; background: var(--lld-surface); color: var(--lld-text); font: inherit; font-size: var(--t-body); font-weight: 600; cursor: pointer; }
.lld-btn:hover { border-color: var(--lld-text); }
.lld-btn--danger { color: var(--lld-bad); }
.lld-btn--danger:hover { border-color: var(--lld-bad); }
.lld-empty-note { margin: 14px 0; font-size: var(--t-body); line-height: 1.5; color: var(--lld-text-2); }
.lld-edge-sentence { margin: 12px 0 0; font-size: var(--t-body); font-weight: 600; color: var(--lld-text); }

.lld-view code, .stage-theory code { padding: 1px 5px; border-radius: 4px; background: var(--lld-bg); font: inherit; font-weight: 600; }

@media (max-width: 760px) {
  .lld-stage-count { display: none; }
  .lld-stage-nav .wab-btn span { display: none; }
  .lld-stage-nav .wab-btn { padding: 0 12px; }
}

/* Settings view in the left panel: PRISM's own lp2-* classes do the layout; these only add the member rows and line title */
#left-panel .lld-member-row { display: flex; gap: 6px; margin: 0 0 6px; }
#left-panel .lld-input { font-size: 11.75px; font-weight: 500; }
#left-panel.lp-v2 .lp2-sections > .lp2-field { padding: 10px 14px; margin: 0; }
#left-panel .lld-add { display: block; margin: 2px 0 6px; }
#left-panel .lld-btn { margin: 4px 0 0; width: 100%; }
#left-panel .lld-edge-title { margin: 6px 0 2px; padding: 0 2px; font-size: var(--t-heading); font-weight: 600; color: var(--lld-text); overflow-wrap: anywhere; }
#left-panel .lp2-sec-b .lp2-field { align-items: center; }

/* Practice > Simulation: the empty state sits in the middle of the panel, as in the High Level Design Simulate tab */
.lld-sim .sim-scenario-wrap { margin-bottom: 4px; }
.lld-sim-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 16px; text-align: center; color: var(--lld-text-2); }
.lld-sim-empty svg { opacity: 0.35; }
.lld-sim-empty .prp-sim-empty-title { margin: 0; font-size: var(--t-body); font-weight: 700; color: var(--lld-text); }
.lld-sim-empty .prp-sim-empty-sub { margin: 0; font-size: var(--t-small); line-height: 1.5; }
.lld-sim-card { padding: 4px 2px; }

/* A closed side panel leaves a labelled button on the canvas (Blocks / Problem), as on a phone, instead of a thin grey tab mid-screen */
@media (min-width: 768px) and (min-height: 501px) {
  .lld-canvas-page .floating-toggle {
    top: 56px; transform: none; width: auto; height: 34px; padding: 0 14px; gap: 6px;
    border-radius: 999px; border: 1px solid var(--lld-border); background: var(--lld-surface); color: var(--lld-text);
    font-size: var(--t-small); font-weight: 600; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  }
  .lld-canvas-page .floating-toggle .ft-label { display: inline; }
  .lld-canvas-page .floating-toggle:hover { background: var(--lld-bg); border-color: var(--lld-text-2); }
}
