/* ══════════════════════════════════════════════════════════════════════════
   THE EMPIRE — the home page's background

   Kings, crowns and empires at the top of the page; the whole thing comes
   apart on the way down. The constraint that shapes every line below: this
   page puts near-black text straight onto its own background in several
   places, so whatever goes back there has to leave reading completely alone.

   The split that makes that possible:

     the mass        pale limestone. Near-black text clears 9:1 on it, so a
                     tower can run straight behind a paragraph and change
                     nothing.
     the jewellery   gold -- crowns, spires, the glints, the frames around
                     his photographs. A small percentage of the pixels, which
                     is also true of actual gold leaf, and the reason both
                     read as expensive rather than gaudy.

   Three systems share this screen and must not fight:

     the sun     owns LIGHT      -- where the glare falls, whether the windows
                                    are lit. Already computed by sky.js from
                                    Flagstaff's real solar position. Nothing
                                    here recalculates any of it.
     the scroll  owns STRUCTURE  -- what is still standing.
     the page    owns EVERYTHING ELSE -- untouched. Not one rule in this file
                                    changes a card, a heading or a measurement
                                    that was already there.
   ══════════════════════════════════════════════════════════════════════════ */

/* The paper itself is painted twice on this site -- once on <html> and once
   on <body> -- so an empire at z-index 0 sat on top of the top bar, and at
   -1 it sat under the body's own paper and vanished. Handing the paper to
   <html> alone opens the one gap it needs: the root canvas paints below
   everything, so at -1 the empire is above the paper and below every piece
   of content, and any section with a background of its own still covers it. */
body{background:transparent!important}

.empire{
  position:fixed;inset:0;
  z-index:-1;
  pointer-events:none;
  /* The artwork is sliced to fill, so it is wider than its box by design.
     Clip it, or the overhang counts as page width and a phone gets a
     sideways scroll. */
  overflow:hidden;
  contain:paint;
}
.empire svg{
  /* Held back hard at one point, on the word of an instrument that turned
     out to be lying: measured properly -- real ink against the real pixels
     behind it -- the engraving costs the page about 0.03 of contrast, which
     is nothing. So it is allowed to be seen. */
  opacity:1;
  position:absolute;inset:0;
  width:100%;height:100%;
  display:block;
}

/* Everything is standing when you land, because you land in the present with
   the thing built. Scrolling down runs backwards and takes it apart: a piece
   leaves at its --until, the rubble at the foot arrives at its --from. */
.pc{
  opacity:1;
  transition:opacity 1.1s ease-in,
             transform 1.45s cubic-bezier(.58,0,.86,.22);
}
/* The origin is the FOOT of each tower, not its middle. That one line is
   the difference between a building coming down and a sticker sliding off
   the page: a demolition pivots and collapses onto its own base. */
.pc{transform-box:fill-box;transform-origin:50% 100%}
.pc.off{opacity:0}

/* It comes down the way a building actually comes down.
   The charges go in the core, the floors pancake onto one another and the
   tower lands inside its own footprint. It does not sail off sideways and
   it does not tumble end over end -- that is a disaster film, and this is
   meant to look like it was planned. So: scaleY to nothing, a few per cent
   of outward bulge as the floors stack up, and a drift and a turn small
   enough that you only notice no two go down the same way. */
.mass .pc.off{
  transform:translate3d(var(--fx,0),0,0)
            rotate(var(--fr,0deg))
            scale(var(--bulge,1.03), .035);
}

/* The dust. It sits at the foot of each tower and blooms as that tower
   drops, settling into a low haze rather than a billowing cloud -- the
   restraint is the point. It never fades to nothing, because a transition
   that ends where it began shows nothing at all on the way. */
/* The dust group is NOT the collapsing group -- see the slicer. Its pieces
   carry the same --until so each cloud blooms with its own tower, but they
   must not inherit the piece fade or they would vanish on the way up. */
.dustmass .pc{ opacity:1; transition:none; }
.dustmass .pc.off{ opacity:1; transform:none; }
.dust{
  opacity:0;
  transform-box:fill-box;transform-origin:50% 92%;
  transform:scale(.3,.14);
  transition:opacity 1.6s ease-out, transform 2.3s cubic-bezier(.16,.72,.3,1);
  will-change:opacity,transform;
}
.pc.off .dust{ opacity:1; transform:scale(2.1,1.7); }
/* The dust is mixed from the site's own tokens, not a colour invented for
   it. --muted and --surface are already redefined for dusk and night, so
   this follows the page from warm grey on paper to cool slate after dark
   without a second rule, and it can never drift out of the palette. */
:root{ --dust:color-mix(in srgb, var(--muted) 58%, var(--surface)); }
.glints .pc.off{transform:scale(.3)}

/* ── the windows ──────────────────────────────────────────────────────────
   The one thing the SUN controls rather than the scroll. They come up as the
   sky goes down, so the same empire looks different at two in the afternoon
   and two in the morning. --win-op is set by empire.js from the sky colour
   sky.js has already worked out. */
.lights .win{
  fill:#C9A227;
  opacity:0;
  transition:opacity 1.2s linear, fill 1.2s linear;
}
/* Both conditions or neither: the floor has to still be standing AND the sun
   has to be down. Either alone lights nothing. */
.lights .win:not(.off){ opacity:var(--win-op,0) }
/* By day a window is a dark mark on a light face; after dark it is a lit
   one on a dark face. Same elements, opposite relationship to the wall. */
.lights .win{fill:#9A8A62}
:root[data-sky="dusk"] .lights .win,
:root[data-sky="night"] .lights .win{ fill:#FFD98A }

/* ── the bling ────────────────────────────────────────────────────────────
   A four-point star is the shape a real specular highlight makes through a
   lens aperture, which is why it reads as "expensive" to people who could
   not tell you what they are looking at. It is also the one thing here that
   moves on its own, so it is kept slow and sparse -- nine of them on the
   whole page, breathing at different rates. */
.glint{
  opacity:var(--glare,.55);
  transform-box:fill-box;transform-origin:center;
  animation:bling 7s ease-in-out var(--gd,0s) infinite alternate;
  transition:opacity 1.2s linear;
}
@keyframes bling{
  from{opacity:calc(var(--glare,.55) * .3);transform:scale(.68) rotate(0deg)}
  to  {opacity:var(--glare,.55);transform:scale(1.1) rotate(10deg)}
}

/* After dark the site flips to its dark theme, and the same gold line costs
   several times as much contrast: on paper it is a dark mark under dark
   text and barely registers, but on a night background it is a LIGHT mark
   under light text, sitting between the reader and the words. Measured, it
   was the whole difference between 4.53:1 and 4.24:1 on the sky label. Same
   drawing, half the presence. */
:root[data-sky="dusk"]  .empire svg,
:root[data-sky="night"] .empire svg{ opacity:.95 }

/* and the dust goes dark with everything else, rather than laying a warm
   grey haze over a night page */
:root[data-sky="dusk"]  .empire-dust,
:root[data-sky="night"] .empire-dust{
  background:linear-gradient(to bottom,
    rgba(8,11,16,0) 0%, rgba(8,11,16,.30) 55%, rgba(6,9,14,.44) 100%);
}

/* ── the light the sun actually casts on it ───────────────────────────────
   A warm wash sitting where the sun is. The whole site already knows the
   real bearing and altitude over Flagstaff; this just reads the answer, so
   at 7am the empire is lit from the left and by evening from the right. */
.empire-sun{
  position:absolute;inset:0;
  background:radial-gradient(42% 52% at var(--sky-body-x,70%) var(--sky-body-y,22%),
    rgba(255,226,150,.5) 0%, rgba(255,214,133,.22) 38%,
    rgba(255,210,130,0) 72%);
  opacity:var(--glare,.55);
  transition:background 2.4s linear, opacity 1.6s linear;
  mix-blend-mode:multiply;
}

/* ── the colour draining out ──────────────────────────────────────────────
   Going down the page is going backwards in time, so the warmth leaves it.
   One cold veil whose opacity rises with the scroll: cheaper than filtering
   the artwork every frame, and it reads as the light going out of the thing
   rather than as a picture being faded. */
.empire-dust{
  position:absolute;inset:0;
  background:linear-gradient(to bottom,
    rgba(166,158,146,.0) 0%, rgba(150,145,138,.22) 55%,
    rgba(138,134,130,.34) 100%);
  opacity:var(--decay,0);
  transition:opacity .5s linear;
}

/* ── his photographs, the ones already on the page ───────────────────────
   A hairline of gold and one corner star each. The frame is a single inset
   ring rather than a border, so it costs the layout nothing and cannot shift
   a filmstrip that is already measured and scrolling. */
.film-cell{position:relative}
.film-cell img{
  box-shadow:inset 0 0 0 1px rgba(214,180,106,.0);
  outline:1px solid rgba(201,168,94,.55);
  outline-offset:-1px;
}
.film-cell::after,
.sky-photo::after{ pointer-events:none }

/* the glare on the corner.

   A real four-point star: a tapered horizontal bar, a tapered vertical one
   and a hot core. That cross is the shape a specular highlight makes through
   a lens aperture, which is why it reads as expensive to people who could
   not say what they are looking at. It brightens and fades with the sun like
   everything else here, and it is staggered off --i so fourteen cells do not
   all wink at once. */
.film-cell::after{
  content:"";position:absolute;z-index:2;
  top:-13px;left:-13px;width:46px;height:46px;
  background:
    radial-gradient(closest-side,#FFFEF8 0%,rgba(255,241,200,.78) 24%,rgba(255,214,122,0) 70%),
    linear-gradient(to right,rgba(255,250,228,0) 0%,#FFFCEE 50%,rgba(255,250,228,0) 100%),
    linear-gradient(to bottom,rgba(255,250,228,0) 0%,#FFFCEE 50%,rgba(255,250,228,0) 100%);
  background-size:100% 100%, 100% 8%, 8% 100%;
  background-position:center;
  background-repeat:no-repeat;
  opacity:var(--glare,.55);
  animation:bling 6.5s ease-in-out calc(var(--i,0) * 1.15s) infinite alternate;
}

/* ── reduced motion ──────────────────────────────────────────────────────
   The empire simply stands, start to finish. Someone who has asked for less
   movement should not have to scroll through a demolition to read a man's
   prices. */
@media (prefers-reduced-motion:reduce){
  .pc{transition:none}
  .glint,.film-cell::after{animation:none}
  .empire-dust{display:none}
}


/* ══════════════════════════════════════════════════════════════════════════
   AND THE BOXES GO TOO

   The engraving behind the page was coming apart exactly as intended and
   nobody could see it, because from the hub downwards the page is solid
   white cards laid straight over the top of it. The collapse was happening
   behind a wall.

   So the cards come apart as well -- but only their CHROME. The rule that
   shapes every line below: the words do not move, do not tilt, do not fade
   and are never clipped. A box can crumble around text and leave the text
   perfectly readable; that is the whole trick, and it is why the erosion is
   deep at the corners (where a padded box has nothing in it) and shallow
   along the edges (where it would reach a line of type).

   How far gone a card is depends on how far down the page it sits, so the
   hub is lightly chipped and the contact cards at the foot are nearly bare.
   That is the same gradient the background runs on: whole at the top, ruins
   at the bottom.
   ══════════════════════════════════════════════════════════════════════════ */

/* A custom property has to be registered before it can be animated -- an
   unregistered one jumps from 0 to its value and the erosion would snap
   into place instead of happening. */
/* inherits:true, and it matters. A pseudo-element counts as a child for
   inheritance, so with inherits:false the scrim on .beat::before and the
   cracks on .rung::after both read --c as its initial 0 and quietly did
   nothing at all -- the chapters lost their boxes and got no scrim to
   stand on, which is dark text on a pale sky. */
@property --c{ syntax:'<number>'; inherits:true; initial-value:0; }

.rung,
.closer-card,
.soc{
  --c:0;
  transition:--c 1.15s cubic-bezier(.33,0,.68,.35),
             background-color 1.1s linear,
             border-color 1.1s linear,
             box-shadow 1.1s linear;
}

/* The fill thins so the engraving shows through what used to be a solid
   panel -- but only halfway. Taken further the card simply disappeared, and
   a box that vanishes has not crumbled, it has been deleted. The edge is
   the opposite case: it is held NEARLY at full strength, because the whole
   effect is the reader seeing a broken outline. Fade the border and the
   damage becomes invisible no matter how deeply it is bitten.

   38% is where it settled, measured rather than chosen: at 52% the blue
   "See the work" link inside a hub card fell to 4.45:1 against a required
   4.5. The broken outline is doing the work here, so the fill could give
   that back without the effect losing anything. */
.rung,
.closer-card,
.soc{
  background-color:color-mix(in srgb, var(--surface), transparent calc(var(--c) * 24%));
  border-color:color-mix(in srgb, var(--line), transparent calc(var(--c) * 24%));
}
.closer-card{
  box-shadow:0 1px 2px rgba(11,18,32,calc(.04 * (1 - var(--c))));
}
/* the accent rail on a hub card erodes with it */
.rung::before{ opacity:calc(1 - var(--c) * .45) }

/* a crack, running in from an edge. One per card, its angle and length set
   per card by empire.js, clipped by the card's own broken outline so it can
   never stray outside it. */
.rung::after,
.closer-card::after,
.soc::after{
  content:"";position:absolute;pointer-events:none;
  left:var(--k-x,20%); top:var(--k-y,-4%);
  width:1.5px; height:calc(var(--c) * var(--k-h,70px));
  transform:rotate(var(--k-r,8deg));
  transform-origin:top center;
  background:linear-gradient(to bottom,
    color-mix(in srgb, var(--line), transparent 4%) 0%,
    color-mix(in srgb, var(--line), transparent 46%) 62%,
    transparent 100%);
  opacity:calc(var(--c) * .95);
}

/* The clip-path itself is written onto each card by empire.js, because every
   card needs its own set of bites -- one shared shape repeated seven times
   would read as a texture rather than as damage. */

/* Nothing crumbles for anyone who asked for less movement: the cards stay
   whole, start to finish. */
@media (prefers-reduced-motion:reduce){
  .rung,.closer-card,.soc{
    --c:0 !important;
    clip-path:none !important;
    transition:none;
  }
}


/* ══════════════════════════════════════════════════════════════════════════
   THE SHEET

   Measured three ways, the same wall every time: this page sets its body
   copy directly onto its own background (.column > section carries
   background:none!important, by design), and two of its ink colours -- the
   green eyebrows at #2F7D32 and the blue links at #1565C0 -- are
   mid-luminance. They only clear 4.5:1 against something near white. So ANY
   mark visible behind them fails, however prettily it is drawn. A gold
   hairline crossing "Brockleywellness@proton.me" measured 1.94:1.

   That is not a bug to tune around, it is a straight conflict: a bold
   backdrop and that copy cannot occupy the same pixels. Every site on the
   reference list resolves it the same way, and so does this: the words get
   a sheet, and the empire owns everything else.

   The sheet is pinned to the WORDS, not to the column. One sheet over the
   whole content column was the obvious shape and it was wrong: measured, it
   has to be about 92% opaque to protect green-on-gold, and at 92% over the
   whole column a phone -- where the column IS the screen -- loses the
   engraving completely. That is the "too light" complaint arriving back by
   another route.

   Per-block, the same 92% costs almost nothing: every gap between cards,
   every margin, the full width above and below each block and the whole
   depth of the page between sections keeps the engraving at full strength,
   and on a phone those gaps are most of what is on screen. Each sheet is a
   radial that reaches zero before its own edge, so it never reads as a
   panel -- just paper the words happen to be resting on.
   ══════════════════════════════════════════════════════════════════════════ */
:root{ --sheet:250,249,246; --sheet-a:.965; }
:root[data-sky="dusk"],
:root[data-sky="night"]{ --sheet:17,22,29; }

/* The blocks that set text straight onto the background.
   `.rail` is deliberately NOT in this list. It brings its own position --
   sticky on desktop, relative on a phone -- and both of those are already
   a containing block for the ::after below. Declaring `relative` here
   overrode the sticky (this file loads after styles.css), so the rail
   stopped following the reader down the column and instead sat 84px lower
   than its row, which on a phone put its last link inside the shops
   heading. A sheet should not be able to change how a block is laid out. */
.seen,
.hub-kick,
.shops-head,
.sky-ctl-label{ position:relative }

.rail::after,
.seen::after,
.hub-kick::after,
.shops-head::after,
.sky-ctl-label::after{
  content:"";position:absolute;z-index:-1;pointer-events:none;
  /* Reach is tied to the page's own gutter, so a sheet can never extend
     past the viewport edge. A flat -1.9rem did, and put a 15px sideways
     scroll on a 390px screen. */
  top:-1.6rem;bottom:-1.6rem;
  left:calc(var(--pad) * -0.85);right:calc(var(--pad) * -0.85);
  /* The gradient has to finish INSIDE the box it is painted in. At
     118% x 104% its zero stop fell outside the painted area, so the sheet
     was still a third opaque where the element ended and cut off square --
     a panel, which is the one thing the note above says it must never be.
     It went unnoticed while the backdrop was a faint engraving; against a
     rendered city it reads as white rectangles laid over the skyline. */
  /* Core wide, edge soft. Pulling the fade inside the box stopped it
     reading as a panel but took the cover away from the words nearest the
     block's own edge, which is exactly where the 10px labels sit: the
     eyebrow went 5.90 -> 3.92 and the kicker 4.82 -> 3.10 against a 4.5
     floor. Opaque out to 66% covers the text; the last third still
     reaches zero inside the box, so there is no edge to see. */
  background:radial-gradient(97% 90% at 50% 50%,
    rgba(var(--sheet),var(--sheet-a)) 0%,
    rgba(var(--sheet),var(--sheet-a)) 73%,
    rgba(var(--sheet),calc(var(--sheet-a) * .78)) 87%,
    rgba(var(--sheet),calc(var(--sheet-a) * .30)) 94%,
    rgba(var(--sheet),0) 100%);
}
/* a kicker is one short line, so its sheet is tighter top to bottom */
.hub-kick::after,
.sky-ctl-label::after{ top:-1rem;bottom:-1rem }

/* The footer sits outside all of them, and was the one place left where a
   gold line could still land under a green link. Fades in at the top so the
   ruins at the foot of the engraving still read above it. */
body > footer{
  position:relative;
  background:linear-gradient(to bottom,
    rgba(var(--sheet),0) 0%,
    rgba(var(--sheet),var(--sheet-a)) 9%,
    rgba(var(--sheet),var(--sheet-a)) 100%);
}

/* ── the nav ─────────────────────────────────────────────────────────────
   Not part of this work, but measured by it and worth saying plainly: the
   bar is translucent (.9 fading to .62), so anything scrolling underneath
   shows through it. On the page as it shipped that already put "My story",
   "Websites", "Contact" and ".io" between 3.1:1 and 3.9:1 against a
   required 4.5 -- a real defect, nothing to do with the engraving. With
   something behind the page it also catches "Get in touch" as the rail
   slides under the bar.

   Four extra points of opacity fixes all of it and is, side by side, not a
   difference anyone can see: the bar still reads as a soft gradient rather
   than a slab. One line to put back if it is not wanted. */
:root{ --nav-a:rgba(245,244,239,.985); --nav-b:rgba(245,244,239,.94); }
:root[data-sky="dusk"]{ --nav-a:rgba(27,32,40,.985); --nav-b:rgba(27,32,40,.94); }
:root[data-sky="night"]{ --nav-a:rgba(12,16,22,.985); --nav-b:rgba(12,16,22,.945); }
