/*
 * 33science theme for calc-core, plus the shared tool-page shell.
 *
 * 1. Variables: overrides --cc-* only, light card, cyan accent (the t33 tokens
 *    --t33-cyan / --t33-coral / --t33-ink, as literals so the check harness,
 *    which has no theme, renders the same).
 * 2. Theme-leak fixes. The parent theme (ruki) styles bare ul, li, table, th,
 *    td, h1-h6, code and input selectors, and ruki-child adds
 *    `.t33-page-main .entry-content a / h1..h6 / ul / li / code` at (0,2,1).
 *    Every fix below is `body.s33-page .cc ...` at (0,2,2) or deeper, so it
 *    wins regardless of source order. No !important, no url(), no :is().
 * 3. The shell block (generated by 33science/tools/_shared/sync-shell.js from
 *    toolpage-shell.css: body class s33-page, root .cc). Do not edit inside
 *    its markers; deploy-check fails on drift.
 * 4. Rules that must beat the shell go AFTER the closing marker and match the
 *    lift selector exactly: `.entry-content > .cc:first-child` is (0,5,1), and
 *    a (0,4,1) override silently loses (the print reset did, twice).
 *
 * Variables for pack CSS: --cc-accent, --cc-accent-ink, --cc-accent-soft,
 * --cc-bg, --cc-card, --cc-text, --cc-muted, --cc-border, --cc-radius,
 * --cc-gap, --cc-pad, --cc-font, --cc-mono, --cc-ok, --cc-warn, --cc-err,
 * --cc-s0 .. --cc-s5 (chart series), --cc-out-min.
 */

.cc.cc-33science {
  --cc-accent: #0a7e9c;
  --cc-accent-ink: #ffffff;
  --cc-accent-soft: #e3f5fa;
  --cc-bg: #ffffff;
  --cc-card: #f5f8fc;
  --cc-text: #1b2233;
  --cc-muted: #5a6378;
  --cc-border: #d5dbe8;
  --cc-radius: 14px;
  --cc-ok: #0f7a4a;
  --cc-warn: #9a5b00;
  --cc-err: #c23b4a;
  --cc-s0: #0a7e9c;
  --cc-s1: #e0475b;
  --cc-s2: #d38b00;
  --cc-s3: #6d4fe0;
  --cc-s4: #0d1430;
  --cc-s5: #8b93a7;
  --cc-font: var(--body-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  color-scheme: light;
  clear: both;
  scroll-margin-top: 90px;
}

/* ---- ruki / ruki-child traps ---- */

/* Spacing under the card; the theme's `.entry-content > *` gives 1.4em. The lift (margin-top) is the shell's. */
body.s33-page .t33-page-main .entry-content > .cc {
  margin-bottom: 2.2em;
}

/* Links: ruki-child colours and underlines every `.entry-content a`, and recolours it on hover. */
body.s33-page .cc a,
body.s33-page .cc a:hover {
  color: var(--cc-accent);
  text-decoration: underline;
}
body.s33-page .cc a.cc-btn,
body.s33-page .cc a.cc-b,
body.s33-page .cc a.cc-btn:hover,
body.s33-page .cc a.cc-b:hover {
  color: var(--cc-text);
  text-decoration: none;
}

/* Headings inside the tool: the theme gives h1-h6 a 30px margin, weight 900 and the title font. */
body.s33-page .cc h1,
body.s33-page .cc h2,
body.s33-page .cc h3,
body.s33-page .cc h4,
body.s33-page .cc h5,
body.s33-page .cc h6 {
  margin: 0 0 0.5em;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--cc-text);
}

/* Lists: ul margins/bullets (`list-style: initial`) and `ul li` padding/margin come from three places. */
body.s33-page .cc ul,
body.s33-page .cc ol {
  margin: 0;
  padding-left: 0;
  list-style: none;
}
body.s33-page .cc li {
  margin: 0;
  padding-left: 0;
}
body.s33-page .cc li::before,
body.s33-page .cc li::after {
  content: none;
}
body.s33-page .cc .cc-list li {
  margin: 0;
  padding: 9px 12px;
}

/* Tables: the theme draws left/top/right borders, a coloured thead and rounded header corners. */
body.s33-page .cc table {
  display: table;
  width: 100%;
  margin: 0;
}
body.s33-page .cc thead { display: table-header-group; }
body.s33-page .cc tbody { display: table-row-group; }
body.s33-page .cc tr { display: table-row; border: 0; }
body.s33-page .cc td,
body.s33-page .cc th {
  display: table-cell;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  color: var(--cc-text);
}

/* Bare `code` is a block with a 30px pad and a left bar sitewide; ruki-child then re-skins it at (0,2,1). */
body.s33-page .cc code {
  display: inline;
  margin: 0;
  padding: 0.1em 0.35em;
  border: 0;
  border-radius: 4px;
  background: var(--cc-card);
  color: var(--cc-text);
  font-family: var(--cc-mono);
  font-size: 0.92em;
  line-height: inherit;
  text-align: left;
  white-space: normal;
}
body.s33-page .cc code.cc-mc {
  display: block;
  padding: 4px 6px;
  font-size: 13px;
  white-space: pre-wrap;
}

/* Theme svg rules must not leak into charts and meters. */
body.s33-page .cc svg { max-width: 100%; }

/* Embed view: white page behind the iframe, so the card has no seam. */
.cc.cc-33science.cc-embed { box-shadow: none; }

/* >>> t33 tool-page shell v1 (generated - edit _shared/toolpage-shell.css) */

/*
 * Makes the lift the card's own. Without a block formatting context the card's
 * negative margin collapses out through `.entry-content`, `article` and
 * `.t33-page-main` -- none of which has top padding -- and lands on `.wrap`,
 * moving the entire column instead of the one element. Measured on the live
 * page before this line existed: `.wrap` top and card top were both 300px, so
 * the declared -72px was in effect on the wrong element and no gate could see
 * the difference.
 */
body.s33-page .t33-page-main .entry-content {
	display: flow-root;
}

/*
 * The prose measure. Enumerated by tag rather than written as
 * `> *:not(.cc)`, which is what the word search shipped first: a
 * :not() selector also narrows MEDIAVINE'S INJECTED CONTAINERS to 760px,
 * quietly shrinking every in-content unit on the page. Ad units, the tool and
 * the tool strip are divs and navs, so enumerating prose tags leaves them at
 * full column width.
 *
 * `:is()` takes the specificity of its heaviest argument -- a type selector,
 * (0,0,1) -- so this lands at (0,3,2) and beats ruki-child's (0,3,1).
 */
body.s33-page .t33-page-main .entry-content > :is(p, h2, h3, h4, h5, h6, ul, ol, dl, blockquote, figure, pre) {
	max-width: 760px;
	margin-left: auto;
	margin-right: auto;
}

/*
 * Room for the card to land in. The theme ships `padding: 170px 0 90px`; the
 * extra bottom padding here is spent by the lift below, so the title keeps the
 * breathing room it has today and the tool does not move down the page.
 */
body.s33-page .t33-page-hero {
	padding-bottom: 132px;
}

/*
 * The lift. Mirrors `.t33-article-media`, which is what the theme already does
 * with a featured image on every other page of the site.
 *
 * The hero is a sibling of `.wrap`, not an ancestor, so its `overflow: hidden`
 * cannot clip this; and it carries no `z-index`, so `z-index: 5` here paints
 * over it. Both of those are the theme's own assumptions -- `.t33-article-media`
 * relies on exactly the same two facts.
 *
 * The ring in the first shadow is load-bearing, not decoration. The word
 * search board's background is #070b1a, byte-identical to the band's bottom
 * gradient stop (--t33-navy-1), so without a hairline the lifted panel would
 * dissolve into the band instead of sitting on it.
 *
 * `border-radius` is deliberately NOT set: each tool keeps its own (18px for
 * the board, 10px for the drill card), and the word search flattens it to 0
 * when the board goes full-bleed on a phone.
 *
 * `:first-child` is a safety catch, not tidiness. If Journey ever inserts a
 * unit at the very top of `.entry-content`, the tool stops being the first
 * child and the lift drops -- which is the right failure. Without it the tool
 * would keep its -72px and ride up over the ad unit.
 */
body.s33-page .t33-page-main .entry-content > .cc:first-child {
	position: relative;
	z-index: 5;
	margin-top: -72px;
	box-shadow:
		0 0 0 1px rgba(232, 238, 252, 0.18),
		0 26px 60px rgba(7, 11, 26, 0.45);
}

/*
 * The first paragraph after the tool carries the page. It is still a top-level
 * child of `.entry-content` -- only its type scale changed.
 */
body.s33-page .t33-page-main .entry-content > .cc + p {
	font-size: 1.18rem;
	line-height: 1.7;
	color: var(--t33-ink-soft, #5a6378);
}

/*
 * Section headings get an accent marker instead of being a bare bold line.
 * `::before` is used rather than a wrapper element precisely because a wrapper
 * would swallow an ad slot.
 */
body.s33-page .t33-page-main .entry-content > h2 {
	position: relative;
	padding-top: 22px;
	margin-top: 2.4em;
}

body.s33-page .t33-page-main .entry-content > h2::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	width: 54px;
	height: 4px;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--t33-cyan, #2bc8e8), var(--t33-coral, #f67280));
}

/*
 * FAQ pairs, styled through an adjacent-sibling selector. A `<details>` or a
 * wrapper would read better in isolation and cost an ad slot per question.
 */
body.s33-page .t33-page-main .entry-content > h3 {
	margin-top: 1.8em;
	font-size: 1.22rem;
}

body.s33-page .t33-page-main .entry-content > h3 + p {
	border-left: 3px solid rgba(43, 200, 232, 0.35);
	padding-left: 16px;
	color: var(--t33-ink-soft, #5a6378);
}

/*
 * Opt-in callout, applied to a top-level <p> in the content/*.html articles.
 * content-check.js balances tags and never inspects attributes, so adding a
 * class to those files is safe.
 */
body.s33-page .t33-page-main .entry-content > p.t33-callout {
	background: var(--t33-paper-soft, #fff7f3);
	border-left: 4px solid var(--t33-coral, #f67280);
	border-radius: 0 var(--t33-radius, 14px) var(--t33-radius, 14px) 0;
	padding: 18px 22px;
	font-size: 1.02rem;
}

body.s33-page .t33-page-main .entry-content > ul > li::marker,
body.s33-page .t33-page-main .entry-content > ol > li::marker {
	color: var(--t33-cyan, #2bc8e8);
}

/* -------------------------------------------------- more science tools --- */

/*
 * Appended by a `the_content` filter, so it is a top-level child of
 * `.entry-content` like any other -- it ADDS an ad boundary rather than
 * removing one, and it reaches pages that do not exist yet.
 */
body.s33-page .t33-page-main .entry-content > .t33-toolstrip {
	margin-top: 3em;
	padding-top: 1.6em;
	border-top: 1px solid #e3e7ef;
}

body.s33-page .entry-content .t33-toolstrip-title {
	margin: 0 0 1em;
	font-size: 0.82rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--t33-ink-soft, #5a6378);
}

body.s33-page .entry-content .t33-toolstrip-list {
	display: grid;
	gap: 14px;
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
	margin: 0;
	padding: 0;
	list-style: none;
}

body.s33-page .entry-content .t33-toolstrip-list li {
	margin: 0;
}

body.s33-page .entry-content .t33-toolstrip-card {
	display: block;
	height: 100%;
	padding: 16px 18px;
	background: var(--t33-paper, #fff);
	border: 1px solid #e3e7ef;
	border-radius: var(--t33-radius, 14px);
	box-shadow: var(--t33-shadow, 0 10px 30px rgba(7, 11, 26, 0.10));
	color: var(--t33-ink, #1b2233);
	text-decoration: none;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body.s33-page .entry-content .t33-toolstrip-card:hover {
	color: var(--t33-ink, #1b2233);
	transform: translateY(-2px);
	box-shadow: var(--t33-shadow-lift, 0 18px 44px rgba(7, 11, 26, 0.16));
}

body.s33-page .entry-content .t33-toolstrip-name {
	display: block;
	font-weight: 800;
	font-size: 1.02rem;
	margin-bottom: 4px;
}

body.s33-page .entry-content .t33-toolstrip-what {
	display: block;
	font-size: 0.92rem;
	line-height: 1.5;
	color: var(--t33-ink-soft, #5a6378);
}

/* ------------------------------------------------------------- phone ---- */

/* 600px is the theme's own hero breakpoint, not a new one. */
@media (max-width: 600px) {

	/*
	 * The phone gutter, reclaimed. The theme gutters this column twice -- the
	 * parent theme's bare `.entry-content { padding: 0 30px }` plus
	 * `.t33-page-main`'s own 18px -- so on a 390px phone the tool had 314px to
	 * work with and lost 76px, a fifth of the screen, to empty margin. Measured,
	 * not guessed.
	 *
	 * 12px rather than 0: the prose inside this column still needs an edge, and
	 * every tool card carries its own padding on top of this. Ad containers are
	 * children of `.entry-content` too, so they get the width back as well.
	 */
	body.s33-page .t33-page-main {
		padding-left: 8px;
		padding-right: 8px;
	}

	body.s33-page .t33-page-main .entry-content {
		padding-left: 12px;
		padding-right: 12px;
	}

	body.s33-page .t33-page-hero {
		padding-bottom: 88px;
	}

	body.s33-page .t33-page-main .entry-content > .cc:first-child {
		margin-top: -44px;
	}

	body.s33-page .t33-page-main .entry-content > .cc + p {
		font-size: 1.1rem;
	}
}

@media (prefers-reduced-motion: reduce) {

	body.s33-page .entry-content .t33-toolstrip-card {
		transition: none;
	}

	body.s33-page .entry-content .t33-toolstrip-card:hover {
		transform: none;
	}
}

/* <<< t33 tool-page shell */

/* ---- print: after the shell, matching its selectors ---- */
@media print {
  body.s33-page header,
  body.s33-page footer,
  body.s33-page nav,
  body.s33-page aside,
  body.s33-page .t33-page-hero,
  body.s33-page .t33-toolstrip,
  body.s33-page .entry-content > :not(.cc),
  body.s33-page [class*="mv-ad"],
  body.s33-page .adthrive,
  body.s33-page iframe {
    display: none;
  }
  body.s33-page .t33-page-main .entry-content > .cc:first-child {
    margin: 0;
    box-shadow: none;
  }
  .cc.cc-33science {
    --cc-text: #000;
    --cc-muted: #333;
    --cc-border: #999;
    --cc-card: #fff;
    --cc-bg: #fff;
    box-shadow: none;
    border: 0;
  }
}
