/* ==================================================================
   CAPE BREWING COMPANY  -  shared motion layer (fx)
   Loaded by every page, in <head>, so the arrival curtain is already
   in place on the first painted frame. Its partner is fx/cbc-fx.js.
   ------------------------------------------------------------------
   WHAT LIVES HERE
     1. Page curtain ... every page-to-page move is one gesture: an ink
        sheet rises over the page you are leaving, carrying the name of
        the place you are going, set like one line of the home hero
        (giant Archivo Black caps on a gold hairline). The next page
        loads behind it and the sheet lifts away. Motion on type, per
        the design laws; the curtain is the one gold element while it
        is up.
     2. Paper grain .... one fixed, static layer of fine grain over the
        whole site so the flat paper and ink fields read as stock, not
        as screen fills. It never animates and never scrolls.

   WHY /fx AND NOT /js
     _headers caches /js/* for a year as immutable. These two files will
     be tuned, so they live in their own folder and revalidate normally.

   TUNABLES
     --fx-word ........ curtain word size. 15vw fits the longest label
                        (BREWERY, GALLERY, PRIVACY) inside the viewport.
     --fx-pad ......... left edge of the word; matches each page's own
                        gutter (20px phone, 32px desktop).
     --fx-in-ms ....... leaving: how long the sheet takes to cover.
     --fx-out-ms ...... arriving: how long the sheet takes to lift.
     --fx-char-ms ..... leaving: each letter's rise.
     --fx-char-gap .... leaving: delay between letters.
     --fx-grain ....... grain strength. 0 switches it off.
     The moment the next page is requested is LEAVE_MS in cbc-fx.js and
     must stay >= --fx-in-ms, or the old page shows through the wipe.
   ================================================================== */
:root{
  --fx-ink:#141210; --fx-paper:#EDE6D8; --fx-gold:#BE9B52;
  --fx-word:15vw;
  --fx-pad:20px;
  --fx-in-ms:620ms;
  --fx-out-ms:780ms;
  --fx-char-ms:560ms;
  --fx-char-gap:28ms;
  --fx-grain:.045;
  --fx-sweep:cubic-bezier(.76,0,.24,1);      /* weighty in-out, the sheet */
  --fx-rise:cubic-bezier(.16,1,.3,1);        /* the site's own ease, the type */
  /* where the hairline sits: just under the word's line box */
  --fx-rule-y:calc(50% + (var(--fx-word) * .5) + 10px);
}
@media(min-width:760px){ :root{--fx-pad:32px} }

/* ---------------------------- PAPER GRAIN ----------------------------
   Two-tone on purpose. The beer panels on beers.html use plain black noise,
   which is right for a mid-tone field but vanishes on the ink sections
   (black specks on near-black) and can only ever darken the paper. Here
   each speck is thresholded to either black or white, so it shows on paper
   AND ink, and the two pull in opposite directions: the locked foundation
   colours keep their value instead of drifting grey under a veil.
   Fixed and inert: one composited layer, no blend mode, nothing repainted
   while the page scrolls. */
.fx-grain{
  position:fixed;inset:0;z-index:9990;pointer-events:none;
  opacity:var(--fx-grain);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='discrete' tableValues='0 1'/%3E%3CfeFuncG type='discrete' tableValues='0 1'/%3E%3CfeFuncB type='discrete' tableValues='0 1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media print{ .fx-grain{display:none} }

/* ---------------------------- THE CURTAIN ----------------------------
   Two renderings of the same sheet, built to be pixel-identical so the
   hand-over between documents cannot be seen:

     LEAVING   a real element (.fx-curtain) that cbc-fx.js adds. Real
               markup, so each letter can rise on its own.
     ARRIVING  html::before (the sheet and its hairline) and html::after
               (the word, read from data-fx-word). Pseudo-elements,
               because the inline script in <head> runs before <body>
               exists and the sheet has to be there on the first frame.

   Kerning is off on both. Split into one box per letter, the leaving
   word loses its kerning pairs; with kerning left on, the arriving word
   (one text run) would sit a few pixels differently and the word would
   visibly jump at the cut. */
.fx-curtain,
html.fx-arriving::before{
  position:fixed;inset:0;z-index:9500;
  background:
    linear-gradient(var(--fx-gold),var(--fx-gold)) no-repeat 0 var(--fx-rule-y) / var(--fx-rule-w,100%) 1px,
    var(--fx-ink);
}
.fx-word,
html.fx-arriving::after{
  position:fixed;left:var(--fx-pad);top:50%;z-index:9501;
  transform:translateY(-50%);
  font-family:"Archivo Black","Arial Black",Impact,sans-serif;font-weight:400;
  font-size:var(--fx-word);line-height:1;letter-spacing:-.02em;
  text-transform:uppercase;white-space:nowrap;font-kerning:none;
  color:var(--fx-paper);
}

/* ---- leaving ---- */
.fx-curtain{
  --fx-rule-w:0%;
  transform:translateY(101%);visibility:hidden;pointer-events:none;
  transition:transform var(--fx-in-ms) var(--fx-sweep);
}
.fx-curtain .fx-word{position:absolute;overflow:hidden}
.fx-ch{display:inline-block;transform:translateY(105%);
       transition:transform var(--fx-char-ms) var(--fx-rise);
       transition-delay:calc(var(--fx-in-ms) * .38 + var(--i) * var(--fx-char-gap))}
/* the hairline draws left to right while the sheet covers: the wait made visible */
.fx-rule{position:absolute;left:0;right:0;top:var(--fx-rule-y);height:1px;
         background:var(--fx-gold);transform:scaleX(0);transform-origin:left center;
         transition:transform calc(var(--fx-in-ms) + 50ms) var(--fx-sweep)}
.fx-curtain.is-on{visibility:visible;pointer-events:auto;transform:none}
.fx-curtain.is-on .fx-ch{transform:none}
.fx-curtain.is-on .fx-rule{transform:none}
/* snapped back with no animation when a page is restored from the
   back/forward cache with the sheet still down */
.fx-curtain.is-reset,.fx-curtain.is-reset *{transition:none!important}

/* ---- arriving ---- */
html.fx-arriving::before{content:"";will-change:transform;
  transition:transform var(--fx-out-ms) var(--fx-sweep)}
html.fx-arriving::after{content:attr(data-fx-word);will-change:transform;
  transition:transform var(--fx-out-ms) var(--fx-sweep)}
/* the word leaves a little faster than the sheet it is printed on, so the
   lift has depth instead of reading as one flat card sliding off */
html.fx-arriving.fx-go::before{transform:translateY(-101%)}
html.fx-arriving.fx-go::after{transform:translateY(calc(-50% - 128vh))}

/* If cbc-fx.js never runs (blocked, failed, slow network), the sheet must
   not strand the visitor behind it. After 3s it removes itself. */
html.fx-arriving::before,html.fx-arriving::after{
  animation:fx-failsafe 1ms linear 3s forwards;
}
@keyframes fx-failsafe{ to{visibility:hidden} }

/* Reduced motion: no curtain at all. cbc-fx.js does not arm it either;
   this covers a flag left behind by a tab that had motion on. */
@media(prefers-reduced-motion:reduce){
  html.fx-arriving::before,html.fx-arriving::after,.fx-curtain{display:none!important}
}

/* ---------------------------- TITLE LETTERS ----------------------------
   Boxes made by fx/cbc-title.js. A word never breaks across lines; the
   letters inside it are what move. */
.t-word{display:inline-block;white-space:nowrap}
.t-ch{display:inline-block;will-change:transform}
