@tailwind base;
@tailwind components;
@tailwind utilities;

/*
  Entropyk — Modelica/Dymola diagram aesthetic.
  Light engineering canvas: white diagram sheet, dotted grid, schematic
  component icons with square fluid connectors and orthogonal connections.
  Chrome is a quiet CAD-tool grey so the white diagram sheet is the focus.
*/
:root {
  --sheet: #ffffff; /* diagram canvas */
  --sheet-grid: #e7ecf2; /* grid dots */
  --chrome: #eef1f5; /* app chrome / panels */
  --chrome-2: #f6f8fb; /* raised inputs */
  --panel: #ffffff;

  --line: #d6dde6; /* hairline borders */
  --line-strong: #b9c3cf;

  --ink: #1a2330; /* primary text */
  --ink-dim: #5d6b7c; /* secondary */
  --ink-faint: #93a0b0; /* tertiary */

  --connector: #1565c0; /* legacy default (water) */
  --wire: #36475a; /* unknown medium */
  --wire-hi: #1565c0;

  /* TIL / Modelica HVAC medium colours */
  --media-refrigerant: #2e7d32;
  --media-water: #1565c0;
  --media-air: #f9a825;

  --accent: #1b6fe0; /* primary action */
  --hot: #e23b2e; /* condenser / high pressure */
  --cold: #1f86e0; /* evaporator / low pressure */
  --liquid: #e0902b; /* liquid line */
  --ok: #1f9d57;
  --warn: #c9821a;

  /* Top command bar — dark CAD chrome */
  --bar: #1c2634;
  --bar-ink: #c4cede;
  --bar-accent: #5eb0ff;

  --font-display: var(--font-display), ui-sans-serif, system-ui, sans-serif;
  --font-mono: var(--font-mono), ui-monospace, "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--chrome);
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input,
select,
button {
  font-family: inherit;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 6px;
  border: 2px solid var(--chrome);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
}

/* ── React Flow — Modelica diagram sheet ────────────────────── */
.react-flow {
  background: var(--sheet);
}
.react-flow__attribution {
  display: none;
}

/* Square fluid connectors (Modelica convention); fill set per medium in JS */
.react-flow__handle {
  width: 8px;
  height: 8px;
  border-radius: 0;
  background: var(--connector);
  border: 1px solid rgba(15, 28, 45, 0.55);
  transition: transform 0.1s ease, filter 0.1s ease;
}
.react-flow__handle:hover,
.react-flow__handle.connectingfrom,
.react-flow__handle.connectingto {
  transform: scale(1.25);
  filter: brightness(0.92);
}
.react-flow__handle-left {
  left: -6px;
}
.react-flow__handle-right {
  right: -6px;
}
.react-flow__handle-top {
  top: -6px;
}
.react-flow__handle-bottom {
  bottom: -6px;
}

.react-flow__edge-path {
  stroke: var(--wire);
  stroke-width: 1.75;
}
.react-flow__edge.selected .react-flow__edge-path,
.react-flow__edge:hover .react-flow__edge-path {
  stroke: var(--wire-hi);
  stroke-width: 2.25;
}
.react-flow__connection-path {
  stroke: var(--connector);
  stroke-width: 1.75;
  stroke-dasharray: 4 3;
}

.react-flow__controls {
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(20, 40, 70, 0.08);
  overflow: hidden;
}
.react-flow__controls-button {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: var(--ink-dim);
  width: 26px;
  height: 26px;
}
.react-flow__controls-button:hover {
  background: var(--chrome-2);
  color: var(--ink);
}
.react-flow__controls-button svg {
  fill: currentColor;
}

.react-flow__node.selected {
  z-index: 10;
}

/* ── Bibliothèque — accordion + stagger reveal ──────────────── */
.palette-cat-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.palette-cat-body.is-open {
  grid-template-rows: 1fr;
}
.palette-cat-inner {
  overflow: hidden;
  min-height: 0;
}

@keyframes palette-item-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.palette-cat-body.is-open .palette-item {
  animation: palette-item-in 200ms ease-out both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

.palette-cat-toggle {
  transition: background-color 140ms ease;
}

.ek-node {
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .palette-cat-body {
    transition: none;
  }
  .palette-cat-body.is-open .palette-item {
    animation: none;
  }
  .ek-node {
    transition: none;
  }
}
