/* ── Section 2: Canvas ───────────────────────────────── */
#canvas-section {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  background: transparent;
}

#canvas-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

#canvas-viewport.is-panning { cursor: grabbing; }

/* ── Infinite crosshair cursor ───────────────────────── */
#canvas-crosshair {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.canvas-crosshair-line {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  background: var(--color-crosshair);
  will-change: transform;
}

.canvas-crosshair-line--horizontal {
  width: 100%;
  height: var(--border-thin);
}

.canvas-crosshair-line--vertical {
  width: var(--border-thin);
  height: 100%;
}

@media (hover: hover) and (pointer: fine) {
  #canvas-crosshair { display: block; }
  body.canvas-active #canvas-crosshair.is-visible { opacity: 1; }

  body.canvas-active #canvas-viewport,
  body.canvas-active #canvas-viewport * { cursor: none !important; }
}

#canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

/* ── Wires (SVG) ─────────────────────────────────────── */
#wire-layer { pointer-events: none; }

body.wires-disabled #wire-layer,
body.wires-disabled .node-handle {
  display: none;
}

body.wires-disabled .node.has-thumbnail {
  border: 0;
}

.wire {
  fill: none;
  stroke: var(--color-wire);
  stroke-width: 1.5px;
  stroke-linecap: round;
  pointer-events: none;
}

.wire-preview {
  stroke: var(--color-wire-preview);
  stroke-dasharray: 6 4;
}

/* ── Project nodes ───────────────────────────────────── */
.node {
  position: absolute;
  width: 240px;
  height: 160px;
  background: var(--accent, var(--color-default-accent));
  border: var(--border-strong) solid var(--accent, var(--color-default-accent));
  cursor: grab;
  user-select: none;
  overflow: visible; /* handles + resize extend outside node bounds */
  transition: box-shadow 180ms ease, opacity 220ms ease, filter 220ms ease;
  z-index: 1;
}

.node:active { cursor: grabbing; }

.node.selected {
  box-shadow:
    0 0 0 2px var(--blue),
    0 0 0 5px var(--blue-glow);
}

.node.faded {
  opacity: 0.2;
  filter: grayscale(0.85) saturate(0.25);
}

/* Clips the thumbnail to node bounds */
.node-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* ── Thumbnail ───────────────────────────────────────── */
.node-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
  pointer-events: none;
}

/* Node with no thumbnail: slightly darken accent for legibility */
.node:not(.has-thumbnail) {
  background: color-mix(in srgb, var(--accent, var(--color-default-accent)) 85%, var(--color-text));
}

/* ── Connector handles ───────────────────────────────── */
.node-handle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: var(--radius-round);
  background: var(--bg);
  border: var(--border-strong) solid var(--color-node-border);
  z-index: 3;
  cursor: crosshair;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

@media (hover: hover) and (pointer: fine) {
  .node:hover:not(.selected) {
    box-shadow: 0 12px 32px rgba(17, 17, 17, 0.14);
  }

  .node-handle:hover {
    background: var(--blue);
    border-color: var(--blue);
    transform: translateY(-50%) scale(1.3);
  }
}

.node-handle--left  { left:  -7px; }
.node-handle--right { right: -7px; }

/* ── Inner title / year ──────────────────────────────── */
.node-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 9px 13px;
  pointer-events: none;
  z-index: 2;
}

.node-label {
  font-family: var(--font-category);
  font-style: normal;
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--node-title-color, var(--color-node-title));
}

.node-year {
  font-family: var(--font-category);
  font-style: normal;
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--node-year-color, var(--color-node-caption));
}

/* Thumbnail captions sit beside the image instead of covering it. */
.node.has-thumbnail .node-inner {
  inset: 0;
  display: block;
  padding: 0;
}

.node.has-thumbnail .node-label,
.node.has-thumbnail .node-year {
  position: absolute;
  left: 0;
  width: 100%;
  color: var(--color-text);
  text-align: left;
}

.node.has-thumbnail .node-label {
  bottom: calc(100% + 7px);
}

.node.has-thumbnail .node-year {
  top: calc(100% + 7px);
}

/* ── Deselect × button ───────────────────────────────── */
.node-close {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: var(--color-node-control);
  border: none;
  color: var(--color-node-control-text);
  font-size: var(--text-md);
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.node.selected .node-close { display: flex; }

/* ── Resize handle ───────────────────────────────────── */
.node-resize {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 10px;
  height: 10px;
  background: var(--blue);
  border: var(--border-strong) solid var(--bg);
  border-radius: var(--radius-xs);
  cursor: se-resize;
  z-index: 5;
  display: none;
}

.node.selected .node-resize { display: block; }

/* ── Filter bar ──────────────────────────────────────── */
#filter-bar {
  position: absolute;
  bottom: 1.75rem;
  left: 1.75rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: flex-start;
}

.filter-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: var(--font-category);
  font-style: normal;
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
  line-height: 1;
}

@media (hover: hover) and (pointer: fine) {
  .filter-btn:hover { color: var(--fg); }
}

.filter-btn:active { transform: scale(0.97); }

.filter-btn.active {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.filter-sep {
  font-family: var(--font-category);
  font-style: normal;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  opacity: 0.5;
  pointer-events: none;
}

/* ── Timeline ─────────────────────────────────────────── */
.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-toggle-btn { font-size: var(--text-xs); letter-spacing: 0.16em; }

.timeline-years {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  transition:
    max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease;
}

.timeline-years.open { max-width: 500px; opacity: 1; }

/* ── Mobile list view ────────────────────────────────── */
#mobile-list {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  padding: 4.5rem 1rem 2rem;
  background: transparent;
  display: none;
}

@media (max-width: 767px) {
  #canvas-section { display: none; }
  #mobile-list    { display: block; }
}

.mobile-projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding-bottom: 2rem;
}

@media (max-width: 380px) {
  .mobile-projects-grid { grid-template-columns: 1fr; }
}

.mobile-card {
  aspect-ratio: 3/2;
  background: var(--accent, var(--color-default-accent));
  border: var(--border-strong) solid var(--accent, var(--color-default-accent));
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}

.mobile-card-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.75;
}

.mobile-card-label {
  font-family: var(--font-category);
  font-style: normal;
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-node-title);
  position: relative;
  z-index: 1;
}


.mobile-card-caption {
  font-family: var(--font-category);
  font-style: normal;
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  color: var(--color-node-caption);
  text-transform: uppercase;
  text-align: right;
  position: relative;
  z-index: 1;
}
