/* ============================================================
   DRY LAB / WET LAB EXCHANGE  —  static/dw-flip.css

   Figure 9.1 in the Wet lab integration chapter. Eight tiles,
   four stages, dry lab above and wet lab below. Each tile flips
   on click to show what that side specified.

   Every class is prefixed dw- so nothing here can reach the
   rail, the model page, the nav or Bootstrap.

   Only the eight glyphs are images: one file each, painted by
   CSS through a mask so they follow the light/dark theme. Tile
   colours live in this file. Headers, labels, connectors and all
   card text are live text.
   ============================================================ */

.dw {
  margin: 0;
  --dw-ink: #14141e;
}
:root[data-theme="dark"] .dw { --dw-ink: #ffffff; }

.dw-grid {
  display: grid;
  grid-template-columns: 40px repeat(4, minmax(0, 1fr));
  gap: 0 14px;
  max-width: 760px;
  margin-inline: auto;
}

/* ---------- stage headers ---------- */
.ir-main .dw-head {
  grid-row: 1;
  text-align: center;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 14px;
}

/* ---------- lane labels ---------- */
.dw-lane { grid-column: 1; display: flex; align-items: center; justify-content: center; }
.dw-lane span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- the tiles ---------- */
.dw-card {
  all: unset;
  box-sizing: border-box;
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1 / 1;
  container-type: inline-size;
  perspective: 1200px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dw-card:focus-visible {
  outline: 3px solid var(--ir-accent);
  outline-offset: 5px;
  border-radius: 22px;
}
.dw-in {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.3, .1, .2, 1);
}
.dw-card[aria-pressed="true"] .dw-in { transform: rotateY(180deg); }

.dw-f {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--tile);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.dw-b {
  transform: rotateY(180deg);
  display: grid;
  align-content: center;
  padding: 9%;
}
.ir-main .dw-b p {
  margin: 0;
  font-size: 7.4cqw;
  line-height: 1.45;
  font-weight: 600;
  letter-spacing: .005em;
  text-align: left;
  hyphens: none;
  -webkit-hyphens: none;
  color: var(--dw-ink);
}

/* one file per glyph, recoloured by the theme */
.dw-ico {
  width: 46%;
  height: 46%;
  background: var(--dw-ink);
  -webkit-mask: var(--ico) center / contain no-repeat;
          mask: var(--ico) center / contain no-repeat;
}

@media (hover: hover) { .dw-card:hover .dw-f { filter: brightness(1.06); } }

/* ---------- connectors ---------- */
.dw-link {
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 0;
}
.dw-link b {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font: 600 10px/1 inherit;
  letter-spacing: -.005em;
  color: var(--dw-ink);
  white-space: nowrap;
}
.dw-link i {
  position: relative;
  display: block;
  width: 2.5px;
  align-self: stretch;
  background: var(--dw-ink);
  border-radius: 2px;
}
.dw-link i::before, .dw-link i::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 11px;
  height: 11px;
  margin-left: -5.5px;
  border-radius: 50%;
  background: var(--dw-ink);
}
.dw-link i::before { top: -5px; }
.dw-link i::after  { bottom: -5px; }

/* ---------- reveal on scroll ---------- */
.dw-rv {
  opacity: 0;
  transform: translateY(12px) scale(.96);
  transition: opacity .5s ease, transform .6s cubic-bezier(.2, 1.2, .4, 1);
}
.dw-rv.dw-on { opacity: 1; transform: none; }

.ir-main .dw-hint {
  text-align: center;
  margin: 20px 0 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ir-accent);
  opacity: .6;
}
.dw-bar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.dw-bar button {
  font: 700 11px/1 inherit;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ir-accent);
  background: none;
  border: 1px solid color-mix(in srgb, var(--ir-accent) 35%, transparent);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

@media (max-width: 860px) {
  .dw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .dw-lane { display: none; }
  .ir-main .dw-head {
  grid-row: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 10px;
}
  .dw-card { grid-column: auto !important; grid-row: auto !important; }
  .dw-link { grid-column: 1 / -1; grid-row: auto; padding: 4px 0 10px; }
  .dw-link b { writing-mode: horizontal-tb; transform: none; font-size: 11px; }
  .dw-link i { width: auto; height: 2.5px; align-self: auto; flex: 1; }
  .dw-link i::before { top: 50%; left: 0; margin: -5.5px 0 0 0; }
  .dw-link i::after  { bottom: auto; top: 50%; left: auto; right: 0; margin: -5.5px 0 0 0; }
  .ir-main .dw-b p {
    margin: 0;
    font-size: 7.4cqw;
    line-height: 1.45;
    text-align: left;
    hyphens: none;
    -webkit-hyphens: none;
    color: var(--dw-ink);
    }
}
@media (prefers-reduced-motion: reduce) { .dw-in, .dw-rv { transition: none; } }