/* ==========================================================================
   DARK MODE FOR THE SALES PAGES
   --------------------------------------------------------------------------
   Loaded by sales_theme.php, beside corner.css, on any sales page that wants
   the switch and the jump buttons. Everything here is scoped to
   html[data-theme="dark"], so in light mode this file changes nothing at all
   and the page is exactly the one the designer built.

   THE PROBLEM THIS SOLVES
     These pages are sliced templates from around 2012. The colour is not in
     the CSS, it is in the JPEGs: template_01 is the header artwork, 02 the
     band that tiles out beside it, 03 the content slice, and so on. The white
     behind the sales copy is an image too -- template_03 is 1000x5 pixels,
     peach for its first 96, white across the middle, peach again at the end,
     tiled down the column. So `background-color: #141820` does nothing: the
     image paints over the top of it.

   HOW IT IS DARKENED WITHOUT TOUCHING A SINGLE FILE
     background-blend-mode. The image stays exactly where the stylesheet put
     it, a dark colour goes on the same element, and the browser multiplies
     one into the other. Multiply is the right operator here because white
     multiplied by anything IS that thing: the white slice becomes the panel
     colour exactly, with no seam. Measured on this template:

       white  #ffffff  x  #22272e  ->  #22272e   (becomes the panel)
       peach  #ffdf9c  x  #22272e  ->  #22221c   (edge survives as a warm line)
       lime   #b4d81e  x  #3a3012  ->  #292902   (dark olive, still the page's green)

     Note the two different blend colours. A neutral dark crushes a coloured
     band into mud, so the BANDS blend against a warm tint that keeps the
     product's own hue, while the content column blends against a neutral.
     Which tint belongs to which product is the one thing worth setting per
     page -- see the tokens below.

   WHAT IS NOT BLENDED
     The artwork. Multiplying the header would dim the thing that sells the
     product, and inverting it would turn the red box cyan and the cash blue.
     So the artwork keeps every pixel it has. What gets dealt with instead is
     the margin baked into its own slice: template_01 carries 96px of lime
     down each side, which would sit on the darkened band as a bright stripe.
     A mask fades those margins out, so the artwork floats on the dark band
     and nothing is cropped, recoloured or deleted.
   ========================================================================== */

/* ON :root, NOT ON html[data-theme="dark"], AND THE DIFFERENCE MATTERS.
   The first version of this file declared these inside the dark block, which
   reads as the tidier place for them and is wrong. js/theme.js reads the two
   fade tokens to find out what colour to fade THROUGH, and it reads them
   while the page is still in the theme it is leaving. Declared in the dark
   block, --ssm-fade-dark does not exist yet at the moment the switch is
   pressed in light mode, so the fade fell back to the admin's own value and
   went light -> #14181d -> a panel that is actually #22272e. Measured, found,
   moved here. On :root both values exist in both themes, which is the whole
   requirement. The --sp-* tokens are only read by dark-scoped rules, so they
   do nothing in light mode and sit here for company. */
:root {
	/* ---- per-product tokens -------------------------------------------
	   These five are the whole palette. To fit another product, override
	   them in a <style> on that page, or in its own stylesheet, and leave
	   the rest of this file alone.

	   --sp-band is the one that matters. Pick a dark version of the band's
	   own hue: warm brown-gold for this page's yellow-to-peach, a deep navy
	   for a blue template, a deep plum for a red one. Multiply only ever
	   darkens, so there is no value that can make a band glow. */
	/* THE ONE TO TUNE. A single layer laid over each band and over the
	   artwork sitting on it, so everything above the sales copy is the same
	   distance darker and nothing can drift out of step. Raise the alpha for
	   a darker top of page, lower it to let more of the design through.
	   A near-black veil keeps the underlying hues; a tinted one pulls them
	   toward the tint, which is occasionally what a very garish header
	   wants. */
	--sp-veil:     rgba(9, 11, 7, .80);
	--sp-band:     #3a3012;   /* still used by the footer slice; see below */
	--sp-panel:    #22272e;   /* the content column blends against this */
	--sp-frame:    #262c33;   /* the white box frames blend against this */
	--sp-ink:      #d7dde4;   /* body copy */
	--sp-ink-soft: #9aa5b1;   /* small print, captions */

	/* The artwork slices are left lit by default; see the long note beside
	   the rule. These three switch that over for a template that darkens
	   cleanly, and are deliberately unset here rather than given a value, so
	   the fallbacks in the rule are what applies:
	       --sp-art-tint    the colour to multiply the slice by
	       --sp-art-blend   multiply, to turn it on
	       --sp-art-shadow  none, since a dimmed slice needs no seating */

	/* What the crossfade fades through, overriding corner.css's admin
	   values. The content column in each theme, because that is most of
	   what is on screen on a sales page. A product that changes --sp-panel
	   should change this to match. */
	--ssm-fade-light: #ffffff;
	--ssm-fade-dark:  #22272e;
}

/* ---- the shell ------------------------------------------------------------
   A colour under everything, so that any gap the slices do not cover (a wide
   window, a short page, the area past the end of the content) is dark rather
   than browser white. */
html[data-theme="dark"] body {
	background-color: #171b21;
	color: var(--sp-ink);
}

/* ---- the bands ------------------------------------------------------------
   The three full-width strips that tile out to the window edges, plus the two
   artwork slices' own backgrounds. Each keeps its image; each gets the warm
   tint multiplied into it. */
html[data-theme="dark"] #headerbg,
html[data-theme="dark"] #contentbg,
html[data-theme="dark"] #footerbg,
html[data-theme="dark"] #headerfooterbg {
	position: relative;
}
/* ONE veil over each band, rather than a blend on each image.
   The reason is the nesting: #header lives INSIDE #headerbg, and #footer
   inside #footerbg, so a single layer on the parent covers the band and the
   artwork in the same pass, with the same colour, at the same opacity. They
   cannot disagree, because they are not being treated separately. A blend
   would have to be applied to each one and would only match where the two
   images happen to carry the same gradient -- true of this template, not
   something to rely on across hundreds of them.

   It also means nothing has to be known about the images. Whatever a band is,
   whatever the slice on top of it is, both end up the same distance darker. */
html[data-theme="dark"] #headerbg::after,
html[data-theme="dark"] #contentbg::after,
html[data-theme="dark"] #footerbg::after,
html[data-theme="dark"] #headerfooterbg::after {
	content: "";
	position: absolute;
	top: 0; right: 0; bottom: 0; left: 0;
	background: var(--sp-veil);
	pointer-events: none;
	z-index: 1;
}

/* ---- the content column ---------------------------------------------------
   The white that is an image. background-color is overridden as well as
   blended: the rule it is beating declares #fff, and a white blend colour
   would leave the slice exactly as white as it started. */
html[data-theme="dark"] #content,
html[data-theme="dark"] .page {
	background-color: var(--sp-panel);
	background-blend-mode: multiply;
	color: var(--sp-ink);
	/* Above the veil on #contentbg, which is its parent. The veil is meant
	   for the band showing either side of this column, not for the sales
	   copy: left underneath it, every word on the page would be behind a
	   sheet of dark. */
	position: relative;
	z-index: 2;
}

/* ---- the artwork ----------------------------------------------------------
   Nothing is done to it here, and that is the point: the veil on its parent
   has already covered it, in the same pass and by the same amount as the band
   it sits on. No blend, no filter, no mask, no invert. Every pixel of the
   JPEG is still the pixel the designer made; it is simply being looked at
   through a dark sheet, which is what happens to everything else up there
   too.

   WHAT IT COSTS, STATED PLAINLY
     This page's opening headline is dark type set directly onto the lime
     inside the header JPEG, and a veil cannot tell type from background. That
     line measured 2.72:1 against its own backdrop in light mode -- already
     low, because it is olive on yellow-green -- and the veil takes it down
     with everything else. It is decoration above the real headline rather
     than a line anyone reads twice, but it is worth knowing before it ships.

     The artwork itself, being saturated red and gold, comes through far
     better than dark-on-light type does.

   IF A PRODUCT WANTS ITS HEADER LEFT LIT
     Raise it above the veil and seat it with a shadow instead:
         #header { z-index: 2; box-shadow: 0 14px 44px rgba(0,0,0,.55); }
     Everything else up there stays dark around it. */

/* The footer gets nothing of its own either. It briefly had a blend on top of
   the veil, on the theory that its near-white top edge needed sinking further
   than the band did -- and rendered, that was simply the same artwork
   darkened twice, which left the ribbon almost invisible. One mechanism, one
   pass, everywhere. */

/* ---- the white box frames -------------------------------------------------
   The component, bonus and testimonial GIFs are 700px-wide white panels used
   as backgrounds for the boxes down the page. Same treatment as the content
   column, one shade lighter so a box still reads as raised off it. */
html[data-theme="dark"] .boxheader,
html[data-theme="dark"] .boxcontent,
html[data-theme="dark"] .boxfooter {
	background-color: var(--sp-frame);
	background-blend-mode: multiply;
}
html[data-theme="dark"] .box {
	border-color: #39414b;
	background-color: rgba(255, 255, 255, .02);
}
/* The two-column panels further down declare a flat background:#fff in the
   stylesheet, with no image involved, so there is nothing to blend and the
   colour is simply replaced. Found by auditing the rendered page for anything
   still light rather than by reading the stylesheet, which is the only way to
   catch these: a page this old has colour in several places at once. */
html[data-theme="dark"] .col,
html[data-theme="dark"] .col2 {
	background-color: var(--sp-frame);
	border-color: #39414b;
}

/* ---- the words ------------------------------------------------------------
   Headings in these templates are usually a dark grey set in the stylesheet,
   which disappears on a dark panel. Links keep their blue: it is the page's
   own accent and it carries enough contrast already. */
html[data-theme="dark"] #content h1,
html[data-theme="dark"] #content h2,
html[data-theme="dark"] #content h3,
html[data-theme="dark"] #content h4,
html[data-theme="dark"] #content h5,
html[data-theme="dark"] .page h1,
html[data-theme="dark"] .page h2,
html[data-theme="dark"] .page h3,
html[data-theme="dark"] .page h4 { color: #f0f4f8; }
html[data-theme="dark"] #content p,
html[data-theme="dark"] #content li,
html[data-theme="dark"] #content td,
html[data-theme="dark"] #content div { color: inherit; }
html[data-theme="dark"] .footer,
html[data-theme="dark"] .smaller,
html[data-theme="dark"] small { color: var(--sp-ink-soft); }
/* Links are recoloured, order buttons are not. A buy button is an <a> with a
   saturated background and its own text colour, and recolouring it put pale
   blue type on the yellow button at the bottom of this page. Anything whose
   class carries "btn" is left exactly as the designer set it, which covers
   the btnyellow / btnblue / btnred / btnzaxaa family these templates use.
   Add sp-keep to anything else that should be left alone. */
html[data-theme="dark"] #content a:not([class*="btn"]):not(.sp-keep) { color: #63b3ed; }
html[data-theme="dark"] #content a:not([class*="btn"]):not(.sp-keep):visited { color: #9f7aea; }
/* An inline background:#FFFFFF written into the markup, which no selector can
   beat without this. */
html[data-theme="dark"] #content [style*="#FFFFFF"],
html[data-theme="dark"] #content [style*="#ffffff"] {
	background-color: var(--sp-frame) !important;
}

/* ---- the order buttons ----------------------------------------------------
   Left alone on purpose. They are the point of the page, they are already
   saturated colour rather than white, and a buy button that changes with the
   theme is a buy button the client has to re-test. Only the grey rules and
   the panel they sit in move. */
html[data-theme="dark"] hr { border-color: #39414b; }
html[data-theme="dark"] .orderform,
html[data-theme="dark"] .order {
	background-color: var(--sp-frame);
	border-color: #39414b;
}

/* ---- pictures -------------------------------------------------------------
   Product shots, screenshots and testimonial photos keep their pixels. A
   bright photo on a dark page is not a bug, it is a photo. The glare comes
   off with a touch less brightness, which changes no hue and no detail. */
html[data-theme="dark"] #content img { filter: brightness(.94); }
/* What is NOT done to them, and why: a white-background product shot cannot
   be keyed out on a dark page with CSS. multiply and darken take the subject
   down with the background, and screen removes black rather than white. There
   is no blend mode that means "drop the white and keep the rest". Tried, and
   it crushed the artwork, so the images keep their backgrounds.

   Where a white edge does look wrong, the honest fix is to make it look
   deliberate rather than to half-remove it: sp-card puts the image on a light
   card so the white reads as the card rather than as a hole in the page. */
html[data-theme="dark"] #content img.sp-card {
	background: #eef1f4;
	border-radius: 6px;
	padding: 8px;
	filter: none;
}

/* ---- the old Top button ---------------------------------------------------
   smoothscroll.js shows this on scroll and the corner now does the same job
   in both directions, so two would be one too many. Hidden rather than
   removed, and !important because that script sets display inline. The markup
   and the script are untouched: switch back to light and it is there again.
   This file only loads where sales_theme.php is included, so a page without
   the corner keeps its own button. */
html #topbtn { display: none !important; }
