/* thescottrocca.com articles: travel. Moving between the list and an article, and from one
   article to the next, should feel like staying in one place.
   Built by Bright Presence Digital, https://brightpresencedigital.com */

/* ------------------------------------------------------------------------------------------
   1. One continuous place
   Going from page to page inside the articles is a single move: the ground holds still, the
   page changes over it, and the title that was clicked travels to become the headline.
   Browsers that cannot do this simply load the next page.
   ------------------------------------------------------------------------------------------ */
@view-transition{navigation:auto;types:travel}

/* Everything in this part applies only to that page to page move, never to a change made
   within a page (the list has its own, for filtering). */
.story-title,.row-title,.onward-title{view-transition-class:title}

/* The page. A short dissolve, shorter than the title's journey. Both pages are painted on the
   same ground, so through the dissolve the ground does not flicker: only its tint changes.
   Titles that are not the one travelling leave and arrive in step with their page. */
html:active-view-transition-type(travel)::view-transition-old(root),
html:active-view-transition-type(travel)::view-transition-new(root){animation-duration:.24s}
html:active-view-transition-type(travel)::view-transition-old(.title):only-child{animation:travel-out .24s both}
html:active-view-transition-type(travel)::view-transition-new(.title):only-child{animation:travel-in .24s both}

/* The title. Its box moves and resizes for the whole half second, so it is the one thing the
   eye follows. The old setting softens out as the new one comes into focus; a plain cross-fade
   of two different line breaks reads as a smear of doubled letters. The second animation in
   each pair is filled in by travel.js, which matches the two settings in size so that neither
   is stretched to fit the other's box. */
html:active-view-transition-type(travel)::view-transition-group(.title){
  z-index:2;animation-duration:.5s;animation-timing-function:cubic-bezier(.4,0,.1,1)}
html:active-view-transition-type(travel)::view-transition-old(.title){
  animation:travel-melt .17s ease-in .04s both,none .5s cubic-bezier(.4,0,.1,1) both;mix-blend-mode:normal}
html:active-view-transition-type(travel)::view-transition-new(.title){
  animation:travel-form .22s ease-out .13s both,none .5s cubic-bezier(.4,0,.1,1) both;mix-blend-mode:normal}

/* A finer version, in three separate layers: the ground, the page, the title. It depends on a
   very tall page being photographed whole as one layer, which today only one family of
   browsers does, so it is offered only there. The test is not about the property it names;
   that property is simply one only those browsers have. Anywhere else, the dissolve above. */
@supports (app-region:drag){
  html:active-view-transition-type(travel) #world{view-transition-name:world}
  html:active-view-transition-type(travel) body{view-transition-name:page}

  /* The ground is carried across as one piece, and its tint eases from one topic's colour to
     the next over the length of the title's journey. */
  html:active-view-transition-type(travel)::view-transition-group(world),
  html:active-view-transition-type(travel)::view-transition-old(world),
  html:active-view-transition-type(travel)::view-transition-new(world){animation-duration:.5s}

  /* The old page leaves quickly, then the new one arrives: they are never on screen together,
     so two layouts are never read through each other. The two pages are scrolled to different
     places, so the layer holds the old position until the old page has gone and only then
     takes the new one (the single step below), instead of sliding between them. */
  html:active-view-transition-type(travel)::view-transition-group(page){
    z-index:1;animation-duration:.14s;animation-timing-function:step-end}
  html:active-view-transition-type(travel)::view-transition-old(page),
  html:active-view-transition-type(travel)::view-transition-old(.title):only-child{
    animation:travel-out .14s ease-in both}
  html:active-view-transition-type(travel)::view-transition-new(page),
  html:active-view-transition-type(travel)::view-transition-new(.title):only-child{
    animation:travel-in .26s ease-out .14s both}
}

@keyframes travel-out{to{opacity:0}}
@keyframes travel-in{from{opacity:0}}
@keyframes travel-melt{to{opacity:0;filter:blur(7px)}}
@keyframes travel-form{from{opacity:0;filter:blur(7px)}}

/* ------------------------------------------------------------------------------------------
   2. A link to a passage
   ------------------------------------------------------------------------------------------ */
/* What a visitor sees when they arrive through such a link: the passage, marked in the
   topic's colour, quietly enough that the words stay the brightest thing. */
::target-text{background-color:color-mix(in srgb,var(--accent-ink) 26%,transparent);color:var(--ink)}

/* The one control, shown under a selection in the article. */
.passage-link{
  position:absolute;z-index:5;margin:0;padding:.55rem .8rem;
  font:600 .875rem/1.15 var(--ui);font-style:normal;letter-spacing:0;text-transform:none;text-indent:0;
  white-space:nowrap;color:var(--ink);
  background:var(--surface);border:1px solid var(--rule-strong);border-radius:6px;
  cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;
  animation:travel-in .14s ease-out both;
}
.passage-link:hover{border-color:var(--accent-ink)}
.passage-link:focus-visible{outline:2px solid var(--accent-ink);outline-offset:2px}
@media (pointer:coarse){.passage-link{padding:.8rem 1rem}}
@media print{.passage-link{display:none}}

/* ------------------------------------------------------------------------------------------
   3. Headings as addresses
   ------------------------------------------------------------------------------------------ */
/* A link to a section lands with air above the heading. A jump the reader makes within the page
   is a glide; arriving from elsewhere at a section is not, the page simply opens there. */
html:focus-within{scroll-behavior:smooth}
.article-content h2{scroll-margin-top:1.5rem}
