/* Culinary Routes – the route map.
   Styles and animation for the SVG produced by lib/route.mjs. */

.route {
  display: block;
  max-width: 100%;
  height: auto;
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
}
.route text {
  fill: currentColor;
  pointer-events: none;
}

/* Lanes */
.route__band { fill: var(--line); opacity: var(--band-alpha); }
.route__band-name {
  font-size: calc(10.5px * var(--fs, 1));
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  fill: var(--line);
  opacity: 0.9;
}

/* Tracks */
.tr__base {
  fill: none;
  stroke: var(--line);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.35s var(--ease-out);
}
.tr--feed .tr__base { stroke-width: 5; }
.tr__flow {
  fill: none;
  stroke: var(--flow);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 13;
  animation: route-flow 1.5s linear infinite;
  transition: opacity 0.35s var(--ease-out);
}
.tr--feed .tr__flow { stroke-width: 1.6; }
@keyframes route-flow { to { stroke-dashoffset: -14; } }

/* Nodes */
.nd { transition: opacity 0.35s var(--ease-out), filter 0.35s var(--ease-out); }
.nd__pop { transform-box: fill-box; transform-origin: center; }
.nd__icon { color: var(--ink); }

.nd--station .nd__ring {
  fill: color-mix(in srgb, var(--cat, var(--paper-2)) 24%, var(--paper-2));
  stroke: var(--line);
  stroke-width: 3;
}
.cat-produce { --cat: var(--cat-produce); }
.cat-dairy { --cat: var(--cat-dairy); }
.cat-protein { --cat: var(--cat-protein); }
.cat-grain { --cat: var(--cat-grain); }
.cat-sweet { --cat: var(--cat-sweet); }
.cat-fat { --cat: var(--cat-fat); }
.cat-spice { --cat: var(--cat-spice); }
.cat-liquid { --cat: var(--cat-liquid); }
.cat-pantry { --cat: var(--cat-pantry); }

.nd__name { font-size: calc(11.5px * var(--fs, 1)); font-weight: 700; }
.nd__qty { font-size: calc(10.5px * var(--fs, 1)); font-weight: 500; fill: var(--ink-3); }
.nd__side { font-size: calc(11.5px * var(--fs, 1)); }
.nd__below { font-size: calc(10.5px * var(--fs, 1)); }
.nd__below .nd__qty { font-size: calc(10px * var(--fs, 1)); }

.nd--process { cursor: pointer; outline: none; }
.nd__box {
  fill: var(--paper-2);
  stroke: var(--ink);
  stroke-width: 2.5;
  transition: stroke 0.2s, stroke-width 0.2s, filter 0.3s;
}
.nd--process:hover .nd__box,
.nd--process:focus-visible .nd__box,
.nd--process.is-selected .nd__box {
  stroke: var(--line);
  stroke-width: 3.5;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--line) 60%, transparent));
}
.nd__out {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: calc(12.5px * var(--fs, 1));
  fill: var(--line);
}
.nd__verb { font-size: calc(10.5px * var(--fs, 1)); font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.nd__meta { font-size: calc(10px * var(--fs, 1)); font-weight: 500; fill: var(--ink-2); }
.nd__badge circle { fill: var(--ink); stroke: var(--paper-2); stroke-width: 2; }
.nd__num { font-size: 10px; font-weight: 800; fill: var(--paper); }

.nd--terminus .nd__halo {
  fill: var(--line);
  opacity: 0.16;
  transform-box: fill-box;
  transform-origin: center;
  animation: route-halo 2.8s ease-in-out infinite;
}
.nd--terminus .nd__ring2 { fill: none; stroke: var(--line); stroke-width: 4; }
.nd--terminus .nd__ring { fill: var(--paper-2); stroke: var(--ink); stroke-width: 2.5; }
.nd__title { font-family: var(--font-display); font-weight: 700; font-size: calc(15px * var(--fs, 1)); }
.nd__yield { font-size: calc(10.5px * var(--fs, 1)); font-weight: 500; fill: var(--ink-2); }
@keyframes route-halo {
  0%, 100% { transform: scale(0.9); opacity: 0.1; }
  50% { transform: scale(1.12); opacity: 0.22; }
}

/* Draw-on choreography. Columns light up left to right. */
.route.is-animated .tr__base {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: route-draw 0.75s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: var(--d, 0s);
}
.route.is-animated .tr__flow {
  opacity: 0;
  animation: route-flow 1.5s linear infinite, route-fade 0.4s forwards;
  animation-delay: 0s, calc(var(--d, 0s) + 0.55s);
}
.route.is-animated .nd__pop {
  opacity: 0;
  transform: scale(0.55);
  animation: route-pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.25) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes route-draw { to { stroke-dashoffset: 0; } }
@keyframes route-fade { to { opacity: 1; } }
@keyframes route-pop { to { opacity: 1; transform: scale(1); } }

/* Living process icons. */
.nd--process .spin,
.nd--process .spin-slow,
.nd--process .beat,
.nd--process .wobble,
.nd--process .rock,
.nd--process .press,
.nd--process .squish,
.nd--process .chop,
.nd--process .slide,
.nd--process .slide-x,
.nd--process .hand,
.nd--process .rise,
.nd--process .bob,
.nd--process .tilt,
.nd--process .flame,
.nd--process .twinkle,
.nd--process .stir,
.nd--process .mercury {
  transform-box: fill-box;
  transform-origin: center;
}
.nd--process .spin { animation: ic-spin 1.1s linear infinite; }
.nd--process .spin-slow { animation: ic-spin 10s linear infinite; }
.nd--process .beat { animation: ic-beat 0.55s ease-in-out infinite alternate; }
.nd--process .wobble { transform-origin: 50% 100%; animation: ic-wobble 0.7s ease-in-out infinite alternate; }
.nd--process .rock { transform-origin: 50% 100%; animation: ic-rock 1.3s ease-in-out infinite alternate; }
.nd--process .press { animation: ic-press 1s ease-in-out infinite alternate; }
.nd--process .squish { transform-origin: 50% 100%; animation: ic-squish 1s ease-in-out infinite alternate; }
.nd--process .chop { transform-origin: 15% 90%; animation: ic-chop 0.7s ease-in-out infinite; }
.nd--process .slide { animation: ic-slide 1s ease-in-out infinite alternate; }
.nd--process .slide-x { animation: ic-slide-x 1.4s ease-in-out infinite alternate; }
.nd--process .hand { transform-origin: 50% 100%; animation: ic-spin 4s linear infinite; }
.nd--process .rise { transform-origin: 50% 100%; animation: ic-rise 2.6s ease-in-out infinite alternate; }
.nd--process .bob { animation: ic-slide 1.2s ease-in-out infinite alternate; }
.nd--process .tilt { transform-origin: 20% 100%; animation: ic-tilt 1.8s ease-in-out infinite alternate; }
.nd--process .flame { transform-origin: 0% 50%; animation: ic-flame 0.45s ease-in-out infinite alternate; }
.nd--process .twinkle { animation: ic-twinkle 1.6s ease-in-out infinite; }
.nd--process .stir { transform-origin: 0% 100%; animation: ic-stir 1.2s ease-in-out infinite alternate; }
.nd--process .mercury { transform-origin: 50% 100%; animation: ic-rise 2s ease-in-out infinite alternate; }
.nd--process .heat path,
.nd--process .steam path,
.nd--process .sizzle circle,
.nd--process .fall circle {
  transform-box: fill-box;
  transform-origin: center;
}
.nd--process .heat path { animation: ic-heat 1.6s ease-in-out infinite; }
.nd--process .steam path { animation: ic-heat 2.2s ease-in-out infinite; }
.nd--process .sizzle circle { animation: ic-sizzle 1s ease-out infinite; }
.nd--process .fall circle { animation: ic-fall 1.2s linear infinite; }
.nd--process .heat path:nth-child(2),
.nd--process .steam path:nth-child(2),
.nd--process .sizzle circle:nth-child(2),
.nd--process .fall circle:nth-child(2) { animation-delay: 0.35s; }
.nd--process .heat path:nth-child(3),
.nd--process .sizzle circle:nth-child(3),
.nd--process .fall circle:nth-child(3) { animation-delay: 0.7s; }

@keyframes ic-spin { to { transform: rotate(360deg); } }
@keyframes ic-beat { from { transform: scaleX(1); } to { transform: scaleX(-1); } }
@keyframes ic-wobble { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
@keyframes ic-rock { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
@keyframes ic-press { from { transform: translateY(0); } to { transform: translateY(2.2px); } }
@keyframes ic-squish { from { transform: scale(1, 1); } to { transform: scale(1.08, 0.82); } }
@keyframes ic-chop { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-14deg) translateY(1px); } }
@keyframes ic-slide { from { transform: translateY(-1.5px); } to { transform: translateY(1.5px); } }
@keyframes ic-slide-x { from { transform: translateX(-2.5px); } to { transform: translateX(2.5px); } }
@keyframes ic-rise { from { transform: scaleY(0.78); } to { transform: scaleY(1); } }
@keyframes ic-tilt { from { transform: rotate(0); } to { transform: rotate(-20deg); } }
@keyframes ic-flame { from { transform: scaleX(0.8) scaleY(0.9); } to { transform: scaleX(1.2) scaleY(1.1); } }
@keyframes ic-twinkle { 0%, 100% { opacity: 0.2; transform: scale(0.7) rotate(0); } 50% { opacity: 1; transform: scale(1.1) rotate(45deg); } }
@keyframes ic-stir { from { transform: rotate(-28deg); } to { transform: rotate(22deg); } }
@keyframes ic-heat { 0% { opacity: 0.15; transform: translateY(2px); } 50% { opacity: 1; } 100% { opacity: 0.15; transform: translateY(-2.5px); } }
@keyframes ic-sizzle { 0% { opacity: 0; transform: translateY(2px) scale(0.6); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-4px) scale(1.1); } }
@keyframes ic-fall { 0% { opacity: 0; transform: translateY(-3px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(3px); } }

/* Focus a line (legend hover) */
.route.has-focus .tr:not(.is-hot),
.route.has-focus .nd:not(.is-hot) { opacity: 0.14; }
.route.has-focus .route__band:not(.is-hot) { opacity: 0.02; }

/* Cook mode */
.route.is-cooking .tr:not(.is-done):not(.is-active),
.route.is-cooking .nd:not(.is-done):not(.is-active) { opacity: 0.16; filter: grayscale(0.7); }
.route.is-cooking .nd.is-done .nd__box { stroke: var(--line); }
.route.is-cooking .nd.is-active .nd__box {
  stroke: var(--line);
  stroke-width: 4.5;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--line) 75%, transparent));
}
.route.is-cooking .nd.is-active .nd__ring { stroke-width: 4; }
.route.is-cooking .tr.is-active .tr__flow { stroke-width: 3; }
.route.is-cooking .tr:not(.is-active) .tr__flow { animation-play-state: paused; }

/* Thumbnails: quieter, no label room. */
.route--thumb .tr__base { stroke-width: 8; }
.route--thumb .tr--feed .tr__base { stroke-width: 6; }
.route--thumb .nd--station .nd__ring { stroke-width: 3.5; }
.route--thumb .nd__box { stroke-width: 3; }

/* Fit versus natural size: the map scrolls on small screens. */
.route-map {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.route-map > .route {
  width: 100%;
  min-width: calc(var(--w) * 0.78px);
}
.route-map.is-natural > .route { width: calc(var(--w) * 1px); max-width: none; }
.route-map.route-map--fit > .route { min-width: 0; }
@media (max-width: 720px) {
  .route-map > .route { min-width: calc(var(--w) * 0.9px); }
}

@media (prefers-reduced-motion: reduce) {
  .route *, .route { animation: none !important; }
  .route .nd__pop { opacity: 1 !important; transform: none !important; }
  .route .tr__base { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
  .route .tr__flow { display: none; }
}
.route.is-static *, .route.is-static { animation: none !important; }
.route.is-static .nd__pop { opacity: 1 !important; transform: none !important; }
.route.is-static .tr__base { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
.route.is-static .tr__flow { display: none; }

@media print {
  .route *, .route { animation: none !important; }
  .route .nd__pop { opacity: 1 !important; transform: none !important; }
  .route .tr__base { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
  .route .tr__flow { display: none; }
  .route-map { overflow: visible; }
  .route-map > .route { min-width: 0; width: 100%; }
}
