/* "The ripple": interactive visual for the case From one application to a landscape */

.ripple {
  margin: 32px 0 8px;
}

.ripple-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.ripple-switch {
  display: inline-flex;
  border: var(--line-w) solid var(--line);
}
.ripple-switch button {
  padding: 8px 16px;
  background: transparent;
  color: var(--text);
  border: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.ripple-switch button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}
.ripple .btn {
  padding: 8px 18px;
}

.ripple-stage {
  position: relative;
  aspect-ratio: 8 / 4;
  border: var(--line-w) solid var(--line);
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 12.5% 25%;
  filter: var(--line-glow);
  overflow: hidden;
}
@media (max-width: 600px) {
  .ripple-stage {
    aspect-ratio: 4 / 6;
    background-size: 25% 16.667%;
  }
}

.ripple-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.ripple-svg .links line {
  stroke: var(--line);
  stroke-width: 2;
  stroke-dasharray: 4 5;
  vector-effect: non-scaling-stroke;
}

/* The ring: scales from the centre of the block that was hit */
.ripple .ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0);
  opacity: 0;
}
.ripple .ring.go {
  animation: ripple-forest 1.1s ease-out forwards;
}
.ripple[data-mode="landscape"] .ring {
  stroke: var(--green);
}
.ripple[data-mode="landscape"] .ring.go {
  animation: ripple-landscape 0.9s ease-out 2 forwards;
}
@keyframes ripple-forest {
  0% { transform: scale(0); opacity: 1; }
  80% { opacity: 0.9; }
  100% { transform: scale(9); opacity: 0; }
}
@keyframes ripple-landscape {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Blocks */
.ripple .blk {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  margin: 0;
  padding: clamp(6px, 1.4vw, 14px);
  background: var(--bg-raised);
  color: var(--text);
  border: var(--line-w) solid var(--line);
  /* A small margin inside the cell, so separate blocks look separate */
  box-shadow: inset 0 0 0 4px var(--bg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
.ripple.ready .blk {
  transition:
    left 0.7s ease, top 0.7s ease, width 0.7s ease, height 0.7s ease,
    opacity 0.5s ease, background-color 0.25s ease, color 0.25s ease,
    box-shadow 0.25s ease;
}
.ripple .blk strong {
  font-size: clamp(0.72rem, 1.6vw, 1.05rem);
  line-height: 1.15;
}
.ripple .blk small {
  font-family: var(--mono);
  font-size: clamp(0.58rem, 1.1vw, 0.72rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
}
.ripple .blk:hover,
.ripple .blk:focus-visible {
  border-color: var(--accent);
}
.ripple .blk:focus-visible {
  outline-offset: -6px;
}

/* In the forest the blocks look alike: all copies of the same thing */
.ripple[data-mode="forest"] .blk:not(.data) {
  background-image: repeating-linear-gradient(
    -59deg,
    var(--line-soft) 0 1px,
    transparent 1px 10px
  );
}

/* Data models in the landscape: hatched yellow, smaller */
.ripple .blk.data {
  background-image: repeating-linear-gradient(
    -59deg,
    color-mix(in srgb, var(--accent-fill) 45%, transparent) 0 2px,
    transparent 2px 12px
  );
  justify-content: center;
}

.ripple .blk.gone {
  opacity: 0;
  pointer-events: none;
}

/* Hit by the hotfix */
.ripple .blk.hit {
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 4px var(--bg), var(--glow);
}
.ripple .blk.hit small {
  color: var(--on-accent);
}
.ripple[data-mode="landscape"] .blk.hit {
  background: var(--green);
  box-shadow: inset 0 0 0 4px var(--bg), var(--green-glow);
}

.ripple-status {
  min-height: 3.2em;
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
}
.ripple-status::before {
  content: "→ ";
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .ripple.ready .blk {
    transition: none;
  }
  .ripple .ring {
    display: none;
  }
}
