/*
 * "Jak to funguje": four steps on the left, an animated diagram on a dark panel on the right
 * (js/flow.js). Tokens come from styles.css.
 */

.flow {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: stretch;
}

/* ------------------------------------------------------------------- steps */

.flow-steps {
  display: grid;
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-step {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  width: 100%;
  padding: 26px 0 26px;
  border: 0;
  border-top: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.flow-steps li:last-child .flow-step {
  padding-bottom: 8px;
}

.flow-step:hover {
  border-top-color: #c9c7c2;
}

.flow-step[aria-pressed="true"] {
  border-top-color: var(--ink);
}

.flow-step-n {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid #c9c7c2;
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.flow-step[aria-pressed="true"] .flow-step-n {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.flow-step-title {
  display: block;
  color: var(--muted);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  transition: color 0.2s ease;
}

.flow-step:hover .flow-step-title,
.flow-step[aria-pressed="true"] .flow-step-title {
  color: var(--ink);
}

.flow-step-text {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.0625rem;
  line-height: 1.55;
}

/* the progress line runs along the top border of the active step */
.flow-step-bar {
  position: absolute;
  left: 0;
  top: -2px;
  display: none;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

.flow[data-autoplay] .flow-step[aria-pressed="true"] .flow-step-bar {
  display: block;
  animation: flow-bar var(--flow-step-time, 4s) linear forwards;
}

.flow[data-paused][data-autoplay] .flow-step[aria-pressed="true"] .flow-step-bar {
  animation-play-state: paused;
}

@keyframes flow-bar {
  to {
    transform: scaleX(1);
  }
}

/* ------------------------------------------------------------------- panel */

.flow-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(20px, 4vw, 40px);
  border-radius: var(--radius);
  background-color: var(--dark);
  background-image: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.075) 1px,
    transparent 1.6px
  );
  background-size: 20px 20px;
  color: var(--on-dark);
  container: flow / inline-size;
}

.flow-panel :focus-visible {
  outline-color: #ffffff;
}

.flow-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.2fr);
  grid-template-rows: repeat(3, auto);
  column-gap: clamp(24px, 9cqw, 72px);
  row-gap: 18px;
  align-items: center;
}

.flow-svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.flow-node[data-node="web"] {
  grid-column: 1;
  grid-row: 1;
}
.flow-node[data-node="email"] {
  grid-column: 1;
  grid-row: 3;
}
.flow-node[data-node="hub"] {
  grid-column: 2;
  grid-row: 2;
}
.flow-node[data-node="console"] {
  grid-column: 3;
  grid-row: 1;
}
.flow-node[data-node="admin"] {
  grid-column: 3;
  grid-row: 2;
}
.flow-node[data-node="phone"] {
  grid-column: 3;
  grid-row: 3;
}

.flow-node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 14px 10px 10px;
  border: 1.5px solid #34343e;
  border-radius: 12px;
  background: var(--dark-raised);
  color: var(--on-dark-muted);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.25;
  transition:
    border-color 0.25s ease,
    color 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.25s ease;
}

.flow-node.is-lit {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 109, 31, 0.12);
}

.flow-ico {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #2f2f3a;
  color: var(--on-dark-muted);
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

.flow-ico svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.flow-node.is-lit .flow-ico {
  background: rgba(255, 109, 31, 0.18);
  color: var(--accent);
}

.flow-label small {
  display: block;
  margin-top: 1px;
  color: var(--on-dark-muted);
  font-size: 0.75rem;
  font-weight: 550;
}

.flow-node[data-node="hub"] {
  padding: 14px 14px 14px 12px;
  background: #2a2a33;
  font-size: 0.9375rem;
}

.flow-node[data-node="hub"] .flow-label {
  white-space: nowrap;
}

.flow-node[data-node="hub"] .flow-ico {
  background: var(--accent);
  color: var(--accent-ink);
}

.flow-node[data-node="hub"] .flow-ico svg {
  fill: currentColor;
  stroke: none;
}

.flow-node[data-node="hub"].is-lit .flow-ico {
  background: var(--accent);
  color: var(--accent-ink);
}

/* the ring that spreads when a message lands in the hub (step 2) */
.flow-node[data-node="hub"]::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  opacity: calc(1 - var(--ring, 1));
  transform: scale(calc(1 + var(--ring, 1) * 0.1));
  pointer-events: none;
}

/* ------------------------------------------------------------- connectors */

.flow-link {
  fill: none;
  stroke: #3c3c47;
  stroke-width: 2;
}

.flow-link-on {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.flow-link-on.is-on {
  opacity: 0.75;
}

.flow-link-on[data-dashed] {
  stroke-dasharray: 3 6;
}

.flow-arrow path {
  fill: var(--accent);
}

.flow-packet {
  fill: var(--accent);
}

.flow-packet-halo {
  fill: var(--accent);
  opacity: 0.22;
}

/* ------------------------------------------------------------------ footer */

.flow-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: clamp(20px, 3vw, 28px);
}

.flow-count {
  color: var(--on-dark-muted);
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.flow-toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid #4a4a56;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.flow-toggle[hidden] {
  display: none;
}

.flow-toggle:hover {
  background: #2a2a33;
}

.flow-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.flow-toggle[data-state="playing"] .flow-toggle-play,
.flow-toggle[data-state="paused"] .flow-toggle-pause {
  display: none;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .flow {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* narrow panel: the nodes stack vertically, the lines run top to bottom */
@container flow (max-width: 560px) {
  .flow-stage {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 8px;
    row-gap: 48px;
  }

  .flow-node[data-node="web"] {
    grid-column: 1 / 4;
    grid-row: 1;
  }
  .flow-node[data-node="email"] {
    grid-column: 4 / 7;
    grid-row: 1;
  }
  .flow-node[data-node="hub"] {
    grid-column: 1 / 7;
    grid-row: 2;
    justify-self: center;
    width: min(100%, 250px);
  }
  .flow-node[data-node="console"] {
    grid-column: 1 / 3;
    grid-row: 3;
  }
  .flow-node[data-node="admin"] {
    grid-column: 3 / 5;
    grid-row: 3;
  }
  .flow-node[data-node="phone"] {
    grid-column: 5 / 7;
    grid-row: 3;
  }

  .flow-node {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 84px;
    padding: 10px 6px;
    font-size: 0.75rem;
    text-align: center;
  }

  .flow-node[data-node="hub"] {
    flex-direction: row;
    min-height: 60px;
    padding: 12px 16px 12px 12px;
    font-size: 0.9375rem;
    text-align: left;
  }

  .flow-ico {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 640px) {
  .flow-step {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 14px;
    padding: 22px 0;
  }

  .flow-step-n {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }

  .flow-step-title {
    font-size: 1.1875rem;
  }

  .flow-step-text {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-step-bar {
    display: none !important;
  }

  .flow-link-on.is-on {
    opacity: 1;
  }

  .flow-node[data-node="hub"]::after {
    display: none;
  }
}
