/* dark.css -- the affiliate hub in the dark.
 *
 * WHY THE HUB AND NOT THE STORE
 *   The store draws its header, its middle band and its footer from image
 *   files, and those images have white baked into them. Turn the page dark and
 *   two white bands sit across it with nothing that can be done about it short
 *   of re-cutting the artwork. The hub has no such images -- every surface on
 *   it is a colour this file can change -- so the switch lives here.
 *
 * HOW IT WORKS
 *   js/theme.js writes data-theme="light" or "dark" on <html> and remembers the
 *   choice in localStorage. Everything below hangs off that attribute, so the
 *   light hub is untouched: nothing in this file applies until the switch is
 *   thrown.
 *
 * HOW TO EXTEND IT
 *   Anything missed shows up as a white patch. Find the selector that paints it
 *   in style.css, hub.css or ../store/catalog.css and add it to the matching
 *   group below rather than starting a new one, so the palette stays in the
 *   handful of tokens at the top.
 */

:root {
	/* Read by theme.js for the crossfade, so the layer it fades through is the
	   colour the page is arriving at. Keep these in step with --page and
	   --ink below or the swap shows a flash of the wrong shade. */
	--ssm-fade-light: #fcfcfc;
	--ssm-fade-dark: #171b21;
}

html[data-theme="dark"] {
	--page: #171b21;      /* behind everything */
	--panel: #1f242c;     /* the white sheet the content sits on */
	--raised: #262d36;    /* cards, rows, anything a step above the panel */
	--sunken: #141821;    /* text boxes, which read as cut into the panel */
	--ink: #d8dee6;       /* body copy */
	--ink-strong: #f0f4f8;/* headings */
	--ink-quiet: #9aa5b2; /* captions and secondary lines */
	--edge: #333c47;      /* borders */
	--link: #5cb3ec;
	--link-visited: #a98fe0;
}

/* ---- the page itself ---------------------------------------------------- */
html[data-theme="dark"] body { background-color: var(--page); color: var(--ink); }
html[data-theme="dark"] .page,
html[data-theme="dark"] .jv-main,
html[data-theme="dark"] .welcome-content,
html[data-theme="dark"] .overlay .popup {
	background-color: var(--panel);
	color: var(--ink);
}
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4 { color: var(--ink-strong); }
html[data-theme="dark"] hr { border-color: var(--edge); }

/* Links. The hub's own menu paints its links white on a blue bar and must not
   be caught by this, so the rule is scoped to the content rather than to a. */
html[data-theme="dark"] .page a:not([class]),
html[data-theme="dark"] .jv-main a:not([class]),
html[data-theme="dark"] .resource-guide a { color: var(--link); }
html[data-theme="dark"] .page a:not([class]):visited,
html[data-theme="dark"] .jv-main a:not([class]):visited { color: var(--link-visited); }

/* ---- text boxes and fields ---------------------------------------------- */
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] select {
	background-color: var(--sunken);
	color: var(--ink);
	border-color: var(--edge);
}
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] input::placeholder { color: var(--ink-quiet); }

/* ---- the resource deck --------------------------------------------------
   The light deck borrows the admin's swipe-tab palette; this is the same
   shape in the dark. The open tab keeps its blue, because that is what says
   which tab is open, and it is legible on either background. */
html[data-theme="dark"] .resource-deck .deck-tab {
	background: #262d36;
	border-color: #3a444f;
	color: var(--ink);
}
html[data-theme="dark"] .resource-deck .deck-tab:hover {
	background: #313b47;
	border-color: #49556343;
}
html[data-theme="dark"] .resource-deck .deck-tab.is-on {
	background: #223040;
	border-color: #3f9ad0;
	border-bottom-color: #223040;
	color: #eaf3fa;
}
html[data-theme="dark"] .resource-deck .deck-arrow {
	background: #223040;
	border-color: #3a444f;
	color: var(--ink);
}
html[data-theme="dark"] .resource-deck .deck-arrow:hover { background: #223040; }
html[data-theme="dark"] .resource-deck .deck-arrow:hover:not(:disabled) {
	background: #2c3d50;
	border-color: #495563;
}
/* The panel the tabs sit on. Added after this file was first written, which is
   why the deck went dark but the sheet under it stayed pale blue. */
html[data-theme="dark"] .resource-deck .deck-panel {
	background: #223040;
	border-color: #3a444f;
}
html[data-theme="dark"] .deck-title { color: var(--ink-strong); }

/* ---- notifications ------------------------------------------------------- */
html[data-theme="dark"] .jv-notice,
html[data-theme="dark"] .copy-toast,
html[data-theme="dark"] .notice {
	background: #193326;
	border-color: #2c5a3f;
	color: #a8e0bf;
}
html[data-theme="dark"] .jv-notice.is-error,
html[data-theme="dark"] .copy-toast.is-error {
	background: #3a2317;
	border-color: #6b4228;
	color: #f2c3a3;
}

/* ---- tiles, rows and tables ---------------------------------------------- */
html[data-theme="dark"] .card {
	background: var(--raised);
	border-color: var(--edge);
	color: var(--ink);
}
html[data-theme="dark"] .card h2,
html[data-theme="dark"] .card h3 { color: var(--ink-strong); }
html[data-theme="dark"] .jv-main .link-row { background: var(--raised); }
html[data-theme="dark"] .resource-guide table,
html[data-theme="dark"] .resource-guide td,
html[data-theme="dark"] .resource-guide th { border-color: var(--edge); color: var(--ink); }

/* The tile pictures are product covers on white. Left as they are: dimming a
   cover misrepresents the product the affiliate is choosing to promote. */

/* ---- the one thing that cannot be recoloured ----------------------------- */
/* The earnings screenshot and the two portraits are photographs. Nothing here
   can change what is inside them, so they are given a quiet edge instead,
   which stops a white rectangle landing flat on a dark page. */
html[data-theme="dark"] .earnings-proof img,
html[data-theme="dark"] img.circle {
	border-radius: 6px;
	box-shadow: 0 0 0 1px var(--edge);
}
html[data-theme="dark"] img.circle { border-radius: 50%; }

/* ---- the remaining white surfaces ---------------------------------------
   Found by sweeping each page in the dark and listing every box still painted
   near-white. If another one turns up, add it here rather than anywhere else,
   so this file stays the whole answer to "what does dark mode touch". */
html[data-theme="dark"] form.controls,
html[data-theme="dark"] form.affiliate-profile,
html[data-theme="dark"] .col2,
html[data-theme="dark"] .ytc-card {
	background: var(--raised);
	border-color: var(--edge);
	color: var(--ink);
}
html[data-theme="dark"] .ytc-card { color: var(--ink); }
html[data-theme="dark"] .ytc-head h2 { color: var(--ink-strong); }
html[data-theme="dark"] .ytc-head a { color: var(--link); }
/* input and select were already covered by type, but the hub also uses bare
   <input> with no type attribute, which that selector cannot reach. */
html[data-theme="dark"] input:not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]) {
	background-color: var(--sunken);
	color: var(--ink);
	border-color: var(--edge);
}

/* ---- the action buttons under a resource --------------------------------
   Copy, Remove Line Breaks and Send Email are <input type="button">, which the
   field rule above deliberately leaves alone -- they are buttons, not boxes to
   type in. That left them in the browser's own near-white chrome, sitting
   bright under a dark panel. */
html[data-theme="dark"] .resource-actions input[type="button"],
html[data-theme="dark"] .resource-actions .resource-post {
	background: #2f3b49;
	border: 1px solid #44515f;
	color: var(--ink);
}
html[data-theme="dark"] .resource-actions input[type="button"]:hover,
html[data-theme="dark"] .resource-actions .resource-post:hover {
	background: #3a4857;
	border-color: #55636f;
	color: var(--ink-strong);
}

/* The rendered text link on a text-link box. It has no card of its own any
   more, so only the words need a colour here. */
html[data-theme="dark"] .deck-sample { color: var(--ink); }
