/* "What is iroh?": the post's own cover art and its at-a-glance block.
   Linked from that post, in every language, and from the blog indexes, whose
   row for it carries the same art; every selector starts with .iroh- (or
   scopes one) so nothing reaches another page.

   One visual language for both: a solid tint line is the direct path, a
   dashed, dimmed line is the relay, and a device is named by its key. */

/* ------------------------------------------------------------ cover art --- */

.iroh-cover {
  justify-self: center;
  width: min(100%, 320px);
}

.iroh-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: 380px;
  overflow: visible;
}

.iroh-art text {
  font-family: var(--font);
}

.iroh-relay {
  fill: var(--surface);
  stroke: var(--hairline-strong);
  stroke-dasharray: 5 4;
}

.iroh-relay-label {
  fill: var(--label-2);
  font-size: 14px;
}

.iroh-relay-path {
  fill: none;
  stroke: var(--label-3);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
  opacity: 0.7;
}

.iroh-direct {
  stroke: var(--tint);
  stroke-width: 3;
  stroke-linecap: round;
}

.iroh-direct-label {
  fill: var(--tint);
  font-size: 15px;
  font-weight: 600;
}

.iroh-device {
  fill: var(--surface);
  stroke: var(--label-3);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.iroh-notch {
  fill: var(--label-3);
}

.iroh-key {
  fill: none;
  stroke: var(--tint);
  stroke-width: 2;
  stroke-linecap: round;
}

.iroh-id {
  fill: var(--tint-fill);
  stroke: var(--tint-line);
}

.iroh-art .iroh-id-text {
  fill: var(--label);
  font-family: var(--mono);
  font-size: 12.5px;
}

.iroh-art .iroh-ip {
  fill: var(--label-3);
  font-family: var(--mono);
  font-size: 11px;
}

.iroh-ip-strike {
  stroke: var(--label-3);
  stroke-width: 1.25;
}

/* At rest the packets wait unseen; the drawing is complete without them. */
.iroh-pkt {
  fill: var(--tint);
  opacity: 0;
}

/* Hole punching, once every few seconds: both ends send at the same moment
   and the packets meet in the middle. */
@media (prefers-reduced-motion: no-preference) {
  .iroh-pkt {
    animation: 4.2s var(--ease-out-soft) 0.6s infinite;
  }

  .iroh-pkt-out {
    animation-name: iroh-punch-out;
  }

  .iroh-pkt-back {
    animation-name: iroh-punch-back;
  }
}

@keyframes iroh-punch-out {
  0% {
    opacity: 0;
    transform: translateX(0);
  }
  8% {
    opacity: 1;
  }
  40% {
    opacity: 1;
    transform: translateX(62px);
  }
  52%,
  100% {
    opacity: 0;
    transform: translateX(66px);
  }
}

@keyframes iroh-punch-back {
  0% {
    opacity: 0;
    transform: translateX(0);
  }
  8% {
    opacity: 1;
  }
  40% {
    opacity: 1;
    transform: translateX(-62px);
  }
  52%,
  100% {
    opacity: 0;
    transform: translateX(-66px);
  }
}

@media (min-width: 820px) {
  .iroh-cover {
    width: 340px;
    margin-top: 28px;
  }
}

/* The same art on the blog index, in the post's row (blog-list.css): under
   the copy on a phone, beside it on a wider screen. The packets wait while the
   row is closed. */
.post-art .iroh-cover {
  --post-art-top: 8px;
  width: 186px;
}

.post-card:not(.is-expanded) .iroh-pkt {
  animation-play-state: paused;
}

@media (min-width: 760px) {
  .post-art .iroh-cover {
    --post-art-top: 14px;
    width: 270px;
    margin-top: 0;
  }
}

/* ------------------------------------------------------- at a glance --- */

.iroh-glance {
  margin: 0 0 56px;
}

/* The order iroh tries, drawn as the cover draws it: key, solid, dashed. */
.iroh-order {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  align-items: center;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: var(--footnote);
  letter-spacing: var(--track-footnote);
}

.iroh-step {
  display: flex;
  align-items: center;
}

.iroh-step + .iroh-step::before {
  content: "";
  width: 22px;
  margin: 0 8px;
  border-top: 2px solid var(--tint);
}

.iroh-step.is-relay::before {
  border-top-style: dashed;
  border-top-color: var(--label-3);
}

.iroh-step.is-key {
  padding: 5px 11px;
  border-radius: var(--r-control);
  background: var(--tint-fill);
  box-shadow: inset 0 0 0 0.5px var(--tint-line);
  color: var(--label);
}

.iroh-step.is-direct {
  color: var(--tint);
  font-weight: 600;
}

.iroh-step.is-relay {
  color: var(--label-2);
}

/* Two columns that read across, like a ledger: what is exposed, what is not. */
.iroh-ledger {
  display: grid;
  border-radius: var(--r-group);
  background: var(--surface);
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
}

.iroh-ledger-col {
  padding: 18px 22px;
}

.iroh-ledger-col + .iroh-ledger-col {
  border-top: 0.5px solid var(--hairline-strong);
}

.iroh-ledger-head {
  margin: 0 0 10px;
  color: var(--label);
  font-size: var(--callout);
  font-weight: 600;
  letter-spacing: var(--track-callout);
}

.iroh-ledger-col ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.iroh-ledger-col li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--label-body);
  font-size: var(--callout);
  line-height: 1.45;
}

.iroh-ledger-col li::before {
  flex: none;
  width: 1em;
  font-weight: 700;
  text-align: center;
}

.iroh-ledger-col.is-sees li::before {
  content: "\25CF";
  color: var(--orange);
  font-size: 0.7em;
}

.iroh-ledger-col.is-hidden li::before {
  content: "\25CB";
  color: var(--green-ink);
  font-size: 0.7em;
}

.iroh-ledger-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 22px 14px;
  border-top: 0.5px solid var(--hairline);
  border-radius: 0 0 var(--r-group) var(--r-group);
  background: var(--well);
  color: var(--label-2);
  font-size: var(--footnote);
  line-height: 1.5;
}

.iroh-ledger-note a {
  color: var(--tint);
}

@media (min-width: 640px) {
  .iroh-ledger {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .iroh-ledger-col + .iroh-ledger-col {
    border-top: 0;
    border-left: 0.5px solid var(--hairline-strong);
  }
}
