/* Doppla — logo reveal (version 1.0.1)

   The converge from section 09 of the brand guidelines. Use it once per
   session at most — a first page load, a splash screen, the opening of a
   presentation. Never on a loop, never on every route change.

   Both blocks set off together and land together. Red starts close; blue
   starts at the end of the wordmark and crosses the whole lockup. Once they
   land, the hole opens and the wordmark fades up.

   Markup. The wordmark is drawn geometry, not text, so it is inline SVG.
   One hole mask covers both blocks, and its id must be unique on the page.

   Each block is two stacked rects: a flat one, which slides in, and a
   gradient one on top, which fades in once the blocks have landed, with
   the hole and the wordmark. The flat rect stays in place beneath it.
   Keep the order below: both of red's rects, then both of blue's. That
   way red never shows through blue while the gradients fade in.

     <div class="doppla-reveal">
       <svg class="doppla-reveal__mark" viewBox="0 0 64 64" aria-hidden="true">
         <defs>
           <mask id="doppla-hole" maskUnits="userSpaceOnUse" x="-400" y="-400" width="864" height="864">
             <rect x="-400" y="-400" width="864" height="864" fill="#fff"/>
             <circle class="doppla-reveal__hole"
                     cx="32" cy="32" r="0" fill="#000">
               <!-- the hole opens by growing its radius, which keeps it
                    centred in every browser. Copy the whole <animate>
                    element, with its easing. -->
               <animate attributeName="r" from="0" to="12" begin="650ms" dur="190ms" fill="freeze" calcMode="spline" keyTimes="0;1" keySplines="0 0 0.58 1"/>
             </circle>
           </mask>
           <!-- both gradients are centred on the hole, as in the static
                mark. They appear only after the blocks have landed, so
                they never move. -->
           <radialGradient id="doppla-hole-red-grad" gradientUnits="userSpaceOnUse"
                            cx="32" cy="32" r="34">
             <stop offset="0" stop-color="#C97356"/>
             <stop offset="1" stop-color="#A85235"/>
           </radialGradient>
           <radialGradient id="doppla-hole-blue-grad" gradientUnits="userSpaceOnUse"
                            cx="32" cy="32" r="34">
             <stop offset="0" stop-color="#2383AB"/>
             <stop offset="1" stop-color="#175973"/>
           </radialGradient>
         </defs>
         <!-- one mask on the group, not one on each rect, so both
              blocks share exactly the same hole edge -->
         <g mask="url(#doppla-hole)">
           <rect class="doppla-reveal__red" x="6" y="6" width="39" height="52" rx="10" fill="#C15E3D"/>
           <rect class="doppla-reveal__red-grad" x="6" y="6" width="39" height="52" rx="10" fill="url(#doppla-hole-red-grad)"/>
           <rect class="doppla-reveal__blue" x="25" y="6" width="33" height="52" rx="10" fill="#1D6E8F"/>
           <rect class="doppla-reveal__blue-grad" x="25" y="6" width="33" height="52" rx="10" fill="url(#doppla-hole-blue-grad)"/>
         </g>
       </svg>
       <svg class="doppla-reveal__wordmark" viewBox="0 0 212.65 59.28"
            role="img" aria-label="Doppla">
         ...geometry from doppla-reveal-demo.html...
       </svg>
     </div>

   Reversed: add .doppla-reveal--reversed, set both block fills to #FFFFFF,
   and give the red block fill-opacity="0.55". Leave
   the two gradient rects out. The monochrome mark is always flat.
*/

.doppla-reveal {
  display: inline-flex;
  align-items: center;
  gap: 0.225em;
  font-size: 96px;          /* the mark's width; scales the whole lockup */
  line-height: 1;
}

.doppla-reveal__mark {
  width: 1em;
  height: 1em;
  flex: none;
  overflow: visible;        /* blue starts far outside the mark's own box */
}

.doppla-reveal__red,
.doppla-reveal__blue {
  transform-box: fill-box;  /* offsets are percentages of each shape's own size */
  transform-origin: center;
}

.doppla-reveal__wordmark {
  width: 2.1265em;
  height: 0.5928em;
  flex: none;
  overflow: visible;
  color: #15151A;              /* the geometry is drawn in currentColor */
}

.doppla-reveal--reversed .doppla-reveal__wordmark {
  color: #F4F3F0;
}

.doppla-reveal__red {
  animation: doppla-converge-red 650ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* Blue fades in on a shorter clock than its slide, so it is fully opaque
   before it reaches red. */
.doppla-reveal__blue {
  animation: doppla-converge-blue 650ms cubic-bezier(0.2, 0.7, 0.2, 1) both,
             doppla-block-fade 263ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* The hole opens through the <animate> element in the markup. The
   wordmark fades up at the same moment, once the blocks have landed. */
.doppla-reveal__wordmark {
  animation: doppla-wordmark-in 400ms ease-out 650ms both;
}

/* The gradients only fade, with the wordmark's duration and easing. The
   hole runs shorter because a circle's area grows with the square of its
   radius, which does not apply to a fade. */
.doppla-reveal__red-grad,
.doppla-reveal__blue-grad {
  animation: doppla-gradient-in 400ms ease-out 650ms both;
}

@keyframes doppla-converge-red {
  from { transform: translateX(-110.3%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes doppla-converge-blue {
  from { transform: translateX(474.2%); }
  to   { transform: translateX(0); }
}

@keyframes doppla-block-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes doppla-wordmark-in {
  from { transform: translateY(0em); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes doppla-gradient-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Required: show the finished lockup straight away. */
@media (prefers-reduced-motion: reduce) {
  .doppla-reveal__red,
  .doppla-reveal__blue,
  .doppla-reveal__red-grad,
  .doppla-reveal__blue-grad,
  .doppla-reveal__wordmark {
    animation: none;
    opacity: 1;
    transform: none;
  }
  /* a media query does not pause the <animate> element, so this
     overrides it; it needs !important to take effect */
  .doppla-reveal__hole {
    r: 12px !important;
  }
}
